Hi everybody,
here is the first draft of the API I propose for the implementation of
the ragdoll plugin (to be extended with other controllers like inverse
kinematic and such).
In this API, there is a first plugin that holds the complementary data
on the skeleton, such as physical properties, colliders, degrees of
freedom, constraints on these degrees, and sub-parts of the skeleton
("body chains"). I chose to call this plugin "bodymesh", in order to
emphasize the physical aspect that is added to the animesh.
The ragdoll controller and the other controllers will be implemented
each one in a separate plugin, in order to be able to load and use them
separately. These controllers inherit from the class
iSkeletonAnimNodeFactory2, they are therefore blend nodes that can be
combined and blended together in the blending tree of the animesh. In
fact, theses nodes may not always be blended like any other nodes. For
example, the methods GetDuration() and SetPlaybackSpeed() of the class
iSkeletonAnimNodeFactory2 does not have any sense for the dynamic
simulation of the ragdoll controller, and the current implementation of
the blending tree may need to be extended in order to handle this.
The ragdoll controller is also a special blend node, because its state
can not be blended in another consecutive state, because otherwise the
state of the dynamic simulation will not be synchronized with the
animesh state. But this controller may use some previously blended state
to give more life to the animation. In order to do that, the state to be
blended in the ragdoll simulation will need to be transformed in some
forces and torques to be applied on the bones of the skeleton. The
method usually used for this is the proportional-derivative controller
(PD-controller).
All these controllers can be used on the whole skeleton or on part of
it. So it should for instance be possible to have an IK controller to
animate the hands and feets of an avatar, while a ragdoll controller
animates the hairs and clothes, and the other parts of the skeleton are
animated from classical animations defined by an artist.
Here is the API:
=======================================
file include/imesh/bodymesh.h
plugin crystalspace.mesh.object.bodymesh
implemented in plugins/mesh/animesh/body
loader in plugins/mesh/animesh/persist/body
=======================================
struct iBodyManager : public iBase {
virtual iBodySkeletonFactory* CreateSkeletonFactory (const char *name) =
0;
virtual iBodySkeletonFactory* FindSkeletonFactory (const char *name) =
0;
virtual void ClearSkeletonFactories () = 0;
};
struct iBodySkeletonFactory : public iBase {
virtual const char* GetName () = 0;
virtual void SetAnimatedMeshFactory (iAnimatedMeshFactory *factory) = 0;
virtual iAnimatedMeshFactory* GetAnimatedMeshFactory () = 0;
virtual void ClearAll () = 0;
virtual csPtr<iBodyBoneFactory> CreateBoneFactory (const char *name,
BoneID boneID) = 0;
virtual csPtr<iBodyBoneFactory> FindBoneFactory (const char *name) = 0;
virtual void ClearBoneFactories () = 0;
virtual void SetRootBoneFactory (iBodyBoneFactory* factory) = 0;
virtual iBodyBoneFactory* GetRootBoneFactory () = 0;
virtual csPtr<iBodyChain> CreateChain (const char *name, BoneID
rootBone, BoneID childBone, ...) = 0;
virtual csPtr<iBodyChain> FindChain (const char *name) = 0;
virtual void ClearChains () = 0;
virtual csPtr<iBodySkeleton> CreateInstance (iAnimatedMesh* mesh) = 0;
}
struct iBodySkeleton : public iBase {
virtual iBodySkeletonFactory* GetFactory () = 0;
virtual iAnimatedMesh* GetAnimatedMesh () = 0;
virtual iBodyBone* GetRootBone () = 0;
}
struct iBodyBoneFactory : public iBase {
virtual const char* GetName () = 0;
virtual BoneID GetAnimeshBone () = 0;
virtual iRigidBody* GetRigidBody () = 0;
virtual iJoint* GetJoint () = 0;
virtual csPtr<iBodyBone> CreateInstance () = 0;
}
struct iBodyBone : public iBase {
virtual iBodyBoneFactory* GetFactory () = 0;
virtual iBodyBone* FindBone (const char *factoryName) = 0;
virtual iRigidBody* GetRigidBody () = 0;
virtual iJoint* GetJoint () = 0;
}
struct iBodyChain : public iBase {
virtual const char* GetName () = 0;
virtual iBodyChainNode* GetRootNode () = 0;
}
struct iBodyChainNode : public iBase {
virtual iBodyBoneFactory* GetBoneFactory () = 0;
virtual uint GetChildCount () = 0;
virtual iBodyChainNode* GetChild (uint index) = 0;
virtual iBodyChainNode* GetParent () = 0;
}
struct iBodyAnimNodeFactory : public iSkeletonAnimNodeFactory2 {
virtual iBodyChain* GetBodyChain () = 0;
}
=======================================
file include/imesh/bodycontrollers/ragdoll.h
plugin crystalspace.mesh.object.bodymesh.controllers.ragdoll
implemented in plugins/mesh/animesh/bodycontrollers/ragdoll
loader in plugins/mesh/animesh/persist/bodycontrollers/ragdoll
=======================================
struct iBodyRagdollManager : public iBase {
csPtr<iBodyRagdollAnimNodeFactory> CreateRagdollAnimNodeFactory
(iBodySkeleton* body, iBodyChain *chain) = 0;
}
struct iBodyRagdollAnimNodeFactory : public iBodyAnimNodeFactory {
}
Feel free to comment, criticize or ask any questions on this
Regards,
Christian
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe:
mailto:[email protected]?subject=unsubscribe