POV-Ray : Newsgroups : povray.newusers : Help with CGS Server Time
6 Sep 2024 06:21:28 EDT (-0400)
  Help with CGS (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Ken
Subject: Re: Help with CGS
Date: 16 Apr 1999 06:09:21
Message: <3716FCE7.6C3C00D4@pacbell.net>
Kevork Abadjian wrote:
> 
> I was looking at the two replies posted to my message and as far as I can see
> Ken explained the situation even better than I could; but he stopped just short
> of a suggestion to fix the problem.
> 
> there is nothing special about the source, I am using the std seen file and
> just and std texture for glass and a switch to toggle on an off the photones.

Stripped down and rearranged for clarity and examples sake I offer the
following two examples of correct and incorrect behavior. Which is which
I leave to the person who renders it to decide but it should be as obvious
as obvious can be.

  camera{
  location  <0.0, 0, -5.0>
  look_at   <0.0, 0.0,  0.0>}


  light_source{<0,440,-300>rgb 1 }


 plane { y,-3 pigment{ rgb 1}}
 plane { z, 3 pigment{ rgb 1}}

 #declare Ball1 = 
 sphere{0,0.4 
  pigment{rgbf<1,1,1,0.97>}
   translate<-0.4,-0.2,0>
    interior {ior 1.99}
 }


 #declare Ball2 = 
 sphere{0,0.4 
  pigment{rgbf<0,0,1,0.97>}
   translate<-0.4, 0.2,0>
    interior {ior 1.19}
 }

#declare cnt=0
       merge {       
#while (cnt < 4)
       object {Ball1 rotate z*90*cnt}
       object {Ball2 rotate z*90*cnt}         
       #declare cnt=cnt+1 
  #end  
 translate x*1.25
}

#declare cnt=0

#while (cnt < 4)
     merge {       
       object {Ball1 rotate z*90*cnt}
       object {Ball2 rotate z*90*cnt}         
 translate x*-1.35 }       
       #declare cnt=cnt+1 
       
  #end  



-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Markus Becker
Subject: Re: Help with CGS
Date: 16 Apr 1999 08:21:54
Message: <37171E09.16D8FD7C@zess.uni-siegen.de>
Ken wrote:
> 
> Markus Becker wrote:
> > What do you expect? If you have the "merge" _inside_ the #while
> > loop, POV creates a "merge"-object fo each pass through the
> > loop. That's the way things work. No need to ask "why?"

> Not altogether a programmer type and struggling to use what I can of these
> functions I expect no more or no less than what I can figure out myself
> of from what I can learn from the generous guidance of others. What is
> intuitively obvious to you is sometimes heap big juju magic to me.

That might be, myself being the programmer-type this has always been
obvious to me. Let me try to give you (or the original poster) a more
detailed explanation:

Case 1, "merge" _inside_ #while:

    #declare n = 0;
+-->  #while (n<10)
|       merge			// a new object is created
|       {
|          object {....}
|       }				// merge object is finished
|     #declare n = n+1;
+-- #end			// loop again and create a new object

Note that each time POV loops through the #while, it parses a 
complete merge-object.

Case 2, "merge" _outside_ #while:

    #declare n = 0;
    merge			// a new object is created
    {
+-->  #while (n<10)
|        object {....}
|     #declare n = n+1;
+-- #end			// loop again and create a new object
    }				// merge object is finished

Note here how the loop only adds new objects to the merge object.

Hope this makes it a little bit more clearer. Even if you're not at
all the programming type [tm], you should get one concept into
your head (no offense meant, it's just the lack of better english):

POV parses the file line by line and the #while only tells it
to parse some lines more often. It is just redirected to a new
position in the file.

The first case would "unroll" (common practice for the programmer
type ;-) to the following:

merge {object {...}}
merge{ object {...}}
merge {object {...}}

anbd the second case unrolls to:

merge
{
  object {...}
  object {...}
  object {...}
  object {...}
}

This should make it clearer.

Markus
-- 

 Ich nicht eine Sekunde!!!" H. Heinol in Val Thorens


Post a reply to this message

From: Nieminen Mika
Subject: Re: Help with CGS
Date: 16 Apr 1999 10:34:06
Message: <37173c4e.0@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: Don't
: ask me why this is so but I found after many hair pulling sessions and
: then finaly by asking in these groups how to solve my problem.

  Markus explained it well. You can also think about it this way:

#declare i=0;
#while(i<4)  // Make 4 copies of this:
                 merge { sphere { ... } }
 #declare i=i+1;
#end

  After parsing the result is:

                 merge { sphere { ... } }
                 merge { sphere { ... } }
                 merge { sphere { ... } }
                 merge { sphere { ... } }



  On the other hand:

merge {

#declare i=0;
#while(i<4)  // Make 4 copies of this:
                 sphere { ... }
 #declare i=i+1;
#end

}

  After parsing the result is:

merge {

                 sphere { ... }
                 sphere { ... }
                 sphere { ... }
                 sphere { ... }

}


  Sometimes the first behaviour is the wanted behaviour. For example:

union {

#declare i=0;
#while(i<4)  // Make 4 copies of this:
                 merge { sphere { ... } sphere { ... } }
 #declare i=i+1;
#end

}

  The result:

union {

                 merge { sphere { ... } sphere { ... } }
                 merge { sphere { ... } sphere { ... } }
                 merge { sphere { ... } sphere { ... } }
                 merge { sphere { ... } sphere { ... } }

}

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Kevork Abadjian
Subject: Re: Help with CGS
Date: 17 Apr 1999 03:05:55
Message: <3718265D.1DADA59B@conted.lan.mcgill.ca>
Thanks to everyone for hempling me;  specially to Ken for the smaple code.  It solved
the problem.




Ken wrote:

> // This should now act correctly for a merge csg operation:
>  #declare cnt=0
>         merge {
>  #while (cnt < 5)
>         object {ball
>                 translate <cnt/2.5,0,0>
>                }
>         #declare cnt=cnt+1
>  #end
> }


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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