POV-Ray : Newsgroups : povray.newusers : Cube in different colors ? Server Time
11 Nov 2024 19:16:54 EST (-0500)
  Cube in different colors ? (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: gamsta@gmx net
Subject: Cube in different colors ?
Date: 10 Sep 2002 12:30:06
Message: <web.3d7e1dbe52cba467df9f5c610@news.povray.org>
Hi! I am new with povray and wanted to render a box where the 6 sides are in
different colors. Is there a way to manipulate the box object, or do i have
to draw the 6 sides as 6 single boxes (CSG). Maybe UVmapping ?

I think this is not a very difficult question. PLEASE HELP.


Post a reply to this message

From: Warp
Subject: Re: Cube in different colors ?
Date: 10 Sep 2002 12:44:36
Message: <3d7e2173@news.povray.org>
gam### [at] gmxnet <gam### [at] gmxnet> wrote:
> Hi! I am new with povray and wanted to render a box where the 6 sides are in
> different colors. Is there a way to manipulate the box object, or do i have
> to draw the 6 sides as 6 single boxes (CSG). Maybe UVmapping ?

  UV-mapping could be a way to do it if you can come up with a pattern
of the form described in chapter 6.7.7.1. I can't think of an easy way
of doing this right now...
  You could do it with six boxes, but that's not the only option.
  Using the intersection of six planes gives you a true box (which is
also usable in CSG) but can be a bit slower. You should definitely
remember to bound this "box" with a true box of the same size
(see bounded_by docs).
  You can also use the polygon or triangle primitives (the latter could
be inside a mesh, taking a bit less memory, I think), and it would be
faster to render but not usable in CSG (even though with a mesh you
can use inside_vector).

-- 
#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

From: Christopher James Huff
Subject: Re: Cube in different colors ?
Date: 10 Sep 2002 17:26:44
Message: <chrishuff-5A612C.17251710092002@netplex.aussie.org>
In article <3d7e2173@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   Using the intersection of six planes gives you a true box (which is
> also usable in CSG) but can be a bit slower. You should definitely
> remember to bound this "box" with a true box of the same size
> (see bounded_by docs).

My feeling is that this would be the fastest way. You may have to tell 
POV not to ignore your bounding, though.


>   You can also use the polygon or triangle primitives (the latter could
> be inside a mesh, taking a bit less memory, I think), and it would be
> faster to render but not usable in CSG (even though with a mesh you
> can use inside_vector).

I don't know if you meant this, but that last paragraph implies that a 
mesh box would be unuseable in CSG. If he uses inside_vector, it will be 
useable for CSG operations.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Ken
Subject: Re: Cube in different colors ?
Date: 10 Sep 2002 21:43:06
Message: <3D7EA09E.DEC45C3E@pacbell.net>
Christopher James Huff wrote:

> I don't know if you meant this, but that last paragraph implies that a
> mesh box would be unuseable in CSG. If he uses inside_vector, it will be
> useable for CSG operations.

Works quite well actually :)

-----------------------------------------------------------

// Macro for creating a basic box object using triangles

#macro Box_Mesh(Vec1,Vec2)

#if (Vec1.x=Vec2.x | Vec1.y=Vec2.y | Vec1.z=Vec2.z) 

#debug "\n  MeshBox detected identical vector values.\n" #end

#local P1=<Vec1.x, Vec1.y, Vec1.z>;
#local P2=<Vec2.x, Vec1.y, Vec1.z>; 
#local P3=<Vec2.x, Vec1.y, Vec2.z>;
#local P4=<Vec1.x, Vec1.y, Vec2.z>;
#local P5=<Vec1.x, Vec2.y, Vec1.z>;
#local P6=<Vec2.x, Vec2.y, Vec1.z>;
#local P7=<Vec2.x, Vec2.y, Vec2.z>;
#local P8=<Vec1.x, Vec2.y, Vec2.z>;

mesh {
       triangle { P5, P1, P2 texture {T1} }
       triangle { P5, P6, P2 texture {T1} }
       triangle { P6, P2, P3 texture {T2} }
       triangle { P6, P7, P3 texture {T2} }
       triangle { P7, P3, P4 texture {T3} }
       triangle { P7, P8, P4 texture {T3} }
       triangle { P8, P4, P1 texture {T4} }
       triangle { P8, P5, P1 texture {T4} }
       triangle { P8, P5, P6 texture {T5} } 
       triangle { P8, P7, P6 texture {T5} }
       triangle { P4, P1, P2 texture {T6} } 
       triangle { P4, P3, P2 texture {T6} }

       inside_vector <0, 0, 1>

     }
#end

default { finish { ambient .4 diffuse .6 } }

#declare T1 = texture { pigment { rgb<1,0,0> }}
#declare T2 = texture { pigment { rgb<0,1,0> }}
#declare T3 = texture { pigment { rgb<0,0,1> }}
#declare T4 = texture { pigment { rgb<1,1,0> }}
#declare T5 = texture { pigment { rgb<1,0,1> }}
#declare T6 = texture { pigment { rgb<0,1,1> }}


// Usage

camera{location<-4,4,-4> look_at 0}

light_source{<-5,5,-5>rgb 1}


difference
{

  Box_Mesh ( <-1,-1,-1>, <1,1,1> )
  cylinder { z*-1.1, z*1.1, .75 pigment { rgb 1 }}

}


-- 
Ken Tyler


Post a reply to this message

From: Ken
Subject: Re: Cube in different colors ?
Date: 10 Sep 2002 23:37:37
Message: <3D7EBB75.342E8017@pacbell.net>
Ken wrote:
> 
> Christopher James Huff wrote:
> 
> > I don't know if you meant this, but that last paragraph implies that a
> > mesh box would be unuseable in CSG. If he uses inside_vector, it will be
> > useable for CSG operations.
> 
> Works quite well actually :)

With limitations. From some tests I just ran it appears the mesh must be
the top level object in the csg operation. If used a secondary object
in a csg it does not work as expected. I wonder if an outside_vector
operator is needed to define the outside of a mesh object as opposed
to the inside?

-- 
Ken Tyler


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Cube in different colors ?
Date: 11 Sep 2002 00:08:19
Message: <Xns92863DC0CA432raf256com@204.213.191.226>
"gam### [at] gmxnet" <gam### [at] gmxnet> wrote in
news:web.3d7e1dbe52cba467df9f5c610@news.povray.org 

> Hi! I am new with povray and wanted to render a box where the 6 sides
> are in different colors. Is there a way to manipulate the box object,
> or do i have to draw the 6 sides as 6 single boxes (CSG). Maybe
> UVmapping ? 

hmm interesting, I was just about to send identical question here...
maybe telepatic ;) ?

so finaly - with method is the fastest ?
maybe some union/merge/intersection of planes ?

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: Cube in different colors ?
Date: 11 Sep 2002 05:42:41
Message: <3d7f1011@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote:
> My feeling is that this would be the fastest way. You may have to tell 
> POV not to ignore your bounding, though.

  I think that POV-Ray only removes user-defined bounding boxes when it
(thinks it) can make a better one itself. However, for planes it doesn't
create bounding boxes at all (because they are infinite) and thus should
not remove the user-defined one. I haven't tried it, though.

> I don't know if you meant this, but that last paragraph implies that a 
> mesh box would be unuseable in CSG. If he uses inside_vector, it will be 
> useable for CSG operations.

  Well, yes. That's what I meant (could have worded it better, though).
  A mesh by itself is not usable in CSG, but if you add inside_vector to
it, then it is.

-- 
#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

From: Warp
Subject: Re: Cube in different colors ?
Date: 11 Sep 2002 05:44:12
Message: <3d7f106b@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
> With limitations. From some tests I just ran it appears the mesh must be
> the top level object in the csg operation. If used a secondary object
> in a csg it does not work as expected.

  I remember that this bug was found months ago. I wonder if anyone made
a proper post at p.bug-reports... (if not, someone should).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: ABX
Subject: Re: Cube in different colors ?
Date: 11 Sep 2002 05:58:58
Message: <8k4unuk183qmnfaropqo2aql15vu989oai@4ax.com>
On Tue, 10 Sep 2002 20:41:41 -0700, Ken <tyl### [at] pacbellnet> wrote:
> With limitations. From some tests I just ran it appears the mesh must be
> the top level object in the csg operation. If used a secondary object
> in a csg it does not work as expected. I wonder if an outside_vector
> operator is needed to define the outside of a mesh object as opposed
> to the inside?

I wonder if it could be becouse of feature described recently in some posts.
All_intersections method for meshes returns only first intersection. I don't
know how intersection test for csg is written but for sended ray mesh looks
like plane so it can behave strange in some cases.

ABX


Post a reply to this message

From: Warp
Subject: Re: Cube in different colors ?
Date: 11 Sep 2002 07:50:32
Message: <3d7f2e08@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> so finaly - with method is the fastest ?
> maybe some union/merge/intersection of planes ?

  I made a test with boxes made of planes, polygons and a mesh (with
differently colored sides) and compared their rendering speed
(-w800 -h600 +a0.1) by randomly placing 500 of them in the scene.
The render times were:

Planes:   75 s
Polygons: 80 s
Mesh:     63 s

  Seems like the mesh wins.

  This is the scene:


// 1: Planes
// 2: Polygons
// 3: Mesh
#declare BoxType = 1;
#declare Amount = 500;


#macro FixCorners(Corner1, Corner2)
  #local X1 = Corner1.x; #local X2 = Corner2.x;
  #local Y1 = Corner1.y; #local Y2 = Corner2.y;
  #local Z1 = Corner1.z; #local Z2 = Corner2.z;
  #if(X1 > X2) #local tmp = X1; #local X1 = X2; #local X2 = tmp; #end
  #if(Y1 > Y2) #local tmp = Y1; #local Y1 = Y2; #local Y2 = tmp; #end
  #if(Z1 > Z2) #local tmp = Z1; #local Z1 = Z2; #local Z2 = tmp; #end
  #local Corner1 = <X1, Y1, Z1>;
  #local Corner2 = <X2, Y2, Z2>;
#end

#macro PlaneBox(Corner1, Corner2, T1, T2, T3, T4, T5, T6)
  #local C1 = Corner1+<0,0,0>;
  #local C2 = Corner2+<0,0,0>;
  FixCorners(C1, C2)
  intersection
  {
    plane { -x, -C1.x texture { T1 } }
    plane {  x,  C2.x texture { T2 } }
    plane { -y, -C1.y texture { T3 } }
    plane {  y,  C2.y texture { T4 } }
    plane { -z, -C1.z texture { T5 } }
    plane {  z,  C2.z texture { T6 } }
    bounded_by { box { C1, C2 } }
  }
#end

#macro PolygonBox(Corner1, Corner2, T1, T2, T3, T4, T5, T6)
  #local C1 = Corner1+<0,0,0>;
  #local C2 = Corner2+<0,0,0>;
  FixCorners(C1, C2)
  union
  {
    polygon
    { 5, C1, <C1.x, C1.y, C2.z>, <C1.x, C2.y, C2.z>, <C1.x, C2.y, C1.z>, C1
      texture { T1 }
    }
    polygon
    { 5, C2, <C2.x, C2.y, C1.z>, <C2.x, C1.y, C1.z>, <C2.x, C1.y, C2.z>, C2
      texture { T2 }
    }
    polygon
    { 5, C1, <C2.x, C1.y, C1.z>, <C2.x, C1.y, C2.z>, <C1.x, C1.y, C2.z>, C1
      texture { T3 }
    }
    polygon
    { 5, C2, <C1.x, C2.y, C2.z>, <C1.x, C2.x, C1.z>, <C2.x, C2.y, C1.z>, C2
      texture { T4 }
    }
    polygon
    { 5, C1, <C2.x, C1.y, C1.z>, <C2.x, C2.y, C1.z>, <C1.x, C2.y, C1.z>, C1
      texture { T5 }
    }
    polygon
    { 5, C2, <C1.x, C2.y, C2.z>, <C1.x, C1.y, C2.z>, <C2.x, C1.y, C2.z>, C2
      texture { T6 }
    }
  }
#end

#macro MeshBox(Corner1, Corner2, T1, T2, T3, T4, T5, T6)
  #local C1 = Corner1+<0,0,0>;
  #local C2 = Corner2+<0,0,0>;
  FixCorners(C1, C2)
  mesh2
  {
    vertex_vectors
    { 8,
      C1, <C2.x, C1.y, C1.z>, <C2.x, C1.y, C2.z>, <C1.x, C1.y, C2.z>,
      <C1.x, C2.x, C1.z>, <C2.x, C2.y, C1.z>, C2, <C1.x, C2.y, C2.z>
    }
    texture_list
    { 6,
      texture { T1 }, texture { T2 }, texture { T3 },
      texture { T4 }, texture { T5 }, texture { T6 }
    }
    face_indices
    { 6*2,
      <0, 3, 7>, 0, <0, 7, 4>, 0,
      <1, 5, 6>, 1, <1, 6, 2>, 1,
      <0, 1, 2>, 2, <0, 2, 3>, 2,
      <4, 7, 6>, 3, <4, 6, 5>, 3,
      <0, 4, 5>, 4, <0, 5, 1>, 4,
      <3, 2, 6>, 5, <3, 6, 7>, 5
    }
  }
#end

camera { location <4,10,-20>*2 look_at 0 angle 35 }
light_source { <100,200,-150>, 1 }

#declare T = array[6]
{
  pigment { rgb 1 },
  pigment { rgb x },
  pigment { rgb y },
  pigment { rgb z },
  pigment { rgb x+y },
  pigment { rgb y+z },
}

#declare Box =
  #switch(BoxType)
    #case(1)
      PlaneBox(-1, 1, T[0], T[1], T[2], T[3], T[4], T[5])
    #break
    #case(2)
      PolygonBox(-1, 1, T[0], T[1], T[2], T[3], T[4], T[5])
    #break
    #case(3)
      MeshBox(-1, 1, T[0], T[1], T[2], T[3], T[4], T[5])
    #break
  #end

#declare S = seed(1);
#declare Ind = 0;
#while(Ind < Amount)
  object
  { Box
    rotate <rand(S)*360, rand(S)*360, rand(S)*360>
    translate (<rand(S),.5,rand(S)>-.5)*50
  }
  #declare Ind = Ind+1;
#end


-- 
#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

Goto Latest 10 Messages Next 3 Messages >>>

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