0
\$\begingroup\$

My mesh drops after a while when rigid body turns green. Maybe I sound wierd, but I am new to bullet-physics and 3d stuff, and don't know the actual cause ;P

It happens on using MotionState. Initial state:

enter image description here

After debugdraw turn green

enter image description here

Here is my code inside render method:

        delta = Math.min(1f / 30f, Gdx.graphics.getDeltaTime());

        world.stepSimulation(delta, 5, 1f/60f);
        stickobj.body.getMotionState().getWorldTransform(stickobj.transform);
        modelBatch.begin(cam);
        modelBatch.render(stickobj, environment);
        modelBatch.end();

Here is my motion State for stickman:

class StickMotionState extends btMotionState {

    Matrix4 transform;
    float radius;

    StickMotionState(float r){
        radius = r;
    }

    @Override
    public void getWorldTransform(Matrix4 trans) {
            trans.set(transform);
            trans.translate(0, -radius, 0);
    }
    @Override
    public void setWorldTransform(Matrix4 trans) {
        transform.set(trans);
    }
}

It works fine without explicitly calling, stickobj.body.getMotionState().getWorldTransform(stickobj.transform); as Xoppa stated in this tutorial, but then my model is offset a little bit.

enter image description here

Also, I don't want to offset origin in blender due to increased calulations in placing them in game. PS: What does that green colour signifies :P

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.