Ho hum... Collision fun!

Hi ttrocha,



I apologise. I was torn between writing another post (and dissapointing you), or just letting it go. I'm afraid to say it didn't make much difference. It made some, but still got me sticking every now and again.



I am working on cleaning up the interpolation (Wiki to follow by the way), and then I will resurrect this issue.



I really do appreciate the effort you put in…



Oh sod it, I'll have another look tonight !!!

Right then… I'm so close I can see the finish line ! Thanks for your advice. All of your perseverance is paying off. It is so nearly working. The only issue is on rotation. A very weird thing is happening. Walls now stop me, but I rotate in to it a bit (ie in to the wall), it sticks… But… If I keep rotating, the gun "pops" out of the other side and I'm back unstuck again.



It's as if the rotation is actually working, but it's hiding it from me until a valid (ie non-colliding) state is reached.



    public void update(float time) {
        if (value(EXIT) > 0) {
            DarkstarUpdater.getInstance().serverLogout();
            System.exit(0); //OK, this is just a demo...
        } else if (value(SNAPSHOT) > 0) {
            DisplaySystem.getDisplaySystem().getRenderer().takeScreenShot("img-" + System.currentTimeMillis());
        }

        Vector3f origTranslation = node.getLocalTranslation().clone();
        Quaternion origRotation = node.getLocalRotation().clone();

        Vector3f newLocation = node.getLocalTranslation().clone();
        Quaternion newRotation = node.getLocalRotation().clone();

        hAngle += TURN_SPEED * time * (value(LEFT) - value(RIGHT));
        newRotation.fromAngles(vAngle, hAngle, 0f);
        node.getLocalRotation().set(newRotation);

        // I don't get this next line. What is getRotationColumn? value must be
        // between 0 and 2. I think 0=x, 1=y and 2=z... But I is baffled!
        Vector3f direction = new Vector3f(node.getLocalRotation().getRotationColumn(2));

        float speed = time * FORWARD_SPEED * (value(DOWN) - value(UP));
        speed *= 1 + (2 * value(FAST)); // Double the speed if the fast button is being pressed.
        newLocation.addLocal(direction.mult(speed));

        node.getLocalTranslation().set(newLocation);
        node.updateGeometricState(0, true);
        node.updateWorldBound();
        node.updateWorldVectors();

        if (node.hasCollision(walls, true)) {
            node.getLocalTranslation().set(origTranslation);
            node.getLocalRotation().set(origRotation);
            node.updateGeometricState(0, true);
        }
    }



I shall play some more, but I think bed time soon ;)

FINALLY, CRACKED IT !!!  :smiley:



The hAngle variable was an instance variable. So I was adding to it, but never taking it away again if there was a collision… Holy crap that's hard!



So thank you ever so much for your help. I'm going to work on cleaning it all up and then displaying a working example here.



Phew ! Off to bed now