@Override public void simpleUpdate(float tpf) { if (loading) { if (loading_frames == 0) { if (game.isMultiplayer() && client.allConnected() == false) { return; } } if (loading_frames == 5) { if (game.isMultiplayer() && client.allLoaded() == false) { return; } } loading(loading_frames); loading_frames++; } else { loops = 0; while (System.currentTimeMillis() > next_game_tick && loops < MAX_FRAMESKIP && (game.isMultiplayer() == false || client.canContinue())) { if (game.isMultiplayer()) { client.update(); } Timer.update(GAME_TPF); game.update(GAME_TPF); next_game_tick += SKIP_TICKS; loops++; } camera.update(tpf); listener.setLocation(cam.getLocation()); listener.setRotation(cam.getRotation()); gui.update(tpf); // nur wegen Kamera auf Minimap } }
public MouseStatus getMouseCollision() { if (gui.isMouseOver()) { return null; } Vector3f origin = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.0f); Vector3f direction = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f); direction.subtractLocal(origin).normalizeLocal(); Ray ray = new Ray(origin, direction); CollisionResults results = new CollisionResults(); clickableNode.collideWith(ray, results); Vector3f v3f = null; Model m = null; if (results.size() > 0) { CollisionResult closest = results.getClosestCollision(); Geometry g = closest.getGeometry(); v3f = closest.getContactPoint(); m = Model.Geometry2Model(g); // return new // MouseStatus(m,closest.getContactPoint().getX(),closest.getContactPoint().getZ()); } if (water != null) { Vector3f waterv = water.collision(ray); if (waterv != null && (v3f == null || waterv.distance(origin) < v3f.distance(origin))) { v3f = waterv; } } if (v3f != null) return new MouseStatus(m, v3f.getX(), v3f.getZ()); return null; }
public void loading(int pos) { if (pos == 0) { camera = new RTSCamera(getCamera()); camera.registerWithInput(inputManager); loadingScreen.setProgress(0.1f, "Making Light"); } else if (pos == 1) { loadShadow(); loadLight(); loadingScreen.setProgress(0.2f, "Loading Terrain"); } else if (pos == 2) { reflectNode = new Node("reflect"); rootNode.attachChild(reflectNode); nonreflectNode = new Node("non reflect"); rootNode.attachChild(nonreflectNode); clickableNode = new Node("clickable"); reflectNode.attachChild(clickableNode); // clickableNode.attachChild(createTerrain()); loadTerrain(); loadWater(); camera.addTerrain(terrain); camera.addWater(water); loadingScreen.setProgress(0.6f, "Loading Doodads"); } else if (pos == 3) { loadDoodads(); loadingScreen.setProgress(0.8f, "Init Game"); } else if (pos == 4) { game.init(); // gui=new GUI(game); game.getMyGame().init(game); if (game.isMultiplayer()) { client.finishedLoading(); } loadingScreen.setProgress(1f, "Finished Loading"); } else if (pos == 5) { loadingScreen.clear(); camera.enable(); gui = new GUI(game); gui.init(); playerInput = new PlayerInput(game); // important input after nifty next_game_tick = System.currentTimeMillis(); Timer.init(); loading = false; } }