BrumeFileManager.AddDirForAll("../../Data/Meshes");


The first line extracts all animation contained in "tiny_4anim.x" and loads them into the animation engine for future lookup.

We then assign the Jog animation to our tiny object in order to animate the mesh and that's all !

Again lauch your project to see the animated tiny.

Finally to see all the animations, override Brume's MoveScene method and add the following source code :


This will load the mesh into the engine and encapsulate it inside a BrumeLightedObject for display. Note that we resized the object because the mesh is really huge ;o)

In order to load the mesh you will also have to add the following ressource path in the constructor :


This tells Brume where to lookup meshe's textures and .x file.

Now you can launch your project. You should obtain this :


BrumeXMesh tinyMesh = new BrumeXMesh(this, "tiny", "tiny_4anim.x", false);

tiny = new BrumeLightedObject(this, "tiny");

tiny.Mesh = tinyMesh;

tiny.Size = 0.005f;

tiny.Orient(new BrumeVector(0, 1, 0), new BrumeVector(0, 0, 1));


protected override void MoveScene(float fElapsedTime)

{

// skinned animation

if (tiny != null && tiny.Animation != null)

{

animTime += fElapsedTime / 1000;

if (animTime > 8.0f)

{

animTime = 0.0f;

}

if (animTime > 6.0f)

{

if (tiny.Animation.Name != "Jog")

tiny.Animation = BrumeAnimationManager.GetAnimation("Jog");

}

else if (animTime > 4.0f)

{

if (tiny.Animation.Name != "Walk")

tiny.Animation = BrumeAnimationManager.GetAnimation("Walk");

}

else if (animTime > 2.0f)

{

if (tiny.Animation.Name != "Wave")

tiny.Animation = BrumeAnimationManager.GetAnimation("Wave");

}

else if (tiny.Animation.Name != "Loiter")

tiny.Animation = BrumeAnimationManager.GetAnimation("Loiter");

}


Home


This tutorial explains how to use skinning in Brume engine. For this tutorial we will use the Microsoft's Tiny mesh as you can easily get the file in DirectX SDK.

But don't hesitate to experiment with your own files !

The rule is : if you see your X mesh animation in DirectX Viewer tool, you must be able to play it in Brume ;o)

Ok so first you need to locate the "tiny_4anim.x" file in DirectX December SDK. It should be located in "SDKHome\Samples\C++\Direct3D\MultiAnimation\".

Create a new project in Visual Studio named "TutorialSkinning" and copy the x file into the following directory "ProjectHome\Data\Meshes".

Then use the "The Basics" tutorial to set up an empty scene and add a new camera to it :


Home


Once done add this source code in the InitGame method :


Now tiny's animations will cycle between Jog, Walk, Wave and Loiter.

Note that you can also use animation events available on the "tiny" object :

- AnimationChange : called if you manualy change the animation property

- AnimationEnd : called at the end of an animation

- AnimationKeyFrame : called at each animation key frame

Click at the images below in order to preview the final result :


override protected void GameInit()

{

this.GlobalAmbientLight = Color.FromArgb(255, 180, 180, 180);

this.BufferClearColor = Color.Black;

camera = new BrumeFPSCamera(this, "camera", new BrumeVector(0.0f, 1.5f, -5.0f), new

BrumeVector(0.0f, 0.0f, 1.0f), new BrumeVector(0.0f, 1.0f, 0.0f));

camera.ChangeNearFarDistances(0.05f, 100.0f);

this.SetActiveCamera(camera);


// get mesh animations into the engine

BrumeAnimationManager.AddAnimationsFromMesh(tinyMesh);

// assign start animation (lookup from animation engine)

tiny.Animation = BrumeAnimationManager.GetAnimation("Jog");


Tutorial : Skinning


This is ok ! But it does not move !

Yes it's true so we need to extract tiny's animations and affect them to our object otherwise Brume animation engine won't animate anything.

Add the following lines at the end of your InitGame method :


 


Please click here to install flash player in order to see this website