POV-Ray : Newsgroups : povray.newusers : Help with CGS Server Time
6 Sep 2024 06:20:06 EDT (-0400)
  Help with CGS (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Ken
Subject: Re: Help with CGS
Date: 16 Apr 1999 04:14:18
Message: <3716E1F0.706FC63A@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.

  Your misunderstanding about how the merge function is supposed to behave
is not to do with the results you are witnessing from the example you are
using but instead of the way you are using a CSG operation inside of a
while loop. The correct way to implement a merge using a csg is like the
example below. It is your while loop rearranged to operate correctly.
When using a CSG within a while loop you must move the merge statement
outside the while statement or it is not acted upon correctly. 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. So without
further ado...


// 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 
}



-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Phil Clute
Subject: Re: Help with CGS
Date: 16 Apr 1999 04:29:36
Message: <3716E849.3493316D@tiac.net>
Well, now I'm a bit confused too...
what am I doing wrong?

MERGE from the docs:
"The union operation just glues objects together, it does not remove the
objects' surfaces inside the union. Under most circumstances this
doesn't matter. However if a transparent union is used, those interior
surfaces will be visible. The merge operations can be used to avoid this
problem. It works just like union but it eliminates the inner
surfaces..."<snip>

I changed the code a little. I dropped the texture to use a pigment that
changes
color from sphere to sphere with a .7 transmit in order to show that
merge did
NOT as the docs say "eliminates the inner surfaces".

Heres my change:
#declare cnt=0;
#while (cnt < 5)
     merge {
          sphere{<-.7,-0.3,0>, 0.4
          translate <cnt/2.5,0,0>
          }
          pigment{rgbt<cnt*0.05,cnt/4.5,0.5,0.7>}//texture {T_Glass3}
          //interior{ior 1.5}
          #if (phon)
               photons{
                   density 0.01*phd
                   reflection on
                   refraction on
               }
          #end
          //rotate y*50        //I was checking to see if it was just an
effect of a bad angle
     }
#declare cnt=cnt+1
#end
------------------------------------------------------------------------

I'll post my render of this in povray.images under "Help with CGS"

--
...coffee?...yes please! extra sugar,extra cream...Thank you.


Post a reply to this message

From: Ken
Subject: Re: Help with CGS
Date: 16 Apr 1999 04:32:59
Message: <3716E652.446B9B61@pacbell.net>
Phil Clute wrote:
> 
> Well, now I'm a bit confused too...
> what am I doing wrong?
> 
> MERGE from the docs:
> "The union operation just glues objects together, it does not remove the
> objects' surfaces inside the union. Under most circumstances this
> doesn't matter. However if a transparent union is used, those interior
> surfaces will be visible. The merge operations can be used to avoid this
> problem. It works just like union but it eliminates the inner
> surfaces..."<snip>
> 
> I changed the code a little. I dropped the texture to use a pigment that
> changes
> color from sphere to sphere with a .7 transmit in order to show that
> merge did
> NOT as the docs say "eliminates the inner surfaces".

Your code suffers the same as his in that the merge needs to be specified
outside the while loop before it will be acted upon.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Phil Clute
Subject: Re: Help with CGS
Date: 16 Apr 1999 04:36:24
Message: <3716E9E1.2979744@tiac.net>
Aha! that fixed it!

--
...coffee?...yes please! extra sugar,extra cream...Thank you.


Post a reply to this message

From: Markus Becker
Subject: Re: Help with CGS
Date: 16 Apr 1999 04:40:24
Message: <3716EA1D.7F0D75F1@zess.uni-siegen.de>
Ken wrote:
> 
> while loop. The correct way to implement a merge using a csg is like the
> example below. It is your while loop rearranged to operate correctly.
> When using a CSG within a while loop you must move the merge statement
> outside the while statement or it is not acted upon correctly. 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.

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?"

Markus


Post a reply to this message

From: Ken
Subject: Re: Help with CGS
Date: 16 Apr 1999 05:07:48
Message: <3716EE77.2B49791E@pacbell.net>
Markus Becker wrote:
> 
> Ken wrote:
> >
> > while loop. The correct way to implement a merge using a csg is like the
> > example below. It is your while loop rearranged to operate correctly.
> > When using a CSG within a while loop you must move the merge statement
> > outside the while statement or it is not acted upon correctly. 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.
> 
> 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?"
> 
> Markus

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.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

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 4 Messages Goto Initial 10 Messages

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