|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'm creating a fairly simple recursive macro which creates a 10x10x10 cube,
and based on the level of recursion, breaks down each sub cube into
10x10x10 cubes, which may be in turn broken down into 10x10x10 cubes...
[take a look at
http://loudsl01-253-100-25.iglou.com/~tiger/pov_images/cube1.png]
Here's the source:
// by Barton Chittenden, based on PYRAMID2.POV by Chris Young
// Define the macro. Parameters are:
// X: position of lower/right/forward block
// Y: position of lower/right/forward block
// Z: position of lower/right/forward block
// E: Length of edge of cube
// L: level of recursion
#macro Cube(X,Y,Z,E,L)
#local Side = E * 0.80;
#if ( L = 0)
box { <X,Y,Z>, <X+Side,Y+Side,Z+Side>
//pigment{color <R,G,B> }
}
#end // if recusion is false
#if (L > 0)
# local New_L = L - 1;
# local New_E = Side / 10;
# local i = 0;
# local j = 0;
# local k = 0;
#while(i < 10)
#while(j < 10)
#while(k < 10)
Cube(
X+i*New_E,
Y+j*New_E,
Z+k*New_E,
New_E, New_L
)
#declare k = k+1;
#end // Xhile k
#declare k = 0;
#declare j = j+1;
#end // while j
#declare j = 0;
#declare i = i+1;
#end // while i
#end // if recursion is true
#end // macro Cube
union {
Cube(-cube_radius,0,-15,10,2)
pigment { color rgb <1,0,0> }
}
light_source { <2,20,-10> color rgb <1,1,1> }
light_source { <2,10,-20> color rgb <1,1,1> }
background { color rgb <0, 0, 0> }
// Cube is 10 units wide... sub cubes
camera {
right x
location <0,3*cube_radius,-25>
look_at <0,0,-3.5>
}
The trouble that I'm having is that I'm running out of memory because there
are numerous tokens created for each sub cube. If I use
Cube(-cube_radius,0,-15,10,1)
I'm fine; it creates 1002 objects (one for each sub cube, then two lights).
the render shows:
0:00:00 Parsing
0:00:00 Creating bounding slabs
0:00:00 Creating vista buffer
0:00:00 Creating light buffers 209K tokens
Indicating roughtly 200 tokens/sub cube
If I increase the recursion level to 2:
Cube(-cube_radius,0,-15,10,2)
I try to render, and it bottoms out at
0:02:12 Parsing 207628K tokens
Now most of the sub cubes are hidden, but because there is some space
between the sub cubes, there are areas where you can see all the way
through the cube. I'm trying to figure out a way of not parsing the sub
cubes that I can't see so that I don't swamp the memory, yet I want to make
sure that the parts of the
structure which are visible actually show correctly.
I'm not stuck on recursion, although that seems to be the simplest way of
generating a structure of this type.
Any thoughts?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
barton wrote:
> I'm not stuck on recursion, although that seems to be the simplest way of
> generating a structure of this type.
Well, your branch factor is a whopping 10^3 = 1000 so obviously you
are not going to achieve a great recursion depth with this approach.
Are you stuck on the 10? Make the division count a parameter and
play with it, e.g., a 5x5x5 cube would be a lot friendlier.
The recursive approach itself is not the problem, just that
the object you are trying to build has a lot of components.
As there are gaps on all levels, almost every box could contribute
something to the output image. However, you might get away with
skipping all inner cubes (i.e., only recurse if one of i,j,k is
exactly 0 or 10), effectively reducing the branch factor to
10x10x10 - 8x8x8 = 488.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> The recursive approach itself is not the problem, just that
> the object you are trying to build has a lot of components.
Well, actually it could be possible to render the million boxes
you'd get at recursion depth 2, so you could try to get over the
parse problem using an iterative approach. Still I'd recommend
to reduce the number of objects. You might even try to fake the
last recursion level by using some sort of checker-like texture
with transparency.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Christian Froeschlin <chr### [at] chrfrde> wrote:
> barton wrote:
>
> > I'm not stuck on recursion, although that seems to be the simplest way of
> > generating a structure of this type.
>
> Well, your branch factor is a whopping 10^3 = 1000 so obviously you
> are not going to achieve a great recursion depth with this approach.
> Are you stuck on the 10? Make the division count a parameter and
> play with it, e.g., a 5x5x5 cube would be a lot friendlier.
Yeah... the point of the exercise it to illustrate how big a billion is ;-)
>
> The recursive approach itself is not the problem, just that
> the object you are trying to build has a lot of components.
>
> As there are gaps on all levels, almost every box could contribute
> something to the output image. However, you might get away with
> skipping all inner cubes (i.e., only recurse if one of i,j,k is
> exactly 0 or 10), effectively reducing the branch factor to
> 10x10x10 - 8x8x8 = 488.
I'm definitely willing to give this a try... stupid question:
how do an 'or' in SDL? I would like to do something like this:
#if( i = 0 or j = 0 or k = 0 or i = 9 or j = 9 or k = 9)
Cube(
X+i*New_E,
Y+j*New_E,
Z+k*New_E,
New_E, New_L
)
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok; I figured it out...
check out http://loudsl01-253-100-25.iglou.com/~tiger/pov_images/cube2.png
for the results...
here's the code:
#macro Cube(X,Y,Z,E,L)
#local Side = E * 0.80;
#if ( L = 0)
box { <X,Y,Z>, <X+Side,Y+Side,Z+Side>
//pigment{color <R,G,B> }
}
#end // if recusion is false
#if (L > 0)
# local New_L = L - 1;
# local New_E = Side / 10;
# local i = 0;
# local j = 0;
# local k = 0;
#while(i < 10)
#while(j < 10)
#while(k < 10)
#if( i = 0 | j = 0 | k = 0 | i = 9 | j = 9 | k = 9)
Cube(
X+i*New_E,
Y+j*New_E,
Z+k*New_E,
New_E, New_L
)
#else
Cube(
X+i*New_E,
Y+j*New_E,
Z+k*New_E,
New_E, New_L - 1
)
#end
#declare k = k+1;
#end // Xhile k
#declare k = 0;
#declare j = j+1;
#end // while j
#declare j = 0;
#declare i = i+1;
#end // while i
#end // if recursion is true
#end // macro Cube
#declare cube_radius = 3.9;
union {
Cube(-cube_radius,0,-15,10,2)
pigment { color rgb <1,0,0> }
}
light_source { <2,20,-10> color rgb <1,1,1> }
light_source { <2,10,-20> color rgb <1,1,1> }
background { color rgb <0, 0, 0> }
// Cube is 10 units wide... sub cubes
camera {
right x
location <0,3*cube_radius,-25>
look_at <0,0,-3.5>
}
What I did was to reduce the recursion level by 2 for the middle cubes ...
so the middle isn't empty, it's just filled with larger cubes that parse
more easily.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
barton wrote:
> Ok; I figured it out...
>
> check out http://loudsl01-253-100-25.iglou.com/~tiger/pov_images/cube2.png
> for the results...
well, now you have a million, good luck reaching for the billion ;)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
As an alternative, create a mesh2 that has the 1st level of 10 x 10 x 10
cubes as a single object, and use copies of that.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
An easier way to cut out the interior cubes, would be to declare a smaller
dummy cube and perform an 'inside' test on that. If your cubes would fall
inside the dummy object, then don't place them.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Christian Froeschlin nous apporta ses lumieres en ce 2007/07/29 13:36:
> barton wrote:
>> Ok; I figured it out...
>>
>> check out
>> http://loudsl01-253-100-25.iglou.com/~tiger/pov_images/cube2.png
>> for the results...
>
> well, now you have a million, good luck reaching for the billion ;)
It should be easier or beter to fake the next step. Use 3 gradiants to place
thin black lines, with the part between the lines transparent.
--
Alain
-------------------------------------------------
Zen Buddhism: Shit is, and is not.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
barton wrote:
> I'm creating a fairly simple recursive macro which creates a 10x10x10 cube,
> and based on the level of recursion, breaks down each sub cube into
> 10x10x10 cubes, which may be in turn broken down into 10x10x10 cubes...
You'll be lucky to get more than two levels of recursion before you have
so many scene objects that your memory manager will scream bloody murder,
UNLESS
You are culling a large proportion of the obects from the scene.
Regards,
John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|