Tutorial 5 Error


12-06-2008 04:41:33

I set up Tutorial 5 and added terrain to it. It works when I don't call the Terrain but, it shows up a Runtime Error when I do.

Here is the full code (I know it probably is not important but, I have no idea what could cause this. I am thinking the SceneManager is causing it):

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Mogre;
using System.Drawing;

namespace Tutorial05
static class Program
static void Main()
OgreStartup ogre = new OgreStartup();

class OgreStartup
Root mRoot = null;
float ticks = 0;

public void Go()

void CreateRoot()
mRoot = new Root();

void DefineResources()
ConfigFile cf = new ConfigFile();
cf.Load("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);

void SetupRenderSystem()
if (!mRoot.ShowConfigDialog())
throw new Exception("The user canceled the configuration dialog.");

//// Setting up the RenderSystem manually.
//RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
//mRoot.RenderSystem = rs;
//rs.SetConfigOption("Full Screen", "No");
//rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

void CreateRenderWindow()
mRoot.Initialise(true, "Main Ogre Window");

//// Embedding ogre in a windows hWnd. The "handle" variable holds the hWnd.
//NameValuePairList misc = new NameValuePairList();
//misc["externalWindowHandle"] = handle.ToString();
//mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

void InitResources()
TextureManager.Singleton.DefaultNumMipmaps = 5;

void CreateScene()
SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
SceneManager mgr2 = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE);
Camera cam = mgr.CreateCamera("Camera");

Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");

cam.Position = new Vector3(0, 200, -400);

mRoot.FrameEnded += new FrameListener.FrameEndedHandler(FrameEnded);
ticks = Environment.TickCount;

void StartRenderLoop()

//// Alternate Rendering Loop
//while (mRoot.RenderOneFrame())
// // Do other things here, such as sleep for a short period of time

bool FrameEnded(FrameEvent evt)
if (Environment.TickCount - ticks > 5000)
return false;

return true;


12-06-2008 11:00:17

Er, Does it give an error message? If so it would be useful to know what it is.
Also have a look in the Ogre.log file and see what the reported error is.

The most likely problem is that Mogre can't find the terrain.cfg file. Have a look in your resources.cfg file. There should be a path to a folder containing the sample terrain.cfg file. If there isn't Mogre won't find it.

There's also a small chance that your graphics card can't handle the terrain texture but my feeling is that the default terrain is pretty basic.

Like I said, if you can tell us what the error message is we can have a better stab at diagnosing the problem