Tutorial # 5 Problems with compile

CK_MACK

20-01-2007 04:10:36

When I attempt to compile tutorial 5, I am getting several errors, which in some ways make sense. But, I am not sure how to solve them exactly.

I get:
The name 'location' does not exist in the current context.
The name 'type' does not exist in the current context.
The name 'group' does not exist in the current context.
The name 'ticks' does not exist in the current context.

I believe the 1st 3 errors come from:

ResourceGroupManager.Singleton.AddResourceLocation(location, type, group); // so I took some guesses:


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

namespace Tutorial05
{
static class Program
{
[STAThread]
static void Main()
{
OgreStartup ogre = new OgreStartup();
ogre.Go();
}
}

class OgreStartup
{
Root mRoot = null;

public void Go()
{
CreateRoot();
DefineResources();
SetupRenderSystem();
CreateRenderWindow();
InitializeResourceGroups();
CreateScene();
StartRenderLoop();
}

void CreateRoot()
{

mRoot = new Root();


ResourceGroupManager.Singleton.AddResourceLocation("C:\\OgreSDK\\bin\\release", "FileSystem", group);
}

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.");

}

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

void InitializeResourceGroups()
{

TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
}

private void CreateScene()
{
SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
Camera cam = mgr.CreateCamera("Camera");
mRoot.AutoCreatedWindow.AddViewport(cam);

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

cam.Position = new Vector3(0, 200, -400);
cam.LookAt(ent.BoundingBox.Center);
// *** throw in a timer so we can end the demo after a short delay
mRoot.FrameEnded += new FrameListener.FrameEndedHandler(FrameEnded);
ticks = Environment.TickCount;
}
bool FrameEnded(FrameEvent evt)
{
if (Environment.TickCount - ticks > 10000)
return false;

return true;
}
void StartRenderLoop()
{
mRoot.StartRendering();
}
}
}


After looking at the code, I can only guess the location and type... resulting in :
ResourceGroupManager.Singleton.AddResourceLocation("C:\\OgreSDK\\bin\\release", "FileSystem", group);

But I am not sure if that is the correct information for the tutorial...
And I don't know what "group" should be, or why I am getting an error with tick.

My preference would be for it to load the mesh as seen in tutorial 4.

Any help would be appreciated.
Thanks,

Marc.

linkerro

20-01-2007 06:39:08

I'm at work right now and don't have a working installation of MOGRE lying around to check, but my guess is that an example on how to do what you're trying to do wold be in the example applications in the ExampleApplication class.

Taking a look at the examples is a good way to learn the diffrences between OGRE and MOGRE. Please take a look at those before posting on the forum and specify you haven't found what you need in them.

Greeting from Romania, Radu.

marc_antoine

20-01-2007 08:02:37

tutorial #5 works just fine with me, wht i did is to copy the non Mogre dll's that are installed at the OGRESDK directory, as i mention in a post when compiling the dll's for ogredotnet, it is import to take the libraries that correspond tot he type of compiling you are doing, by this i mean to take the Release or Debug libraries if you are compiling in debug o Release mode, for me i'm working in Release Mode.

this is a list of the dll's i have in my release dir (the release directory is the realease of the application i'm developing ). and copied from the Release dir of the ogresdk dir.

18/09/2006 05:27 p.m. 1,593,344 CEGUIBase.dll
04/10/2006 08:06 p.m. 299,008 CeguiBindings.dll
04/10/2006 08:06 p.m. 446,464 CeguiDotNet.dll
18/09/2006 05:27 p.m. 188,416 CEGUIFalagardBase.dll
18/09/2006 05:27 p.m. 278,528 CEGUITaharezLook.dll
18/09/2006 05:27 p.m. 311,296 CEGUIWindowsLook.dll
18/09/2006 05:27 p.m. 1,683,456 cg.dll
18/09/2006 05:27 p.m. 761,856 DevIL.dll
18/09/2006 05:27 p.m. 73,728 ILU.dll
18/09/2006 05:27 p.m. 15,872 ILUT.dll
14/01/2007 05:29 p.m. <DIR> media
18/09/2006 05:27 p.m. 323 media.cfg
04/10/2006 08:28 p.m. 32,768 Mogre.Cegui.dll
13/11/2006 01:52 p.m. 6,417,408 Mogre.dll
16/11/2006 07:05 p.m. 57,344 MogreFramework.dll
12/11/2006 03:08 p.m. 147,456 MogreNewt.dll
14/01/2007 03:55 p.m. 409 ogre.cfg
18/01/2007 11:47 p.m. 87,075 Ogre.log
04/10/2006 04:23 a.m. 16,896 OgreBindings_Cegui.dll
12/11/2006 01:31 p.m. 61,440 OgreGUIRenderer.dll
12/11/2006 01:20 p.m. 2,586,112 OgreMain.dll
12/11/2006 01:39 p.m. 372,736 OgrePlatform.dll
18/09/2006 05:27 p.m. 271 Plugins.cfg
12/11/2006 01:29 p.m. 167,936 Plugin_BSPSceneManager.dll
12/11/2006 01:29 p.m. 49,152 Plugin_CgProgramManager.dll
12/11/2006 01:30 p.m. 229,376 Plugin_OctreeSceneManager.dll
12/11/2006 01:31 p.m. 103,424 Plugin_ParticleFX.dll
12/11/2006 01:34 p.m. 1,208,320 RenderSystem_Direct3D9.dll
12/11/2006 01:37 p.m. 512,000 RenderSystem_GL.dll
31/12/2006 12:27 p.m. 695 resources.cfg
18/09/2006 05:27 p.m. 55,808 zlib1.dll


where :

04/10/2006 08:28 p.m. 32,768 Mogre.Cegui.dll
13/11/2006 01:52 p.m. 6,417,408 Mogre.dll
16/11/2006 07:05 p.m. 57,344 MogreFramework.dll
12/11/2006 03:08 p.m. 147,456 MogreNewt.dll


are from the Mogre Release dir.



also check the resources section in your pplication explorer, delete the references to the Mogre dll's nd add them again (remember to add the ones specific for the type of compilation "debug" or "Release")

hope this helps, if you got a solution please post it :) and if this works let me know .

Avictus

20-01-2007 16:04:26


ResourceGroupManager.Singleton.AddResourceLocation(location, type, group);


The above code is just an example of the method call. You're actually using the method a little further down in the code inside the DefineResources method:


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);
}
}
}


You can see in the last line there the AddResourceLocation method being called.

All you need to do is remove the line that says "ResourceGroupManager.Singleton.AddResourceLocation("C:\\OgreSDK\\bin\\release", "FileSystem", group);" The only thing in the CreateRoot() method will be "mRoot = new Root()".

Avictus

20-01-2007 16:12:13

As far as the "ticks" variable goes, you need to declare it inside the OgreStartp class, but outside of any methods.

"ticks" is being assigned to at the end of the CreateScene() method, but you haven't declared it in your code yet. Update your code to be similar to the following:


class OgreStartup
{
Root mRoot = null;
int ticks; // Add this line here

public void Go()

.......
}

CK_MACK

20-01-2007 18:57:38

Thank you for the help.

I definitely appreciate the help with the DLL's because, up until now, I had been using the original project (and the original DLLs that were set up early), and when I created the new project, I did not add the needed DLL's to Debug and Release folders.

The other 2 things that helped were:

class OgreStartup
{
Root mRoot = null;
int ticks; // added this line


and commented out here:
void CreateRoot()
{
mRoot = new Root();
// ResourceGroupManager.Singleton.AddResourceLocation(location, type, group);


I confirmed that the following files were in my debug directory:
Mogre.dll, resources.cfg, media.cfg, plugins.cfg, and ogre.cfg. (I have not used CEGUI so did not add those, and some of the others, tho, perhaps later I will need them too)

The following code compiled:

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

namespace Tutorial05
{
static class Program
{
[STAThread]
static void Main()
{
OgreStartup ogre = new OgreStartup();
ogre.Go();
}
}

class OgreStartup
{
Root mRoot = null;
int ticks;

public void Go()
{
CreateRoot();
DefineResources();
SetupRenderSystem();
CreateRenderWindow();
InitializeResourceGroups();
CreateScene();
StartRenderLoop();
}

void CreateRoot()
{

mRoot = new Root();
// ResourceGroupManager.Singleton.AddResourceLocation(location, type, group);
}

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.");

}

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

void InitializeResourceGroups()
{

TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
}

private void CreateScene()
{
SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
Camera cam = mgr.CreateCamera("Camera");
mRoot.AutoCreatedWindow.AddViewport(cam);

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

cam.Position = new Vector3(0, 200, -400);
cam.LookAt(ent.BoundingBox.Center);
// *** throw in a timer so we can end the demo after a short delay
mRoot.FrameEnded += new FrameListener.FrameEndedHandler(FrameEnded);
ticks = Environment.TickCount;
}
bool FrameEnded(FrameEvent evt)
{
if (Environment.TickCount - ticks > 10000)
return false;

return true;
}
void StartRenderLoop()
{
mRoot.StartRendering();
}
}
}


Thanks, again.