|
|
I want to join Archimedian mesh2 objects precisely to one another (think
Magnetix). Is there a way to fish normal and vertex data out of a
declared mesh2 given a face index or will I have to create a separate
vertex array?
Is there a variant of ReorientCenter that takes 6 points, 3 from one
triangle and three from the other, that will line up the first triangle
to exactly fit the other?
#macro ReorientTriangle(p1,p2,p3,p4,p5,p6)
#local tr1 = transform { matrix <p1.x,p1.y,p1.z, p2.x,p2.y,p2.z,
p3.x,p3.y,p3.z, 0,0,0> inverse }
#local tr2 = transform { matrix <p4.x,p4.y,p4.z, p5.x,p5.y,p5.z,
p6.x,p6.y,p6.z, 0,0,0> }
transform tr1
transform tr2
#end
// Tetrahedron (Tetrad)
#declare aTetrad = sqrt(2);
#declare Tetrad = mesh2 {
vertex_vectors { 4,
<-.5, -.5, -.5>,
<0.5, -.5, 0.5>,
<-.5, 0.5, 0.5>,
<0.5, 0.5, -.5>
}
face_indices { 4,
<0,1,2>,<0,2,3>,<0,3,1>,<3,2,1>
}
//Reorient(<-1,-1,-1>,y)
}
#declare vTetrad = array[4] {
<-.5, -.5, -.5>,
<0.5, -.5, 0.5>,
<-.5, 0.5, 0.5>,
<0.5, 0.5, -.5>
}
// Cuboctahedron (Cuboct)
#declare aCuboct = sqrt(0.5);
#declare Cuboct = mesh2 {
vertex_vectors { 18,
<0,-0.5,-0.5>,
<0, 0.5,-0.5>,
<0,-0.5, 0.5>,
<0, 0.5, 0.5>,
<-0.5, 0,-0.5>,
< 0.5, 0,-0.5>,
<-0.5, 0, 0.5>,
< 0.5, 0, 0.5>,
<-0.5,-0.5, 0>,
< 0.5,-0.5, 0>,
<-0.5, 0.5, 0>,
< 0.5, 0.5, 0>,
<-0.5, 0.0, 0.0>,
< 0.5, 0.0, 0.0>,
< 0.0,-0.5, 0.0>,
< 0.0, 0.5, 0.0>,
< 0.0, 0.0,-0.5>,
< 0.0, 0.0, 0.5>
}
face_indices { 32,
<8,4,0>,<1,4,10>,<11,5,1>,<0,5,9>,
<2,6,8>,<9,7,2>,<3,7,11>,<10,6,3>,
<4,8,12>,<8,6,12>,<6,10,12>,<10,4,12>,
<9,5,13>,<7,9,13>,<11,7,13>,<5,11,13>,
<0,8,14>,<8,2,14>,<2,9,14>,<9,0,14>,
<10,1,15>,<3,10,15>,<11,3,15>,<1,11,15>,
<0,4,16>,<4,1,16>,<1,5,16>,<5,0,16>,
<6,2,17>,<3,6,17>,<7,3,17>,<2,7,17>,
}
}
#declare vCuboct = array[18] {
<0,-0.5,-0.5>,
<0, 0.5,-0.5>,
<0,-0.5, 0.5>,
<0, 0.5, 0.5>,
<-0.5, 0,-0.5>,
< 0.5, 0,-0.5>,
<-0.5, 0, 0.5>,
< 0.5, 0, 0.5>,
<-0.5,-0.5, 0>,
< 0.5,-0.5, 0>,
<-0.5, 0.5, 0>,
< 0.5, 0.5, 0>,
<-0.5, 0.0, 0.0>,
< 0.5, 0.0, 0.0>,
< 0.0,-0.5, 0.0>,
< 0.0, 0.5, 0.0>,
< 0.0, 0.0,-0.5>,
< 0.0, 0.0, 0.5>
}
#declare _aspect = image_width/image_height;
light_source { x*50, rgb <1,0,0> }
light_source { y*50, rgb <0,1,0> }
light_source { z*50, rgb <0,0,1> }
camera {
location <-2.0, 2.0, 0.0>
look_at <0.0, 0.0, 0.0>
rotate y*20
}
object { Cuboct scale 1 pigment { rgb 1 } }
object { Tetrad
ReorientTriangle(
vTetrad[0],vTetrad[2],vTetrad[1],vCuboct[1],vCuboct[4],vCuboct[10] )
pigment { rgb 0.75 }
}
I tested this and got an unexpected result... the fourth point in the
tetrahedron is way off course while the first three points are spot on.
I need a set of translations and rotations that have the normals
facing each other, the face centers and first points matching.
Ideas are welcome.
Post a reply to this message
|
|