Crystal Space 2.0.0: 4.10.19.2 Furmesh Animation

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 4.10.19.2 Furmesh Animation

Written by Alexandru - Teodor Voicu, voicualexandruteodor@gmail.com.

#### Introduction

Furmeshes support a variety of animations, from simple inherited animations, that come from objects on which the furmesh is attached, to complex animations, based on physics objects, such as Bullet ropes.

There are three main interfaces that can be used for animating furmeshes:

- `iFurAnimationControl`. This interface only provides the most basic methods needed to update guide fur strands positions (see section Furmesh Mesh Object) on each frame. It can be used to initially set up the furs directions and disable it afterwards.
- `iFurAnimatedMeshControl`. This interface extends the `iFurAnimationControl` in order to support simple animations inherited from the base mesh. As the name suggest this only works with AnimatedMeshes, but can be easily extended to support other types of meshes that provide access to positions, normals, tangents and binormals render buffers.
- `iFurPhysicsControl`. Although the `iFurAnimatedMeshControl` can be used for animating fur, for animating hairs, physical forces, such as gravity or winds or adequate response to movement, had to be added, using dynamic systems. The `iFurPhysicsControl` interface is designed to work with Bullet dynamic system to provide a physical simulation for hair on Animated Meshes.

#### Creating Furmesh Animations

Creating both `iFurAnimatedMeshControl` and `iFurPhysicsControl` is done via the `iFurMeshType` interface, using the `CreateFurAnimatedMeshControl`, respectively the `CreateFurPhysicsControl` methods.

An example of creating such `iFurAnimationControl` interfaces is:

    ...
    // Load furMesh
    csRef<CS::Mesh::iFurMeshType> furMeshType =
      csQueryRegistry<CS::Mesh::iFurMeshType> (hairTest->object_reg);
    if (!furMeshType)
      return hairTest->ReportError("Failed to locate CS::Mesh::iFurMeshType plugin!");
    ...
    // Create Hair Physics Control
    hairPhysicsControl = scfQueryInterface<CS::Mesh::iFurPhysicsControl>
      (furMeshType->CreateFurPhysicsControl("krystal_hairs_physics"));
    // Set up Hair Physics Control
    hairPhysicsControl->SetBulletDynamicSystem(hairTest->bulletDynamicSystem);
    hairPhysicsControl->SetRigidBody(headBody);
    hairPhysicsControl->SetAnimatedMesh(animesh);
    ...
    // Create Animation Physics Control
    animationPhysicsControl = scfQueryInterface<CS::Mesh::iFurAnimatedMeshControl>
      (furMeshType->CreateFurAnimatedMeshControl("krystal_hairs_animation"));
    // Set Animation Physics Control
    animationPhysicsControl->SetAnimatedMesh(animesh);
    animationPhysicsControl->SetDisplacement(ifms->GetDisplacement());
    ...
    // Regiseter Animation Control with the furmesh
    furMesh->SetAnimationControl(animationPhysicsControl);
    furMesh->StartAnimationControl();
    ...

This document was generated using texi2html 1.76.