Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
share|improve this question
1  
I'd say this is too localized for the site. Voting to close. In the mean time, you may want to include the crash text. – Byte56 Jan 9 at 23:20
This problem is typically tackled with with a debugger, especially since you have the source code for everything you use. – Sam Hocevar Jan 10 at 0:01

closed as too localized by Byte56, Sam Hocevar, michael.bartnett, Maik Semder, Nicol Bolas Jan 10 at 8:11

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.