本文整理汇总了C++中PxRigidBody::getAngularVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ PxRigidBody::getAngularVelocity方法的具体用法?C++ PxRigidBody::getAngularVelocity怎么用?C++ PxRigidBody::getAngularVelocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxRigidBody
的用法示例。
在下文中一共展示了PxRigidBody::getAngularVelocity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAngularVelocity
vec3f PhysActor_PhysX::GetAngularVelocity()
{
if (!impl->physActor)
{
LOG("Cannot get angular velocity from actor because actor ptr is null!");
return vec3f(0.0f, 0.0f, 0.0f);
}
PxRigidBody* actor = nullptr;
if (impl->physActor->isRigidDynamic() || impl->physActor->isRigidBody())
actor = (PxRigidBody*)impl->physActor;
else
{
LOG("Cannot get angular velocity from actor because actor is not a Rigid Dynamic or Rigid Body actor.");
return vec3f(0.0f, 0.0f, 0.0f);
}
if (!actor)
return vec3f(0.0f, 0.0f, 0.0f);
PxVec3 velocity = actor->getAngularVelocity();
vec3f vConv(velocity.x, velocity.y, velocity.z);
return vConv;
}
示例2: getVelocityAtPosInternal
PX_INLINE PxVec3 getVelocityAtPosInternal(const PxRigidBody& body, const PxVec3& point)
{
PxVec3 velocity = body.getLinearVelocity();
velocity += body.getAngularVelocity().cross(point);
return velocity;
}
示例3: destroyWallBlock
void SimulationEventCallback::destroyWallBlock(const PxRigidBody& _krRigidBody, const PxShape& _krShape)
{
Entity* wallBlock = static_cast<Entity*>(_krRigidBody.userData);
if (find(m_destroyedWallBlocks.begin(), m_destroyedWallBlocks.end(), wallBlock) != m_destroyedWallBlocks.end())
{
return;
}
PxBoxGeometry geometry;
_krShape.getBoxGeometry(geometry);
PxTransform transform = _krRigidBody.getGlobalPose();
Matrix44 transformation = PhysXMatrix::toMatrix44(transform);
PxVec3 angularVelocity = _krRigidBody.getAngularVelocity();
PxVec3 linearVelocity = _krRigidBody.getLinearVelocity();
m_destroyedWallBlocks.push_back(wallBlock);
GazEngine::removeEntity(*wallBlock);
float halfSize = geometry.halfExtents.x / 2.0f;
Matrix44 fragment0Transformation = transformation;
getTranslation3(fragment0Transformation) += Vector3(-halfSize, halfSize, 0.0f);
Entity* pFragment0 = CreateWallBlock(fragment0Transformation, halfSize, *m_pParentNode);
PxRigidBody* pFragment0RigidBody = pFragment0->getSingleComponent<PhysXBody>()->getActor()->isRigidBody();
pFragment0RigidBody->setAngularVelocity(angularVelocity);
pFragment0RigidBody->setLinearVelocity(linearVelocity);
// The body only got a position in the constructor... lets give it a rotation too.
PxTransform fragment0Transform = transform;
fragment0Transform.p += PxVec3(-halfSize, halfSize, 0.0f);
pFragment0RigidBody->setGlobalPose(fragment0Transform);
Matrix44 fragment1Transformation = transformation;
getTranslation3(fragment1Transformation) += Vector3(halfSize, halfSize, 0.0f);
Entity* pFragment1 = CreateWallBlock(fragment1Transformation, halfSize, *m_pParentNode);
PxRigidBody* pFragment1RigidBody = pFragment1->getSingleComponent<PhysXBody>()->getActor()->isRigidBody();
pFragment1RigidBody->setAngularVelocity(angularVelocity);
pFragment1RigidBody->setLinearVelocity(linearVelocity);
// The body only got a position in the constructor... lets give it a rotation too.
PxTransform fragment1Transform = transform;
fragment1Transform.p += PxVec3(halfSize, halfSize, 0.0f);
pFragment1RigidBody->setGlobalPose(fragment1Transform);
Matrix44 fragment2Transformation = transformation;
getTranslation3(fragment2Transformation) += Vector3(halfSize, -halfSize, 0.0f);
Entity* pFragment2 = CreateWallBlock(fragment2Transformation, halfSize, *m_pParentNode);
PxRigidBody* pFragment2RigidBody = pFragment2->getSingleComponent<PhysXBody>()->getActor()->isRigidBody();
pFragment2RigidBody->setAngularVelocity(angularVelocity);
pFragment2RigidBody->setLinearVelocity(linearVelocity);
// The body only got a position in the constructor... lets give it a rotation too.
PxTransform fragment2Transform = transform;
fragment2Transform.p += PxVec3(halfSize, -halfSize, 0.0f);
pFragment2RigidBody->setGlobalPose(fragment2Transform);
Matrix44 fragment3Transformation = transformation;
getTranslation3(fragment3Transformation) += Vector3(-halfSize, -halfSize, 0.0f);
Entity* pFragment3 = CreateWallBlock(fragment3Transformation, halfSize, *m_pParentNode);
PxRigidBody* pFragment3RigidBody = pFragment3->getSingleComponent<PhysXBody>()->getActor()->isRigidBody();
pFragment3RigidBody->setAngularVelocity(angularVelocity);
pFragment3RigidBody->setLinearVelocity(linearVelocity);
// The body only got a position in the constructor... lets give it a rotation too.
PxTransform fragment3Transform = transform;
fragment3Transform.p += PxVec3(-halfSize, -halfSize, 0.0f);
pFragment3RigidBody->setGlobalPose(fragment3Transform);
}