I have a great problem with Open Dynamic Engine: when I declare dMass variable, my program crash in
geom = dCreateBox(phy->getSpace(), sideLength.x, sideLength.y, sideLength.z);
It too crash if write after the dMass variable declaration:
float t;
t = 2;
std::cout<<t<<std::endl;
Can anybody help me?
My code:
BoxObject.cpp
void BoxObject::Initialize()
{
PhysicObject::Initialize();
Physics *phy = (Physics*)getParent()->getEngine()->services.GetService(1);
sideLength = glm::vec3(1.0f);
float t;
t=20;
std::cout<<t<<std::endl; **//CRASH HERE**
geom = dCreateBox(phy->getSpace(), sideLength.x, sideLength.y, sideLength.z);
dGeomSetBody(geom,body);
}
BoxObject.hpp
#ifndef BOXOBJECT_H
#define BOXOBJECT_H
#include "PhysicObject.hpp"
#include "../glm/glm.hpp"
class BoxObject : public PhysicObject
{
public:
BoxObject();
BoxObject(glm::vec3, glm::vec3, glm::vec3);
virtual ~BoxObject();
glm::vec3 getSides(void);
void setSides(glm::vec3);
void setGeom(dGeomID);
protected:
void Initialize(void);
private:
glm::vec3 sideLength;
};
#endif // BOXOBJECT_H
PhysicsObject.cpp
void PhysicObject::Initialize()
{
setVisible(false);
Physics *phy = (Physics*)getParent()->getEngine()->services.GetService(1);
body = dBodyCreate(phy->getWorld());
dMassSetZero(&mass);
std::cout<<"Inicializado PO"<<std::endl;
}
PhysicsObject.hpp
#ifndef PHYSICOBJECT_H
#define PHYSICOBJECT_H
#include "Component.hpp"
#include "../glm/glm.hpp"
#define dSINGLE
#include <ode/ode.h>
#define DENSITY 0.5
class PhysicObject : public Component
{
public:
PhysicObject();
virtual ~PhysicObject();
virtual dMass* getMass(void);
virtual glm::vec3 getPosition(void);
virtual void setPosition(glm::vec3);
virtual glm::vec3 getEulerRotation(void);
virtual void setEulerRotation(glm::vec3);
virtual glm::mat4 getRotation(void);
virtual void setRotation(glm::mat4);
virtual glm::vec3 getVelocity(void);
virtual void setVelocity(glm::vec3);
virtual dGeomID getGeom(void);
virtual void setGeom(dGeomID);
virtual void Update(void);
virtual void Draw(void);
protected:
virtual void Initialize();
virtual void Load();
dMass mass;
glm::vec3 linearVelocity;
dBodyID body;
dGeomID geom;
private:
};
#endif // PHYSICOBJECT_H