|
|
Hello,
I'm trying to add normals to triangles.
Let's say I've got this mesh2 object:
mesh2 {
vertex_vectors {
4
, <-4.22827, 3.07201, 49.7261>, <-3.49716, 3.88399, 49.7261>, <-10.3386,
11.4822, 47.5528>, <-12.5, 9.08178, 47.5528> }
face_indices {
2
, <2, 0, 1>, <0, 2, 3>
}
texture { pigment { color rgbf <0.976471, 0.843137, 0.172549, 0> } }
finish { MATERIAL } interior { MATERIAL_INT }
}
This renders fine.
So next step, adding normals.
Am I right that I need to do the following:
- for each triangle, e.g.:
p1: <-10.3386, 11.4822, 47.5528>, p2: <-4.22827, 3.07201, 49.7261>, p3:
<-3.49716, 3.88399, 49.7261>
and
q1: <-4.22827, 3.07201, 49.7261>, q2: <-10.3386, 11.4822, 47.5528>, q3:
<-12.5, 9.08178, 47.5528>
calculate the normals:
normal 1 = (p2 - p1) * (p3 - p1)
normal 2 = (p3 - p2) * (p2 - p1)
normal 3 = (p2 - p3) * (p2 - p1)
normal 4 = (q2 - q1) * (q3 - q1)
normal 5 = (q3 - q2) * (q2 - q1)
normal 6 = (q2 - q3) * (q2 - q1)
- then put those normals in a:
normals_vectors {
6, (normal 1), (normal 2), etc.
}
But then I'm lost. What should I put in normal_indices { } ?
Post a reply to this message
|
|