Ogreode and ogeapplicaion problem

zhein04

15-02-2012 03:10:56

I have a bit of problem using the mWorld->setCollisionListener(this)

i am using the predefault format using the ogreapp plugin for visual studio

here is the code
/*
-----------------------------------------------------------------------------
Filename: test.cpp
-----------------------------------------------------------------------------


This source file is generated by the
___ _ __ __ _ _
/___\__ _ _ __ ___ /_\ _ __ _ __/ / /\ \ (_)______ _ _ __ __| |
// // _` | '__/ _ \ //_\\| '_ \| '_ \ \/ \/ / |_ / _` | '__/ _` |
/ \_// (_| | | | __/ / _ \ |_) | |_) \ /\ /| |/ / (_| | | | (_| |
\___/ \__, |_| \___| \_/ \_/ .__/| .__/ \/ \/ |_/___\__,_|_| \__,_|
|___/ |_| |_|
Ogre 1.7.x Application Wizard for VC9 (July 2011)
http://code.google.com/p/ogreappwizards/
-----------------------------------------------------------------------------
*/

#include "test.h"

//-------------------------------------------------------------------------------------
test::test(void)
{
}
//-------------------------------------------------------------------------------------
test::~test(void)
{
}

//-------------------------------------------------------------------------------------
void test::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f));

/** Add physics to Ogre */
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->setContactCorrectionVelocity(1.0);
mWorld->setCollisionListener(this)

mSpace = mWorld->getDefaultSpace();
mWorld->setShowDebugGeometries(true);
}



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

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
test app;

try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}

return 0;
}

#ifdef __cplusplus
}
#endif





Then this is the error that is always appearing
Error 1 error C2664: 'OgreOde::World::setCollisionListener' : cannot convert parameter 1 from 'test *const ' to 'OgreOde::CollisionListener *' c:\users\visual studio 2008\projects\test\test\src\test.cpp 42 test


what is that?

dermont

15-02-2012 07:20:39

It looks like you haven't setup your collision listener correctly, eg:

test.h

class test : public ExampleApplication,public OgreOde::CollisionListener
{
...
protected:
virtual bool collision(OgreOde::Contact* contact);
...


test.cpp

...
bool test::collision(OgreOde::Contact* contact)
{
// Check for collisions between things that are connected and ignore them
OgreOde::Geometry * const g1 = contact->getFirstGeometry();
OgreOde::Geometry * const g2 = contact->getSecondGeometry();

if (g1 && g2)
{
const OgreOde::Body * const b1 = g1->getBody();
const OgreOde::Body * const b2 = g2->getBody();
if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2))
return false;
}

// Set the friction at the contact
contact->setCoulombFriction(OgreOde::Utility::Infinity);
contact->setBouncyness(0.1);
...
// Yes, this collision is valid
return true;
}