Skip to content

PokeD/PokeD.Graphics.Animation

Repository files navigation

PokeD.Graphics.Animation

Portion of code taken from tainicom.Aether.Animation

Processors

Example

-Import 3D model with GPU Animated Model or CPU Animated Model Processor.
Use SkinnedEffect for GPU and BasicEffect or AlphaTestEffect for CPU based animation.

-Load as any 3D Model:

_model = Content.Load<Model>("animatedModel");

-Load the Skeletal and Material animation from model:

_skeletalAnimations = _model.GetSkeletalAnimations();
_skeletalAnimations.SetClip("ClipName");
  
_materialAnimations = _model.GetMaterialAnimations();
_materialAnimations.SetClip("ClipName");
_skeletalAnimations = _model.GetSkeletalAnimations();
var skeletalClip = _skeletalAnimations.Clips["ClipName"];
_skeletalAnimations.SetClip(skeletalClip);
  
_materialAnimations = _model.GetMaterialAnimations();
var materialClip = _materialAnimations.Clips["ClipName"];
_materialAnimations.SetClip(materialClip);

-Update animation on every frame:

_skeletalAnimations.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
_materialAnimations.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);

-Draw GPU Skeletal animation:

foreach (ModelMesh mesh in _model.Meshes)
{
  foreach (var meshPart in mesh.MeshParts)
  {
    meshPart.effect.SetBoneTransforms(_animations.AnimationTransforms);
    // set effect parameters, lights, etc          
  }
  mesh.Draw();
}

-Draw GPU Material animation:
MonoGame's shaders do not support it, create one yourself. -Draw CPU Skeletal and Material animation:

foreach (ModelMesh mesh in _model.Meshes)
{
  foreach (var meshPart in mesh.MeshParts)
  {
    meshPart.UpdateVertices(_skeletalAnimations.AnimationTransforms, _materialAnimations.AnimationTransforms);
    // set effect parameters, lights, etc
  }
  mesh.Draw();
}

Releases

No releases published

Packages

No packages published

Languages