POV-Ray : Newsgroups : povray.advanced-users : Advanced script, idea/help. : Re: Script, idea/help. Server Time
30 Jul 2024 14:21:28 EDT (-0400)
  Re: Script, idea/help.  
From: Spider
Date: 18 Apr 1999 14:27:58
Message: <371A14F0.2171AD73@bahnhof.se>
Well, I get your points very well, and so far i'm with you, but what I'm after
is to make a bit more general implementation, ie. how to make it work on several
shapes that aren't identified.
I'd need some kind of data-structure in an array, like this.

shape[0..10] //10 points, 0 is always the lowest, the rest can be anything 
else.
in each point you'll need:
position : (0 for the lowest, <0 for nonexisting=
angle:	At  what angle does it point
length : How long is it.

This could be rather easy to implement in a pov script, like :

//Must be #declare for #macros to access it.
#declare arr = array[10][3]
10 is the index, what point are we talking about.
3 are the elements, theese should be vectors
(Point, Angle, Length)
#declare cPoint = 0;
#declare cAngle = 1;
#declare cLength = 2;

#macro init()
  #local I = 0;
  #while(I<10)
    //Don't loop, this is faster.
    #declare arr[I][cPoint] = <-1,-1,-1>;
    #declare arr[I][cAngle] = <0,0,0>;
    #declare arr[I][cLength] = <0,0,0>;
    #local I = I + 1;
  #end
#end
And to set a point, you'd only need to loop the array and look for the first
unset point.

To implement this I'd need to do it with Cylinders, but my problem is, how to
utilize the angle...

Ok, I think I got it as I typed here...
This is only ideas..

#macro Draw(Level)
  #if(Level>0)
    union {
      #local I = 0;
      #while(I<10)
        #if(!arr[I][cPoint]=<-1,-1,-1>)
          cylinder {
            <0,0,0>, arr[I][cLength], 0.25
            rotate arr[I][cAngle]
            translate arr[I][cPoint]
          }
          object { 
            Draw(Level-1)
	    rotate arr[I][cLength]
            rotate arr[I][cAngle]
            translate arr[I][cPoint]
          }
        #end
        #local I = I + 1;
      #end
    }
  #end
#end

I'll have to test this further.
(can't do so now, POV is wooooorking. *doh*)
(been doing so for 4 hours now, still parsing)

Any ideas/comments before I develop ?
(anyone else want to do it, do it ,-)


Margus Ramst wrote:
> 
> I don't thin you have to stick "advanced" to every heading simply to justify
> posting here :)
> 
> Anyway, what you want seems simple enough. I won't discuss making the
> initial object. But as for adding it recursively - here's how I imagine it:
> 
> You first generate the 1st level object. Save all the end points _and_
> directions of the respective branches in an array.
> Now, take a point in the array, and scale, rotate & translate both your 1st
> level object - and all the points & directions in the array - relative to
> the current point and the corresponding direction.
> You now have a second-level instance of the object and its end
> points/directions. Repeat the process to the desired recursion level,
> similar to the "pyramid" example macro...
> 
> I know this didn't come out all that well. Hopefully you got the main idea.
> I'll try to create an example macro when I have more time.
> 
> Margus
> 
> Spider wrote in message <371A0393.9EE2D65E@bahnhof.se>...
> >Hello.
> >I've been working around in my old demo programming libraries, and found a
> nice
> >"so called" fractal effect, where you created an image consisting of lines.
> >A base line, the angle of this line upwards, and one or more intersecting
> lines
> >for this one. With the angles set.
> >
> >This creation was then applied to all ends of itself(a new copy on each
> line
> >end). the procedure was repeated a limited amount of time, and in the end
> you
> >had a nice "tree/bush" creation(and some other very interesting things).
> >
> >Now I'm thinking loosly on creating something like this in POV, but for the
> >moment I have no idea on how to do it.
> >
> >Anyone get the concept, care to come with ideas?
> >
> >
> >--
> >//Spider
> >        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
> >What I can do and what I could do, I just don't know anymore
> >                "Marian"
> >        By: "Sisters Of Mercy"
> >

-- 
//Spider
        [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
What I can do and what I could do, I just don't know anymore
                "Marian"
        By: "Sisters Of Mercy"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.