ObjectARX, AutoCAD. Среда программирования библиотеки C++


         

facing the viewport and which


// facing the viewport and which are not.
//
int which_faces;
which_faces = ((C - A).crossProduct(B - A)).z > 0.0 ? 1 : 0;
which_faces |= ((D - A).crossProduct(C - A)).z > 0.0 ? 2 : 0;
which_faces |= ((B - A).crossProduct(D - A)).z > 0.0 ? 4 : 0;
which_faces |= ((B - D).crossProduct(C - D)).z > 0.0 ? 8 : 0;
// Those edges that meet between two faces that are
// facing away from the viewport will be hidden edges,
// so draw them blue; otherwise, they are visible
// edges. (This example is incomplete, as the test is
// indeterminate when the face is edge-on to the
// screen -- neither facing away nor toward the screen.)
// Draw the six edges connecting the vertices using eye
// coordinate geometry that can be clipped back and front.
//
AcGePoint3d verts[2];
Adesk::UInt16 color;
// AB
color = which_faces & 0x5 ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = AEye;
verts[1] = BEye;
pV->geometry().polylineEye(2, verts);
// AC
color = which_faces & 0x3 ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = AEye;
verts[1] = CEye;
pV->geometry().polylineEye(2, verts);
// AD
color = which_faces & 0x6 ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = AEye;
verts[1] = DEye;
pV->geometry().polylineEye(2, verts);
// CD
color = which_faces & 0xa ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = CEye;
verts[1] = DEye;
pV->geometry().polylineEye(2, verts);
// DB
color = which_faces & 0xc ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = DEye;
verts[1] = BEye;
pV->geometry().polylineEye(2, verts);
// BC
color = which_faces & 0x9 ? kYellow : kBlue;
pV->subEntityTraits().setColor(color);
verts[0] = BEye;
verts[1] = CEye;
pV->geometry().polylineEye(2, verts);
}

Содержание  Назад  Вперед