private void fixRefreshFlags(){ // force transforms to update below this node spatial.updateGeometricState(); // force world bound to update Spatial rootNode = spatial; while (rootNode.getParent() != null){ rootNode = rootNode.getParent(); } rootNode.getWorldBound(); }
public static void validateScene(Spatial scene) { scene.updateGeometricState(); scene.depthFirstTraversal(VISITOR); }
public void update(){ int w = image.getWidth(); int h = image.getHeight(); float wr = (float) cam.getWidth() / image.getWidth(); float hr = (float) cam.getHeight() / image.getHeight(); scene.updateGeometricState(); for (int y = 0; y < h; y++){ for (int x = 0; x < w; x++){ Vector2f v = new Vector2f(x * wr,y * hr); Vector3f pos = cam.getWorldCoordinates(v, 0.0f); Vector3f dir = cam.getWorldCoordinates(v, 0.3f); dir.subtractLocal(pos).normalizeLocal(); Ray r = new Ray(pos, dir); results.clear(); scene.collideWith(r, results); if (results.size() > 0){ image.setRGB(x, h - y - 1, 0xFFFFFFFF); }else{ image.setRGB(x, h - y - 1, 0xFF000000); } } } label.repaint(); }
return null; debugShape.updateGeometricState(); return debugShape;
return null; debugShape.updateGeometricState(); return debugShape;
@Override public void update(float tpf) { // update VR pose & cameras if( environment.getVRViewManager() != null ) { environment.getVRViewManager().update(tpf); } else if( environment.getObserver() != null ) { environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation()); } if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) { // only update geometric state here if GUI is in manual mode, or not in VR // it will get updated automatically in the viewmanager update otherwise // TODO isn't this done by SimpleApplication? for (Spatial spatial : application.getGuiViewPort().getScenes()) { //spatial.updateLogicalState(tpf); spatial.updateGeometricState(); } } // use the analog control on the first tracked controller to push around the mouse environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf); }
public void makeMissile() { Vector3f pos = spaceCraft.getWorldTranslation().clone(); Quaternion rot = spaceCraft.getWorldRotation(); Vector3f dir = rot.getRotationColumn(2); Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); missile.rotate(0, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound(); final Vector3f extent = box.getExtent(null); BoxCollisionShape boxShape = new BoxCollisionShape(extent); missile.setName("Missile"); missile.rotate(rot); missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0)); missile.setLocalRotation(hoverControl.getPhysicsRotation()); missile.setShadowMode(ShadowMode.Cast); RigidBodyControl control = new BombControl(assetManager, boxShape, 20); control.setLinearVelocity(dir.mult(100)); control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03); missile.addControl(control); rootNode.attachChild(missile); getPhysicsSpace().add(missile); }
public static void optimize(Spatial source, boolean toFixed){ optimizeScene(source, toFixed); source.updateLogicalState(0); source.updateGeometricState(); }
private void fixRefreshFlags(){ // force transforms to update below this node spatial.updateGeometricState(); // force world bound to update Spatial rootNode = spatial; while (rootNode.getParent() != null){ rootNode = rootNode.getParent(); } rootNode.getWorldBound(); }
private void fixRefreshFlags(){ // force transforms to update below this node spatial.updateGeometricState(); // force world bound to update Spatial rootNode = spatial; while (rootNode.getParent() != null){ rootNode = rootNode.getParent(); } rootNode.getWorldBound(); }
/** * For internal use only * specific render for the ragdoll(if debugging) * @param rm * @param vp */ public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (!debug) { attachDebugShape(space.getDebugManager()); } for (Iterator<PhysicsBoneLink> it = boneLinks.values().iterator(); it.hasNext();) { PhysicsBoneLink physicsBoneLink = it.next(); Spatial debugShape = physicsBoneLink.rigidBody.debugShape(); if (debugShape != null) { debugShape.setLocalTranslation(physicsBoneLink.rigidBody.getMotionState().getWorldLocation()); debugShape.setLocalRotation(physicsBoneLink.rigidBody.getMotionState().getWorldRotationQuat()); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } } } }
@Override public void updateGeometricState(){ if ((refreshFlags & RF_LIGHTLIST) != 0){ updateWorldLightList(); } if ((refreshFlags & RF_TRANSFORM) != 0){ // combine with parent transforms- same for all spatial // subclasses. updateWorldTransforms(); } if (!children.isEmpty()) { // the important part- make sure child geometric state is refreshed // first before updating own world bound. This saves // a round-trip later on. // NOTE 9/19/09 // Although it does save a round trip, for (Spatial child : children.getArray()) { child.updateGeometricState(); } } if ((refreshFlags & RF_BOUND) != 0){ updateWorldBound(); } assert refreshFlags == 0; }
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } debugShape.setLocalTranslation(getPhysicsLocation()); debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }
return null; debugShape.updateGeometricState(); return debugShape;
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } debugShape.setLocalTranslation(spatial.getWorldTranslation()); debugShape.setLocalRotation(spatial.getWorldRotation()); debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }
public Octree(Spatial scene, int minTrisPerNode){ scene.updateGeometricState();
@Override public void updateGeometricState() { if ((refreshFlags & RF_LIGHTLIST) != 0) { updateWorldLightList(); } if ((refreshFlags & RF_TRANSFORM) != 0) { // combine with parent transforms- same for all spatial // subclasses. updateWorldTransforms(); } if (!children.isEmpty()) { // the important part- make sure child geometric state is refreshed // first before updating own world bound. This saves // a round-trip later on. // NOTE 9/19/09 // Although it does save a round trip, for (Spatial child : children.getArray()) { child.updateGeometricState(); } if (needMeshUpdate) { updateModelBound(); needMeshUpdate = false; } } if ((refreshFlags & RF_BOUND) != 0) { updateWorldBound(); } assert refreshFlags == 0; }
public void render(RenderManager rm, ViewPort vp) { if (enabled && space != null && space.getDebugManager() != null) { if (debugShape == null) { attachDebugShape(space.getDebugManager()); } //TODO: using spatial traslation/rotation.. debugShape.setLocalTranslation(spatial.getWorldTranslation()); debugShape.setLocalRotation(spatial.getWorldRotation()); debugShape.updateLogicalState(0); debugShape.updateGeometricState(); rm.renderScene(debugShape, vp); } }