Mario Lenci
unread,Sep 26, 2011, 3:45:04 AM9/26/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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?