POV-Ray : Newsgroups : povray.general : CSG vs. Shape Modifiers : Re: CSG vs. Shape Modifiers Server Time
8 Aug 2024 10:25:34 EDT (-0400)
  Re: CSG vs. Shape Modifiers  
From: Eitan Tal
Date: 20 Jan 2001 13:07:21
Message: <3A69D3AA.3154D48@netvision.net.il>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
 
<p>Eitan Tal wrote:
<blockquote TYPE=CITE>Take a look at this:
<p><font size=-2>#version 3</font>
<p><font size=-2>//#include "colors.inc"</font>
<p><font size=-2>global_settings</font>
<br><font size=-2>{</font>
<br><font size=-2>  assumed_gamma 1.0</font>
<br><font size=-2>}</font>
<p><font size=-2>// ----------------------------------------</font>
<br><font size=-2>camera</font>
<br><font size=-2>{</font>
<br><font size=-2>  location  <0.0, 0.5, -2.0></font>
<br><font size=-2>  direction 1.5*z</font>
<br><font size=-2>  right     4/3*x</font>
<br><font size=-2>  look_at   <0.0, 0.5,  0.0></font>
<br><font size=-2>}</font>
<p><font size=-2>sky_sphere</font>
<br><font size=-2>{</font>
<br><font size=-2>  pigment</font>
<br><font size=-2>  {</font>
<br><font size=-2>    gradient y</font>
<br><font size=-2>    color_map { [0.0 color blue 0.6] [1.0
color rgb 1] }</font>
<br><font size=-2>  }</font>
<br><font size=-2>}</font>
<p><font size=-2>light_source</font>
<br><font size=-2>{</font>
<br><font size=-2>  0*x // light's position (translated below)</font>
<br><font size=-2>  color red 1.0  green 1.0  blue 1.0 
// light's color</font>
<br><font size=-2>  translate <-30, 30, -30></font>
<br><font size=-2>}</font>
<br><font size=-2>//Parameters for the RawMaterial (fungus)</font>
<br><font size=-2>#declare toph = 4</font>
<br><font size=-2>#declare w1 = 12</font>
<br><font size=-2>#declare h1 = 22</font>
<br><font size=-2>#declare w2 = 21</font>
<br><font size=-2>#declare CheckPoint = 11</font>
<br><font size=-2>#declare h2 = (w2 * CheckPoint) / w1</font>
<br><font size=-2>#declare CenterX = 10.5</font>
<br><font size=-2>#declare CenterY = 17</font>
<br><font size=-2>#declare r = 3</font>
<br><font size=-2>#declare r1 = 2.16</font>
<p><font size=-2>//Parameters for the Room</font>
<br><font size=-2>#declare WallThickness = 1</font>
<br><font size=-2>#declare Size = 10</font>
<p><font size=-2>#declare RawMaterial =</font>
<br><font size=-2>merge {</font>
<br><font size=-2>  box</font>
<br><font size=-2>  {</font>
<br><font size=-2>    <(w2-w1)/2,0,0>  // one corner
position <X1 Y1 Z1></font>
<br><font size=-2>    <(w2+w1)/2,h1,1>  // other
corner position <X2 Y2 Z2></font>
<br><font size=-2>  }</font>
<br><font size=-2>  cylinder</font>
<br><font size=-2>  {</font>
<br><font size=-2>    0*z, 1*z, 0.43</font>
<br><font size=-2>    scale <w2,h2,1></font>
<br><font size=-2>    translate <CenterX, CenterY,0></font>
<br><b><font size=-2>   <font color="#FF0000">bounded_by {box
{<-1,CheckPoint,-1>,<w2+1,CenterY,2>}}</font></font></b>
<br><font size=-2> }</font>
<br><font size=-2>  cylinder</font>
<br><font size=-2>  {</font>
<br><font size=-2>    0*z, 1*z, 0.43</font>
<br><font size=-2>    scale <w2,h2-3.5,1></font>
<br><font size=-2>    translate <CenterX, CenterY,0></font>
<br><font size=-2>    <b><font color="#FF0000">bounded_by
{box {<-1,CenterY,-1>,<w2+1,h1,2>}}</font></b></font>
<br><font size=-2>  }</font>
<br><font size=-2>  difference</font>
<br><font size=-2>  {</font>
<br><font size=-2>    box {</font>
<br><font size=-2>      <(w2-w1)/2,h1,0>,</font>
<br><font size=-2>      <(w1+w2)/2,h1+toph,1></font>
<br><font size=-2>    }</font>
<br><font size=-2>    cylinder {-1*z, 2*z, r</font>
<br><font size=-2>      scale <w2/2, toph,
1></font>
<br><font size=-2>      translate
<((w2-w1)/2)-(r1*w2/2),h1+(r1*toph),0></font>
<br><font size=-2>    }</font>
<br><font size=-2>    cylinder {-1*z, 2*z, r</font>
<br><font size=-2>      scale <w2/2, toph,
1></font>
<br><font size=-2>      translate
<((w2+w1)/2)+(r1*w2/2),h1+(r1*toph),0></font>
<br><font size=-2>    }</font>
<br><font size=-2>  }</font>
<br><font size=-2>}</font>
<br><font size=-2>#declare Room =</font>
<br><font size=-2>difference {</font>
<br><font size=-2>  box {</font>
<br><font size=-2>    <-Size,-Size,-Size>,</font>
<br><font size=-2>    <Size,Size,Size></font>
<br><font size=-2>  }</font>
<p><font size=-2>{</font>
<br><font size=-2>  <0,0,0>,<50,50,50></font>
<br><font size=-2>  bounded_by {</font>
<br><font size=-2>    box{<-100,-100,0>,<20,30,50>}</font>
<br><font size=-2>  }</font>
<br><font size=-2>}</font>
<p><font color="#3333FF"><font size=-2>difference {</font></font>
<br><font color="#3333FF"><font size=-2>  object {Room pigment{color
rgb <1,1,1>}}</font></font>
<br><b><font color="#3333FF">  object {RawMaterial scale <0.5,0.5,2>
translate <-4.5,-4.5,-11> pigment {color rgb 1}}</font></b>
<br><font color="#3333FF"><font size=-2>  translate <0,0,50></font></font>
<br><font color="#3333FF"><font size=-2>}</font></font>
<br><b><font color="#009900">//</font>object {RawMaterial scale <0.5,0.5,2>
translate <-4.5,-4.5,39> pigment {color rgb 1}}</b>
<p>If you skip the difference (marked in blue) by <font color="#009900">/*</font>
and <font color="#009900">*/ </font><font color="#000000">and remove the
</font><b><font color="#009900">//
</font></b><font color="#000000">of the line above,</font>
<br><font color="#000000">you get different results: the difference ignores
the cutting of the big cylinder. </font><b><font color="#FF0000"><font size=-2>(marked
in red above)</font></font></b>
<br><font color="#000000">why? and how do I get over this problem?</font>
<p><font color="#000000">  Thanks in advance</font>
<br><font color="#000000">  -Eitan Tal</font>
<br><font color="#000000">Icq: 1515298</font></blockquote>
And if you change the bounded_by into clipped_by, the difference will not
work at all -- it will make
<br>the object dissapear. that makes sense because clipped_by makes the
object to be unreal, I mean
<br>if you try to fill it, it will take infinite screen. that might be
a reason.
<p>Question 2: what's the difference between union {} and merge {} ?</html>


Post a reply to this message

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