Skip to content

Attitude of Mass of Cylinder and Capsule Wrong #56

@basil-huber

Description

@basil-huber

In the functions Model::addCylinder(...) and Model::addCapsule take the direction of the axis of the cylinder. We pass this direction to dMassSetCylinderTotal. We then set the cylinder's attitude depending on the orientation. This means we first set the orientation of the mass correct and then turned it to be wrong.

boost::shared_ptr<SimpleBody> Model::addCylinder(float mass,
        const osg::Vec3& pos, int direction, float radius, float height,
        int label) {
    dMass massOde;
    dMassSetCylinderTotal(&massOde, mass, direction, radius, height);
    dxGeom* g = dCreateCylinder(this->getCollisionSpace(), radius, height);
    osg::Quat rotateCylinder;
    if (direction == 1) {
        rotateCylinder.makeRotate(osg::inDegrees(90.0), osg::Vec3(0, 1, 0));
    } else if (direction == 2) {
        rotateCylinder.makeRotate(osg::inDegrees(90.0), osg::Vec3(1, 0, 0));
    }

    boost::shared_ptr<SimpleBody> body(new SimpleBody(shared_from_this(),
                massOde, g, pos, rotateCylinder));
    this->addBody(body, label);
    return body;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions