[Solved] First Bleeding project from scratch without ...

toglia

16-05-2008 08:12:23

Well, I thought it was time to make my very first NxOgre project from scratch (helped by nullsquared shadow demo code) and decided to go with Bleeding. I had used Cake as framework for a couple months and although I did some cool stuff I really didn't understand much of the technical issues, (still don't, but I will someday :D)

Right now I have my project entirely rigged so that I can use NxOgre's include and libs files, copied PhysX files beside my executable, and some other stuff needed too. After all that I could compile and run a new World and Scene code perfectly, the problem came with bodies...

To the point! when I add a body I get a crash here:
NxOgreSceneRenderer.cpp
void SceneRenderer::render(const TimeStep& ts) {
if (ts.Delta > 0)
HERE -> mSources.Each<const TimeStep&>(&RenderableSource::render, ts);
}


I hope this code could help, its the simple framework I'm trying to use.
(I removed all nullsquared comments just to make the code smaller)


#include <Ogre.h>
#include <OIS/OIS.h>
#include <ctime>
#include "NxOgre.h"
using namespace std;
using namespace Ogre;
using namespace NxOgre;

struct Mgr: public Ogre::WindowEventListener { Variables } mgr;
void initRenderer() {}
void stopRenderer() {}
void initResources() {}
void initInput() {}
void stopInput() {}
void captureInput() {}

void initPhysics() {
mgr.mWorld = new World("time-controller: ogre");
mgr.mScene = mgr.mWorld->createScene("myScene", "gravity: yes, floor: yes");
}

void stopPhysics() {
delete mgr.mWorld;
}


void setupScene() {

mgr.mScene->createBody("player", new NxOgre::Sphere(1), Vector3(0,20,0), "model: esfera320.mesh", "mass: 1");

}

void handleScene(float dt) {}


#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{

initRenderer();
initResources();

initPhysics();

initInput();
setupScene();

float currentTime = float(mgr.timer->getMilliseconds()) * 0.001;

for (bool running = true; running; running = running && mgr.running) {

Ogre::WindowEventUtilities::messagePump();

float deltaTime = (float(mgr.timer->getMilliseconds()) * 0.001) - currentTime;
currentTime += deltaTime;

captureInput();

if (mgr.keys->isKeyDown(OIS::KC_ESCAPE))
running = false;


handleScene(deltaTime);

running = running && mgr.root->renderOneFrame();

}
stopInput();
stopPhysics();
stopRenderer();

}


Full working code here: http://toglia.com.ve/code/mainNxOgre.cpp

What do you guys think? Is it possible to use Nxogre with a custom render frame loop?

Thanks!

betajaen

16-05-2008 11:24:42

No, it's all fine. Except for one thing:

mgr.mScene = mgr.mWorld->createScene("myScene", "gravity: yes, floor: yes, renderer: ogre");

toglia

16-05-2008 15:57:54

Ooops... :shock: I had read that on the short guide, thought I was using it! :oops:

Thanks Betajaen! as always right on the spot.

So happy that I have moved to Bleeding now :D

betajaen

16-05-2008 16:25:07

No problem.