POV-Ray : Newsgroups : povray.newusers : #Declare-ing objects Server Time
14 Nov 2024 04:29:47 EST (-0500)
  #Declare-ing objects (Message 1 to 3 of 3)  
From: Michael
Subject: #Declare-ing objects
Date: 23 Apr 1999 15:20:11
Message: <3720B9C5.AAAB88E8@aol.com>
Greetings.
I've licked my last tootsie pop for a while.
So I've given thought to a new project:  I'm giving my mom a wishing
well for Mother's Day.
So I've been trying to get #declare and object...
here's my stuff so far:
//Begin Well test
  #declare Brick_1 = box { <0,0,0>,<1.5,1,3> }
  #include "colors.inc"
  camera {
    location <1, 2, -5>
    look_at  <0, 0,  0>
  }
  object { Brick_1  pigment { Red } }
  light_source { <10,100,-10> color White  }
//End well test
Here's my problem.
The brick renders OK.  (I'm not worried about texture yet.)  I can't
figure out how to make it so that every brick is 1.5x1x3, and then
rotate it enough around a set size sphere, just to make it appear
round...
Basically, all i need help with is the #declare and the object call.
Also, instead of having 15-20 object {Brick_1} calls with a different
translate/rotate in each one, is there a way to have just one object
call using variables, sort of a #declare Turn or something?  I've stared
at and read the help on this for over an hour and a half, now...
I do this to get rid of frustration, and end up frustrated at the
computer and myself... UGH.

Thanks for your help.
Michael


Post a reply to this message

From: TonyB
Subject: Re: #Declare-ing objects
Date: 23 Apr 1999 16:27:52
Message: <3720B72F.3BE3A7AD@panama.phoenix.net>
Use a #while loop.


Post a reply to this message

From: Ken
Subject: Re: #Declare-ing objects
Date: 23 Apr 1999 16:59:06
Message: <3720D0A5.4F12F40@pacbell.net>
Michael wrote:
> 
> Greetings.
> I've licked my last tootsie pop for a while.
> So I've given thought to a new project:  I'm giving my mom a wishing
> well for Mother's Day.
> So I've been trying to get #declare and object...
> here's my stuff so far:
> //Begin Well test
>   #declare Brick_1 = box { <0,0,0>,<1.5,1,3> }
>   #include "colors.inc"
>   camera {
>     location <1, 2, -5>
>     look_at  <0, 0,  0>
>   }
>   object { Brick_1  pigment { Red } }
>   light_source { <10,100,-10> color White  }
> //End well test
> Here's my problem.
> The brick renders OK.  (I'm not worried about texture yet.)  I can't
> figure out how to make it so that every brick is 1.5x1x3, and then
> rotate it enough around a set size sphere, just to make it appear
> round...
> Basically, all i need help with is the #declare and the object call.
> Also, instead of having 15-20 object {Brick_1} calls with a different
> translate/rotate in each one, is there a way to have just one object
> call using variables, sort of a #declare Turn or something?  I've stared
> at and read the help on this for over an hour and a half, now...
> I do this to get rid of frustration, and end up frustrated at the
> computer and myself... UGH.
> 
> Thanks for your help.
> Michael

  Like TonyB mentioned use a while loop. Assuming you already know how
to use a while loop that would be fine. I get the impression that as
a new user you don't know how to use a while loop so that advice
maybe of little use without at least some instruction.

  There are a couple of things you can do to get the shape you want.
The easy way does not teach you what and you will eventualy have to
learn it anyway. There is a file that will produce rounded brick
structures for you using an inclede file. The file itself requires
some experience to use and may not be your best choice of options.
Here is the link to the site where you can look at it to see if it
can help:

http://www.mediaport.net/Artichaud/Tran/sources/gtsrcee.htm


  Even if you don't understand how to use the files available at that
site I recommend you down load them now beacause later you will find
them very nice utilites and tools to have at your disposal.



-------
Method #2

  For a do it yourself solution I can demonstrate this to you that
is sure to help out a lot. Unfortunatly I don't have a lot of time
right now to explain the whole process to you. Basicaly what I am
using below is one of the programming like directives available in
Pov to create and rotate several copies of one declared box. For a
great tutorial on how this works ( it is the same one that taught me)
see the Sonya Roberts tutorials on using the programming directives
with Pov-Ray at:

http://www.spake.org/rtimes/

Look in the Povabilities section.

  The very basics of the operation is I first declare one brick
(box). I then translate the brick to where the outer edge of the
well's wall should be. Once in place I used a while loop to create
several copies of the original brick by rotating it around the y
axis. For the diameter of the well vs. the size of the brick I
determined how many copies and the degrees of rotation I needed and
the bricks were generated automaticaly by Pov-Ray.

 It is important to know why this works like this (not the while loop
but the translate/rotate operation). If you rotate an object while
it is centered at xyz all it will do is spin around. If you first
translate the object then rotate it will then "orbit" around the xyz
center point. You could use the same method with individual object
statements but the while loop makes it a lot easier and take less
coding work.

  I did not have time to adapt your example to my code so I quickly
put this demonstration together for you. I encourage you once you get
mom's wishing well done to play around with the code to see what makes
it work. Also you should definitely see the tutorial on the subject I
mentioned. It will open your eyes to the possiblites of the features
I used here.

And please tell your mom happy mothers day for me to.

Cheers,

-- 
Ken Tyler

mailto://tylereng@pacbell.net


// Beginning of wishing well sscen file.

  // duh !
  camera { location<-0,5,-15> look_at 0 }

  // Enlightening code work here
  light_source { < 0, 235,  -10> rgb 1 }
  light_source { < 0,  10, -153> rgb 1 }


  // The real meat and potatos of the example starts here

  // declare 1 brick
  #declare Brick = 
    box{-1,1 
         scale<0.75,0.5,1.5>
          pigment { rgb<.7,.3,0> }
        }

  // Make a ring of bricks
  #declare Ring_Set1 =
   union {
     #declare Rot1 = 0;
      #while  (Rot1< 24)
       object { Brick 
                 translate <-11,.5, 0> 
                  rotate -y*15*Rot1
              }
     #declare Rot1 = Rot1 + 1;
    #end
         }

  // Make a second ring of bricks. Like the first but rotated so the
  // cracks from the first row do not line up with the second row  
  #declare Ring_Set2 =
   union {
     #declare Rot2 = 0;
      #while  (Rot2< 24)
       object { Brick 
                 translate <-11,.5, 0>
                  rotate y*7.5 
                  rotate -y*15*Rot2
              }
     #declare Rot2 = Rot2 + 1;
    #end   
         }

  // Takes the two ring sets and translates them upward to form
  // the well's walls.
  #declare Well_Body =
   union {
     #declare Trans = 0;
      #while  (Trans< 6)
       union  {
        object { Ring_Set1 }
        object { Ring_Set2 translate y*1.1}
                 translate <0,2.2*Trans, 0>
              }
     #declare Trans = Trans + 1;
    #end
   }

  // The well body object complete
  object { Well_Body scale .25 }
  
  // A really ugly simulation of grass for background color
  plane{y,0 texture{pigment{color rgb<.2,.8,.3>}finish{crand .05 ambient .2
  diffuse .2}normal{waves 1 frequency 1000 scale 70000}scale 6}}

// End of wishing will scenefile.


Post a reply to this message

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