room

28 views
Skip to first unread message

Mario Lenci

unread,
Sep 26, 2011, 3:45:04 AM9/26/11
to jinn...@googlegroups.com
Hi,
I'm here with an other question, I'm having a bit of trouble implementing my easy Android die game. I have to implement a die that can be moved by shaking the device.
My idea was to build a room made of boxies objects to make the die bouncing inside of it in front of the camera.
But i can't figure out how to set the walls values and position, the die keep going out of my ranges, here is the code of the initialization:

       //creazione del mondo fisico physic world
        physic_world = new DefaultScene(new SAP2(),
                new NonsmoothNonlinearConjugateGradient(10),
                new DefaultDeactivationPolicy());
        physic_world.setTimestep(0.1);

        // add bound the world
        // floor dimension depending on the camera FOV
        float h = (float)Math.tan(cam.getMaxFOV()/2);
        float w = h *width/height;
        h *= (10 + floorDepth + Math.abs( cam.getPosition().z));
        w *= (10 + floorDepth + Math.abs( cam.getPosition().z ));
       
        //FRONT
        p_front = new Body("front", new Box(w*2,h*2,10));
        p_front.setPosition(new Vector3(0,0,10));
       
        //FLOOR
        p_floor = new Body("floor", new Box(w*2, h*2, 10));
        p_floor.setPosition(new Vector3(0, 0, floorDepth));
        p_floor.setFixed(true);
       
        //TOP
        p_top_wall = new Body("top", new Box(w*2, 10, floorDepth));
        p_top_wall.setPosition(new Vector3(0, h/2, floorDepth/2));
        p_top_wall.setFixed(true);
       
        //BOTTOM
        p_bottom_wall = new Body("bottom", new Box(w*2, 10, floorDepth));
        p_bottom_wall.setPosition(new Vector3(0, -h/2, floorDepth/2));
        p_bottom_wall.setFixed(true);
       
        //LEFT
        p_left_wall = new Body("left", new Box(10 , h*2, floorDepth));
        p_left_wall.setPosition(new Vector3(-w/2, 0, floorDepth/2));
        p_left_wall.setFixed(true);
       
        //RIGHT
        p_right_wall = new Body("right", new Box(10, h*2, floorDepth));
        p_right_wall.setPosition(new Vector3(w/2, 0, floorDepth/2));
        p_right_wall.setFixed(true);

        // create a die
        p_dice = new Body("box", new Box(5, 5, 5));
        p_dice.setPosition(new Vector3(0, 0, 20));


i know that the camera isn't orth so i know it won't render it all in front of the camera but for what i can understand it souldn't go out of the "room" i build out of 6 BOXes.

do you see any BIG mistake in the bounds values?

Mario Lenci

unread,
Sep 26, 2011, 3:50:28 AM9/26/11
to jinn...@googlegroups.com
i actually forgot to add the walls to the physic world, i added it... but it keep going out of the room after a while.

Sry for the dumb question. It's probably to early in the morning, i just need more coffe ^^.

Mario Lenci

unread,
Sep 26, 2011, 5:09:07 AM9/26/11
to jinn...@googlegroups.com
is it possible that when a body is too fast it just pass trought the walls in between 2 frames?
cause i noticed that when the die is slow it bouce on the walls but when is fast it seems it just pass trought them. is there a way to fix this problem?
Reply all
Reply to author
Forward
0 new messages