Crashing at setMaterialGroupID with col callback override

tanaka

26-07-2008 07:39:53

Hello everybody. In the project I am currently working on I am having some trouble setting up some materials to use in a custom callback.

The program crashes when I try to call setMaterialGroupID.

Here is the test class which inherits from the newton callback class.


#include <OgreNewt.h>

using namespace Ogre;
using namespace OgreNewt;

class CarCollision : public ContactCallback
{
int UserProcess();

};



#include <OgreNewt.h>
#include "CarCollision.h"

using namespace Ogre;
using namespace OgreNewt;


int UserProcess(){

printf("test\n");

return 0;

}



In my createScene() function I create the materials:


carMID = new MaterialID(m_World);
matPair = new MaterialPair(m_World, carMID, carMID);
matPair->setContactCallback(customCar);


And eventually pass them through to my vehicle class:

RallyCar::RallyCar(Ogre::SceneManager* mgr, OgreNewt::World* world, Ogre::Vector3& position, Ogre::Quaternion& orient, OgreNewt::MaterialID* material) : OgreNewt::Vehicle()
{
// save the scene manager
mSceneMgr = mgr;
mWorld = world;

carMaterial = material;

//...


This is where the problem occurs, after setting up the body for a vehicle:


bod->setMaterialGroupID(carMaterial);


Finally, here is a screenshot of the debug output:



Thank you very much for any assistance.

tanaka

26-07-2008 07:44:06

Oh and just a little extra note, I wanted it set up so that a collision between two cars triggers the user callback but I'm not really sure if this was the way to do it (as you can see I have passed the material into the MaterialPair function twice).