Using Demo01 in a non-"Example" project SceneNode

neomxl

04-12-2007 20:11:34

Hello.

I am trying to work Demo1 ino my project, but it doesn't include the example header files.

It compiles, but when I press the Spacebar it doesn't fire anything. I have done some debugging and in the demo:

OgreNewtFrameListener.cpp
if (mKeyboard->isKeyDown(OIS::KC_SPACE))
{
if (timer <= 0.0)
{
Ogre::Vector3 dir, vec;
Ogre::Quaternion camorient = msnCam->getWorldOrientation();
vec = Ogre::Vector3(0,0,-1);


when debuging msnCam has a whole host of nice attributes associated with it, however, when I debug mine, my msnCam has many "unable to evaluate expression" next to attribute names. In particular the mOrientation of my msnCam variables are garbage.

I have followed back all the definitions of the SceneNodes and my code is nearly exactly the same. It seems to me like my SceneNode needs some kind of initialisation - but I don't see that anywhere in the demo or the example headers.

The Demo version has an Ogre::SceneNode* in the Application header and a SceneNode* in the FrameListener header as do I, the only time they are referenced after this are in setupScene() to set them to a new child node and then in createFrameListener (my FrameListener code is exactly the sme as the Demo's except I have an extra couple of attributes). This is what I do for my msnCam inside setupScence():

msnCam = mgr->getRootSceneNode()->createChildSceneNode("CameraNode");
cam = mgr->createCamera("Camera");
cam->setPosition(0,800,0);
cam->lookAt(Vector3(0,0,0));
msnCam->attachObject(cam);
msnCam->setPosition( 0.0, -10.0, 20.0);


while the Demo does this, noteing that some of mCamera settings are already set in the Example header:

msnCam = mSceneMgr->getRootSceneNode()->createChildSceneNode();
msnCam->attachObject( mCamera );
mCamera->setPosition(0.0, 0.0, 0.0);
msnCam->setPosition( 0.0, -10.0, 20.0);


I don't see any difference besides a few numbers and the fact I include a "Name". Anything else code wise is identical - this is why i feel there is a line of code I am missing to 'initialise' my msnCam somehow.

I would be grateful for any support,
Thanks
neomxl

neomxl

05-12-2007 15:27:18

**many hours of coffee later**

Ok I found something inteseresting that I can't fathom.

In the frameListener Ctor I pass in my Scene Manager (I'm following this in debug mode stepping through) and it's initialised all well and fine. At the beggining of my Frame Started Function, its is still all well and nice. Then it appears if I do any function it ruins the pointer to the scene manager. Here is the simplest code I could think of:

inside framStarted function
SceneNode *n = mSceneMgr->getRootSceneNode()->createChildSceneNode("MyNode1");

This simple line turns my SceneManager pointer to garbage and has the knock on effect of messing everything else up. Initially I used the scene manager to get a camera and make it ->LookAt a Mesh. When debugging it turned itself to a garbage pointer but it still made the camera look at the player every single frame.

I'm using unbuffer input and use the sceneManager to translate a node in my world dependant on the key pressed. All these still work even though the pointer seems to have been corrupted somehow.

I hope somehow knows what on Earth is going on.

albino

18-12-2007 15:08:53

well some things to check out:
1. are you sure you have set the newton world size properly?

2. code some lines so you can move your camera around so you can see
if the input system works and if there are objects spawned on the field.

3. msnCam->getWorldOrientation(); caused me problems so i changed it to
msnCam->getOrientation();