/** * 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 final AppStateManager getStateManager() { return app.getStateManager(); }
@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); }
@Override protected void initialize(Application app) { this.camera = app.getCamera(); this.listener = app.getListener(); }
@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 initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; if (app.getInputManager() != null) { if (flyCam == null) { flyCam = new FlyByCamera(app.getCamera()); } flyCam.registerWithInput(app.getInputManager()); } }
if (environment.getApplication() != null){ Camera clonecam = cam.clone(); ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam); clonecam.setParallelProjection(true); viewPort.setClearFlags(true, true, true); pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D)tex, false); viewPort.attachScene(pic); viewPort.setOutputFrameBuffer(null);
/** * 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 protected void initialize(Application app) { Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", new ColorRGBA(0, 0, 0, 0.5f)); mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); Geometry darkenStats = new Geometry("StatsDarken", new Quad(PANEL_WIDTH, app.getCamera().getHeight())); darkenStats.setMaterial(mat); darkenStats.setLocalTranslation(0, -app.getCamera().getHeight(), -1); ui.setLocalTranslation(app.getCamera().getWidth() - PANEL_WIDTH, app.getCamera().getHeight(), 0); font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt"); bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); prof.setRenderer(app.getRenderer()); rootLine = new StatLineView("Frame"); rootLine.attachTo(ui); ui.attachChild(hideInsignificantField); final InputManager inputManager = app.getInputManager(); if (inputManager != null) { inputManager.addMapping(TOGGLE_KEY, new KeyTrigger(KeyInput.KEY_F6));
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; }
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = app; this.oldTimer = app.getTimer(); app.setTimer(new IsoTimer(framerate)); if (file == null) { String filename = System.getProperty("user.home") + File.separator + "jMonkey-" + System.currentTimeMillis() / 1000 + ".avi"; file = new File(filename); } processor = new VideoProcessor(); List<ViewPort> vps = app.getRenderManager().getPostViews(); for (int i = vps.size() - 1; i >= 0; i-- ) { lastViewPort = vps.get(i); if (lastViewPort.isEnabled()) { break; } } lastViewPort.addProcessor(processor); }
private ViewPort setupViewBuffers(Camera cam, String viewName) { // TODO this function is identical to that in VRViewManagerOpenVR; merge the two. if (environment != null) { if (environment.getApplication() != null) { ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while (spatialIter.hasNext()) { viewPort.attachScene(spatialIter.next()); } // The viewbuffer to render into will be set during prerender. 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."); } } }
offCamera.lookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y); offView = environment.getApplication().getRenderManager().createPreView("GUI View", offCamera); offView.setClearFlags(true, true, true); offView.setBackgroundColor(ColorRGBA.BlackNoAlpha); Iterator<Spatial> spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ offView.attachScene(spatialIter.next()); guiQuad = (Geometry)environment.getApplication().getAssetManager().loadModel("Common/Util/gui_mesh.j3o"); } else { guiQuad = new Geometry("guiQuad", new CenterQuad(1f, 1f)); Material mat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/GuiOverlay.j3md"); mat.getAdditionalRenderState().setDepthTest(!overdraw); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
@Override public void initialize(AppStateManager stateManager, Application app) { if (!super.isInitialized()){ InputManager inputManager = app.getInputManager(); inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); inputManager.addListener(this, "ScreenShot"); List<ViewPort> vps = app.getRenderManager().getPostViews(); ViewPort last = vps.get(vps.size()-1); last.addProcessor(this); if (shotName == null) { shotName = app.getClass().getSimpleName(); } } super.initialize(stateManager, app); }
/** * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. * @return the scene observer. * @see #setObserver(Spatial) */ public Object getObserver() { if( observer == null ) { if (application != null){ return application.getCamera(); } else { throw new IllegalStateException("VR environment is not attached to any application."); } } return observer; }
@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 public void cleanup() { super.cleanup(); if (app.getInputManager() != null) { flyCam.unregisterInput(); } }
@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 run() { app.enqueue(new Callable<Void>() { @Override public Void call() throws Exception { listener.start(); return null; } }); store = generatePrefilteredEnvMap(sourceMap, targetMapSize, fixSeamsMethod, store); app.enqueue(new Callable<Void>() { @Override public Void call() throws Exception { listener.done(face); return null; } }); }
/** * 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); }