本文整理汇总了C++中PxShape::getHeightFieldGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ PxShape::getHeightFieldGeometry方法的具体用法?C++ PxShape::getHeightFieldGeometry怎么用?C++ PxShape::getHeightFieldGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxShape
的用法示例。
在下文中一共展示了PxShape::getHeightFieldGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNodeForActor
//.........这里部分代码省略.........
case PxGeometryType::eCAPSULE:
{
PxCapsuleGeometry capsule;
shape->getCapsuleGeometry( capsule );
osg::Capsule* capsuleShape = new osg::Capsule(
localPos, capsule.radius, capsule.halfHeight * 2.0f);
capsuleShape->setRotation( localQuat );
geode->addDrawable( new osg::ShapeDrawable(capsuleShape) );
}
break;
case PxGeometryType::eBOX:
{
PxBoxGeometry box;
shape->getBoxGeometry( box );
osg::Box* boxShape = new osg::Box(localPos,
box.halfExtents[0] * 2.0f, box.halfExtents[1] * 2.0f, box.halfExtents[2] * 2.0f);
boxShape->setRotation( localQuat );
geode->addDrawable( new osg::ShapeDrawable(boxShape) );
}
break;
case PxGeometryType::eCONVEXMESH:
{
PxConvexMeshGeometry convexMeshGeom;
shape->getConvexMeshGeometry( convexMeshGeom );
// TODO: consider convexMeshGeom.scale
PxConvexMesh* convexMesh = convexMeshGeom.convexMesh;
if ( convexMesh )
{
/*for ( unsigned int i=0; i<convexMesh->getNbPolygons(); ++i )
{
}*/
// TODO
}
}
break;
case PxGeometryType::eTRIANGLEMESH:
{
PxTriangleMeshGeometry triangleMeshGeom;
shape->getTriangleMeshGeometry( triangleMeshGeom );
// TODO: consider triangleMeshGeom.scale
PxTriangleMesh* triangleMesh = triangleMeshGeom.triangleMesh;
if ( triangleMesh )
{
osg::ref_ptr<osg::Vec3Array> va = new osg::Vec3Array( triangleMesh->getNbVertices() );
for ( unsigned int i=0; i<va->size(); ++i )
(*va)[i] = toVec3( *(triangleMesh->getVertices() + i) ) * localMatrix;
osg::ref_ptr<osg::DrawElements> de;
if ( triangleMesh->getTriangleMeshFlags()&PxTriangleMeshFlag::eHAS_16BIT_TRIANGLE_INDICES )
{
osg::DrawElementsUShort* de16 = new osg::DrawElementsUShort(GL_TRIANGLES);
de = de16;
const PxU16* indices = (const PxU16*)triangleMesh->getTriangles();
for ( unsigned int i=0; i<triangleMesh->getNbTriangles(); ++i )
{
de16->push_back( indices[3 * i + 0] );
de16->push_back( indices[3 * i + 1] );
de16->push_back( indices[3 * i + 2] );
}
}
else
{
osg::DrawElementsUInt* de32 = new osg::DrawElementsUInt(GL_TRIANGLES);
de = de32;
const PxU32* indices = (const PxU32*)triangleMesh->getTriangles();
for ( unsigned int i=0; i<triangleMesh->getNbTriangles(); ++i )
{
de32->push_back( indices[3 * i + 0] );
de32->push_back( indices[3 * i + 1] );
de32->push_back( indices[3 * i + 2] );
}
}
geode->addDrawable( createGeometry(va.get(), NULL, NULL, de.get()) );
}
}
break;
case PxGeometryType::eHEIGHTFIELD:
{
PxHeightFieldGeometry hfGeom;
shape->getHeightFieldGeometry( hfGeom );
// TODO: consider hfGeom.*scale
PxHeightField* heightField = hfGeom.heightField;
if ( heightField )
{
// TODO
}
}
break;
}
}
return transform.release();
}