Load bhkRigidBody

android-ndk22
Alexei Dobrohotov 3 years ago
parent c01fff280a
commit 25f4d05c2e

@ -150,6 +150,8 @@ static std::map<std::string,RecordFactoryEntry> makeFactory()
factory["bhkConvexVerticesShape"] = {&construct <bhkConvexVerticesShape> , RC_bhkConvexVerticesShape };
factory["bhkBoxShape"] = {&construct <bhkBoxShape> , RC_bhkBoxShape };
factory["bhkListShape"] = {&construct <bhkListShape> , RC_bhkListShape };
factory["bhkRigidBody"] = {&construct <bhkRigidBody> , RC_bhkRigidBody };
factory["bhkRigidBodyT"] = {&construct <bhkRigidBody> , RC_bhkRigidBodyT };
return factory;
}

@ -69,6 +69,82 @@ namespace Nif
mNormal = nif->getVector3();
}
void bhkRigidBodyCInfo::read(NIFStream *nif)
{
if (nif->getVersion() >= NIFStream::generateVersion(10,1,0,0))
{
nif->skip(4); // Unused
mHavokFilter.read(nif);
nif->skip(4); // Unused
if (nif->getBethVersion() != NIFFile::BethVersion::BETHVER_FO4)
{
if (nif->getBethVersion() >= 83)
nif->skip(4); // Unused
mResponseType = static_cast<hkResponseType>(nif->getChar());
nif->skip(1); // Unused
mProcessContactDelay = nif->getUShort();
}
}
if (nif->getBethVersion() < 83)
nif->skip(4); // Unused
mTranslation = nif->getVector4();
mRotation = nif->getQuaternion();
mLinearVelocity = nif->getVector4();
mAngularVelocity = nif->getVector4();
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++)
mInertiaTensor[i][j] = nif->getFloat();
mCenter = nif->getVector4();
mMass = nif->getFloat();
mLinearDamping = nif->getFloat();
mAngularDamping = nif->getFloat();
if (nif->getBethVersion() >= 83)
{
if (nif->getBethVersion() != NIFFile::BethVersion::BETHVER_FO4)
mTimeFactor = nif->getFloat();
mGravityFactor = nif->getFloat();
}
mFriction = nif->getFloat();
if (nif->getBethVersion() >= 83)
mRollingFrictionMult = nif->getFloat();
mRestitution = nif->getFloat();
if (nif->getVersion() >= NIFStream::generateVersion(10,1,0,0))
{
mMaxLinearVelocity = nif->getFloat();
mMaxAngularVelocity = nif->getFloat();
if (nif->getBethVersion() != NIFFile::BethVersion::BETHVER_FO4)
mPenetrationDepth = nif->getFloat();
}
mMotionType = static_cast<hkMotionType>(nif->getChar());
if (nif->getBethVersion() < 83)
mDeactivatorType = static_cast<hkDeactivatorType>(nif->getChar());
else
mEnableDeactivation = nif->getBoolean();
mSolverDeactivation = static_cast<hkSolverDeactivation>(nif->getChar());
if (nif->getBethVersion() == NIFFile::BethVersion::BETHVER_FO4)
{
nif->skip(1);
mPenetrationDepth = nif->getFloat();
mTimeFactor = nif->getFloat();
nif->skip(4);
mResponseType = static_cast<hkResponseType>(nif->getChar());
nif->skip(1); // Unused
mProcessContactDelay = nif->getUShort();
}
mQualityType = static_cast<hkQualityType>(nif->getChar());
if (nif->getBethVersion() >= 83)
{
mAutoRemoveLevel = nif->getChar();
mResponseModifierFlags = nif->getChar();
mNumContactPointShapeKeys = nif->getChar();
mForceCollidedOntoPPU = nif->getBoolean();
}
if (nif->getBethVersion() == NIFFile::BethVersion::BETHVER_FO4)
nif->skip(3); // Unused
else
nif->skip(12); // Unused
}
/// Record types
void bhkCollisionObject::read(NIFStream *nif)
@ -223,4 +299,15 @@ namespace Nif
filter.read(nif);
}
void bhkRigidBody::read(NIFStream *nif)
{
bhkEntity::read(nif);
mInfo.read(nif);
mConstraints.read(nif);
if (nif->getBethVersion() < 76)
mBodyFlags = nif->getUInt();
else
mBodyFlags = nif->getUShort();
}
} // Namespace

@ -85,6 +85,86 @@ struct TriangleData
void read(NIFStream *nif);
};
enum class hkMotionType : uint8_t
{
Motion_Invalid = 0,
Motion_Dynamic = 1,
Motion_SphereInertia = 2,
Motion_SphereStabilized = 3,
Motion_BoxInertia = 4,
Motion_BoxStabilized = 5,
Motion_Keyframed = 6,
Motion_Fixed = 7,
Motion_ThinBox = 8,
Motion_Character = 9
};
enum class hkDeactivatorType : uint8_t
{
Deactivator_Invalid = 0,
Deactivator_Never = 1,
Deactivator_Spatial = 2
};
enum class hkSolverDeactivation : uint8_t
{
SolverDeactivation_Invalid = 0,
SolverDeactivation_Off = 1,
SolverDeactivation_Low = 2,
SolverDeactivation_Medium = 3,
SolverDeactivation_High = 4,
SolverDeactivation_Max = 5
};
enum class hkQualityType : uint8_t
{
Quality_Invalid = 0,
Quality_Fixed = 1,
Quality_Keyframed = 2,
Quality_Debris = 3,
Quality_Moving = 4,
Quality_Critical = 5,
Quality_Bullet = 6,
Quality_User = 7,
Quality_Character = 8,
Quality_KeyframedReport = 9
};
struct bhkRigidBodyCInfo
{
HavokFilter mHavokFilter;
hkResponseType mResponseType;
unsigned short mProcessContactDelay;
osg::Vec4f mTranslation;
osg::Quat mRotation;
osg::Vec4f mLinearVelocity;
osg::Vec4f mAngularVelocity;
float mInertiaTensor[3][4];
osg::Vec4f mCenter;
float mMass;
float mLinearDamping;
float mAngularDamping;
float mTimeFactor{1.f};
float mGravityFactor{1.f};
float mFriction;
float mRollingFrictionMult;
float mRestitution;
float mMaxLinearVelocity;
float mMaxAngularVelocity;
float mPenetrationDepth;
hkMotionType mMotionType;
hkDeactivatorType mDeactivatorType;
bool mEnableDeactivation{true};
hkSolverDeactivation mSolverDeactivation;
hkQualityType mQualityType;
unsigned char mAutoRemoveLevel;
unsigned char mResponseModifierFlags;
unsigned char mNumContactPointShapeKeys;
bool mForceCollidedOntoPPU;
void read(NIFStream *nif);
};
/// Record types
// Abstract Bethesda Havok object
@ -240,5 +320,14 @@ struct bhkListShape : public bhkShapeCollection
void read(NIFStream *nif) override;
};
struct bhkRigidBody : public bhkEntity
{
bhkRigidBodyCInfo mInfo;
bhkSerializableList mConstraints;
unsigned int mBodyFlags;
void read(NIFStream *nif) override;
};
} // Namespace
#endif

@ -137,7 +137,9 @@ enum RecordType
RC_hkPackedNiTriStripsData,
RC_bhkConvexVerticesShape,
RC_bhkBoxShape,
RC_bhkListShape
RC_bhkListShape,
RC_bhkRigidBody,
RC_bhkRigidBodyT
};
/// Base class for all records

Loading…
Cancel
Save