static void update(float deltaTime) { float dt = deltaTime*10.f; float angX,angY,r; render_get_view_angle(angX,angY,r); ctrl_update(); if(ctrl_button_pressed(BTN_UP)) { angX -= 0.05f*dt; if(angX < -1.4f) angX = -1.4f; if(angX > -0.01f) angX = -0.01f; } if(ctrl_button_pressed(BTN_DOWN)) { angX += 0.05f*dt; if(angX < -1.4f) angX = -1.4f; if(angX > 0.0f) angX = 0.0f; } if(ctrl_button_pressed(BTN_LEFT)) { angY -= 0.05f*dt; } if(ctrl_button_pressed(BTN_RIGHT)) { angY += 0.05f*dt; } if(ctrl_button_pressed(BTN_ZOOM_OUT)) { r *= (1.f+0.1f*dt); if(r > 500.0f) r = 500.0f; } if(ctrl_button_pressed(BTN_ZOOM_IN)) { r *= (1.f-0.1f*dt); if(r < 1.0f) r = 1.0f; } if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { physics_create_scene(sceneId); } if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { physics_create_scene(++sceneId); } if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { simulating = !simulating; } if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { simulating = true; } else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { simulating = false; } render_set_view_angle(angX,angY,r); }
void update(void) { float angX,angY,r; render_get_view_angle(angX,angY,r); ctrl_update(); if(ctrl_button_pressed(BTN_UP)) { angX -= 0.05f; if(angX < -1.4f) angX = -1.4f; if(angX > -0.01f) angX = -0.01f; } if(ctrl_button_pressed(BTN_DOWN)) { angX += 0.05f; if(angX < -1.4f) angX = -1.4f; if(angX > -0.01f) angX = -0.01f; } if(ctrl_button_pressed(BTN_LEFT)) { angY -= 0.05f; } if(ctrl_button_pressed(BTN_RIGHT)) { angY += 0.05f; } if(ctrl_button_pressed(BTN_ZOOM_OUT)) { r *= 1.1f; if(r > 500.0f) r = 500.0f; } if(ctrl_button_pressed(BTN_ZOOM_IN)) { r *= 0.9f; if(r < 1.0f) r = 1.0f; } if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { physics_create_scene(sceneId); } if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { physics_create_scene(++sceneId); } if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { simulating = !simulating; } if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { simulating = true; } else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { simulating = false; } int w,h; render_get_screent_size(w,h); ctrl_set_screen_size(w,h); static PfxVector3 pickPos(0.0f); if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_DOWN) { int sx,sy; ctrl_get_cursor_position(sx,sy); PfxVector3 wp1((float)sx,(float)sy,0.0f); PfxVector3 wp2((float)sx,(float)sy,1.0f); wp1 = render_get_world_position(wp1); wp2 = render_get_world_position(wp2); pickPos = physics_pick_start(wp1,wp2); } else if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_KEEP) { int sx,sy; ctrl_get_cursor_position(sx,sy); PfxVector3 sp = render_get_screen_position(pickPos); PfxVector3 wp((float)sx,(float)sy,sp[2]); wp = render_get_world_position(wp); physics_pick_update(wp); } else if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_UP) { physics_pick_end(); } render_set_view_angle(angX,angY,r); }