/** * Create a new instanced version of the {@link DirectionalLightShadowFilterVR directional light shadow filter}. * @param application the application that this filter is attached to. * @param camera * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048, etc...) * @param nbSplits the number of shadow maps rendered (the more shadow maps the more quality, the less fps). * @param instancedRendering <code>true</code> if this filter has to use instance rendering and <code>false</code> otherwise. * @param rightCamera the camera used as right eye in stereo rendering mode. */ public InstancedDirectionalShadowFilter(Application application, Camera camera, int shadowMapSize, int nbSplits, boolean instancedRendering, Camera rightCamera) { super(application.getAssetManager(), shadowMapSize, nbSplits, "Common/MatDefs/VR/PostShadowFilter.j3md"); this.instanceRendering = instancedRendering; this.rightCamera = rightCamera; }
@Override public void initialize(AppStateManager stateManager, Application app) { renderManager = app.getRenderManager(); assetManager = app.getAssetManager(); inputManager = app.getInputManager(); for (Binding binding : bindings) { bind(binding); } super.initialize(stateManager, app); }
@Override public void initEvent(Application app, Cinematic cinematic) { super.initEvent(app, cinematic); audioNode = new AudioNode(app.getAssetManager(), path, stream); audioNode.setPositional(false); setLoopMode(loopMode); }
@Override protected void initialize(Application app) { debugNode = new Node("Environment debug Node"); Sphere s = new Sphere(16, 16, 0.15f); debugGeom = new Geometry("debugEnvProbe", s); debugMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/reflect.j3md"); debugGeom.setMaterial(debugMaterial); debugBounds = BoundingSphereDebug.createDebugSphere(app.getAssetManager()); if (scene == null) { scene = app.getViewPort().getScenes().get(0); } }
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; if (app instanceof SimpleApplication) { SimpleApplication simpleApp = (SimpleApplication)app; if (guiNode == null) { guiNode = simpleApp.guiNode; } if (guiFont == null ) { guiFont = simpleApp.guiFont; } } if (guiNode == null) { throw new RuntimeException( "No guiNode specific and cannot be automatically determined." ); } if (guiFont == null) { guiFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); } loadFpsText(); loadStatsView(); loadDarken(); }
public ArmatureDebugger addArmatureFrom(Armature armature, Spatial forSpatial) { ArmatureDebugger ad = armatures.get(armature); if(ad != null){ return ad; } JointInfoVisitor visitor = new JointInfoVisitor(armature); forSpatial.depthFirstTraversal(visitor); ad = new ArmatureDebugger(forSpatial.getName() + "_Armature", armature, visitor.deformingJoints); ad.setLocalTransform(forSpatial.getWorldTransform()); if (forSpatial instanceof Node) { List<Geometry> geoms = new ArrayList<>(); findGeoms((Node) forSpatial, geoms); if (geoms.size() == 1) { ad.setLocalTransform(geoms.get(0).getWorldTransform()); } } armatures.put(armature, ad); debugNode.attachChild(ad); if (isInitialized()) { ad.initialize(app.getAssetManager(), app.getCamera()); } return ad; }
/** * Attaches Statistics View to guiNode and displays it on the screen * above FPS statistics line. * */ public void loadStatsView() { statsView = new StatsView("Statistics View", app.getAssetManager(), app.getRenderer().getStatistics()); // move it up so it appears above fps text statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0); statsView.setEnabled(showStats); statsView.setCullHint(showStats ? CullHint.Never : CullHint.Always); guiNode.attachChild(statsView); }
/** * Initialize this state prior to its 1st update. Should be invoked only by * a subclass or by the AppStateManager. * * @param stateManager the manager for this state (not null) * @param app the application which owns this state (not null) */ @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.rm = app.getRenderManager(); this.assetManager = app.getAssetManager(); setupMaterials(app); physicsDebugRootNode.setCullHint(Spatial.CullHint.Never); viewPort = rm.createMainView("Physics Debug Overlay", app.getCamera()); viewPort.setClearFlags(false, true, false); viewPort.attachScene(physicsDebugRootNode); }
Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); ySize = tex.getImage().getHeight(); mouseImage.setHeight(ySize); mouseImage.getMaterial().getAdditionalRenderState().setDepthWrite(false); } else { Texture tex = environment.getApplication().getAssetManager().loadTexture(texture); mouseImage.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, true); ySize = tex.getImage().getHeight(); mouseImage.setHeight(ySize);
/** * Initialize this state prior to its 1st update. Should be invoked only by * a subclass or by the AppStateManager. * * @param stateManager the manager for this state (not null) * @param app the application which owns this state (not null) */ @Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.rm = app.getRenderManager(); this.assetManager = app.getAssetManager(); setupMaterials(app); physicsDebugRootNode.setCullHint(Spatial.CullHint.Never); viewPort = rm.createMainView("Physics Debug Overlay", app.getCamera()); viewPort.setClearFlags(false, true, false); viewPort.attachScene(physicsDebugRootNode); }
public void onAction(String name, boolean keyPressed, float tpf) { Sphere bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = app.getAssetManager().loadTexture(key2); mat2.setTexture("ColorMap", tex2); if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(app.getCamera().getLocation()); RigidBodyControl bulletControl = new RigidBodyControl(10); bulletg.addControl(bulletControl); bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); space.add(bulletControl); } } };
pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); viewPort.attachScene(pic); viewPort.setOutputFrameBuffer(null);
pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); viewPort.attachScene(pic); viewPort.setOutputFrameBuffer(null);
private ViewPort setupMirrorBuffers(Camera cam, Texture2D tex, boolean expand) { if (environment != null) { if (environment.getApplication() != null) { Camera clonecam = cam.clone(); ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam); clonecam.setParallelProjection(true); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); Picture pic = new Picture("fullscene"); pic.setLocalTranslation(-0.75f, -0.5f, 0f); if (expand) { pic.setLocalScale(3f, 1f, 1f); } else { pic.setLocalScale(1.5f, 1f, 1f); } pic.setQueueBucket(Bucket.Opaque); pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D) tex, false); viewPort.attachScene(pic); viewPort.setOutputFrameBuffer(null); pic.updateGeometricState(); return viewPort; } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
@Override protected void initialize( Application app ) { graph = new Geometry("profiler", profiler.getMesh()); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setBoolean("VertexColor", true); graph.setMaterial(mat); graph.setLocalTranslation(0, 300, 0); graph.setLocalScale(1, scale, 1); Mesh mesh = new Mesh(); background = new Geometry("profiler.background", mesh); mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setBoolean("VertexColor", true); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); background.setMaterial(mat); background.setLocalTranslation(0, 300, -1); background.setLocalScale(1, scale, 1); refreshBackground(); InputManager inputManager = app.getInputManager(); if( inputManager != null ) { inputManager.addMapping(INPUT_MAPPING_PROFILER_TOGGLE, new KeyTrigger(KeyInput.KEY_F6)); inputManager.addListener(keyListener, INPUT_MAPPING_PROFILER_TOGGLE); } }
@Override protected void initialize(Application app) { vp = app.getRenderManager().createMainView("debug", app.getCamera()); vp.attachScene(debugNode); vp.setClearDepth(true); this.app = app; for (ArmatureDebugger armatureDebugger : armatures.values()) { armatureDebugger.initialize(app.getAssetManager(), app.getCamera()); } app.getInputManager().addListener(actionListener, "shoot", "toggleJoints"); app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT), new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); app.getInputManager().addMapping("toggleJoints", new KeyTrigger(KeyInput.KEY_F10)); debugNode.addLight(new DirectionalLight(new Vector3f(-1f, -1f, -1f).normalizeLocal())); debugNode.addLight(new DirectionalLight(new Vector3f(1f, 1f, 1f).normalizeLocal(), new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f))); vp.setEnabled(false); }
public void loadDarken() { Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", new ColorRGBA(0,0,0,0.5f)); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); darkenFps = new Geometry("StatsDarken", new Quad(200, fpsText.getLineHeight())); darkenFps.setMaterial(mat); darkenFps.setLocalTranslation(0, 0, -1); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenFps); darkenStats = new Geometry("StatsDarken", new Quad(200, statsView.getHeight())); darkenStats.setMaterial(mat); darkenStats.setLocalTranslation(0, fpsText.getHeight(), -1); darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenStats); }
Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); leftMat.setTexture("Texture", leftEyeTexture); Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); distortionScene.attachChild(leftEye); Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); rightMat.setTexture("Texture", rightEyeTexture); Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware()));
/** * Initialize the materials. * * @param app the application which owns this state (not null) */ private void setupMaterials(Application app) { AssetManager manager = app.getAssetManager(); DEBUG_BLUE = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_BLUE.getAdditionalRenderState().setWireframe(true); DEBUG_BLUE.setColor("Color", ColorRGBA.Blue); DEBUG_GREEN = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_GREEN.getAdditionalRenderState().setWireframe(true); DEBUG_GREEN.setColor("Color", ColorRGBA.Green); DEBUG_RED = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_RED.getAdditionalRenderState().setWireframe(true); DEBUG_RED.setColor("Color", ColorRGBA.Red); DEBUG_YELLOW = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_YELLOW.getAdditionalRenderState().setWireframe(true); DEBUG_YELLOW.setColor("Color", ColorRGBA.Yellow); DEBUG_MAGENTA = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_MAGENTA.getAdditionalRenderState().setWireframe(true); DEBUG_MAGENTA.setColor("Color", ColorRGBA.Magenta); DEBUG_PINK = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_PINK.getAdditionalRenderState().setWireframe(true); DEBUG_PINK.setColor("Color", ColorRGBA.Pink); }
/** * Initialize the materials. * * @param app the application which owns this state (not null) */ private void setupMaterials(Application app) { AssetManager manager = app.getAssetManager(); DEBUG_BLUE = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_BLUE.getAdditionalRenderState().setWireframe(true); DEBUG_BLUE.setColor("Color", ColorRGBA.Blue); DEBUG_GREEN = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_GREEN.getAdditionalRenderState().setWireframe(true); DEBUG_GREEN.setColor("Color", ColorRGBA.Green); DEBUG_RED = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_RED.getAdditionalRenderState().setWireframe(true); DEBUG_RED.setColor("Color", ColorRGBA.Red); DEBUG_YELLOW = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_YELLOW.getAdditionalRenderState().setWireframe(true); DEBUG_YELLOW.setColor("Color", ColorRGBA.Yellow); DEBUG_MAGENTA = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_MAGENTA.getAdditionalRenderState().setWireframe(true); DEBUG_MAGENTA.setColor("Color", ColorRGBA.Magenta); DEBUG_PINK = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); DEBUG_PINK.getAdditionalRenderState().setWireframe(true); DEBUG_PINK.setColor("Color", ColorRGBA.Pink); }