Error on Create Scene [Surrender]

marceloharmonia

01-07-2009 19:38:37

hello, I have the NxOgre 1.0. I compiled and tried use this with my project, but I receive a error mensage in the line:
mScene = mWorld->createScene("NxOgreScene", mSceneMgr, "gravity: yes, floor: yes, renderer: ogre");
I don't know what is a problem.... The error mensage is:
Unhandled exception at 0x0022b161 (NxOgre.dll) in OgreTest.exe: 0xC0000005: Access violation reading location 0x00000000.

Please, help me!
Cpp code:
#include "appboot.h"

AppBoot::AppBoot() //Construct, limpa os ponteiros para evitar que retomem um valor da memória
{
mOgre = 0;
mSceneMgr = 0;
mViewport = 0;
mCamera = 0;
overlay = new SimpleOverlay();
}

AppBoot::~AppBoot() //Destruct, finaliza o programa antes de fechar
{
delete mWorld;
delete overlay;
if(mOgre) delete mOgre;
}

bool AppBoot::boot() //foi definida como função bool(boolean) para retornar um valor entre true e false
{
mOgre = new Ogre::Root("plugin.ini","config.ini","log.txt");
mOgre->restoreConfig();
if(!mOgre->showConfigDialog()) //Se clicou em cancelar
return false; //retorna falso e fecha a engine se não
mOgre->initialise(true, "Teste no Ogre3D");
mSceneMgr = mOgre->createSceneManager(Ogre::ST_GENERIC, "DefaultSceneManager"); //Cria o Scene Manager
mCamera = mSceneMgr->createCamera("MainCamera"); //Cria uma câmera
window = mOgre->getAutoCreatedWindow(); //Pega a janela criada pelo ogre e joga no ponteiro de janelas window
mViewport = window->addViewport(mCamera); //Adciona a camera à janela e cria um viewport
mCamera->setNearClipDistance(5); //Modifica o valor da área onde o 3D corta os objetos que ficam muito próximos a câmera
mCamera->setAspectRatio((Ogre::Real)1.333333); //Muda o Aspecto da câmera
mViewport->setBackgroundColour(Ogre::ColourValue(1,1,1));//Muda a cor de fundo da tela... Obs: para tranformar RGB para float é só por corRGB/255.0f

size_t hWnd = 0; // Identificação da janela
window->getCustomAttribute("WINDOW", &hWnd); // pega a identificação da janela que o ogre criou
mInputManager = OIS::InputManager::createInputSystem(hWnd); // e passa para o OIS criar o sistema de input nela
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, false)); // cria o objeto responsável por ler os comandos do mouse
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false)); // cria o objeto responsável por ler os comandos do teclado
//unsigned int width, height, depth; // variáveis para guardar o tamanho da janela para passar para o OIS
//int top, left; // posição da janela na tela
//window->getMetrics(width, height, depth, left, top); // pega o tamanho e posição da tela
//const OIS::MouseState &ms = mMouse->getMouseState(); // retorna o estado atual do mouse
//ms.width = width; //coloca o estado atual do mouse para que a área onde ele responda ao jogo seja a mesma da tela
//ms.height = height; //idem

CreateScene(); //chama a função pra cria a cena
return true; //Retorna true para informar que o ogre foi inicializado
}

void AppBoot::run() //função main (principal)
{
bool running = true; // cria uma boolean e diz que é true (1)

while(running) //laço principal, enquanto running for verdadeira, repete
{
Ogre::ControllerValueRealPtr tmpFTV = Ogre::ControllerManager::getSingleton().getFrameTimeSource(); // pega um ponteiro para o timer do ogre
mFrameTime = tmpFTV->getValue(); // retorna o valor de tempo da ultma frame
Ogre::WindowEventUtilities::messagePump(); //atualiza a tela
mKeyboard->capture(); // comando para o OIS ler o teclado para ver as teclas sendo apertadas
mMouse->capture(); // idem com o mouse
Update(mFrameTime); //chama a função update
mOgre->renderOneFrame(); //rendeniza um quadro
if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) // se o botão do teclado (Esc) estiver apertado
running = false; // coloca running como false para fechar o jogo
}
}

void AppBoot::CreateScene()
{
Ogre::ResourceGroupManager* resourceGroup = Ogre::ResourceGroupManager::getSingletonPtr(); //Reserva um poteiro pro resource manager
resourceGroup->addResourceLocation("data", "FileSystem", "General"); //Define a pasta e seus arquivos ao resource
resourceGroup->addResourceLocation("data/cubemapsJS.zip", "Zip", "General"); //Idem
resourceGroup->initialiseResourceGroup("General"); // Inicializa o resource group, procura todos os arquivos dentro das pastas

overlay->setupOverlay();
overlay->createFont("ArbekaFont","arbeka.ttf");
Text1 = overlay->createText("FPS:","ArbekaFont",26/600.0f,10/800.0f,10/600.0f);

mWorld = new NxOgre::World("use-log: yes, time-controller: ogre");
mScene = mWorld->createScene("NxOgreScene", mSceneMgr, "gravity: yes, floor: yes, renderer: ogre");

mSceneMgr->setSkyBox(true,"Examples/MorningSkyBox"); //Define um SkyBox
mCamera->setPosition(0.0f,0.0f,500.0f); //Muda a posição da camera
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

mPlayer = mSceneMgr->createEntity("Robot","robot.mesh"); //Cria uma entidade
mPlayer->setCastShadows(true);
mPlayerNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("roboNode");
mPlayerNode->attachObject(mPlayer);
}

void AppBoot::Update(float time)
{
const Ogre::RenderTarget::FrameStats& stats = window->getStatistics();
overlay->editText(Text1,"FPS: "+Ogre::StringConverter::toString(stats.lastFPS));
}


and Header code:
#include <Ogre.h>
#include <OIS\OIS.h>
#include "stdafx.h"
#include "SimpleOverlay.h"
#include <NxOgre.h>

class AppBoot
{
public:
AppBoot();
~AppBoot();

bool boot();
void run();

private:
void CreateScene();
void Update(float time);

Ogre::Root* mOgre;
Ogre::RenderWindow* window;
Ogre::SceneManager* mSceneMgr;
Ogre::Camera* mCamera;
Ogre::Viewport* mViewport;
Ogre::Entity* mPlayer;
Ogre::SceneNode* mPlayerNode;

OIS::InputManager * mInputManager;
OIS::Keyboard * mKeyboard;
OIS::Mouse * mMouse;

float mFrameTime;

int Text1;

SimpleOverlay* overlay;

NxOgre::World* mWorld;
NxOgre::Scene* mScene;
NxOgre::Body* roboBody;
NxOgre::Actor* cuboActor;
NxOgre::ActorGroup* primGrupo;
NxOgre::ActorGroup* segGrupo;
};

betajaen

01-07-2009 20:23:39

You have a null pointer somewhere. Your NxOgre seems to be fine. Can you trace the error to the offending line?

marceloharmonia

01-07-2009 22:20:10

The error is in the archive "NxOgreScene.cpp" on the line mScene = mOwner->getSDK()->createScene(mDescription);
And occur when I try create a Scene. Sorry I don't undestand what you can say with this: "Can you trace the error to the offending line?". How i can do this?

Sorry my gramaticals erros, I don't know speak english very much. Oh, if you have a Messenger add me in this, my e-mail is marcelo_liliu@hotmail.com

Trank you!

spacegaier

01-07-2009 22:54:00

"Can you trace the error to the offending line?". How i can do this?
Via debugging. Set a breakpoint somewhere in your code at a place of which you definetly know that there isn't a problem so far. Then the programm will stop there and then you can go line by line through your code and so find out in which line of your code the crash occurs.

marceloharmonia

01-07-2009 23:22:14

Tranks spacegaier, I have discovered the offending line:
mScene = mOwner->getSDK()->createScene(mDescription);
On the archive "NxOgreScene.cpp" of NxOgre SDK.
Please, someone know solve this? I Need correct this error the fastest possible.
Trank you for attention!

betajaen

01-07-2009 23:26:01

The reason why NxOgre is crashing is due to a null-pointer exception (Your computer is using a function to a pointer that does not exist).

In all probability it is your code. I would double check all major classes; Root, SceneManager exist and are passed correctly into NxOgre. I had a quick look though, it seems fine. But I think a bit of debugging of your code is in order.

Also; Just to eliminate things - what does the NxOgre log say?

marceloharmonia

02-07-2009 00:03:49

Hum... Ok, I checked my project and don't have null-pointer. Also when I comment the line taht create a Scene the program don't return a error, I have said before that problem is in this line: mScene = mOwner->getSDK()->createScene(mDescription); of "NxOgreScene.cpp".
In debug mode i checked that "Autos Window" show the values of the arguments of a line code... So in the line mScene = mOwner->getSDK()->createScene(mDescription); We have theses values:

And 2 are: 0x00000000 or Null. This do me think that error is in this line, i don't know if I have pass invalids arguments for createScene function, but the problem is on Scene Class. I'm crazy with this problem and can't correct it.
Please help me to find a solution.
Trank you.

PS: Oh, Can you send me a example of ogre aplication using NxOgre?

betajaen

02-07-2009 00:44:19

Right, it isn't your program. Apologies to say it was.

I can tell from there that the Scene description is invalid which is causing the Scene not to be created and possibly the PhysX SDK wasn't started. Can you post a copy of the NxOgre log for me. It will be a file in the same directory as your application.

marceloharmonia

02-07-2009 00:56:29

lol, the log of nxOgre is empty and the log of Ogre go only to a function of a before line of creation of NxOgre World...
And Now?

Edit: If the PhysX SDK not initialized which had an error occurs in creating the world, had not?

Edit2: The problem isn't on my project, I downloaded the source code of this tutorials http://www.ogre3d.org/wiki/index.php/NxOgre_Tutorial_Simple_Sample and compile, but occur the same mistake.

spacegaier

02-07-2009 20:09:54

So, why don't switch to NxOgre 1.5.5 (BloodyMess)?