On 11/06/2014 at 04:46, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform: Mac OSX ;
Language(s) : C++ ;
---------
The documentation is not clear if local, global, screen or camera coordinates are to be used.
Anyway, I'm getting the face normals with:
N = CalcFaceNormal(pt_list, pol)*op_matrix;
(pt_list is the points array of the object, pol is the Cpolygon that I'm checking and op_matrix is the global matrix of the object)
I'm getting the central point of the face with:
a=pol.a;
b=pol.b;
c=pol.c;
d=pol.d;
pa=pt_list[a]*op_matrix;
pb=pt_list[b]*op_matrix;
pc=pt_list[c]*op_matrix;
pd=pt_list[d]*op_matrix;
if (c==d)
{
cp=(pa+pb+pc)*.333333333f;
nface=3;
}
else
{
cp=(pa+pb+pc+pd)*.25f;
nface=4;
}
And, finally, I'm checking for the visibility of a face with:
bf=bd->BackfaceCulling(bd->WC_V(N),bd->WC(cp));
This works fine as long as the object is at the origin (0,0,0) and is not rotated. If I orbit around the object, the correct faces are not drawn.
But if I move or rotate the object, it breaks! I mean, faces that are supposed to be seen are reported as non-visible and vice-versa.
So, how should we really be able to use BackfaceCulling?
p.s. I already searched the forum and found no solution for it although some other already had the same doubt.