|
|
I'm having some difficulty embedding a loop into an array declaration.
Is this not allowed?
Do I have to declare the array and then initialize it afterward with #declare
ExpandedArray [LoopVariable] = SomeValue; ?
I'm also curious about how folks who code this type of thing handle the
requirement for a comma, since the LAST element of the array doesn't have one.
Is there internal POV-Ray Black Magic that handles this?
#####################################################################
#declare EightHedron = array [6] {
<1, 0, 0>, <-1, 0, 0>, <0, 1, 0>, <0, -1, 0>, <0, 0, 1>, <0, 0, -1>
}
#declare BasisArray = array [8][3] {
{EightHedron [0], EightHedron [4], EightHedron [2]},
{EightHedron [2], EightHedron [4], EightHedron [1]},
{EightHedron [1], EightHedron [1], EightHedron [4]},
{EightHedron [3], EightHedron [4], EightHedron [0]},
{EightHedron [0], EightHedron [2], EightHedron [5]},
{EightHedron [2], EightHedron [1], EightHedron [5]},
{EightHedron [1], EightHedron [3], EightHedron [5]},
{EightHedron [2], EightHedron [0], EightHedron [5]}
} //end BasisArray
#declare Octahedron = union {
#for (Side, 0, 7)
triangle {
#for (Vertex, 0, 2)
BasisArray[Side][Vertex]
#end
}
#end // end for Side
pigment {Red}
}
// **** THIS IS WHERE THE PARSER WANTS A { before the #, but issues an
"insufficient number of initializers" when it's placed before the #for
#declare BasisNumber = dimension_size (BasisArray, 1);
#declare ExpandedArray = array [4 * BasisNumber][3] {
#for (BasisTriangle, 0, BasisNumber-1)
{BasisArray[BasisTriangle][0],
(BasisArray[BasisTriangle][0]+BasisArray[BasisTriangle][1])/2,
(BasisArray[BasisTriangle][0]+BasisArray[BasisTriangle][2])/2},
{BasisArray[BasisTriangle][1],
(BasisArray[BasisTriangle][1]+BasisArray[BasisTriangle][0])/2,
(BasisArray[BasisTriangle][1]+BasisArray[BasisTriangle][2])/2},
{BasisArray[BasisTriangle][2],
(BasisArray[BasisTriangle][2]+BasisArray[BasisTriangle][0])/2,
(BasisArray[BasisTriangle][2]+BasisArray[BasisTriangle][1])/2},
{(BasisArray[BasisTriangle][0]+BasisArray[BasisTriangle][1])/2,
(BasisArray[BasisTriangle][1]+BasisArray[BasisTriangle][2])/2,
(BasisArray[BasisTriangle][2]+BasisArray[BasisTriangle][0])/2}
#end // end for BasisTriangle
}
#declare ExpandedNumber = dimension_size (ExpandedArray, 1);
#declare ExpandedOctahedron = union {
#for (Side, 0, ExpandedNumber-1)
triangle {
#for (Vertex, 0, 2)
ExpandedArray[Side][Vertex]
#end
}
#end // end for Side
pigment {Red}
}
Post a reply to this message
|
|