Working on morph targets
This commit is contained in:
@@ -89,7 +89,7 @@ BoatModule::BoatModule(flecs::world &ecs)
|
||||
ECS::get<EngineData>()
|
||||
.mWorld->addRigidBody(
|
||||
0, boat.mEnt,
|
||||
Ogre::Bullet::CT_BOX,
|
||||
Ogre::Bullet::CT_HULL,
|
||||
nullptr, 2, 0x7fffffff);
|
||||
b2e.entities[body.body] = e;
|
||||
std::vector<Ogre::Node *> slots =
|
||||
|
||||
@@ -203,17 +203,40 @@ CharacterAnimationModule::CharacterAnimationModule(flecs::world &ecs)
|
||||
Ogre::Quaternion rot = ch.mBodyNode->getOrientation();
|
||||
Ogre::Vector3 pos = ch.mBodyNode->getPosition();
|
||||
Ogre::Vector3 boneMotion = ch.mBoneMotion;
|
||||
v.velocity = Ogre::Math::lerp(
|
||||
v.velocity, rot * boneMotion / eng.delta,
|
||||
0.99f);
|
||||
v.velocity = Ogre::Vector3::ZERO;
|
||||
float safeDelta =
|
||||
Ogre::Math::Clamp(eng.delta, 0.001f, 0.99f);
|
||||
#if 0
|
||||
if (!e.has<CharacterInActuator>()) {
|
||||
v.velocity = Ogre::Math::lerp(
|
||||
v.velocity,
|
||||
rot * boneMotion / safeDelta, 0.99f);
|
||||
} else {
|
||||
// v.velocity = rot * boneMotion / safeDelta;
|
||||
v.velocity = Ogre::Math::lerp(
|
||||
v.velocity,
|
||||
rot * boneMotion / safeDelta, 0.99f);
|
||||
}
|
||||
#endif
|
||||
v.velocity = rot * boneMotion / safeDelta;
|
||||
if (!e.has<CharacterDisablePhysics>() &&
|
||||
!e.has<CharacterInActuator>()) {
|
||||
if (eng.startupDelay <= 0.0f)
|
||||
v.velocity += v.gvelocity;
|
||||
v.velocity.y = Ogre::Math::Clamp(
|
||||
v.velocity.y, -10.5f, 1000000.0f);
|
||||
v.velocity.y = Ogre::Math::Clamp(v.velocity.y,
|
||||
-10.5f, 10.0f);
|
||||
}
|
||||
// if (v.velocity.squaredLength() > 1.4f * 1.4f)
|
||||
// v.velocity = v.velocity.normalisedCopy() * 1.4f;
|
||||
// ch.mBoneMotion = Ogre::Vector3::ZERO;
|
||||
// safety
|
||||
// std::cout << "velocity: " << v.velocity << std::endl;
|
||||
v.velocity.x =
|
||||
Ogre::Math::Clamp(v.velocity.x, -16.0f, 16.0f);
|
||||
v.velocity.z =
|
||||
Ogre::Math::Clamp(v.velocity.z, -16.0f, 16.0f);
|
||||
v.velocity.y =
|
||||
Ogre::Math::Clamp(v.velocity.y, -10.5f, 10.0f);
|
||||
});
|
||||
ecs.system<const EngineData, const AnimationControl,
|
||||
const CharacterBase, CharacterVelocity>("HandleSwimming")
|
||||
@@ -258,6 +281,12 @@ CharacterAnimationModule::CharacterAnimationModule(flecs::world &ecs)
|
||||
if (body.mController) {
|
||||
Ogre::Vector3 rotMotion =
|
||||
v.velocity * eng.delta;
|
||||
rotMotion.x = Ogre::Math::Clamp(
|
||||
rotMotion.x, -0.04f, 0.04f);
|
||||
rotMotion.y = Ogre::Math::Clamp(
|
||||
rotMotion.y, -0.025f, 0.1f);
|
||||
rotMotion.z = Ogre::Math::Clamp(
|
||||
rotMotion.z, -0.04f, 0.04f);
|
||||
btVector3 currentPosition =
|
||||
body.mGhostObject
|
||||
->getWorldTransform()
|
||||
|
||||
@@ -165,76 +165,6 @@ struct Animation {
|
||||
kf->setRotation(Ogre::Quaternion::IDENTITY);
|
||||
}
|
||||
mRootTrack->setListener(mListener);
|
||||
#if 0
|
||||
OgreAssert(mHipsTrack, "no hips track");
|
||||
OgreAssert(mRootTrack, "no Root track");
|
||||
#endif
|
||||
#if 0
|
||||
if (mRootTrack) {
|
||||
Ogre::Vector3 delta = Ogre::Vector3::ZERO;
|
||||
Ogre::Vector3 motion = Ogre::Vector3::ZERO;
|
||||
for (j = 0; j < mRootTrack->getNumKeyFrames(); j++) {
|
||||
Ogre::Vector3 trans =
|
||||
mRootTrack->getNodeKeyFrame(j)
|
||||
->getTranslate();
|
||||
if (j == 0)
|
||||
delta = trans;
|
||||
else
|
||||
delta = trans - motion;
|
||||
mRootTrack->getNodeKeyFrame(j)->setTranslate(
|
||||
delta);
|
||||
motion = trans;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
if (!mMetaRootTrack) {
|
||||
Ogre::Bone *bone = nullptr;
|
||||
OgreAssert(skeleton->hasBone("MetaRoot"),
|
||||
"no bone MetaRoot");
|
||||
if (skeleton->hasBone("MetaRoot"))
|
||||
bone = skeleton->getBone("MetaRoot");
|
||||
#if 0
|
||||
else
|
||||
bone = skeleton->createBone("MetaRoot");
|
||||
#endif
|
||||
bone->setPosition(Ogre::Vector3::ZERO);
|
||||
bone->setOrientation(Ogre::Quaternion::IDENTITY);
|
||||
std::vector<
|
||||
std::pair<float, std::pair<Ogre::Vector3,
|
||||
Ogre::Quaternion> > >
|
||||
keyframes;
|
||||
for (j = 0; j < mRootTrack->getNumKeyFrames(); j++) {
|
||||
Ogre::TransformKeyFrame *kf =
|
||||
mRootTrack->getNodeKeyFrame(j);
|
||||
const Ogre::Vector3 &pt = kf->getTranslate();
|
||||
const Ogre::Quaternion &rt = kf->getRotation();
|
||||
float tp = kf->getTime();
|
||||
keyframes.push_back({ tp, { pt, rt } });
|
||||
#if 0
|
||||
new_kf->setTranslate(pt);
|
||||
new_kf->setTranslate(kf->getTranslate());
|
||||
new_kf->setRotation(kf->getRotation());
|
||||
#endif
|
||||
kf->setTranslate(Ogre::Vector3::ZERO);
|
||||
kf->setRotation(Ogre::Quaternion::IDENTITY);
|
||||
}
|
||||
mMetaRootTrack = mSkelAnimation->createNodeTrack(
|
||||
bone->getHandle());
|
||||
OgreAssert(mMetaRootTrack,
|
||||
"failed to create node track");
|
||||
for (j = 0; j < keyframes.size(); j++) {
|
||||
Ogre::TransformKeyFrame *new_kf =
|
||||
mMetaRootTrack->createNodeKeyFrame(
|
||||
keyframes[j].first);
|
||||
new_kf->setTranslate(keyframes[j].second.first);
|
||||
new_kf->setRotation(keyframes[j].second.second);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
mRootTrack = track;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
Ogre::String getName()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user