|
![](/i/fill.gif) |
"sam kim" <nomail@nomail> wrote in message
news:web.498df9d6a703dd17c859cee0@news.povray.org...
>
> I understand the procedure for csg you just described.
> How would I put the torus in a mesh object?
> And how can i create a flag with mesh?
> Wouldn't I need to use a modeller for that?
>
You could use a modeller if you like, but the mesh2 definition isn't too
hard to code by hand for simple shapes.
There are also some mesh2 generation macros that you might care to Google.
The example below creates a mesh2 using nested loops, which might be a bit
scary if you've never done any programming.
The first section of the mesh2 definition loops 100 times horizontally and
for each 'column' loops 100 times vertically to build a grid of points. I've
kept the x and y coordinates uniformly spaced and varied the z coordinate
using a horizontal sine wave. The sind function is in the standard include
file "math.inc", hence the #include statement.
The second part of the mesh2 definition uses more nested loops to define how
the points join together as triangles. There's one less square face per side
than points (99 rather than 100). There are two triangular faces defined
with each iteration of the loop. They are defined by referencing the indices
of the points defined in the first part of the mesh2.
Each loop contains a little bit of logic to add a comma to all but the last
line.
The texture MyTexture is built up of a sequence of textures (it's a layered
texture). Everything but the first texture (plain White) has a transparent
background (rgbt 1) so that the lower layers show through. The intersections
of a torus and a thin box are stretched in the Z dimension so that we have a
good depth of colour to make sure it doesn't turn white at the extremities
of the waves.
As I mentioned, it's a bit more complicated than is usually attempted by
newbies, so if any of that makes your head hurt just say and I'll try and
explain it better. :-)
Regards,
Chris B.
camera {location <4.5,9,-8> look_at <4.5,2.5,0>}
light_source {<-10,20,-25>, rgb 1}
#include "math.inc"
// First declare a layered texture
#declare MyTexture =
texture {pigment {rgb 1}}
texture { pigment { object {
intersection {
torus {0.97,0.08 rotate -x*90 translate <2,3,0>}
box {-0.000001*z,<9,5,0.010001>}
scale <1,1,100000>
}
color rgbt 1
color rgb <0,0,0.2> // Blue
}}}
texture { pigment { object {
intersection {
torus {0.97,0.08 rotate -x*90 translate <4.5,3,0>}
box {-0.000002*z,<9,5,0.010002>}
scale <1,1,100000>
}
color rgbt 1
color rgb <0,0,0> // Black
}}}
texture { pigment { object {
intersection {
torus {0.97,0.08 rotate -x*90 translate <7,3,0>}
box {-0.000003*z,<9,5,0.010003>}
scale <1,1,100000>
}
color rgbt 1
color rgb <1,0,0> // Red
}}}
texture { pigment { object {
intersection {
torus {0.97,0.08 rotate -x*90 translate <3.25,2,0>}
box {-0.000004*z,<9,5,0.010004>}
scale <1,1,100000>
}
color rgbt 1
color rgb <0.8,0.68,0> // Yellow
}}}
texture { pigment { object {
intersection {
torus {0.97,0.08 rotate -x*90 translate <5.75,2,0>}
box {-0.000005*z,<9,5,0.010005>}
scale <1,1,100000>
}
color rgbt 1
color rgb <0,0.2,0> // Green
}}}
// Now draw the object and apply the texture to it
mesh2 {
vertex_vectors {10000,
#local I = 0;
#while (I<100)
#local J = 0;
#while (J<100)
<9*I/99,5*J/99,sind(I*20)*0.1>
#if (J<99&I<99)
,
#end
#local J = J+1;
#end
#local I = I+1;
#end
}
face_indices {
99*99*2,
#local I = 1;
#while (I<100)
#local J = 1;
#while (J<100)
<(I-1)*100+(J-1),(I)*100+(J-1),(I)*100+(J)>,
<(I)*100+(J),(I-1)*100+(J),(I-1)*100+(J-1)>
#if (J<99&I<99)
,
#end
#local J = J+1;
#end
#local I = I+1;
#end
}
texture {MyTexture }
}
Post a reply to this message
|
![](/i/fill.gif) |