|
![](/i/fill.gif) |
"Mark Birch" <las### [at] hotmail com> wrote:
> You could try creating a seperate union for all the instances of a component
> with a particular material, eg:
>
> union{ // material1
> object{complicatedObject1 rotate<instance1> translate<instance1>}
> object{complicatedObject2 rotate<instance2> translate<instance2>}
> material{material1}
> }
>
> union{ // material2
> object{complicatedObject1 rotate<instance1> translate<instance1>}
> object{complicatedObject2 rotate<instance2> translate<instance2>}
> material{material2}
> }
>
> You could also put all the translations/rotations for each instance into an
> array to make it easier to build/modify the unions...
>
> union{
> #local ca = 0;
> #while(ca<numobjects)
> object{complicatedobject1 rotate<myarray[0][ca]>
> translate<myarray[1][ca]>}
> #local ca = ca+1;
> #end
> material{material1}
> }
>
> HTH
Using arrays is a good idea, as is storing the transformation in a variable.
In my situation it is really rather unfeasible to group objects separately
according to their material because I am using rather complicated
architecture that is occurring in several nested layers.
So it's something to the effect of...
#declare ComplicatedObject[01-04] = union { /* mess of primitives, some with
different materials */ }
#declare ComplicatedObject[05-08] = union { /* mess of primitives and
ComplicatedObjects */}
#declare ComplicatedObject[09-12] = union { /* mess of yet more
ComplicatedObjects*/ }
In this sort of circumstance it is really quite difficult to get the
materials on a world coordinate system, without adding a whole lot of
redundant code, regardless of method. This sort of code causes me tons of
problems because I change something without fixing all of the instances
where the change is used, and then the whole thing explodes.
But fortunately, I started out on this project using macros, and now I know
that I can pass the transformation into the macro.
#macro ComplicatedObject(params, T) union {
/* mess of primitives, whatnot */
primitive { ...
transform {T}
material {...}
}
} #end
As Charles said, it may be less efficient in terms of speed and memory, but
for me, at least, it's easier to write!
Post a reply to this message
|
![](/i/fill.gif) |