本文整理汇总了C++中PxPhysics::createCollection方法的典型用法代码示例。如果您正苦于以下问题:C++ PxPhysics::createCollection方法的具体用法?C++ PxPhysics::createCollection怎么用?C++ PxPhysics::createCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxPhysics
的用法示例。
在下文中一共展示了PxPhysics::createCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserializeFromRepXFile
void CEntity::deserializeFromRepXFile(const std::string &file, int group, const std::vector<int>& groupList, const Logic::IPhysics* component) {
// Obtenemos el puntero al servidor de fisicas
Physics::CServer* physicsServer = Physics::CServer::getSingletonPtr();
PxScene* scene = physicsServer->getActiveScene();
PxPhysics* physics = physicsServer->getPhysxSDK();
PxCooking* cooking = physicsServer->getCooking();
assert(scene);
// Preparar parámetros para deserializar
PxDefaultFileInputData data(file.c_str());
PxCollection* bufferCollection = physics->createCollection();
PxCollection* sceneCollection = physics->createCollection();
PxStringTable* stringTable = &PxStringTableExt::createStringTable( CServer::getSingletonPtr()->getFoundation()->getAllocatorCallback() );
PxUserReferences* externalRefs = NULL;
PxUserReferences* userRefs = NULL;
// Deserializar a partir del fichero RepX
repx::deserializeFromRepX(data, *physics, *cooking, stringTable, externalRefs,
*bufferCollection, *sceneCollection, userRefs);
// Añadir entidades físicas a la escena
physics->addCollection(*sceneCollection, *scene);
// Buscar una entidad de tipo PxRigidActor. Asumimos que hay exactamente 1 en el fichero.
_actor = NULL;
for (unsigned int i = 0; i < sceneCollection->getNbObjects() && !_actor; ++i) {
PxSerializable* p = sceneCollection->getObject(i);
_actor = p->is<PxRigidActor>();
}
assert(_actor);
// Anotar el componente lógico asociado a la entidad física
_actor->userData = (void*)component;
// Establecer el grupo de colisión
PxSetGroup(*_actor, group);
// Establecer los filtros de colisión
Physics::CServer::getSingletonPtr()->setupFiltering(_actor, group, groupList);
// Liberar recursos
bufferCollection->release();
sceneCollection->release();
}