|
![](/i/fill.gif) |
Am 13.02.2011 15:29, schrieb Marco:
> I hqve the ewirdest thing: I copied a Round_Box_Union, but cannot give it a
> texture, like the round_box I copied it from. In the 2nd I get this error (note:
> only in the 2nd one, not the first! ???)
>
> Parse Error: Expected 'object or directive', texture found instead
>
> #declare listBox=union{
> Round_Box_Union
> (
> //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
> <-7, 0.25, 6> <-1, 1.5, -7>, 0.2)
> texture {T_Gold_1A}
> }
>
> Round_Box_Union
> (
> //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
> <-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1)
> texture {T_Gold_1A}
> }
>
> This has worked before, before I added the 2nd Round_Box I did get a nicely
> rendered
> Round_Box, with fancy Gold_1A texture and all.
Jim already posted the proper solution; to understand what is happening,
let's reformat your code to better see the structure (which is always a
good idea when you get errors you don't understand):
#declare listBox = union {
Round_Box_Union(<-7, 0.25, 6> <-1, 1.5, -7>, 0.2)
texture {T_Gold_1A}
Round_Box_Union(<-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1)
texture {T_Gold_1A}
}
Now recall that the Round_Box_Union macro evaluates to a union itself,
so here's an outline of what your code evaluates to:
#declare listBox = union {
union {...}
texture {T_Gold_1A}
union {...}
texture {T_Gold_1A}
}
As you can see, the texture statements doen't pertain to each individual
rounded box union - they pertain to your whole listBox union instead.
Which is obviously not what you intended to do.
In this case, where the textures are identical, the solution is trivial:
Just remove the first texture statement. However, if you need one of the
boxes to have a different texture, you'll have to apply the textures to
the individual boxes.
Obviously you can't add the textures to the Round_Box_Union in a
straightforward way, as that's a macro. However, if you first assign the
macro results to an identifier, the solution should be pretty obvious:
#declare MyRoundedBox1 = Round_Box_Union(...)
#declare MyRoundedBox2 = Round_Box_Union(...)
#declare listBox = union {
object { MyRoundedBox1 texture {...} }
object { MyRoundedBox2 texture {...} }
}
And, as Jim already demonstrated, the object statement doesn't
necessarily require an identifier; you can instead insert full-fledged
object descriptions there, e.g.:
object { sphere {...} ... }
This of course is pretty useless for verbatim object descriptions, but
is pretty useful when using macros that expand to a full object
description - as in your case:
#declare listBox = union {
object { Round_Box_Union(...) texture {...} }
object { Round_Box_Union(...) texture {...} }
}
Post a reply to this message
|
![](/i/fill.gif) |