/** * Call this when you remove the terrain or this control from the scene. * It will clear up any threads it had. */ public void detachAndCleanUpControl() { if (indexer != null) { indexer.cancel(true); indexer = null; } getSpatial().removeControl(this); }
/** * Internal use only. */ @Override public void setSpatial(Spatial spatial) { if (spatial == null && skeletonControl != null) { this.spatial.removeControl(skeletonControl); } super.setSpatial(spatial); //Backward compatibility. if (spatial != null && skeletonControl != null) { spatial.addControl(skeletonControl); } }
@Override public void visit(Spatial spatial) { SkeletonControl control = spatial.getControl(SkeletonControl.class); if (control != null) { Armature armature = skeletonArmatureMap.get(control.getSkeleton()); SkinningControl skinningControl = new SkinningControl(armature); Map<String, List<Spatial>> attachedSpatials = new HashMap<>(); for (int i = 0; i < control.getSkeleton().getBoneCount(); i++) { Bone b = control.getSkeleton().getBone(i); Node n = control.getAttachmentsNode(b.getName()); n.removeFromParent(); if (!n.getChildren().isEmpty()) { attachedSpatials.put(b.getName(), n.getChildren()); } } spatial.removeControl(control); spatial.addControl(skinningControl); for (String name : attachedSpatials.keySet()) { List<Spatial> spatials = attachedSpatials.get(name); for (Spatial child : spatials) { skinningControl.getAttachmentsNode(name).attachChild(child); } } } }
spatial.removeControl(control); spatial.addControl(composer);
throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node."); model.removeControl(sc); model.addControl(sc);
throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node."); model.removeControl(sc); model.addControl(sc);
@Override protected void removeMic() { if (currentMicControl != null) { currentMicControl.getSpatial().removeControl(currentMicControl); } } }
/** * Call this when you remove the terrain or this control from the scene. * It will clear up any threads it had. */ public void detachAndCleanUpControl() { if (executor != null) executor.shutdownNow(); getSpatial().removeControl(this); }
/** * Internal use only. */ @Override public void setSpatial(Spatial spatial) { if (spatial == null && skeletonControl != null) { this.spatial.removeControl(skeletonControl); } super.setSpatial(spatial); //Backward compatibility. if (spatial != null && skeletonControl != null) { spatial.addControl(skeletonControl); } }
/** * Internal use only. */ @Override public void setSpatial(Spatial spatial) { if (spatial == null && skeletonControl != null) { this.spatial.removeControl(skeletonControl); } super.setSpatial(spatial); //Backward compatibility. if (spatial != null && skeletonControl != null) { spatial.addControl(skeletonControl); } }
@Override protected void controlUpdate(float tpf) { if (!isEnabled() || spatial == null) { return; } if (tick > 1) { spatial.removeControl(this); onExit(); return; } moveCamera(); tick += tpf * SPEED; }
@Override protected void removeMic() { if (currentMicControl != null) { currentMicControl.remove(pcSpeaker); if (chart != null) { chart.dispose(); currentMicControl.remove(chart); } currentMicControl.getSpatial().removeControl(currentMicControl); } }
@Override protected void controlUpdate(float tpf) { Vector3f pos = spatial.getLocalTranslation(); // FIXME set real height by BoundingBox height if (pos.y > MapLoader.FLOOR_HEIGHT + 0.3f) { spatial.move(0, -tpf * GRAVITY, 0); } else { enabled = false; spatial.setLocalTranslation(pos.x, MapLoader.FLOOR_HEIGHT + 0.3f, pos.z); spatial.removeControl(this); onLanded(); } }
@Override public void runCommand(Application app) { DevicesAppState devicesAppState = app.getStateManager().getState(DevicesAppState.class); ServerAppState serverAppState = app.getStateManager().getState(ServerAppState.class); Node device = devicesAppState.getDevice(smartphoneId); AndroidVirtualDevice avd = serverAppState.getAVD(smartphoneId); if (device != null && avd != null) { List<Spatial> screens = SpatialUtils.getSpatialsByRole(device, "Screen"); System.out.println("#Screen = " + screens.size()); if (screens.size() > 0) { Spatial screen = screens.get(0); ScreenAVDControl c = screen.getControl(ScreenAVDControl.class); if (on && c == null) { screen.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); c = new ScreenAVDControl((Geometry) screen, avd); screen.addControl(c); c.setFrecuency(frecuency); } else if (!on && c != null) { screen.removeControl(c); } setState(State.Success); return; } } setState(State.Fail); } @Override
throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node."); model.removeControl(sc); model.addControl(sc);
@Override protected void controlUpdate(float tpf) { // TODO add normal physics control if (tick > 11) { plugDecay.removeFromParent(); spatial.removeControl(this); } else if (tick > 9) { velocity -= GRAVITY * tpf; for (Spatial piece : plugDecay.getChildren()) { float rotate = (float) piece.getUserData("rotate") * 10 * tpf; float pv = (float) piece.getUserData("velocity") - GRAVITY * tpf; piece.setUserData("velocity", pv); piece.move(0, pv * tpf, 0); //float step = (float) piece.getUserData("yAngle"); //piece.move(tpf * FastMath.cos(step), velocity * tpf, tpf * FastMath.sin(step)); piece.rotate(rotate, rotate, rotate); } } else if (tick > 6) { plug.removeFromParent(); plugDecay.setCullHint(Spatial.CullHint.Inherit); } tick += tpf; }
throw new IllegalArgumentException("The root node of the model should have a SkeletonControl. Make sure the control is there and that it's not on a sub node."); model.removeControl(sc); model.addControl(sc);
onDie(spatial.getLocalTranslation()); spatial.removeFromParent(); spatial.removeControl(this);
model.removeControl(sc); model.addControl(sc);
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (enabled) { // The camera camera = new PossessionCamera(app.getCamera(), creature.getAttributes().getSpeed(), creature.getFirstPersonOscillateScale()); loadCameraStartLocation(); FunnyCameraContol fcc = new FunnyCameraContol(app.getCamera(), target.getSpatial()); fcc.setLookAtOffset(new Vector3f(0, creature.getAttributes().getEyeHeight(), 0)); fcc.setHeight(creature.getAttributes().getHeight()); fcc.setDistance(1.5f); // The controls registerInput(); } else { unregisterInput(); target.getSpatial().removeControl(FunnyCameraContol.class); target = null; } }