Moderator: Brume Dev Team
human.AnimationStates.PlayMode = BrumeAnimationParams.PLAY_LOOP;
// move
if (BrumeKeyboard.IsPressed(BrumeKey.W))
{
// if !walking and !running
if (human.Animation != animations[ANIM_WALK_start] && human.Animation != animations[ANIM_WALK_player] && human.Animation != animations[ANIM_run_player])
{
human.Animation = animations[ANIM_WALK_start];
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.S))
{
// if !walking & ! running
if (human.Animation != animations[ANIM_walk_start_back] && human.Animation != animations[ANIM_walk_back] && human.Animation != animations[ANIM_run_back])
{
human.Animation = animations[ANIM_walk_start_back];
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.A))
{
// if not walking left
if (human.Animation != animations[ANIM_walk_left] && human.Animation != animations[ANIM_run_left])
{
if (running)
{
human.Animation = animations[ANIM_run_left];
}
else
{
human.Animation = animations[ANIM_walk_left];
}
}
}
else if (BrumeKeyboard.IsPressed(BrumeKey.D))
{
// if not walking right
if (human.Animation != animations[ANIM_walk_right] && human.Animation != animations[ANIM_run_right])
{
if (running)
{
human.Animation = animations[ANIM_run_right];
}
else
{
human.Animation = animations[ANIM_walk_right];
}
}
}
else // no keys
{
if (human.Animation != animations[ANIM_IDLE_stance])
{
human.Animation = animations[ANIM_IDLE_stance];
// update pos en fontion du root object
human.UpdatePos(inCar, car);
}
}
// direction
BrumeVector newDir = camera5.Dir;
newDir.Y = 0.0f;
newDir.Normalize();
human.Orient(newDir, human.Up);
public void HumanAnimationEnd(BrumeObject sender)
{
if (sender.Animation != null)
{
switch (sender.Animation.Name)
{
case "run_player": break;
case "WALK_player": break;
case "WALK_start": if (running) sender.Animation = animations[ANIM_run_player]; else sender.Animation = animations[ANIM_WALK_player]; break;
case "walk_start_back": if (running) sender.Animation = animations[ANIM_run_back]; else sender.Animation = animations[ANIM_walk_back]; break;
case "Run_stop": break;
case "run_back": break;
case "walk_back": break;
}
// update pos en fontion du root object
if (!inCar)
{
human.UpdatePos(inCar, car);
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Brume.Tests
{
public class Sample : Brume
{
private BrumeFPSCamera camera1 = null;
private BrumeLight directionalLight = null;
private BrumeLightedObject tiny = null;
public Sample() : base()
{
BrumeFileManager.AddDirForAll("../../../Data/Internal");
BrumeFileManager.AddDirForAll("../../Data");
}
override protected void GameInit()
{
camera1 = new BrumeFPSCamera(this, "camera1", new BrumeVector(0, 0, -5.0f), new BrumeVector(0.0f, 0.0f, 1.0f), new BrumeVector(0.0f, 1.0f, 0.0f));
this.SetActiveCamera(camera1);
this.BufferClearColor = Color.Black;
this.GlobalAmbientLight = Color.FromArgb(255, 100, 100, 100);
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;
directionalLight.Update();
BrumeXMesh tinyMesh = new BrumeXMesh(this, "tiny", "tiny_4anim.x", false);
BrumeAnimationManager.AddAnimationsFromMesh(tinyMesh);
tiny = new BrumeLightedObject(this, "tiny");
tiny.Animation = BrumeAnimationManager.GetAnimation("Wave");
tiny.Mesh = tinyMesh;
tiny.Size = 0.005f;
tiny.Pos.Y = -1.5f;
tiny.Pos.Z = 5.0f;
tiny.Orient(new BrumeVector(0, 1, 0), new BrumeVector(0, 0, 1));
}
static float moveSpeed = 100.0f;
static float factor = 0.01f;
protected override void MoveScene(float fElapsedTime)
{
directionalLight.Update();
// Tiny moves
if (BrumeKeyboard.IsPressed(BrumeKey.UpArrow))
{
if (tiny.Animation == null || tiny.Animation.Name != "Walk")
{
tiny.Animation = BrumeAnimationManager.GetAnimation("Walk");
}
tiny.Orient(new BrumeVector(0, 1, 0), new BrumeVector(0, 0, -1));
tiny.Pos += -tiny.Up * factor; // factor is move speed in this case
}
else if (BrumeKeyboard.IsPressed(BrumeKey.RightArrow))
{
if (tiny.Animation == null || tiny.Animation.Name != "Walk")
{
tiny.Animation = BrumeAnimationManager.GetAnimation("Walk");
}
tiny.Orient(new BrumeVector(0, 1, 0), new BrumeVector(-1, 0, 0));
tiny.Pos += -tiny.Up * factor; // factor is move speed in this case
}
else
{
if (tiny.Animation == null || tiny.Animation.Name != "Wave")
{
tiny.Animation = BrumeAnimationManager.GetAnimation("Wave");
tiny.Orient(new BrumeVector(0, 1, 0), new BrumeVector(0, 0, 1));
}
}
// FPS camera move
BrumeFPSCamera camera = (BrumeFPSCamera)this.ActiveCamera;
if (camera != null && (this.DebugConsole.debugLevel != 2 || BrumeKeyboard.IsPressed(BrumeKey.Space)))
{
camera.FPSOrient((float)MouseDeltaX / (float)2, (float)MouseDeltaY / (float)2);
// 5 - moving
if (MouseDeltaZ > 0.0f)
moveSpeed *= 0.5f;
else
if (MouseDeltaZ < 0.0f)
moveSpeed /= 0.5f;
if (BrumeKeyboard.IsPressed(BrumeKey.W))
camera.FPSMove(camera.Dir * (fElapsedTime / moveSpeed));
if (BrumeKeyboard.IsPressed(BrumeKey.S))
camera.FPSMove(-camera.Dir * (fElapsedTime / moveSpeed));
if (BrumeKeyboard.IsPressed(BrumeKey.D))
camera.FPSMove(camera.Right * (fElapsedTime / moveSpeed));
if (BrumeKeyboard.IsPressed(BrumeKey.A))
camera.FPSMove(-camera.Right * (fElapsedTime / moveSpeed));
}
// moving
base.MoveScene(fElapsedTime);
}
protected override void RenderScene()
{
base.RenderScene();
}
protected override void AfterRendering()
{
base.AfterRendering();
// exit ?
if (BrumeKeyboard.IsPressed(BrumeKey.Escape))
{
this.Close();
return;
}
}
public static void Main()
{
using (Sample game = new Sample())
{
game.Play();
}
}
}
}
Users browsing this forum: No registered users and 0 guests