本文整理汇总了C++中PxCollection::serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ PxCollection::serialize方法的具体用法?C++ PxCollection::serialize怎么用?C++ PxCollection::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxCollection
的用法示例。
在下文中一共展示了PxCollection::serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportWholeScene
bool PhysXWorld::ExportWholeScene(const char *filename) const
{
using namespace physx::repx;
if (!PhysXSDK || !PhysXScene)
return false;
PxCollection *cl = PhysXSDK->createCollection();
if (!cl)
return false;
PhysxUserFileWriteStream fs(filename);
RepXCollection* theCollection = createCollection(PhysXSDK->getTolerancesScale(), PhysXFoundation->getAllocatorCallback());
RepXIdToRepXObjectMap* theIdMap = RepXIdToRepXObjectMap::create(PxGetFoundation().getAllocatorCallback());
addSDKItemsToRepX ( *PhysXSDK, *theIdMap, *theCollection); //add physcis object
addSceneItemsToRepX ( *PhysXScene, *theIdMap, *theCollection); //add physcis object
// physx::repx::addObjectsToScene(theCollection, physics, cooking, scene, mStringTable );
theCollection->save(fs);
theCollection->destroy();
theIdMap->destroy();
return true;
// PxCollectForExportSDK(*PhysXSDK, *cl);
// PxCollectForExportScene(*PhysXScene, *cl);
ObjectIterator iter = GameWorld().GetFirstOfAllObjects();
while( iter.current )
{
GameObject* o = iter.current;
if (o->PhysicsObject)
{
PxActor *a = o->PhysicsObject->getPhysicsActor();
PxSerialFlags f = a->getSerialFlags();
a->collectForExport(*cl);
break;
}
iter = GameWorld().GetNextOfAllObjects( iter );
}
PxU32 numObjs = cl->getNbObjects();
numObjs;
cl->serialize(fs);
PhysXSDK->releaseCollection(*cl);
fclose(fs.fpw);
FILE* fp=NULL;
if( (fp = fopen(filename, "rb")) )
{
fseek(fp, 0, SEEK_END);
PxU32 fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
PX_ASSERT(fileSize!=0);
void* mem = malloc(fileSize+PX_SERIAL_FILE_ALIGN);
void* mem16 = (void*)((size_t(mem) + PX_SERIAL_FILE_ALIGN)&~(PX_SERIAL_FILE_ALIGN-1));
fread(mem16, 1, fileSize, fp);
fclose(fp);
PxUserReferences* convexRefs = PhysXSDK->createUserReferences();
PxCollection* collection = PhysXSDK->createCollection();
collection->deserialize(mem16, convexRefs, NULL);
PxU32 numObjs = collection->getNbObjects();
for (PxU32 i = 0; i < numObjs; ++i)
{
PxSerializable *o = collection->getObject(i);
const char * name = o->getConcreteTypeName();
PX_ASSERT(name);
}
}
return true;
}