POV-Ray : Newsgroups : povray.general : viewing the inside of csg_box.pov example Server Time
6 Nov 2024 04:17:14 EST (-0500)
  viewing the inside of csg_box.pov example (Message 1 to 4 of 4)  
From: tec
Subject: viewing the inside of csg_box.pov example
Date: 13 Sep 2004 10:28:24
Message: <4145ae88$1@news.povray.org>
Hello Everyone,
    I am executing the csg_box example with no errors. I have modified the 
exampleto use a mesh2 in place of the box because I want to take the 
difference of the box (mesh2) and a sphere so I can see the inside triangles 
of the box. I want to be able to see the inside of the boxes' triangles 
(mesh2) after I cut away the sphere. I don't want to see the curved slice 
that the sphere made. Currently, I see the background through the sliced 
hole but I really want to see the inside of the box (mesh2).

I am using the difference function. Does this function use the stencil 
buffer? Is there a way to get the vertices back after I cut a chuck out of 
the box?

Here is my code:
// Persistence of Vision Ray Tracer Scene Description File
// File: mesh2.pov
// Vers: 3.5
// Desc: mesh2 demonstration scene
// Date: November/December 2001
// Auth: Christoph Hormann

// -w320 -h240
// -w512 -h384 +a0.3

//#version 3.5;

global_settings { assumed_gamma 2.2 }


light_source { <-10, 3, -20> color red 1 green 1 blue 1 }

camera {
   location  <0, 0, -8>
   direction <0, 0, 1.2071>
   look_at   <0, 0, 0>
}

background {
  color rgb < 0.60, 0.70, 0.5 >
}

#declare Mesh_C=
mesh2{
  vertex_vectors{
    8
    <-1, -1, -1>, < 1, -1, -1>,
    <-1,  1, -1>, < 1,  1, -1>,
    <-1, -1,  1>, < 1, -1,  1>,
    <-1,  1,  1>, < 1,  1,  1>,
  }

  face_indices{
    24,
    <1,0,2>, // bottom
    <2,3,1>,
    <1,2,0>, // bottom inside
    <2,1,3>,

    <4,5,6>, // top
    <5,7,6>,
    <4,6,5>, // top inside
    <5,6,7>,

    <5,1,3>, // right
    <3,7,5>,
    <5,3,1>, // right inside
    <3,5,7>,

    <0,4,2>, // left
    <2,4,6>,
    <0,2,4>, // left inside
    <2,6,4>,

    <2,6,3>,// back
    <2,7,3>,
    <2,3,6>,// back inside
    <2,3,7>,

    <0,1,4>, // front
    <1,5,4>,
    <0,4,1>, // front inside
    <1,4,5>,

  }

}

difference {

object {
  Mesh_C
  //texture { Mesh_TextureA }
  //rotate 180*z
  //rotate 90*x
    finish {
       ambient 0.2
       diffuse 0.8
    }
    pigment { color red 0 green 0 blue 1 }
    translate <-1.5, 0.5, 1>
}

sphere { <0.0, 0.0, 0.0>, 1
   finish {
      ambient 0.2
      diffuse 0.8
      phong 1
   }
   pigment { color red 1 green 0 blue 0 }
}

}

Thanks,
Tim


Post a reply to this message

From: Tim Nikias
Subject: Re: viewing the inside of csg_box.pov example
Date: 13 Sep 2004 10:36:52
Message: <4145b084$1@news.povray.org>
> I am using the difference function. Does this function use the stencil
> buffer? Is there a way to get the vertices back after I cut a chuck out of
> the box?

POV-Ray doesn't make use of the stencil buffer, or any other part of a
graphics acceleration hardware. It is entirely run by the CPU, the
memory/harddisk and the OS.

Additionally, POV-Ray uses raytracing techniques to do CSG. In effect, when
it tries to render the mesh2-box after you've difference the sphere, it will
check the surface if it is lying inside the sphere. If it is, it is
discarded and the ray is traced further into the scene. Otherwise, the
surface is kept and recursive rays will be shot to generate
reflections/refractions/transparency etc.

As such, there is no special feature to re-incorporate triangles that have
been cut away using CSG.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Mike Williams
Subject: Re: viewing the inside of csg_box.pov example
Date: 14 Sep 2004 04:19:12
Message: <ZcbKpAAXlqRBFw0F@econym.demon.co.uk>
Wasn't it tec who wrote:
>Hello Everyone,
>    I am executing the csg_box example with no errors. I have modified the 
>exampleto use a mesh2 in place of the box because I want to take the 
>difference of the box (mesh2) and a sphere so I can see the inside triangles 
>of the box. I want to be able to see the inside of the boxes' triangles 
>(mesh2) after I cut away the sphere. I don't want to see the curved slice 
>that the sphere made. Currently, I see the background through the sliced 
>hole but I really want to see the inside of the box (mesh2).

1. The reason you see the background instead of the curved surface of
the sphere is that you have omitted the inside_vector keyword from your
mesh. CSG only works properly with meshes that have their insides
defined. If you add "inside_vector <0, 0, 1>" to the end of your mesh2
then the CSG operation will work correctly.

2. To see the inside of your box you don't want to use "difference" you
want to use "clipped_by". Difference subtracts one solid object from
another. Clipped_by removes part of the surface of the object. It works
just as well with boxes as with meshes, so you can either write

object {
  Mesh_C
  finish {
     ambient 0.2
     diffuse 0.8
  }
  pigment { color red 0 green 0 blue 1 }
  translate <-1.5, 0.5, 1>
  clipped_by {
    sphere { <0.0, 0.0, 0.0>, 1 inverse}
  }
}

or write

box {-1,1
  finish {
     ambient 0.2
     diffuse 0.8
  }
  pigment { color red 0 green 0 blue 1 }
  translate <-1.5, 0.5, 1>
  clipped_by {
    sphere { <0.0, 0.0, 0.0>, 1 inverse}
  }
}

[It's a little hard to see what's going on here but that's just because
it's so dark inside the box.]


>I am using the difference function. Does this function use the stencil 
>buffer? Is there a way to get the vertices back after I cut a chuck out of 
>the box?

There is no "stencil buffer".

In a sense, there aren't really any vertices inside POVRay either,
they're only in the scene description language to allow you to describe
the surfaces.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Warp
Subject: Re: viewing the inside of csg_box.pov example
Date: 14 Sep 2004 05:03:55
Message: <4146b3fb@news.povray.org>
tec <tec### [at] mil-teccom> wrote:
> I am using the difference function. Does this function use the stencil 
> buffer?

  It may be a good idea to study a bit how a pure raytracer works.
You have clearly been using too much scanline renderers... ;)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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