ObjectARX, AutoCAD. C++

         

2: - 2


// ones blue.

//

// Set the extents of the pyramid here because

// AcGiViewportGeometrys polylineEye() doesnt

// set extents.

//

for (Adesk::UInt32 i = 0; i < mNumVerts; i++) {

AcGePoint3d pt[2];

pt[0] = mVerts[i];

pt[1] = mVerts[(i + 1) % mNumVerts];

pW->geometry().setExtents(pt);

}

return Adesk::kFalse; // Call viewport draws.

}

// Otherwise, give HIDE, SHADE, RENDER, or proxy graphics

// a pyramid with filled faces.

//

const Adesk::UInt32 faceListSize = 16;

static Adesk::Int32 faceList[faceListSize] = {

3, 0, 1, 2,

3, 0, 2, 3,

3, 0, 3, 1,

3, 1, 2, 3

};

pW->geometry().shell(mNumVerts, mVerts, faceListSize, faceList);

return Adesk::kTrue; // Do not call viewportDraw.

}

void

AsdkViewGeomSamp::viewportDraw(AcGiViewportDraw* pV)

{

// For this viewport, draw a pyramid with yellow

// visible lines and blue hidden lines.

//

// Get this viewports net transform. This transform

// includes this entitys block transforms and this

// viewports view transform; it does not include the

// perspective transform if were in perspective

// mode; that currently has to be applied separately

// when in perspective mode.

//

AcGeMatrix3d modelToEyeMat;

pV->viewport().getModelToEyeTransform(modelToEyeMat);

// Get the pyramids vertices.

//

AcGePoint3d A = mVerts[0];

AcGePoint3d B = mVerts[1];

AcGePoint3d C = mVerts[2];

AcGePoint3d D = mVerts[3];

// Convert them to the viewports eye coordinates.

//

A.transformBy(modelToEyeMat);

B.transformBy(modelToEyeMat);

C.transformBy(modelToEyeMat);

D.transformBy(modelToEyeMat);

// Save the eye coordinates.

//

AcGePoint3d AEye = A;

AcGePoint3d BEye = B;

AcGePoint3d CEye = C;

AcGePoint3d DEye = D;

// Perform the perspective transform if necessary.

//

if (pV->viewport().isPerspective()) {

pV->viewport().doPerspective(A);

pV->viewport().doPerspective(B);

pV->viewport().doPerspective(C);

pV->viewport().doPerspective(D);

}

// From that view, figure out which faces are