|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I've hunted a bit in the docs and the newsgroups, but was rather surprised
to not be able to find a simple solution for this problem. I figured that
someone might know a workaround, so I thought I would ask.
What I want to do is to use world coordinates in a material, without needing
to set the material at a root level. Normally this wouldn't be a problem,
but I have a lot of objects with different materials inside a union, of
which there are many instances. I want the material for each instance to
use the world coordinate system, but there does not appear to be a way to
do that.
As an example:
#declare myComposite = union {
object {
complicatedObject1
material{material1}
}
object {
complicatedObject2
material{material2}
}
}
object { // instance 1
myComposite
translate <...>
rotate <...>
}
object { // instance 2
myComposite
translate <...>
rotate <...>
}
I want both instances to use the same coordinate system in their materials,
but that doesn't work with the current code.
The only way I know how to do this is to reorganize the groups so that I am
creating unions based on materials, and then to assign the material at the
top level, but for repeated objects with complicated materials, this gets
really tedious.
Does anyone know any good workarounds for this?
Thank you!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
You could put your rotation & translation into a transform variable & then
apply the inverse transformation to the materials which would also be
instanced. Note though that there've been a number of posts on here
mentioning that the (more tedious) method you mentioned will be more
efficient in terms of render speed & memory usage.
Charles
"Calvin" <ash### [at] gmailcom> wrote:
> I've hunted a bit in the docs and the newsgroups, but was rather surprised
> to not be able to find a simple solution for this problem. I figured that
> someone might know a workaround, so I thought I would ask.
>
> What I want to do is to use world coordinates in a material, without needing
> to set the material at a root level. Normally this wouldn't be a problem,
> but I have a lot of objects with different materials inside a union, of
> which there are many instances. I want the material for each instance to
> use the world coordinate system, but there does not appear to be a way to
> do that.
>
> As an example:
>
> #declare myComposite = union {
> object {
> complicatedObject1
> material{material1}
> }
>
> object {
> complicatedObject2
> material{material2}
> }
> }
>
> object { // instance 1
> myComposite
> translate <...>
> rotate <...>
> }
>
> object { // instance 2
> myComposite
> translate <...>
> rotate <...>
> }
>
> I want both instances to use the same coordinate system in their materials,
> but that doesn't work with the current code.
>
> The only way I know how to do this is to reorganize the groups so that I am
> creating unions based on materials, and then to assign the material at the
> top level, but for repeated objects with complicated materials, this gets
> really tedious.
>
> Does anyone know any good workarounds for this?
> Thank you!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Mark Birch" <las### [at] hotmailcom> 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
|
|
| |
| |
|
|
|
|
| |
|
|