Basic OgreOde initialisation

kiczor

09-01-2008 18:56:50

Hi, i am currently fighting with ogreode and my app gets crached. Can any one tell me what is needed to be done to properly initialise OgreOde. I was trying to set up OgreOde according to SimpleScenes but it still crashes. Can anyone describe process for me?


thanks a lot:)

Fred

09-01-2008 19:28:27

That is a tutorial about first steps with ogreode.
http://www.ogre3d.org/wiki/index.php/Fi ... th_OgreODE

kiczor

10-01-2008 16:51:49

That is a tutorial about first steps with ogreode.
http://www.ogre3d.org/wiki/index.php/Fi ... th_OgreODE


i've tried that and app starts but it crashes here is code:


#include "ExampleApplication.h"
#include "ExampleFrameListener.h"

#include "OgreOde_Core.h"
using namespace Ogre;

class TutorialFrameListener : public ExampleFrameListener {
public:
TutorialFrameListener(RenderWindow* window, Camera* camera, OgreOde::World* world, OgreOde::StepHandler* stepper) : ExampleFrameListener(window, camera) {
_world = world;
_stepper = stepper;
}
virtual ~TutorialFrameListener() {}

bool frameEnded(const Ogre::FrameEvent& evt) {
Ogre::Real time = 0.1;
if (_stepper->step(time))
{
_world->synchronise();
}
}

OgreOde::World* _world;
OgreOde::StepHandler* _stepper;
Camera* _camera;
RenderWindow* _window;
};


class TutorialApplication : public ExampleApplication
{
protected:
public:
TutorialApplication()
{
}

~TutorialApplication()
{
}


protected:
virtual void createCamera(void)
{
}

virtual void createViewports(void)
{
}

virtual void createFrameListener(void)
{
mFrameListener= new TutorialFrameListener(mWindow, mCamera, mWorld, mStepper);
//mFrameListener->showDebugOverlay(true);
mRoot->addFrameListener(mFrameListener);
}

void createScene(void)
{

// create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");

// set its position, direction
mCamera->setPosition(Vector3(0,10,100));
mCamera->lookAt(Vector3(0,0,0));
mCamera->setNearClipDistance(5);

// Create one viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);

Light *light = mSceneMgr->createLight("Light1");
light->setType(Light::LT_POINT);
light->setPosition(Vector3(0, 150, 250));
light->setDiffuseColour(1.0, 1.0, 1.0);
light->setSpecularColour(1.0, 1.0, 1.0);

mWorld = new OgreOde::World(mSceneMgr);
mWorld->setGravity(Ogre::Vector3(0,-9.80665,0));
mWorld->setCFM(10e-5);
mWorld->setERP(0.8);
mWorld->setAutoSleep(true);
mWorld->setAutoSleepAverageSamplesCount(10);
mWorld->setContactCorrectionVelocity(1.0);
mSpace = mWorld->getDefaultSpace();

const Ogre::Real _time_step = 0.5;
const Ogre::Real time_scale = Ogre::Real(1.7);
const Ogre::Real max_frame_time = Ogre::Real(1.0 / 4);
mStepper = new OgreOde::StepHandler(mWorld, OgreOde::StepHandler::QuickStep,_time_step, max_frame_time,
time_scale);

OgreOde::InfinitePlaneGeometry *mGround;
OgreOde::Body *mBody;
OgreOde::Geometry *mGeom;
//OgreOde::BoxMass *mMass;
Ogre::SceneNode *mNode;
Ogre::Entity *mEntity;
mGround = new OgreOde::InfinitePlaneGeometry(Plane(Ogre::Vector3(0,1,0),0), mWorld, mWorld->getDefaultSpace());
// Use a load of meshes to represent the floor
int i = 0;
StaticGeometry* s;
s = mSceneMgr->createStaticGeometry("StaticFloor");
s->setRegionDimensions(Ogre::Vector3(160.0, 100.0, 160.0));
// Set the region origin so the center is at 0 world
s->setOrigin(Ogre::Vector3::ZERO);
for (Real z = -80.0;z <= 80.0;z += 20.0)
{
for (Real x = -80.0;x <= 80.0;x += 20.0)
{
String name = String("Ground") + StringConverter::toString(i++);
Entity* entity = mSceneMgr->createEntity(name, "plane.mesh");
entity->setQueryFlags (1<<4);
entity->setUserObject(mGround);
entity->setCastShadows(false);
s->addEntity(entity, Ogre::Vector3(x,0,z));
}
}
s->build();

mEntity = mSceneMgr->createEntity("crate","crate.mesh");
mEntity->setQueryFlags (1<<2);
mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("crate");
mNode->attachObject(mEntity);
mEntity->setNormaliseNormals(true);
mEntity->setCastShadows(true);
mBody = new OgreOde::Body(mWorld);
mNode->attachObject(mBody);
Vector3 size(10.0,10.0,10.0);
OgreOde::BoxMass mMass(0.5,size);
mMass.setDensity(5.0,size);
mGeom = (OgreOde::Geometry*)new OgreOde::BoxGeometry(size, mWorld, mSpace);
mNode->setScale(size.x * 0.1,size.y * 0.1,size.z * 0.1);
mBody->setMass(mMass);
mGeom->setBody(mBody);
mEntity->setUserObject(mGeom);
mBody->setOrientation(Quaternion(Radian(5.0),Ogre::Vector3(0,0,0)));
mBody->setPosition(Vector3(0,120,-20));

}

OgreOde::World *mWorld;
OgreOde::Space *mSpace;
OgreOde::StepHandler *mStepper;
TutorialFrameListener* mFrameListener;
};

#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
// Create application object
TutorialApplication app;

try {
app.go();
} catch( Exception& e ) {
#if OGRE_PLATFORM == PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
fprintf(stderr, "An exception has occurred: %s\n",
e.getFullDescription().c_str());
#endif
}

return 0;
}


error msg is:
*** Initializing OIS ***
Texture: spot_shadow_fade.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
/usr/libexec/<unknown>: No such file or directory.

warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff82bfe000

Debug stack:

Thread [0] (Suspended: Signal 'SIGCONT' received. Description: Continued.)
18 waitpid() 0x00002ac6db3a63ef
17 g_spawn_sync() 0x00002ac6dd1dbc95
16 g_spawn_command_line_sync() 0x00002ac6dd1dbf98
15 <symbol is not available> 0x00002aaaacf9451f
14 <signal handler called>() 0x00002ac6db344430
13 std::_Rb_tree<std::string, std::pair<std::string const, Ogre::MovableObject*>, std::_Select1st<std::pair<std::string const, Ogre::MovableObject*> >, std::less<std::string>, std::allocator<std::pair<std::string const, Ogre::MovableObject*> > >::_M_erase() 0x00002ac6da3f3b80
12 Ogre::Entity::detachAllObjectsImpl() 0x00002ac6da3ea7be
11 Ogre::Entity::_deinitialise() 0x00002ac6da3ecf1f
10 Ogre::Entity::~Entity() 0x00002ac6da3ed0eb
9 Ogre::SceneManager::destroyAllMovableObjects() 0x00002ac6da55d9e1
8 Ogre::SceneManager::clearScene() 0x00002ac6da55ee91
7 Ogre::OctreeSceneManager::clearScene() 0x00002aaaab6838a9
6 Ogre::SceneManagerEnumerator::shutdownAll() 0x00002ac6da575f80
5 Ogre::Root::shutdown() 0x00002ac6da545bc6
4 Ogre::Root::~Root() 0x00002ac6da5480a2
3 ~ExampleApplication() /home/kiczor/workspace/odeTest/include/ExampleApplication.h:83 0x000000000040ebde
2 ~TutorialApplication() /home/kiczor/workspace/odeTest/src/main.cpp:40 0x000000000040ec99
1 main() /home/kiczor/workspace/odeTest/src/main.cpp:178 0x0000000000404f30
gdb (10.01.08 17:50)



what is wrong with it?

irado

10-01-2008 18:49:37

one time this error show for me too, into i stop the use the mesh that have the image with error. But if this image is the one terrain, look the configurations of terrain.

bye

kiczor

10-01-2008 19:16:03

one time this error show for me too, into i stop the use the mesh that have the image with error. But if this image is the one terrain, look the configurations of terrain.

bye


thanks for answer :) but my english is far from perfection, i dont understand this, i have tired to change meshs and materials, it didnt help :( but if i comment _stepper->step() and _world->synchronise in TutorialFrameListener::frameEnded() app doesn't crash and nothing happens of course... :( if anyone knows what i did wrong pls share with me. Now i will give a closer look to SimpleScenes maybe i will find what is wrong...

update:

when i move _stepper->step() and _world->synchronise() to be executed after pressing a key it works without crashing even if i hold key... so where can i find a simple mechanism to limit a frame rate?