One logical expansion of CFDG is to move to 3D

Let the developers know what you think of the software and what can be done to either improve the CFDG language or the Context Free program.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
mycelium
Posts: 29
Joined: Tue Aug 28, 2007 4:21 am
Location: Italy
Contact:

One logical expansion of CFDG is to move to 3D

Post by mycelium »

I post my ideas about 3D features in Context Free beacause I think it would be a great opportunity for new beautiful designs.
Unfortunately I don't have time to try to implement it and probably I am not able to.

Context3 (by Nom) has probably already implemented this, but I was never able to use it and now it seems like it is not available anymore.

Structure Synth is a very nice 3D version of Context Free but truly it is very different.
- Structure Synth is oriented in creating 3D models
- Context Free is oriented in painting

----------------------------------------------------------------------------------

1. Rendering Engine.
CF rendering engine should be the same. Output is a "paint" not different from what is now.

2. Fixed Camera and flat projection default
- this allows total compatibility with previous designs.
- a simple directive may specify different camera parameters. (ie: camera {distance 100 angle 30})

3. 3D Geometry 3d rotations
- 3D is maybe already implemented in CF since we can specify z coordinate.
- What we need is the rx and ry parameters (rx: rotate around x axis; ry: rotate around y axis;) r parameter equals to rz

4. 3D basic objects
a) Sprites. Sprites are figures that are always drawn perpendicolar to z axis (painted flat). The existing figures SQUARE, CIRCLE, TRIANGLE, can be the default built-in sprites.
b) Planar figures such as DISK or FACE should be painted with geometry stretched according to 3d rotation and each pixel may have a different z coord.

5. Shades and lights
No shades and no lights.
Shading can be obtained manipulating colors. Maybe cycling brightness and saturation like hue could help.

----------------------------------------------------------------------------------

Conclusion
- CF can evolute to 3D without loosing its unique features such as the ability of drawing millions of shapes and have superb antialias.
- The first step to 3D could be having 3D rotations.
- A basic 3D implementation in CF opens the door to unique, ultra detailed, 3d fractal architectures.

mycelium
Posts: 29
Joined: Tue Aug 28, 2007 4:21 am
Location: Italy
Contact:

Re: One logical expansion of CFDG is to move to 3D

Post by mycelium »

Update...

I implemented some of this idea using (a lot of) parameters and some code with the new V3.

built in z coord seems to work really very well even with a huge number of shapes and a lot of transparencies.

A 3d wire
http://www.contextfreeart.org/gallery/view.php?id=2806

A dephormed sphere
http://www.contextfreeart.org/gallery/view.php?id=2809

A fractal
http://www.contextfreeart.org/gallery/view.php?id=2810

A dephormed cube filled with a wire
http://www.contextfreeart.org/gallery/view.php?id=2815


Math for 3d rotations was taken from here

mycelium
Posts: 29
Joined: Tue Aug 28, 2007 4:21 am
Location: Italy
Contact:

Re: One logical expansion of CFDG is to move to 3D

Post by mycelium »

Update 2
After the first 3D designs I discovered that I always did similar things, using similar tecniques and doing a lot of copy/paste of formulas...

Since this didn't seem a complex job, I implemented a preprocessor (or maybe a translator, I don't know in what category it should be) that takes a modified 3D-CFDG code and creates a standard CFDG v3 code. It does some simple and mechanical things adding 3d formulas and manipulating strings in every shape / rule declaration, this is why I consider it a preprocessor.
I used PHP because I am familiar with it and it has many string manipulation functions.

Once translated, the 3D reference system and transformations are managed with the numeric parameters of the shape directive. Calculations and anything else is done normally by CFA.

In 1st implementation, some days ago, I used directly x,y,z, s of CFA to manage position and scaling. But I had sometimes problems with Z coord and this also was limitative for some aspects. The nice thing was that the smallest size internal directive for terminating the rendering still worked.

In 2nd and actual implementation absolute x,y,z are part of the new reference system. In this way it is also possible to create perspective view, shodows on a plane and maybe other things. (like in spaghetti chair)

The 3d shape adjustments are

X, Y, Z : move relatively x,y,z
RX RY RZ : rotate around X, Y or Z relative axis, R is same of RZ
SX SY SZ : scale relative axis X Y Z
S : SX,SY,SZ in identical manner

There is no skew and flip.
It is possible to mirror the reference system setting SX or SY or SZ to -1

3D primitives are implemented directly in CFA using paths too, directly using the variables rapresenting the reference system, for exemple a 4 side TUBO (a pipe) primitive in the semprevivo.

Rendering termination is obtained by specifing an absolute minimum shape size. Since I couldn't use "If" command (scope of variables is limited inside control structure) termination is obtained using boolean operation in the s adjustment of the shape... s (size > minimum).

Post Reply