我现在正在调查 PhysX,我一直坚持序列化。当我尝试序列化关节时,反序列化失败并出现错误:
code: 8
message: NpActorTemplate::resolvePointers: connector not found.
file: ..\..\PhysX\src\NpActor.cpp
line: 95
但如果没有关节,它可以正常工作并反序列化所有对象。正确序列化关节是否需要任何其他操作?代码有序列化部分:
material1->collectForExport(*collection);
material->collectForExport(*collection);
mesh->collectForExport(*collection);
for (__int8 i = 0; i < 4; ++i)
{
actors[i]->collectForExport(*collection);
aggregate->addActor(*actors[i]);
}
aggregate->collectForExport(*collection);
joints[0] = PxD6JointCreate(*physics, actors[0], PxTransform(PxVec3(2, -.5f, 0)), actors[1], PxTransform(PxVec3(0)));
PxD6JointDrive drive(1000, 100, PX_MAX_F32, true);
joints[0]->setMotion(PxD6Axis::eX, PxD6Motion::eFREE);
joints[0]->setMotion(PxD6Axis::eY, PxD6Motion::eFREE);
joints[0]->setMotion(PxD6Axis::eZ, PxD6Motion::eFREE);
joints[0]->setDrive(PxD6Drive::eX, drive);
joints[0]->setDrive(PxD6Drive::eY, drive);
joints[0]->setDrive(PxD6Drive::eZ, drive);
joints[0]->setDrivePosition(PxTransform(PxVec3(2, -.5f, 0)));
joints[0]->setDriveVelocity(PxVec3(0), PxVec3(0));
for (__int8 i = 0; i < 1; ++i)
{
joints[i]->collectForExport(*collection);
}
反序列化:
_pxBuffer = _aligned_malloc(length, PX_SERIAL_FILE_ALIGN);
//filling the buffer here
_pxCollection = pxContext->GetPhysics()->createCollection();
_pxCollection->deserialize(_pxBuffer, 0, 0);