// sets an animation for the torus
BrumeAnimation animation = new BrumeAnimation();
animation.Name = "Move Torus";
animation.TotalTime = 3.0f;
animation.AnimatedElements = new BrumeAnimatedElement;
animation.AnimatedElements.Name = torus.Name;
animation.AnimatedElements.RotationKeys = new BrumeRotationKey;
animation.AnimatedElements.RotationKeys.Time = 0.0f;
animation.AnimatedElements.RotationKeys.Rotation = BrumeQuaternion.Identity;
animation.AnimatedElements.RotationKeys.Time = 1.5f;
animation.AnimatedElements.RotationKeys.Rotation = BrumeQuaternion.RotationAxis(new BrumeVector(1, 1, 0), (float)Math.PI);
animation.AnimatedElements.RotationKeys.Time = 3.0f;
animation.AnimatedElements.RotationKeys.Rotation = BrumeQuaternion.RotationAxis(new BrumeVector(1, 0, 1), (float)Math.PI);
animation.AnimatedElements.TranslationKeys = new BrumeTranslationKey;
animation.AnimatedElements.TranslationKeys.Time = 3.0f;
animation.AnimatedElements.TranslationKeys.Translation = new BrumeVector(-4.0f,0,0);
torus.Animation = animation;
torus.AnimationStates.PlayMode = BrumeAnimationParams.PLAY_LOOP;
directionalLight = new BrumeDirectionalLight(this, "Directionnal Light", new BrumeVector(-1.0f, -1.0f,
1.0f), new BrumeVector(-1.0f, 1.0f, 1.0f), Color.FromArgb(255, 170, 170, 170));
directionalLight.Specular = Color.FromArgb(255, 255, 255, 255);
directionalLight.Enabled = true;
First we create a BrumeXMesh in order to load the .x file but in order to see the mesh we need an object. For this purpose, we will use a BrumeLightedObject (this is a generic empty object).
We affect the mesh to the object by using the "Mesh" property and we tell the object that it has to deal with specular light by setting the "SpecularLighting" render state.
At this step, if you lauch the project, you should obtain this :
In the code above, we created a directional light with white specular color. You can change the specular color to other values to see the difference in colors.
Next we load our X mesh into the engine. For this tutorial we will use a torus mesh that is included with Brume but you can experiment with your own meshes.
BrumeXMesh torusMesh = new BrumeXMesh(this, "torus_specular", "torus_specular.x", false);
BrumeLightedObject torus = new BrumeLightedObject(this, "torus");
torus.Size = 1.0f;
torus.Mesh = torusMesh;
torus.RenderStates.SpecularLighting = BrumeRenderParams.COLOR_SOURCE_COLOR2;
override protected void GameInit()
this.GlobalAmbientLight = Color.FromArgb(255, 0, 0, 0);
this.BufferClearColor = Color.Black;
camera = new BrumeFPSCamera(this, "camera", new BrumeVector(-5.0f, 0.5f, -30.0f), new
BrumeVector(0.0f, 0.0f, 1.0f), new BrumeVector(0.0f, 1.0f, 0.0f));
This code creates a new BrumeAnimation object named "Move Torus". The animation will last for 3 seconds.
To achieve animation we create a BrumeAnimatedElement (the name is set to the object name torus.Name) that has 3 rotation keys and only one translation key (this will only set the position of the torus -> try to experiment with more translation keys !).
The rotation keys will rotate the torus around some arbitrary axis to help us apreciate specular lighting.
What happens between animation keys ? Brume's animation engine will simply interpolate between them in order to achieve a smooth animation !
This way it's really easy to animate the objects you add in the scene. So try to modify the values and make your own animations simply by adding rotation, scale and translation keys.
And don't forget that you can do the same with all Brume objects (cameras and lights as well).
Click on the images below to see the result :
Tutorial : Specular light
This tutorial will explain you how to load an X mesh into the engine and how to setup a specular light to achive nice effects.
Note that your mesh must be designed with specular materials.
Create a new project named "TutorialSpecular" (look at "The Basics" tutorial for more informations) and add a camera, set a black background color and no ambient light :
Once it's done, define a directional light that will produce specular lightning :
It works but it's not very funny...
Let's add some animation to our torus !
In the InitGame method, after creating the torus object, add this source code :