XainFaith
07-06-2010 01:25:26
Hi there i am currently making a map Editor using MOgre for my rendering and translation window, Problem is that it is not displaying objects.
I have a Windows Form timer set to call a DoRender Function every 16 milliseconds witch translates to roughly 60 fps if not just abit more.
The RenderOnFrame Function returns a value of true so it appears to be rendering. I have tested the mesh as its from the game Engine and its a simple
Textured Cube Exported From Blender with a Texture and it displays fine and with the texture in the Game Engine.
No Errors are thrown from Ogre and it all seems to be setup fine the form code i will post below is an MDI child for the editor app however i am currently testing it bolth as the mdi child and by itself.
Yep no entirly sure what is going on but ill take even a guess at this point. Thanks for any help.
Regards XainFaith.
EDIT:
SOLVED refer to below
Well thats embarssing... it turns out i forgot to set the near plane clipping... I had prevously wrote the code but my compiler crashed and i lost all the files. Turns out i was under the impression that the line of code was in there when it was not.
Sorry for the bother. Thanks Everyone
I have a Windows Form timer set to call a DoRender Function every 16 milliseconds witch translates to roughly 60 fps if not just abit more.
The RenderOnFrame Function returns a value of true so it appears to be rendering. I have tested the mesh as its from the game Engine and its a simple
Textured Cube Exported From Blender with a Texture and it displays fine and with the texture in the Game Engine.
No Errors are thrown from Ogre and it all seems to be setup fine the form code i will post below is an MDI child for the editor app however i am currently testing it bolth as the mdi child and by itself.
public partial class MOgreForm : Form
{
#region Private Vars
Root mRoot = null;
RenderWindow mRenderWindow = null;
Camera mCam = null;
SceneManager mSceneManager = null;
protected MOIS.InputManager inputManager;
protected MOIS.Keyboard inputKeyboard;
//Render Timer
System.Windows.Forms.Timer mRenderTimer = null;
#endregion
#region Public Vars
#endregion
#region Public Methods
public MOgreForm()
{
InitializeComponent();
}
public void StartUp(string ProjectFolder)
{
try
{
// Create root object
this.mRoot = new Root();
// Define Resources
ConfigFile cf = new ConfigFile();
cf.Load(ProjectFolder += "resources.cfg", "\t:=", true);
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
// Setup RenderSystem
RenderSystem rs = this.mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
this.mRoot.RenderSystem = rs;
rs.SetConfigOption("Full Screen", "No");
rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
// Create Render Window
this.mRoot.Initialise(false, "Main Ogre Window");
NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = Handle.ToString();
this.mRenderWindow = this.mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);
// Init resources
TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
// Create a Simple Scene
this.mSceneManager = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
this.mCam = this.mSceneManager.CreateCamera("Camera");
this.mCam.AutoAspectRatio = true;
this.mRenderWindow.AddViewport(this.mCam);
this.mCam.Position = new Mogre.Vector3(0, 0, -40);
this.mRenderTimer = new System.Windows.Forms.Timer();
this.mRenderTimer.Interval = 16;
this.mRenderTimer.Enabled = true;
this.mRenderTimer.Start();
this.mRenderTimer.Tick += new EventHandler(mRenderTimer_Tick);
//Setup our few events handles
this.Disposed += new EventHandler(MOgreForm_Disposed);
this.Move += new EventHandler(MOgreForm_Move);
//Add an object to test the render
Entity ent = this.mSceneManager.CreateEntity("ninja", "Cube.mesh");
this.mSceneManager.RootSceneNode.CreateChildSceneNode("Test", new Mogre.Vector3(0, 0, 0)).AttachObject(ent);
this.mCam.LookAt(ent.BoundingBox.Center);
MOIS.ParamList pl = new MOIS.ParamList();
IntPtr windowHnd;
pl.Insert("WINDOW", this.Handle.ToString());
inputManager = MOIS.InputManager.CreateInputSystem(pl);
// Create all devices (except joystick, as most people have Keyboard/Mouse) using unbuffered input.
inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
}
catch (System.Runtime.InteropServices.SEHException)
{
if (OgreException.IsThrown)
MessageBox.Show(OgreException.LastException.FullDescription,
"An Ogre exception has occurred!");
else
throw;
}
return;
}
#endregion
#region Private Methods
private void MOgreForm_Move(object sender, EventArgs e)
{
this.mRenderWindow.WindowMovedOrResized();
}
private void MOgreForm_Disposed(object sender, EventArgs e)
{
if (this.mRoot != null)
{
this.mRoot.Dispose();
this.mRoot = null;
}
if (this.mRenderWindow != null)
{
this.mRenderWindow.Dispose();
this.mRenderWindow = null;
}
if (this.mRenderTimer != null)
{
this.mRenderTimer.Dispose();
this.mRenderTimer = null;
}
if (this.mCam != null)
{
this.mCam.Dispose();
this.mCam = null;
}
}
private void mRenderTimer_Tick(object sender, EventArgs e)
{
this.DoRender();
}
private void DoRender()
{
if (this.mRoot != null)
{
// Capture all key presses since last check.
inputKeyboard.Capture();
if (inputKeyboard.IsKeyDown(KeyCode.KC_UP))
{
this.mCam.MoveRelative(new Mogre.Vector3(0, 0, -0.1f));
}
if (inputKeyboard.IsKeyDown(KeyCode.KC_DOWN))
{
this.mCam.MoveRelative(new Mogre.Vector3(0, 0, 0.1f));
}
if (inputKeyboard.IsKeyDown(KeyCode.KC_RIGHT))
{
this.mCam.MoveRelative(new Mogre.Vector3(0.1f, 0, 0));
}
if (inputKeyboard.IsKeyDown(KeyCode.KC_LEFT))
{
this.mCam.MoveRelative(new Mogre.Vector3(-0.1f, 0, 0));
}
bool Temp = this.mRoot.RenderOneFrame();
}
}
#endregion
}
Yep no entirly sure what is going on but ill take even a guess at this point. Thanks for any help.
Regards XainFaith.
EDIT:
SOLVED refer to below
Well thats embarssing... it turns out i forgot to set the near plane clipping... I had prevously wrote the code but my compiler crashed and i lost all the files. Turns out i was under the impression that the line of code was in there when it was not.
Sorry for the bother. Thanks Everyone