Throw a noob a bone

Lykaios

04-11-2007 00:43:30

Okay, I've read through the guide a good number of times, and I believe I have a firm grasp of the hierarchy of nxOgre. What I don't have is any idea of the 9 lines of code (I'm sure) which is necessary to make a rendered "box on the floor scene".

I would love anyone who could post just the basic code necessary to render a scene that waits for the escape key to exit. I don't need any OIS code or anything beyond the extreme basics. I can't believe I can't figure this out, I know how to move cameras, check for buffered and unbuffered user input, and all that (everything in the OGRE tutorials) but can't do this.

I don't even care about the inevitable immense flaming I'm sure to receive.

Please help!!

Basic code for rendering a scene with a floor and a box.

Thanks so much,
~Lykaios

Aiursrage2k

04-11-2007 03:48:45

If you searched the forum I sure you would find the answer. Regardless

NxOgre::World* m_world;
NxOgre::Scene* m_scene;
...
m_world = new World();
NxOgre::SceneParams sp;
sp.setToDefault();
sp.time_step_method = NxOgre::SceneParams::CN_VARIABLE;
sp.floor = true;
sp.gravity = NxVec3(0,-9.8,0);

m_scene = m_world->createScene("sceneName",m_sceneManager,sp);
m_scene->createBody("Cube.mesh",new NxOgre::CubeShape(1),Vector3(0,0,0));

Lykaios

04-11-2007 07:42:06

Well, I'm very grateful. I did search the forum but couldn't find a consolidated answer. Most of my results were very specific.

Thanks very much for your help.

~Lykaios

betajaen

04-11-2007 10:26:38

Actually this piece of code is a bit better:

World* mWorld = new World();
Scene* mScene = mWorld->createScene("NameOfScene", "gravity: yes, floor: yes, time-step-method: variable");
mScene->createBody("BodyName;MeshName.mesh", new CubeShape(1), Vector3(0,0.5,0), "mass: 10");


You should also read the short guide.

Lykaios

05-11-2007 05:29:41

Right, that's how I create the body,

is it then just straight ogre code to set up a viewport, camera, and then render?

I know the guide front and back, but unless I'm missing something, there isn't a section on rendering yet. I really hope this doesn't sound impatient or anything, I know you're working very hard and I appreciate it beta, I just can't wait to get my proof-of-concept up and running.

Thanks again,
~Lykaios

CaseyB

05-11-2007 07:19:15

You set up the camera and viewport the same way you would with any other Ogre app, NxOgre takes care of the rendering for you. So if you plug the code that betajaen gave you into an existing Ogre app you should see the cube sitting on the floor.

Lykaios

05-11-2007 07:35:54

Thanks,

I'm trying to work it into a basic Ogre application, and I'm coming up with linker errors directly related to the mWorld->createScene(...)
void createScene(void)
{
World* mWorld = new World();
mSceneMgr = mWorld->getRoot()->createSceneManager(ST_GENERIC);
Scene* mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes, time-step-method: variable");
mScene->createBody("Robot;Robot.mesh", new CubeShape(1), Vector3(0,1,0), "mass: 10");
mSceneMgr->setAmbientLight( ColourValue( 1,1,1 ) );

}


The errors all look similar to this one:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class Ogre::Root * __thiscall NxOgre::World::getRoot(void)" referenced in function "protected: virtual void __thiscall TutorialApplication::createScene(void)"



I'm wondering if the problem isn't just my scene name. I have included everything that I need to include, and the linker knows where the NxOgre libraries are. Any ideas?

Thanks guys,
~Lykaios

betajaen

05-11-2007 09:16:39

Did you just reference the Ogre and NxOgre headers or did you literally copy them into your project?

Lykaios

05-11-2007 22:42:26

I actually added them into the include folder of my project. I think it stems from the way I'm getting root. I'm using the right method for this, right? I could make a new SceneManager using the typical ogre tree method, but I was under the impression that I should use the world->getRoot() instead.

Thanks,
~Lykaios

betajaen

05-11-2007 23:22:11

You don't add any headers from external libraries to your own project, you merley reference them in the project settings.

Remove them, and your linker errors will most probably vanish.

Lykaios

06-11-2007 03:53:03

No, what happened was that I had earlier added the linker, .libs, and include stuff into my Visual Studio default project properties, and had assumed they were in my current project properties.

They weren't, now I feel like a freaking moron.

Good news is it works.

I'm going to learn how to create an NxOgre VS2005 project template, and then make one. Should I send it to you to include into your releases?

Lemme know, and thanks for the help (I know how stupid this all was),

~Lykaios

[edit] I'm having to paste all the .dll's into the debug folder. Is there any way around this? Perhaps a project setting or linker setting or a piece of code? Just wondering.

Lykaios

06-11-2007 05:09:03

virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("Cam1");
mCamera->setPosition(Vector3(0,10,5000));
mCamera->lookAt(Vector3(0,0,0));
}
virtual void createViewports(void)
{
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}
void createScene(void)
{

World* mWorld = new World();
mSceneMgr = mWorld->getRoot()->createSceneManager(ST_GENERIC);
Scene* mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes, time-step-method: variable");
mScene->createBody("Robot;Robot.mesh", new CubeShape(1), Vector3(0,1,0), "mass: 10");
mSceneMgr->setAmbientLight( ColourValue( 0,0,0 ) );
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
Light* mLight = mSceneMgr->createLight("whiteLight");
mLight->setType(Light::LT_POINT);
mLight->setPosition(Vector3(0,50,0));
mLight->setDiffuseColour(.5,.5,.5);
mLight->setSpecularColour(.5,.7,.2);
}


The program compiles and runs just fine. However, there is nothing to see. Just completely blank.

At this point I know I should just stop posting and go bang my head up against a wall or something, but I'm so close I really want this to work.

Thanks again,
~Lykaios

betajaen

06-11-2007 09:17:35

The ambient light is zero, and your 5000 metres away from the Robot.


Have you tried using Cake?