POV-Ray : Newsgroups : povray.advanced-users : Random, Displaying values, and a parsing logistics question: : Re: Random, Displaying values, and a parsing logistics question: Server Time
29 Jul 2024 18:29:39 EDT (-0400)
  Re: Random, Displaying values, and a parsing logistics question:  
From: Ron Parker
Date: 2 May 2001 15:18:24
Message: <slrn9f0nbb.d8q.ron.parker@fwi.com>
On Wed, 02 May 2001 22:03:27 +0200, Eitan Tal wrote:
>1. How do I use a random value? I remember that a sample had shown that.
>

First, declare a seed:

#declare S=seed(124526); // use some other value for different sequences
                         // of random numbers.

Then use it with the rand function:

#declare R=rand(S) sets R to a random number between 0 and 1 (including 0
but not including 1.)  More info can be found in the "float functions" topic
in the Fine Manual.

>2. is it possible to display a value to debug? #debug doesn't do that,
>nor #warning.

#debug wants string arguments.  Look at the "string functions" topic in 
the Fine Manual.  You want the "str" function.

>3. if I use a random texture for a single object:
>
>#declare myObject = box {<0,0,0> <1,1,1> pigment {color rgb <random,
>random, random>}}
>
>and do:
>
>object {myObject}
>object {myObject translate <1,0,0>}
>
>will they have different colors?

No.  Declaring an object actually creates that object in memory,  It doesn't
reparse the object declaration every time you use it like C's #define does.
To do that, you need #macro:

#macro myObject()
  box {0 1 pigment {color rgb <rand(S), rand(S), rand(S)>}}
#end

object {myObject()}
object {myObject() translate x}



-- 
#local R=<7084844682857967,32787982,826975826580>#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

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