[SOLVED]Error trying to load an scene

mabh

09-03-2009 19:46:23

Hello everybody,
I'm both, new in forums and not very good in English, but I hope you could help me.
I'm trying to load a scene with oFusion (VC++ 2008) but I always obtain the next errors:

1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>OfusionVC2008.cpp
1>f:\ofusionvc2008\ofusionvc2008\include\ofusionvc2008.h(64) : error C2065: 'mInputDevice' : undeclared identifier
1>f:\ofusionvc2008\ofusionvc2008\include\ofusionvc2008.h(64) : error C2227: left of '->isKeyDown' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>f:\ofusionvc2008\ofusionvc2008\include\ofusionvc2008.h(64) : error C2065: 'KC_C' : undeclared identifier

Could you tell me what I am doing bad, please?

This is the code of the .h file:


#include "ExampleApplication.h"

// oScene loader library header file
#include "OgreOSMScene.h"

// Callback handler to post-process created objects
class oSceneCallback : public OSMSceneCallbacks {
public:

// We override the OnCreate method for cameras (See IXMLSceneCallbacks class)
void OnCameraCreate(Ogre::Camera* pCamera, TiXmlElement* pCameraDesc) {

// If a camera of name "FirstCamera" is loaded, it will be set as the default current
if(pCamera->getName() == "FirstCamera")
Ogre::Root::getSingleton().getAutoCreatedWindow()->getViewport(0)->setCamera(pCamera);
}

};


// Event handler to animate
class OfusionVC2008FrameListener : public ExampleFrameListener
{
protected:

SceneManager* mSceneMgr;

public:
OfusionVC2008FrameListener(SceneManager* sceneMgr, RenderWindow* win, Camera* cam)
: mSceneMgr(sceneMgr), ExampleFrameListener(win, cam)
{
}


bool frameStarted(const FrameEvent& evt)
{

static Real timeDelay = 0;
static Real currentTime = 0;

timeDelay -= evt.timeSinceLastFrame;

// We can cycle cameras with the 'c' key
if (mInputDevice->isKeyDown(KC_C) && timeDelay <= 0) {

Camera* firstCam;
Camera* currentCam = mWindow->getViewport(0)->getCamera();

Viewport* vp = mWindow->getViewport(0);

SceneManager::CameraIterator it = mSceneMgr->getCameraIterator();

if(it.hasMoreElements())
firstCam = it.peekNextValue();

while(it.hasMoreElements()) {

Ogre::Camera* cam = it.getNext();

if(currentCam == cam) {
Ogre::Camera* camera = it.hasMoreElements() ? it.getNext() : firstCam;
vp->setCamera(camera);
}
}

timeDelay = 0.5f;

}

// We update all loaded animations each frame
SceneManager::AnimationIterator animationIt = mSceneMgr->getAnimationIterator();

while(animationIt.hasMoreElements()) {
Animation* animation = animationIt.getNext();

const Animation::NodeTrackList& trackList = animation->_getNodeTrackList();

Animation::NodeTrackList::const_iterator it = trackList.begin();
Animation::NodeTrackList::const_iterator iend = trackList.end();

for(; it != iend; ++it) {
const Ogre::NodeAnimationTrack* track = it->second;
track->getAssociatedNode()->resetToInitialState();
}

currentTime += evt.timeSinceLastFrame;
animation->apply(currentTime);
}

// Call default
return ExampleFrameListener::frameStarted(evt);

}
};

class oSceneLibApplication : public ExampleApplication {
public:

oSceneLibApplication() {}

protected:

// Just override the mandatory create scene method
void createScene(void)
{
// Here is the code that will load the scene file
// A fixed filename "scene.osm" is implemented for this demo

// Create the scene loader
OSMScene oScene;

// Create an oE_Loader Callback object to post-process created objects
oSceneCallback oe_Callback;

// Initialises with the scene to be loaded and the callback if requiered
oScene.initialise("Ttris.osm", &oe_Callback);

// create and setup the scene in the root node
oScene.createScene();


mSceneMgr = oScene.getSceneManager();

// Get the list of cameras loaded with the scene
OSMScene::CameraList camList = oScene.getCameraList();

if(!camList.empty()) {

// If loaded with the scene, set the first camera as the default camera
mCamera = camList[0];

// A viewport has been created and assigned to the first camera automatically
// (The TSM needs it to initialize the terrain world geometry)
}
else {

// Create a default camera in case no cameras were saved in the scene

mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,500));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);

// If a viewport was not automatically created, (no cameras saved in the scene)
// create a default viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}

}

// The scene manager will be created by the Scene Loader lib
void chooseSceneManager(void) {}
void createCamera(void) {}
void createViewports(void) {}

// Create new frame listener
void createFrameListener(void)
{
mFrameListener= new OfusionVC2008FrameListener(mSceneMgr, mWindow, mCamera);
mRoot->addFrameListener(mFrameListener);
}

};


Thank you very much

Lioric

10-03-2009 02:24:29

See this thread for the solution to your issue

http://www.ogre3d.org/addonforums/viewtopic.php?f=5&t=7121&p=41647

mabh

10-03-2009 17:54:36

Hello,
Thank you Lioric, I have seen the post an the problem has been solved, but now after the screen of Ogre Engine Rendering Setup, a message like this appears:

Exception not controlled in 0x00000000 in OfusionVC2008.exe: 0xC0000005: Infraction of access on having read the location 0x00000000.

Could you help me please?

Thank you very much.

Lioric

12-03-2009 15:29:56

You need to create your application in Debug mode and post a trace of the application state, or just debug your application stepping on each line to define where the issue is (it seems an unitialized or dangling pointer)

mabh

15-03-2009 18:37:42

Hello,
I have debugged the program step by step and the program fails in the next instruction:

> OfusionVC2008.exe!ExampleApplication::loadResources() Line 248 + 0x19 bytes C++


ResourceGroupManager::getSingleton().initialiseAllResourceGroups();


I have executed the program with direct3D9 as rendering subsistem, and the program worked well.
Could it be an installation problem?

Thank you very much

mabh

30-03-2009 17:24:21

Hello,

I noticed that the problem was either the graphic card drivers or the directx so I have reinstalled both of them and now the problem is solved.

Thank you very much