本文整理汇总了C++中NxShape::getGlobalPose方法的典型用法代码示例。如果您正苦于以下问题:C++ NxShape::getGlobalPose方法的具体用法?C++ NxShape::getGlobalPose怎么用?C++ NxShape::getGlobalPose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxShape
的用法示例。
在下文中一共展示了NxShape::getGlobalPose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReleaseRandomShape
// Release one of the shapes from our compound. At the moment
// we are just releasing the first object in the array.
// As long as the index is below the number of shapes (uiNumShapes)
// it should work, but be careful about releasing an object inside
// other objects (for performance reasons)
void ReleaseRandomShape()
{
// Get the array of pointers to shapes
NxShape*const* ppShapeArray = mainBox->getShapes();
// Find out how many shapes there are left
NxU32 uiNumShapes = mainBox->getNbShapes();
// Don't remove the last shape (or we'll have a shapeless actor)
if (uiNumShapes < 2)
return;
// Record the pose of the shape we intend to release, for later
NxShape* pShapeToRelease = ppShapeArray[0];
NxMat34 mNewBoxPose = pShapeToRelease->getGlobalPose();
// Release the object, and make a note of the new total number of objects
mainBox->releaseShape(*pShapeToRelease);
--iNumberObjects;
// We need to update the mass and intertial tensors. We choose to base it
// on the density of the objects, which are all fBoxDensity
mainBox->updateMassFromShapes(fBoxDensity, 0.0f);
// Create the new box, in the pose we recorded earlier
CreateBoxPiece(mNewBoxPose);
}
示例2: DrawActor
void CPhysicsManager::DrawActor (NxActor* actor, CRenderManager* render)
{
CPhysicUserData* physicUserData = NULL;
physicUserData =(CPhysicUserData*)actor->userData;
//Si está petando aquí quiere decir que se ha registrado un objeto físico sin proporcionarle UserData
assert(physicUserData);
if( !physicUserData->GetPaint())
{
return;
}
NxShape*const* shapes = actor->getShapes();
NxU32 nShapes = actor->getNbShapes();
nShapes = actor->getNbShapes();
while (nShapes--)
{
switch(shapes[nShapes]->getType())
{
case NX_SHAPE_PLANE:
{
CColor color = physicUserData->GetColor();
float distance = shapes[nShapes]->isPlane()->getPlane().d;
NxVec3 normal = shapes[nShapes]->isPlane()->getPlane().normal;
Vect3f n(normal.x,normal.y,normal.z);
render->DrawPlane(100.f, n, distance,color,40,40);
}
break;
case NX_SHAPE_BOX:
{
NxF32 m_aux[16];
shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux);
Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12],
m_aux[1], m_aux[5], m_aux[9], m_aux[13],
m_aux[2], m_aux[6], m_aux[10], m_aux[14],
m_aux[3], m_aux[7], m_aux[11], m_aux[15]);
render->SetTransform(m);
NxVec3 boxDim = shapes[nShapes]->isBox()->getDimensions();
CColor color = physicUserData->GetColor();
render->DrawCube(Vect3f(boxDim.x*2,boxDim.y*2,boxDim.z*2), color);
//render->DrawCube(boxDim.y*2,color);
}
break;
case NX_SHAPE_SPHERE:
{
NxF32 m_aux[16];
shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux);
Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12],
m_aux[1], m_aux[5], m_aux[9], m_aux[13],
m_aux[2], m_aux[6], m_aux[10], m_aux[14],
m_aux[3], m_aux[7], m_aux[11], m_aux[15]);
render->SetTransform(m);
NxReal radius = shapes[nShapes]->isSphere()->getRadius();
CColor color = physicUserData->GetColor();
render->DrawSphere(radius,MAX_ARISTAS,color);
}
break;
case NX_SHAPE_CAPSULE:
{
NxF32 m_aux[16];
shapes[nShapes]->getGlobalPose().getColumnMajor44(m_aux);
Mat44f m( m_aux[0], m_aux[4], m_aux[8], m_aux[12],
m_aux[1], m_aux[5], m_aux[9], m_aux[13],
m_aux[2], m_aux[6], m_aux[10], m_aux[14],
m_aux[3], m_aux[7], m_aux[11], m_aux[15]);
Mat44f translation, total;
translation.SetIdentity();
render->SetTransform(m);
const NxReal & radius = shapes[nShapes]->isCapsule()->getRadius();
const NxReal & height = shapes[nShapes]->isCapsule()->getHeight();
CColor color = physicUserData->GetColor();
translation.Translate(Vect3f(0.f, (height*0.5f), 0.f));
total = m * translation;
render->SetTransform(total);
render->DrawSphere(radius,MAX_ARISTAS,color);
translation.Translate( Vect3f(0.f, -(height*0.5f), 0.f ));
total = m * translation;
render->SetTransform(total);
render->DrawSphere(radius, MAX_ARISTAS, color); }
break;
case NX_SHAPE_CONVEX:
break;
case NX_SHAPE_MESH:
{
NxShape* mesh = shapes[nShapes];
NxTriangleMeshDesc meshDesc;
mesh->isTriangleMesh()->getTriangleMesh().saveToDesc(meshDesc);
typedef NxVec3 Point;
typedef struct _Triangle { NxU32 p0; NxU32 p1; NxU32 p2; } Triangle;
NxU32 nbVerts = meshDesc.numVertices;
//.........这里部分代码省略.........