What do I need?

Prophet

17-08-2008 11:56:09

Okay, I'm taking a crash course into 3d-programming and I've arrived to NxOgre. Now, it's quite new so I understand this, but there is quite a lack of code (or I've been blind).
Generally I try my way forward, but now I have no idea what I need. So, basically, what classes do I need to use to be able to add objects into a scene and having them colliding with each other?
And does NxOgre render the objects for you, or do you have to retrieve them from the scene/world and render them manually?

Thanks in advance!
Oh, and if there is any place that has some NxOgre-specific code, please tell me! (Except the NxOgre site, which is lovely, but a bit lacking)

nargil

17-08-2008 13:43:25

basicly you need

NxOgre::World
NxOgre::Scene

If you use the ->createBody method of Scene then nxOgre will load and render the entity for you. If you use ->createActor then nothing will be rendered

Prophet

17-08-2008 14:15:34

Ah. But how does NxOgre knows how and when to render? Doesn't it need all that extra stuff with viewports and so?

betajaen

17-08-2008 15:15:49

No, Ogre does all of that. Ogre does all the rendering, NxOgre sits alongside of it and some-times hints at Ogre these things need to be rendered.

Prophet

17-08-2008 16:13:33

Ah. So if I add this code
mWorld = new NxOgre::World("log: yes, time-controller: ogre");
mScene = mWorld->createScene("gravity: yes, floor: yes");
mScene->createBody(NxOgre::VisualIdentifier(), new NxOgre::Cube (1.0f), Vector3(0, 50, 0), "mass 10"); //I have no idea what the VisualIdentifier does by the way

and I'll have a cube that's rendered and physicsed (what ever)? That seems waaaay too easy.
And while betajaen's reading; your website is the nicest looking site I've ever seen. Been in love with it since I first saw it.

Blitzprog

17-08-2008 16:24:19

Yes, that's the way it works :)

Instead of
NxOgre::VisualIdentifier()
you should insert the name of your mesh, e.g.
"cube.1m.mesh"
You can also have a look at these sites:
http://translate.google.de/translate?u= ... e&ie=UTF-8
http://blitzprog.de/doc/nxogre/namespace_nx_ogre.html
http://www.ogre3d.org/phpBB2addons/view ... hp?p=30039 (Python)

mcaden

17-08-2008 17:55:29

I found http://www.nxogre.org/shortguide to be quite helpful, even though it's unfinished.

http://ogre.irados.org/textos/bibliotecas/NxParte1.htm is also quite helpful, although it's in Portuguese.

Prophet

17-08-2008 20:23:40

Yes, the short guide is helpful (and amusing), but as you said, incomplete.
Hm, I followed Blitzprog's links, which were kinda helpful, but even though I followed the tutorial (as best as I could), it crashes when rendering. Using this code:
//Definitions
NxOgre::World *mWorld;
NxOgre::Scene *mScene;
NxOgre::Body *boxB;
NxOgre::Actor *boxA;
NxOgre::ActorGroup *primGroup;
NxOgre::ActorGroup *secGroup;

//Init
mWorld = new NxOgre::World ( "log: yes, time-controller: ogre");
mScene = mWorld->createScene ( "main", "controller: accumulator, gravity: yes, floor: yes");
NxOgre::NodeRenderableParams Nxvp;
Nxvp.setToDefault ();
Nxvp.mIdentifier = "BoxN";
Nxvp.mIdentifierUsage = Nxvp.IU_Create;
Nxvp.mGraphicsModel = "Box01.mesh";
Nxvp.mGraphicsModelScale = NxVec3 (1, 1, 1);
Nxvp. mGraphicsModelMaterial = "Examples / CloudySky";
boxA = mScene->createBody (Nxvp.mIdentifier, new NxOgre::Cube (100), Vector3 (0, 50, 0), Nxvp, "mass: 10");

I don't get any error message from either Ogre (except old mesh, does that make a difference?) or NxOgre. I did however add a log when my frame listener was called and it appears that it renders a few frames (with my last code; 8, new code; 1) then crashes. I get the "Send Error Report" that we've all learned to love. What am I doing wrong?

betajaen

17-08-2008 20:41:20

Try it this way:

//Definitions
NxOgre::World *mWorld;
NxOgre::Scene *mScene;
NxOgre::Body *boxB;
NxOgre::Actor *boxA;

//Init
mWorld = new NxOgre::World ( "log: yes, time-controller: ogre");
mScene = mWorld->createScene ( "main", "controller: accumulator, gravity: yes, floor: yes");
boxA = mScene->createBody ("Box01.mesh", new NxOgre::Cube (100), Vector3 (0, 250, 0), "mass: 10");

Prophet

17-08-2008 20:56:08

Hm, sure tidied up the code, but it still crashes. Any idea why?

mcaden

17-08-2008 21:34:03

I assume you have a "Box01.mesh" where ogre can find it?

Prophet

17-08-2008 21:37:01

Yes. Further down in my code I have Ogre creating the box and this box I can see. To be extra sure, I've added a skydome and temporarily hidden the box (created by Ogre) so that I can clearly see that there is no box rendered by NxOgre. I just can't find what's wrong!

betajaen

17-08-2008 21:41:19

Are you sure the Camera isn't inside the box, the Ogre meshes are pretty huge in real-world scale.

Have you tried Cake?

mcaden

17-08-2008 22:47:48

debug it, find which line it's crashing on.

Prophet

18-08-2008 13:36:38

It's not inside the camera (or vice versa). Is it very important to run the "Place me in your Ogre directory and run.WindowsOnly.bat"? Because when I run it, it says "Can't find file..." (it just flashes really quickly).
And I haven't tried Cake, since I can't actually find it.

Edit:It crashes at line 101 in nxogrerenderablesource.cpp. The code as follows:
void RenderableSource::render_Absolute(const TimeStep& ts) {
mRenderPose = getSourcePose(ts);
mRenderable->setPose(mRenderPose); //<- CRASH
}

It works fine with mScene->createActor(), but not with createBody().
(Cleaned the post)