HIDIHO!

giving something back to the Flash community

structure synth + sunflow

Tags: , , ,

structuresynth cover
happy new year to you, my beloved reader :)

I’ve been extra busy lately with a soon-to-be-offically-released website. it was a lot of stress but the result is pretty satisfactory to all extents. Funnily enough, my last project for the agency (RAPP) was also the most exciting.

so, since last sunday I’ve been recovering and taking it easy / monitoring gently the end of the project. this gave me the occasion to try out structure synth along with sunflow.

unlike most 3D modeling softwares, structure synth allows one to create rules that will generate a 3D mesh. it’s pretty much like the L-system thing (def.) on which I had been working a while ago ( article[FR] ). the principle is the same ; you give a bunch of rules that are executed recursively. it’s just that it’s in 3D and it’s rendered with a kick ass engine :D

it looks like this ( check my brand new flickr account for bigger pictures ):

structure synth
structure synth cube
structure synth
structure synth cube
structuresynth
structure synth

Now the least I can say is that structure synth’s language is extremely limited ; you can manipulate only the position/rotation/scale (PRS) and eventually a transformation matrix + a couple of properties.
but guess what ; it’s enough! :)
for instance the following snippet:

/*
@author nicolas barradeau
*/
// Camera settings. Place these before first rule call.
set translation [0 0 -20]
set rotation [	0.151268 0.0834454 0.985012 
		0.267793 0.955749 -0.122094 
		-0.95161 0.282253 0.122229 ]
set pivot [0 4 0]
set scale 1.1575
set background #FFFFFF
set maxobjects  5400

//variables
#define _col0 #F00
#define _col1 #FF0
#define _inc 0.1

//ground
{ s 100 0.01 100 y -10 color #FFF }box

//seed = 14
40 * {   y 0.1 ry 9 rz -2 s 1.01 1.01 1.01 color _col0  }column

rule column w 0.5
{
{ y 0.5 ry 18   blend _col1 _inc     }box
}
rule column w 0.2
{
{ x -0.25 z -0.25 y 0.5 s 0.8  blend _col1 _inc     } box
}
rule column w 0.2
{
20 * { rx 1 ry 1.5 rz 3 s 0.75 0.95 1.10  
	blend _col1 _inc }box
}

will give this alien looking shape
structuresynth demo

note that there is a PRNG that generates a seed. it’s auto-incremental by default but it can be switched off allowing you to keep track of the variations of a given set of rules.
the ‘w’ param after the rule’s name is the weight of the rule namely the number of chances it has to be picked up each time the rule is called.

here’s another example with a more complex set of rules:

/*
@author nicolas barradeau	
*/
// Camera settings. Place these before first rule call.
set translation [0 0 -20]
set rotation [	
		0.22177 -0.798972 0.559059
		-0.773209 0.205259 0.600059 
		-0.594185 -0.565345 -0.572249 ]
set pivot [0 0 0]
set scale 0.65
set background #FFF

//cube's size
#define _width 5
#define _height 5
#define _depth 5
//colors/iterations for the corners
#define iterations 18
#define _col0 #172A29
#define _col1 #097B69

rule CUBE
{
	{ x -_width y _height z -_depth }C000
	{ x  _width y _height z -_depth  } C001
	{ x  _width y -_height z -_depth  } C011
	{ x -_width y -_height z -_depth  } C010

	{ x -_width y _height z _depth }C100
	{ x  _width y _height z _depth  } C101
	{ x  _width y -_height z _depth  } C111
	{ x -_width y -_height z _depth  } C110
}
CUBE

//8 CORNERS
rule C000{	CORNER 	}
rule C001{	{ rx 0 ry -90 rz 0 }CORNER		}
rule C011{	{rx 180 ry 180 rz 0 }CORNER		}
rule C010{	{rx 180 ry 90 rz 0 }CORNER		}

rule C100{	{rx 0 ry 90 rz 0 }CORNER		}
rule C101{	{rx 0 ry 180 rz 0 }CORNER		}
rule C111{	{rx 180 ry -90 rz 0 }CORNER		}
rule C110{	{rx 180 ry 0 rz 0 }CORNER		}

//ARC
rule ARC maxdepth iterations {
	{ z 0.85 rx 6.5 s 0.95 blend _col1 0.09 } ARC
	box
}
//CORNER
rule CORNER
{
	{ color _col0 }ARC
	{ color _col0 rx -90 ry 90 }ARC 
	{ color _col0 rz 90 ry -90 }ARC
}

which should be rendered like:
structuresynth cube

oh btw when I say render I mean with sunflow.
structure synth allows you to export a template for sunflow.

sunflow is also a pretty sharp tool :)
I was impressed by the speed at which it computes global illuminations( which is known to be a very expensive rendering method)
I haven’t pushed it too far though yet I’ve tweaked the example files and obtained pretty interesting results.
I’m sure we could include pictures to break the regularity of the renders.
was also thinking of an actionscript template for structure synth, like to export the meshes to a given flash 3D format. I don’t know if it’s worth given that most of the effect comes from the render.
So I thought of an exporter for the flash 3D engines models but it doesn’t make much sense either ( the *.jar won’t run on any server… ).
anyway, I keep in mind that such pictures are pretty easy to obtain and I’m glad to have had enough time to try it out.

happy coding :)

Tags: , , ,

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.