Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tags in this Discussion

PxCollection or RepXCollection for RepX file
  • Hi!

    I would like to load a .repx file and create actors from it. Can I use a PxCollection to deserialize the data in .repX? If not how use RepXCollection and instanciateCollection()? Unfortunately I didn't find many documentations on how loading a .repx and any examples on RepXCollection.

    Thanks.
  • 1 Comment sorted by
  • Vote Up0Vote Down Hai Loc Lu
    Posts: 102 Accepted Answer
    #include "RepXUtility.h"

    // Do your pre-processing here before adding RepX actors to your scene
    struct MyOwnRepXCoreItemAdder
    {
    PxScene* mScene;

    MyOwnRepXCoreItemAdder( PxScene* inScene) : mScene( inScene ) {}

    void operator()( const void* inId, PxConvexMesh* ) {}
    void operator()( const void* inId, PxTriangleMesh* ) {}
    void operator()( const void* inId, PxHeightField* ) {}
    void operator()( const void* inId, PxClothFabric* ) {}
    void operator()( const void* inId, PxMaterial* inData ) {}
    void operator()( const void* inId, PxRigidStatic* ) {}
    void operator()( const void* inId, PxRigidDynamic* inActor )
    {
    mScene->addActor( *inActor );
    }
    void operator()( const void* inId, PxArticulation* inArticulation ) { mScene->addArticulation( *inArticulation ); }
    void operator()( const void* inId, PxCloth* inData ) { mScene->addActor( *inData ); }
    void operator()( const void* inId, PxParticleSystem* inActor ) { mScene->addActor( *inActor ); }
    void operator()( const void* inId, PxParticleFluid* inActor ) { mScene->addActor( *inActor ); }
    void operator()( const void* inId, PxJoint* inJoint ) {}
    void operator()( const void* inId, PxAggregate* inData ) { mScene->addAggregate( *inData ); }
    };



    PxStringTable* stringTable = &PxStringTableExt::createStringTable( getFoundation().getAllocator() );
    PxToolkit::FileInputData data(getFilename("YourRepXFile.repx"));
    RepXCollection* collection = createCollection(data, getFoundation().getAllocator());

    //addObjectsToScene(collection, &getFramework().getPhysics(), &getFramework().getCooking(), &getFramework().getActiveScene(), stringTable);

    repx::RepXIdToRepXObjectMap* theIdMap( PxToolkit::createIdMap() );
    physx::repx::instantiateCollection( collection, theIdMap, &getPhysics(), &getCooking(), stringTable, true, MyOwnRepXCoreItemAdder(&getActiveScene()) );
    theIdMap->destroy();

    collection->destroy();
    stringTable->release();