POV-Ray : Newsgroups : povray.general : Function: Problem in Defining : Re: Function: Problem in Defining Server Time
18 Apr 2024 16:36:08 EDT (-0400)
  Re: Function: Problem in Defining  
From: clipka
Date: 5 Apr 2018 12:21:25
Message: <5ac64d05$1@news.povray.org>
Am 05.04.2018 um 17:57 schrieb Sven Littkowski:
> Thanks. Yes, I assumed that there are many errors in my function. But I
> am still not sure, how to develop a code that does what I need to be done.

You can't do it with a function, because `rand()` cannot be called from
within a function.

However, since you're only using it to generate a scene (as opposed to
using it for something where it would have to be evaluated during
rendering, such asn in an isosurfaces or function pattern), the good
news is that you don't need a function anyway - a macro will do nicely.

For example, to define a "pseudo-function" that gives you a random
number in a specific range, you might use:

    #declare MySeed = seed(4711);
    #macro MyRand(Min,Max)
      // compute stuff
      #local Rand = rand(MySeed);
      #local Result = Min + (Max-Min)*Rand;
      // "return" the computed value
      Result
    #end


Post a reply to this message

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