Facial Animation Demo conversion

Mwr

26-04-2006 23:15:17

I've converted the ogre 1.2 facial animation demo to ogreDotNet (I couldn't see it anywhere so hope no one had already done it). I have it working but hit a couple of problems, the main one being that WindowEventArgs.window.getname() calls (in Cegui event handlers) alway seem to return a "object not set to a instance" error like:

### Exception Object reference not set to an instance of an object.
CeguiDotNet
at CeguiDotNet.CeguiBindingsPINVOKE.String_c_str(HandleRef jarg1)
at CeguiDotNet.String.c_str()
at CeguiDotNet.Window.getName()

So I had to work around that and give each scrollbar its own event handler. The other thing that I had to work around is that CeguiDotnet doesn't seem to support window layout files.

Anyway at the moment I don't have anywhere to upload the code to so I'm going to paste it here (I hope thats okay), incase anyone finds it useful. It still needs tidying up and such, and I haven't added the labels for the scrollbars yet.

Sorry its so long (too long to really post here, I think).

using System;
using System.Drawing;

using OgreDotNet;
using OgreDotNet.Cegui;

using CeguiDotNet;

namespace DemoCEGUI
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///

enum ScrollbarIndex
{
SI_HAPPY = 0,
SI_SAD = 1,
SI_ANGRY = 2,
SI_A = 3,
SI_E = 4,
SI_I = 5,
SI_O = 6,
SI_U = 7,
SI_C = 8,
SI_W = 9,
SI_M = 10,
SI_L = 11,
SI_F = 12,
SI_T = 13,
SI_P = 14,
SI_R = 15,
SI_S = 16,
SI_TH = 17,
SI_COUNT = 18
};
class CEGUIApplication : ExampleApplication
{
protected OgreCEGUIRenderer mGuiRenderer = null;
protected GuiSystem mGuiSystem = null;
protected Window mBackgroundWindow = null;
protected Window mEditorWindow = null;
protected PushButton mQuitButton = null;
protected Editbox mEditbox = null;
protected Log mLog = null;
protected CeguiDotNet.Scrollbar[] scrollbars;
protected Window mEditorGuiSheet=null;
protected CeguiDotNet.RadioButton radio=null;
protected RadioButton radio1=null;
protected AnimationState speakAnimState;
protected AnimationState manualAnimState;
protected VertexPoseKeyFrame manualKeyFrame;

protected string[] scrollbarNames = {
"Facial/Happy_Scroll",
"Facial/Sad_Scroll",
"Facial/Angry_Scroll",
"Facial/A_Scroll",
"Facial/E_Scroll",
"Facial/I_Scroll",
"Facial/O_Scroll",
"Facial/U_Scroll",
"Facial/C_Scroll",
"Facial/W_Scroll",
"Facial/M_Scroll",
"Facial/L_Scroll",
"Facial/F_Scroll",
"Facial/T_Scroll",
"Facial/P_Scroll",
"Facial/R_Scroll",
"Facial/S_Scroll",
"Facial/TH_Scroll",
};

protected ushort[] poseIndexes =
{ 1, 2, 3, 4, 7, 8, 6, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};

protected bool mPlayanimation;

protected override void CreateScene()
{
mLog = LogManager.Singleton.createLog("DemoCEGUI.log", false, true );
mLog.LogMessage("My new Log. Hells yeah!");

base.mSceneManager.AmbientLight = Color.FromArgb(125,125,125,125);
base.mSceneManager.SetSkyDome(true, "Examples/CloudySky", 5, 8);

mGuiRenderer = new OgreCEGUIRenderer( base.mRenderWindow,
(byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY, false, 3000, mSceneManager );
mGuiRenderer.Initialise();
//mGuiSystem = new GuiSystem(mGuiRenderer);
mGuiSystem = GuiSystem.CreateGuiSystemSpecial(mGuiRenderer);

Logger.Instance.setLoggingLevel(LoggingLevel.Insane);

SchemeManager.Instance.LoadScheme("TaharezLook.scheme");
mGuiSystem.SetDefaultMouseCursor("TaharezLook", "MouseArrow");
mGuiSystem.DefaultFontName = "Tahoma-12";


mBackgroundWindow = WindowManager.Instance.CreateWindow("DefaultWindow", "BackgroundWindow");
mGuiSystem.GUISheet = mBackgroundWindow;

mEditorWindow = WindowManager.Instance.CreateWindow("TaharezLook/FrameWindow", "TestWindow");
mBackgroundWindow.AddChildWindow( mEditorWindow );
mEditorWindow.SetSize(0.3f, 0.75f);
mEditorWindow.SetPosition(0.7f, 0.05f);
mEditorWindow.Text = "Facial Demo";
mEditorWindow.SubscribeEvents();

scrollbars=new Scrollbar[18];
create_scrollbars();

radio=WindowManager.Instance.CreateRadioButton("TaharezLook/RadioButton", "Facial/Radio/Play");
radio.setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
radio.SetPosition(60,350);
radio.SetSize(90,40);
radio.SubscribeEvents();
radio.setSelected(true);
radio.enable();
radio.SelectStateChanged+=new CeguiDotNet.WindowEventDelegate(this.radio_changed);
mEditorWindow.AddChildWindow(radio);

radio1=WindowManager.Instance.CreateRadioButton("TaharezLook/RadioButton", "Facial/Radio/Manual");
radio1.setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
radio1.SetPosition(60,375);
radio1.SetSize(90,40);
radio1.SubscribeEvents();
radio1.enable();
mEditorWindow.AddChildWindow(radio1);
mEditorWindow.Show();

Light l= mSceneManager.CreateLight("mainLight");
l.SetPosition(20,80,50);
l.SetDiffuseColour(1,1,1);

l=mSceneManager.CreateLight("mainLight2");
l.SetPosition(-120,-80,-50);
l.SetDiffuseColour(0.7f,0.7f,0.6f);

OgreDotNet.MeshPtr meshptr= MeshManager.Instance.Load("facial.mesh",OgreDotNet.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
Mesh mesh= meshptr.Get();
Animation anim=mesh.createAnimation("manual",0);
VertexAnimationTrack track = anim.CreateVertexTrack(4,OgreDotNet.VertexAnimationType.VAT_POSE);

manualKeyFrame = track.createVertexPoseKeyFrame(0);
// create pose references, initially zero
for (int i = 0; i < 18; ++i)
{
manualKeyFrame.addPoseReference(poseIndexes[i], 0.0f);
}


Entity head= mSceneManager.CreateEntity("Head","facial.mesh");
speakAnimState=head.GetAnimationState("Speak");
speakAnimState.Enabled=true;
manualAnimState=head.GetAnimationState("manual");
//manualAnimState.Enabled=true;
manualAnimState.SetTimePosition(0);

SceneNode headnode=mSceneManager.GetRootSceneNode().CreateChildSceneNode();
headnode.AttachObject(head);
mCamera.SetPosition(-20,50,150);
mCamera.LookAt=new Math3D.Vector3(0,35,0);

mPlayanimation = true;

}

protected bool QuitClicked( WindowEventArgs e )
{
Console.WriteLine("Quit Clicked");
return true;
}

protected bool radio_changed(WindowEventArgs e)
{
mPlayanimation=!mPlayanimation;
speakAnimState.Enabled=mPlayanimation;
manualAnimState.Enabled=!mPlayanimation;
for (int i = 0; i < 18; ++i)
{
// enable / disable scrollbars
scrollbars[i].setEnabled(!mPlayanimation);
}

return true;
}

//**********************************************
// 18 scrollbar event handlers to get around the .getname() error

protected bool Scrollbar( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[0],scrollbars[0].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar1( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[1],scrollbars[1].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar2( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[2],scrollbars[2].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar3( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[3],scrollbars[3].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar4( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[4],scrollbars[4].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar5( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[5],scrollbars[5].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar6( WindowEventArgs e )
{

manualKeyFrame.updatePoseReference(poseIndexes[6],scrollbars[6].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar7( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[7],scrollbars[7].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar8( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[8],scrollbars[8].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar9( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[9],scrollbars[9].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar10( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[10],scrollbars[10].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar11( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[11],scrollbars[11].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar12( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[12],scrollbars[12].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar13( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[13],scrollbars[13].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar14( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[14],scrollbars[14].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar15( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[15],scrollbars[15].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar16( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[16],scrollbars[16].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}
protected bool Scrollbar17( WindowEventArgs e )
{
manualKeyFrame.updatePoseReference(poseIndexes[17],scrollbars[17].getScrollPosition());
manualAnimState.getParent()._notifyDirty();
return true;
}


//**************************************************
protected override bool FrameStarted( FrameEvent e )
{
speakAnimState.AddTime(e.TimeSinceLastFrame);
base.FrameStarted(e);
return true;
}

protected override void KeyClicked( KeyEvent e )
{
base.KeyClicked( e );

switch (e.KeyCode)
{
case KeyCode.P:
mRenderWindow.WriteContentsToFile("CeguiNet.png");
break;
}
}

protected override void KeyPressed(KeyEvent e)
{
//mLog.LogMessage("KeyPressed KeyCode = " + (uint)e.KeyCode + " isReadonly=" + mEditbox.isReadOnly() );
GuiSystem.Instance.injectKeyDown( (UInt32)e.KeyCode );
GuiSystem.Instance.injectChar( (UInt32)e.KeyChar );

base.KeyPressed (e);
}

protected override void KeyReleased( KeyEvent e )
{
//mLog.LogMessage("KeyReleased KeyCode = " + (uint)e.KeyCode );
GuiSystem.Instance.injectKeyUp( (uint)e.KeyCode );

base.KeyReleased(e);
}


protected override void MousePressed(MouseEvent e)
{
switch( e.ButtonID )
{
case 16:
GuiSystem.Instance.InjectMouseButtonDown( MouseButton.Left );
break;
case 32:
GuiSystem.Instance.InjectMouseButtonDown( MouseButton.Right );
break;
}
}

protected override void MouseReleased(MouseEvent e)
{
switch( e.ButtonID )
{
case 16:
GuiSystem.Instance.InjectMouseButtonUp( MouseButton.Left );
break;
case 32:
GuiSystem.Instance.InjectMouseButtonUp( MouseButton.Right );
break;
}
}


protected override void MouseMotion(MouseMotionEvent e)
{
GuiSystem.Instance.InjectMouseMove(e.DeltaX*mRenderWindow.Width,
e.DeltaY*mRenderWindow.Height);
}

protected override void MouseDragged(MouseMotionEvent e)
{
this.MouseMotion( e );
}

public void create_scrollbars()
{

//needed to get around lack of support for layout files
int counter=0;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/Happy_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,75);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/Sad_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,90);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar1);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/Angry_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,105);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar2);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/A_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,120);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar3);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/E_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,135);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar4);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/I_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,150);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar5);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/O_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,165);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar6);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/U_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,180);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar7);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/C_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,195);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar8);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/W_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,210);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar9);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/M_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,225);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar10);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/L_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,240);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar11);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/F_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,255);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar12);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/T_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,270);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar13);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/P_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,285);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar14);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/R_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,300);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar15);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/S_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,315);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar16);
counter++;

scrollbars[counter]=WindowManager.Instance.CreateScrollbar("TaharezLook/HorizontalScrollbar","Facial/TH_Scroll");
scrollbars[counter].setMetricsMode(CeguiDotNet.MetricsMode.Absolute);
scrollbars[counter].SetPosition(60,330);
scrollbars[counter].SetSize(120,10);
scrollbars[counter].setDocumentSize(1.1f);
scrollbars[counter].setPageSize(0.1f);
scrollbars[counter].setStepSize(0.05f);
scrollbars[counter].setOverlapSize(0.05f);
mEditorWindow.AddChildWindow(scrollbars[counter]);
scrollbars[counter].SubscribeEvents();
scrollbars[counter].ScrollPositionChanged+=new CeguiDotNet.WindowEventDelegate(this.Scrollbar17);
counter++;

for (int i = 0; i < 18; ++i)
{
// disable scrollbars
scrollbars[i].setEnabled(false);
}

}
public override void Dispose()
{
WindowManager.Instance.destroyAllWindows();
mGuiSystem.Dispose();
mGuiRenderer.Dispose();
base.Dispose();
}

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
CEGUIApplication app = new CEGUIApplication();
try
{
app.Start();
}
catch ( Exception ex)
{
Console.WriteLine( "### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
finally
{
try
{
app.Dispose();
}
catch ( Exception ex)
{
Console.WriteLine( "### Exception {0}\n{1}\n{2}", ex.Message ,ex.Source , ex.StackTrace );
}
}
}
}
}

DigitalCyborg

27-04-2006 00:09:06

good job!

we need to start another page in the ODN wiki for converted code like this.

Mwr

29-04-2006 10:33:55

I've been trying to change this so that a user can type in a sentence and then the animation will be lip synched to that sentence. Its a feature I want to add to my game (that the animations are dynamically created to match what the character is saying) so I was trying it out on this demo first.

However I've hit a few problems, these are really ogre problems rather than OgreDotNet but as I've posted in the main Ogre forums and had no replies (http://www.ogre3d.org/phpBB2/viewtopic.php?t=19863), I though I would just check if anyone here has any ideas.

What I originally wanted to do was for each character, a place holder speech animation is created on its mesh (like the manual animation in this demo) and then whenever that character was to say something, I would change the length of the animation and the time positions of the keyframes (as well as the pose references). However the length of a animation and the time of a keyframe are read only so that idea didn't work.

Next I decided that I would have to delete the old animation and then create a new one with the same name (every time the character wanted to talk) and then add new keyframes to that animation. This works except for one problem, the AnimationStates on the entity are still the same length as the original place holder animation.

Now I thought that Entity.refreshAvailableAnimationState() would update these, but it doesn't. That only updates animationstates from animations attached to the skeleton, not vertex animations (morph/pose) that are stored directly in the mesh.

So I have been trying to find out if there is either another way of doing what I want to do (I don't want to create an animation at startup for every setence that the character can say as this doesn't fit in with my requirements). Or if anyone knows if I change the core Entity.refreshAvailableAnimationState() to also update about vertex animations if that will cause problems.

Like I said I know these are Ogre things not OgreDotNet, but as I posted about it in " Using OGRE in practice" forum a couple of days ago and haven't had any replies, I don't know if there is something simple I'm missing or if no one just knows the answer.

At the moment I have a work around, in that I make the original placeholder animation longer than I think any needed animations will be and then once I create a new one I store the length of it and only play the new animation for that stored length (not the length of the AnimationState, which is still the same length as the original animation), but this still isn't ideal.