It is
rather common for mesh objects to be used with some transformations,
like
scale, rotate and
translate. In this case, the macro which computes the
edges would need to know the coordinates and normal of the mesh after
the transformation (and not those given in the definition of the mesh).
However, there is an efficient and cheap way to get the correct results
without computing these coordinates. As the edges depends only
on the relative orientation of
the mesh and the point of view, it is enough to apply
the inverse transformation to the
point of view.
One should not forget that when a
transformation is composed of several basic transformations,
the inverse transformation is
given by the composition of the inverse of the basic transformations,
in
the reverse order !
Suppose you are applying the following
transformation to your mesh :
scale
<sx,sy,sz>
//scaling
rotate y*Yrot
//rotation
translate <tx,ty,tz>
//translation |
then PdV1 is obtained from the location
of the camera (called here PdV) as :
#declare
PdV1
= PdV - <tx,ty,tz>; //inverse translation
#declare PdV1 = vrotate(PdV1,<0,-Yrot,0>);
//inverse
rotation
#declare PdV1 = <PdV1.x/sx, PdV1.y/sy, PdV1.z/sz>;
//inverse
scaling |
Do not forget to apply the original
transformation to the edge object !
object{Edges_mymesh
scale<sx,sy,sz>
rotate
y*Yrot
translate <tx,ty,tz>
} |
Note that if you apply different
transformations to
the different meshes declared in your input file, you must
define
a different PdV1 for each mesh. To do so, edit the file
"declarations_mymesh.inc", uncomment the line "PdV1 = PdV;"
which
is right before each macro call, and define PdV1 as needed before each
macro call.