POV-Ray : Newsgroups : povray.newusers : trace function debug.. Server Time
31 Oct 2024 21:22:01 EDT (-0400)
  trace function debug.. (Message 1 to 6 of 6)  
From: albe99
Subject: trace function debug..
Date: 19 Apr 2007 02:40:02
Message: <web.46270ddf948c2c92df6ff5fd0@news.povray.org>
Dear friends..
imagining to place some objects (trees) on an height_field with a trace
function
like this, for example:

//-------- Placing the trees -------------
#declare Seed=seed(2);
#declare Spacing=0.24;
#declare Cnt=0;

#declare PosX=-3;

#while (PosX < 3)

  #declare PosY=-3;

  #while (PosY < 3)

    // trace function
    #declare Norm = <0, 0, 0>;
    #declare Start = <PosX+(rand(Seed)-0.5)*Spacing,
PosY+(rand(Seed)-0.5)*Spacing, 1.0>;
    #declare Pos = trace (
                  Terrain_Obj,     // object to test
                  Start,           // starting point
                  -z,              // direction
                  Norm );          // normal


    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is
found, normal differs from 0
      #if ((vdot(Norm, z)>0.85) & (Pos.z < 0.25))
      // criteria for placing trees: not too steep and not too high
        object {
          TreeA (0.05+rand(Seed)*0.02)
          translate Pos
        }
        #declare Cnt=Cnt+1;
      #end
    #end

    #declare PosY=PosY+Spacing;

  #end

  #declare PosX=PosX+Spacing;
#end

...if you wanted to know, using debug, the xyz position for each placed tree,
how can I do?...

I would want debugging a string like "translate <x,y,z>" for every object
in order to insert them in a .inc file.

can someone help me?, please..
Alberto.


Post a reply to this message

From: Tim Attwood
Subject: Re: trace function debug..
Date: 19 Apr 2007 02:59:17
Message: <46271345$1@news.povray.org>
#include "strings.inc" at the beginning, so you can use vstr.
Then in your loop , just put...

#debug concat("A tree at: <",vstr(3, Pos,", ", 0,1),"> ")

You can put a "slash n" in there at the end for a line feed too.


Post a reply to this message

From: Tim Attwood
Subject: Re: trace function debug..
Date: 19 Apr 2007 03:01:02
Message: <462713ae$1@news.povray.org>
> #include "strings.inc" at the beginning, so you can use vstr.
Oh, wait, you don't need "strings.inc" this is a built in function.


Post a reply to this message

From: Alain
Subject: Re: trace function debug..
Date: 19 Apr 2007 05:56:33
Message: <46273cd1$1@news.povray.org>
albe99 nous apporta ses lumieres en ce 19-04-2007 02:36:
> Dear friends..
> imagining to place some objects (trees) on an height_field with a trace
> function
> like this, for example:

> //-------- Placing the trees -------------
> #declare Seed=seed(2);
> #declare Spacing=0.24;
> #declare Cnt=0;

> #declare PosX=-3;

> #while (PosX < 3)

>   #declare PosY=-3;

>   #while (PosY < 3)

>     // trace function
>     #declare Norm = <0, 0, 0>;
>     #declare Start = <PosX+(rand(Seed)-0.5)*Spacing,
> PosY+(rand(Seed)-0.5)*Spacing, 1.0>;
>     #declare Pos = trace (
>                   Terrain_Obj,     // object to test
>                   Start,           // starting point
>                   -z,              // direction
>                   Norm );          // normal


>     #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is
> found, normal differs from 0
>       #if ((vdot(Norm, z)>0.85) & (Pos.z < 0.25))
>       // criteria for placing trees: not too steep and not too high
>         object {
>           TreeA (0.05+rand(Seed)*0.02)
>           translate Pos
>         }
>         #declare Cnt=Cnt+1;
>       #end
>     #end

>     #declare PosY=PosY+Spacing;

>   #end

>   #declare PosX=PosX+Spacing;
> #end

> ...if you wanted to know, using debug, the xyz position for each placed tree,
> how can I do?...

> I would want debugging a string like "translate <x,y,z>" for every object
> in order to insert them in a .inc file.

> can someone help me?, please..
> Alberto.

You want to build an inc file, so, the debug is not the way to go.
What you need is the file writing possibility.
Start by opening a file:
#fopen Handle "fileName.inc" write  early in the scene
then you use:
#write ( Handle, Your_Translate )  Next to each object in place of the #debug 
instruction.

Once you are finished, you close the file:
#fclose Handle


-- 
Alain
-------------------------------------------------
"Sure, everyone's in favor of saving Hitler's brain, but when you put it into 
the body of a great white shark, suddenly you're a madman." 
             --Futurama


Post a reply to this message

From: albe99
Subject: Re: trace function debug..
Date: 19 Apr 2007 08:40:01
Message: <web.462761ff35d026caef6b50d70@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
>
> You want to build an inc file, so, the debug is not the way to go.
> What you need is the file writing possibility.
> Start by opening a file:
> #fopen Handle "fileName.inc" write  early in the scene
> then you use:
> #write ( Handle, Your_Translate )  Next to each object in place of the #debug
> instruction.
>
> Once you are finished, you close the file:
> #fclose Handle
>

very good..
adding #debug concat("A tree at: <",vstr(3, Pos,", ", 0,1),">n")
I can see the positions of all the objects..so, I can copy/paste and
insert them in my .inc file..

the file writing possibility is very interesting..but I have some trouble
to write the code..
now I try again..


Post a reply to this message

From: albe99
Subject: Re: trace function debug..
Date: 20 Apr 2007 01:15:02
Message: <web.46284b1435d026cadf6ff5fd0@news.povray.org>
...finally I wrote this:

//-------- Placing the trees -------------

#fopen FileHandle "tree_test.inc" write

#declare Seed=seed(2);
#declare Spacing=0.24;
#declare Cnt=0;

#declare PosX=-3;

#while (PosX < 3)

  #declare PosY=-3;

  #while (PosY < 3)

    // trace function
    #declare Norm = <0, 0, 0>;
    #declare Start = <PosX+(rand(Seed)-0.5)*Spacing,
PosY+(rand(Seed)-0.5)*Spacing, 1.0>;
    #declare Pos = trace (
                  Terrain_Obj,     // object to test
                  Start,           // starting point
                  -z,              // direction
                  Norm );          // normal


    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is
found, normal differs from 0
      #if ((vdot(Norm, z)>0.85) & (Pos.z < 0.25))
      // criteria for placing trees: not too steep and not too high
        object {
          TreeA (0.05+rand(Seed)*0.02)
          translate Pos
        }

#write (FileHandle, concat("translate <",vstr(3, Pos,", ", 0,1),">n"))

        #declare Cnt=Cnt+1;
      #end
    #end

    #declare PosY=PosY+Spacing;

  #end

  #declare PosX=PosX+Spacing;
#end

#fclose FileHandle


Post a reply to this message

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