PxRigidStatic* PxCreateStatic(PxPhysics& sdk, 
							  const PxTransform& transform, 
							  PxShape& shape)
{
	PX_CHECK_AND_RETURN_NULL(transform.isValid(), "PxCreateStatic: transform is not valid.");

	PxRigidStatic* s = sdk.createRigidStatic(transform);
	if(s)
		s->attachShape(shape);
	return s;
}
Пример #2
0
void PhysxScene::AddCapsuleFromU3D(killer::proto::U3DPhysxCapsule& capsule) {
	if (capsule.raduis() <= 0.0f || capsule.height() <= 0.0f) {
        LOG_ERROR(0, 0, "capsule error|%s", capsule.ShortDebugString().c_str());
		return;
	}

	PxShape *shape = PhysxCommonSigleton::get_mutable_instance().GetPhysics().createShape(PxCapsuleGeometry(capsule.raduis(), capsule.height() * 0.5), *px_material_);
	PxTransform localTrans(PxVec3(PxReal(capsule.pos().x()), PxReal(capsule.pos().y()), PxReal(capsule.pos().z())));
	PxRigidStatic *actor = PhysxCommonSigleton::get_mutable_instance().GetPhysics().createRigidStatic(localTrans);

	actor->attachShape(*shape);
	px_scene_->addActor(*actor);

	shape->release();
}
Пример #3
0
void PhysxScene::AddBoxFromU3D(killer::proto::U3DPhysxBox& box) {
	if (box.x_extents() <= 0.0f || box.y_extents() <= 0.0f || box.z_extents() <= 0.0f) {
        LOG_ERROR(0, 0, "box error|%s", box.ShortDebugString().c_str());
		return;
	}

	PxShape *shape = PhysxCommonSigleton::get_mutable_instance().GetPhysics().createShape(PxBoxGeometry(box.x_extents() * 0.5f, box.y_extents() * 0.5f, box.z_extents() * 0.5), *px_material_);

	PxTransform localTrans(PxVec3(PxReal(box.pos().x()), PxReal(box.pos().y()), PxReal(box.pos().z())));
	PxRigidStatic *actor = PhysxCommonSigleton::get_mutable_instance().GetPhysics().createRigidStatic(localTrans);

	actor->attachShape(*shape);
	px_scene_->addActor(*actor);

	shape->release();
}