OgreNewt doesn't work.

ArcanumGame

26-09-2010 21:44:14

Hello there.

My application crashes, when I'm using OgreNewt.
(OgreNewt 2.0 with Ogre 1.7.1 on Windows 7 Prof. 64bit)

It's fully compiled (http://www.ogre3d.org/addonforums/viewtopic.php?f=4&t=11510&start=30).
Now I've tried to put that new Framelistener into my Game:

oid ArcanumEngineBase::createFrameListener(void)
{
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;

mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

mInputManager = OIS::InputManager::createInputSystem( pl );

mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));

mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);

//Set initial mouse clipping size
windowResized(mWindow);

//Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, mMouse, this);
// mTrayMgr->showLogo(OgreBites::TL_CENTER);
mTrayMgr->hideCursor();

// create a params panel for displaying sample details
Ogre::StringVector items;
items.push_back("cam.pX");
items.push_back("cam.pY");
items.push_back("cam.pZ");
items.push_back("");
items.push_back("cam.oW");
items.push_back("cam.oX");
items.push_back("cam.oY");
items.push_back("cam.oZ");
items.push_back("");
items.push_back("Filtering");
items.push_back("Poly Mode");

mDetailsPanel = mTrayMgr->createParamsPanel(OgreBites::TL_NONE, "DetailsPanel", 200, items);
mDetailsPanel->setParamValue(9, "Bilinear");
mDetailsPanel->setParamValue(10, "Solid");
mDetailsPanel->hide();

mRoot->addFrameListener(this);
OgreNewt::BasicFrameListener* mOgreNewtListener;
mOgreNewtListener = new OgreNewt::BasicFrameListener( mWindow, mWorld, 120 );
}


Compiling works, but when I'm launching the .exe, it crashes.
This code is the reason:

mOgreNewtListener = new OgreNewt::BasicFrameListener( mWindow, mWorld, 120 );

Why does this happen?
PS: BasicFrameListener from OgreNewt does not work.
I've added the (*.h) and (*.cpp) files to my solution and
added #include "OgreNewt_BasicFrameListener.h" to my
BaseApplicationEngine.h ...

Some strange error appeared, when I wanted to launch
and I just deleted the two lines of BasicFrameListener, and
it worked again.

The error is:

The application failed to initialize properly (0xc000007b). Click OK to terminate.

SFCBias

27-09-2010 00:39:42

Have you initialized OgreNewt? I see no code where you create the world.

ArcanumGame

28-09-2010 16:44:46

I've initialised it in the createScene() funktion.

In the header-file:
OgreNewt::World *mWorld;

In the cpp-file:
mWorld = new OgreNewt::World();

SFCBias

30-09-2010 01:36:16

Well i can't see why it wouldn't work. SO try this. Instead of using the basicFrameListener, in you're main loop simple call mWorld->update(timeSinceLastFrame); because that really all the frameListener is doing. If it doesnt work then ill need to see more code.

ArcanumGame

02-10-2010 19:16:14

When I call the
mWorld = new OgreNewt::World();
then it crashes down. I've no Idea, what
to do now. :?:
When I delete the code and just insert the
mWorld->update(evt.timeSinceLastFrame);
same error appears .. maybe it's because of
there is no World initialised but maybe its
because something is broken?
Seems, that the OgreNewt 2.0 is'nt that stable?

My framelistener looks like this and overrides the framelistener some posts ago:

bool ArcanumEngine::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
if(mWindow->isClosed())
{
return false;
}

if(mShutDown)
{
return false;
}
//Need to capture/update each device
mKeyboard->capture();
mMouse->capture();

mTrayMgr->frameRenderingQueued(evt);
mWorld->update(evt.timeSinceLastFrame);

// Foreward * Backwards
CharacterNode->translate(0, 0, RUNNING_FOREWARD*evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);
CharacterNode->translate(0, 0, RUNNING_BACKWARD*evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);
// Left * Right
CharacterNode->translate(RUNNING_LEFT*evt.timeSinceLastFrame, 0, 0, Ogre::Node::TS_LOCAL);
CharacterNode->translate(RUNNING_RIGHT*evt.timeSinceLastFrame, 0, 0, Ogre::Node::TS_LOCAL);
// Up * Down
CharacterNode->translate(0, RUNNING_UPWARD*evt.timeSinceLastFrame, 0, Ogre::Node::TS_LOCAL);
CharacterNode->translate(0, RUNNING_DOWNWARD*evt.timeSinceLastFrame, 0, Ogre::Node::TS_LOCAL);

return true;
}

SFCBias

02-10-2010 21:47:32

Its pretty stable. I can't imagine what could be happening. Let me see the ogre.log please.

ArcanumGame

03-10-2010 14:25:32

It seems that I've got it working now.
I just didn't use the basic framelistener from the tutorial.
I've integrated the line:
mWorld->update(evt.timeSinceLastFrame);
how can I make the collision for two (*.mesh) objects now?
The one is the world, the second is the character. I cant use
something like
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Box( mWorld, size );
for something like a world, because it's not a cube. is there
a function, that will do it? My createScene - function looks like this:

// Initialize the Physic
mWorld = new OgreNewt::World();

MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.0, 0.0, 0.0));
mSceneMgr->setShadowTexturePixelFormat(PF_FLOAT32_R);
mSceneMgr->setShadowCasterRenderBackFaces(true);
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);

mSceneMgr->setShadowColour(ColourValue(0, 0, 0));
mSceneMgr->setShadowTextureSize(2048);
mSceneMgr->setShadowTextureCount(3);
mSceneMgr->setShadowFarDistance(3000);
mSceneMgr->setShadowTextureFadeStart(0.1f);
mSceneMgr->setShadowTextureSelfShadow(true);

Ogre::Entity* levelMesh = mSceneMgr->createEntity("Level", "Worldmesh.mesh");
levelMesh->setCastShadows(true);
Ogre::SceneNode* levelMeshNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
levelMeshNode->attachObject(levelMesh);

Ogre::Entity* CharacterMesh = mSceneMgr->createEntity("SinbadBody", "Sinbad.mesh");
CharacterMesh->setCastShadows(true);
CharacterNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
CharacterNode->attachObject(CharacterMesh);
CharacterNode->scale(Ogre::Vector3(25.0, 25.0, 25.0));
CharacterNode->setPosition(Ogre::Vector3(100, 90, 0));
CharacterNode->attachObject(mCamera);

Ogre::Light* l = mSceneMgr->createLight("MainLight");
l->setPosition(200,500,400);
l->setDiffuseColour(0.7, 0.7, 0.8);
l->resetShadowFarDistance();
l->setSpecularColour(0.3, 0.3, 0.3);
}


What would the code looks like, if i want a collision of
both objects .. ? :)
EDIT:
I can't use the

OgreNewt::CollisionPtr col( new OgreNewt::CollisionPrimitives::TreeCollision( mWorld, ent, true));

because it shows me C2661: no overloaded function takes number parameters
when I add a 0 to ...::TreeCollision( mWorld, ent, true, 0), then it compiles,
but don't do anything when I start the application, just stay blackscreen.

SFCBias

03-10-2010 21:33:14

Have you looked at kallaspriit's Minimal OgreNewt application? It should give you some insight on what you need to know.
http://code.google.com/p/minimal-ogrenewt/