A collection is a set of PxBase objects. PxBase objects can be added to the collection regardless of other objects they depend on. Objects may be named using PxSerialObjectId values in order to resolve dependencies between objects of different collections.
Serialization and deserialization only work through collections.
A scene is typically serialized using the following steps:
-# create a serialization registry -# create a collection for scene objects -# complete the scene objects (adds all dependent objects, e.g. meshes) -# serialize collection -# release collection -# release serialization registry
For example the code may look like this:
\code PxPhysics* physics; // The physics PxScene* scene; // The physics scene SerialStream s; // The user-defined stream doing the actual write to disk
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 1) PxCollection* collection = PxSerialization::createCollection(*scene); // step 2) PxSerialization::complete(*collection, *registry); // step 3) PxSerialization::serializeCollectionToBinary(s, *collection, *registry); // step 4) collection->release(); // step 5) registry->release(); // step 6) \endcode
A scene is typically deserialized using the following steps:
-# load a serialized collection into memory -# create a serialization registry -# create a collection by passing the serialized memory block -# add collected objects to scene -# release collection -# release serialization registry
For example the code may look like this:
\code PxPhysics* physics; // The physics PxScene* scene; // The physics scene void* memory128; // a 128-byte aligned buffer previously loaded from disk by the user - step 1)
PxSerializationRegistry* registry = PxSerialization::createSerializationRegistry(*physics); // step 2) PxCollection* collection = PxSerialization::createCollectionFromBinary(memory128, *registry); // step 3) scene->addCollection(*collection); // step 4) collection->release(); // step 5) registry->release(); // step 6) \endcode
-
Nested Class Summary
Nested classes/interfaces inherited from class physx.NativeObject
NativeObject.Allocator<T> -
Field Summary
FieldsFields inherited from class physx.NativeObject
address, isExternallyAllocated, SIZEOF_BYTE, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_POINTER, SIZEOF_SHORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a PxBase object to the collection.voidAdds a PxBase object to the collection.voidAdds an id to a member PxBase object.static PxCollectionarrayGet(long baseAddress, int index) booleanReturns whether the collection contains a certain PxBase object.find(long id) Looks for a PxBase object given a PxSerialObjectId value.longGets the PxSerialObjectId name of a PxBase object within the collection.intgetNbIds()Gets number of PxSerialObjectId names in this collection.intGets number of PxBase objects in this collection.getObject(int index) Gets the PxBase object of this collection given its index.voidrelease()Deletes a collection object.voidRemoves a PxBase member object from the collection.voidremoveId(long id) Removes id from a contained PxBase object.static PxCollectionwrapPointer(long address) Methods inherited from class physx.NativeObject
checkNotNull, equals, getAddress, hashCode
-
Field Details
-
SIZEOF
public static final int SIZEOF -
ALIGNOF
public static final int ALIGNOF- See Also:
-
-
Constructor Details
-
PxCollection
protected PxCollection() -
PxCollection
protected PxCollection(long address)
-
-
Method Details
-
wrapPointer
-
arrayGet
-
add
Adds a PxBase object to the collection.Adds a PxBase object to the collection. Optionally a PxSerialObjectId can be provided in order to resolve dependencies between collections. A PxSerialObjectId value of PX_SERIAL_OBJECT_ID_INVALID means the object remains without id. Objects can be added regardless of other objects they require. If the object is already in the collection, the ID will be set if it was PX_SERIAL_OBJECT_ID_INVALID previously, otherwise the operation fails.
-
add
Adds a PxBase object to the collection.Adds a PxBase object to the collection. Optionally a PxSerialObjectId can be provided in order to resolve dependencies between collections. A PxSerialObjectId value of PX_SERIAL_OBJECT_ID_INVALID means the object remains without id. Objects can be added regardless of other objects they require. If the object is already in the collection, the ID will be set if it was PX_SERIAL_OBJECT_ID_INVALID previously, otherwise the operation fails.
- Parameters:
id- Optional PxSerialObjectId id
-
remove
Removes a PxBase member object from the collection.Object needs to be contained by the collection.
-
contains
Returns whether the collection contains a certain PxBase object.- Returns:
- Whether object is contained.
-
addId
Adds an id to a member PxBase object.If the object is already associated with an id within the collection, the id is replaced. May only be called for objects that are members of the collection. The id needs to be unique within the collection.
- Parameters:
id- PxSerialObjectId id to be given to the object
-
removeId
public void removeId(long id) Removes id from a contained PxBase object.May only be called for ids that are associated with an object in the collection.
- Parameters:
id- PxSerialObjectId value
-
getNbObjects
public int getNbObjects()Gets number of PxBase objects in this collection.- Returns:
- Number of objects in this collection
-
getObject
Gets the PxBase object of this collection given its index.- Parameters:
index- PxBase index in [0, getNbObjects())- Returns:
- PxBase object at index index
-
find
Looks for a PxBase object given a PxSerialObjectId value.If there is no PxBase object in the collection with the given id, NULL is returned.
- Parameters:
id- PxSerialObjectId value to look for- Returns:
- PxBase object with the given id value or NULL
-
getNbIds
public int getNbIds()Gets number of PxSerialObjectId names in this collection.- Returns:
- Number of PxSerialObjectId names in this collection
-
getId
Gets the PxSerialObjectId name of a PxBase object within the collection.The PxBase object needs to be a member of the collection.
- Returns:
- PxSerialObjectId name of the object or PX_SERIAL_OBJECT_ID_INVALID if the object is unnamed
-
release
public void release()Deletes a collection object.This function only deletes the collection object, i.e. the container class. It doesn't delete objects that are part of the collection.
-