This example takes a line segment defined in model coordinates and creates its equivalents in eye and display coordinates. When displayed, all lines will overlap.
void AsdkCoordSamp::subViewportDraw (AcGiViewportDraw* pV) { pV->subEntityTraits().setFillType(kAcGiFillAlways); const int count = 3; AcGePoint3d verts[count]; verts[0] = AcGePoint3d(0.0, 0.0, 0.0); verts[1] = AcGePoint3d(1.0, 0.0, 0.0); verts[2] = AcGePoint3d(1.0, 1.0, 0.0); // Draw model space line segment. // pV- >subEntityTraits().setColor(kBlue); pV->geometry().polygon(count, verts); // Compute its representation in eye space. // AcGeMatrix3d mat; pV->viewport ().getModelToEyeTransform(mat); for (int i = 0; i < count; i++) { verts[i].x += 0.01; verts[i].y += 0.01; verts[i].z += 0.01; verts[i].transformBy (mat); } // Display the eye coordinate equivalent of the // model space polygon. // pV->subEntityTraits().setColor(kGreen); pV- >geometry().polygonEye(count, verts); // Convert from eye to display coordinates. // for (int i = 0; i < count; i++) { verts[i].x += 0.01; verts[i].y += 0.01; verts[i].z += 0.01; } // Draw the display space equivalent of the // model space polygon. // pV->subEntityTraits ().setColor(kRed); pV->geometry().polygonDc(count, verts); }
void AsdkCoordSamp::viewportDraw(AcGiViewportDraw* pV) { pV->subEntityTraits().setFillType(kAcGiFillAlways); const int count = 3; AcGePoint3d verts[count]; verts[0] = AcGePoint3d(0.0, 0.0, 0.0); verts[1] = AcGePoint3d(1.0, 0.0, 0.0); verts[2] = AcGePoint3d(1.0, 1.0, 0.0); // Draw model space line segment. // pV->subEntityTraits().setColor(kBlue); pV->geometry().polygon(count, verts); // Compute the line's representation in eye space. // AcGeMatrix3d mat; pV->viewport().getModelToEyeTransform(mat); for (int i = 0; i < count; i++) { verts[i].x += 0.01; verts[i].y += 0.01; verts[i].z += 0.01; verts[i].transformBy(mat); } // Display the eye coordinate equivalent of the // model space polygon. // pV->subEntityTraits().setColor(kGreen); pV->geometry().polygonEye(count, verts); // Convert from eye to display coordinates. // for (i = 0; i < count; i++) { verts[i].x += 0.01; verts[i].y += 0.01; verts[i].z += 0.01; } // Draw the display space equivalent of the // model space polygon. // pV->subEntityTraits().setColor(kRed); pV->geometry().polygonDc(count, verts); }