/** @param visible */ public void setSymbolVisible(boolean visible) { if (visible) { CurrentData.getEditorWindow() .getB3DApp() .enqueue( new Callable<Void>() { @Override public Void call() throws Exception { if (light instanceof DirectionalLight) { node.setLocalTranslation( CurrentData.getEditorWindow() .getB3DApp() .getCamera() .getLocation() .clone() .add( CurrentData.getEditorWindow() .getB3DApp() .getCamera() .getDirection() .mult(10))); } CurrentData.getEditorWindow().getB3DApp().getEditorNode().attachChild(node); return null; } }); } else { CurrentData.getEditorWindow() .getB3DApp() .enqueue( new Callable<Void>() { @Override public Void call() throws Exception { CurrentData.getEditorWindow().getB3DApp().getEditorNode().detachChild(node); return null; } }); } }
private void updateLightDirection(final Vector3f direction) { rotationPanel.getFloat3Panel().setVector(direction); CurrentData.getEditorWindow() .getB3DApp() .enqueue( new Callable<Void>() { @Override public Void call() throws Exception { ((SpotLight) lightModel.getLight()).setDirection(direction); Vector3f end = lightModel .getRepresentative() .getLocalTranslation() .add( ((SpotLight) lightModel.getLight()) .getDirection() .mult(((SpotLight) lightModel.getLight()).getSpotRange())); Mesh mesh = new Line(lightModel.getRepresentative().getLocalTranslation(), end); mesh.setPointSize(5); lightModel.getSymbol().setMesh(mesh); return null; } }); }
/** @param l */ public LightModel(Light l) { light = l; if (!(l instanceof AmbientLight)) { symbolMaterial = new Material( CurrentData.getEditorWindow().getB3DApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); symbolMaterial.setColor("Color", l.getColor()); representativeMaterial = new Material( CurrentData.getEditorWindow().getB3DApp().getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); if (l instanceof DirectionalLight) { /*Light*/ DirectionalLight dLight = (DirectionalLight) l; /*Representativ*/ representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showDirectionalLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setMaterial(representativeMaterial); /*Symbol*/ Vector3f end = CurrentData.getEditorWindow() .getB3DApp() .getCamera() .getLocation() .add(CurrentData.getEditorWindow().getB3DApp().getCamera().getDirection().mult(20)) .add(dLight.getDirection().mult(100)); Line symbolMesh = new Line(representative.getWorldTranslation(), end); symbolMesh.setPointSize(5); symbol = new Geometry("LightSymbol", symbolMesh); symbol.setMaterial(symbolMaterial); } else if (l instanceof PointLight) { PointLight pLight = (PointLight) l; representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showPointLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setMaterial(representativeMaterial); representative.setLocalTranslation(pLight.getPosition()); symbol = new Geometry("LightSymbol", new Sphere(15, 15, pLight.getRadius())); symbol.setMaterial(symbolMaterial); symbolMaterial.getAdditionalRenderState().setWireframe(true); } else if (l instanceof SpotLight) { /*Light*/ SpotLight sLight = (SpotLight) l; /*Representativ*/ representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showSpotLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setLocalTranslation(sLight.getPosition()); representative.setMaterial(representativeMaterial); /*Symbol*/ Vector3f end = sLight.getPosition().add(sLight.getDirection().mult(sLight.getSpotRange())); Line symbolMesh = new Line(representative.getWorldTranslation(), end); symbolMesh.setPointSize(5); symbol = new Geometry("LightSymbol", symbolMesh); symbol.setMaterial(symbolMaterial); } node.attachChild(representative); if (symbol != null) { node.attachChild(symbol); } } }