public void simpleInitApp() { original = new Sphere(4, 4, 1); original.setStatic(); //original.setInterleaved(); // this will make sure all spheres are rendered always rootNode.setCullHint(CullHint.Never); solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m"); cam.setLocation(new Vector3f(0, 5, 0)); cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y); Logger.getLogger(Node.class.getName()).setLevel(Level.WARNING); Logger.getLogger(NativeObjectManager.class.getName()).setLevel(Level.WARNING); }
public void onAction(String name, boolean isPressed, float tpf) { if (isPressed) return; Material mat; if (isLit){ mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m"); debugTangents.setCullHint(CullHint.Inherit); }else{ mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setTexture("NormalMap", assetManager.loadTexture("Models/TangentBugs/test_normal.png")); debugTangents.setCullHint(CullHint.Always); } isLit = !isLit; badModel.setMaterial(mat); } }, "space");
guiNode.setCullHint(CullHint.Never); dummyCam = new Camera();
public void readScenes(JsonPrimitive defaultScene, Node rootNode) throws IOException { if (scenes == null) { //no scene... lets handle this later... throw new AssetLoadException("Gltf files with no scene is not yet supported"); } for (JsonElement scene : scenes) { Node sceneNode = new Node(); //specs says that only the default scene should be rendered, // if there are several scenes, they are attached to the rootScene, but they are culled sceneNode.setCullHint(Spatial.CullHint.Always); sceneNode.setName(getAsString(scene.getAsJsonObject(), "name")); JsonArray sceneNodes = scene.getAsJsonObject().getAsJsonArray("nodes"); sceneNode = customContentManager.readExtensionAndExtras("scene", scene, sceneNode); rootNode.attachChild(sceneNode); for (JsonElement node : sceneNodes) { readChild(sceneNode, node); } } //Setting the default scene cul hint to inherit. int activeChild = 0; if (defaultScene != null) { activeChild = defaultScene.getAsInt(); } rootNode.getChild(activeChild).setCullHint(Spatial.CullHint.Inherit); }
private void displayNormals(Spatial s) { final Node debugTangents = new Node("debug tangents"); debugTangents.setCullHint(Spatial.CullHint.Never); rootNode.attachChild(debugTangents); final Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debugMat.getAdditionalRenderState().setLineWidth(2); s.depthFirstTraversal(new SceneGraphVisitorAdapter() { @Override public void visit(Geometry g) { Mesh m = g.getMesh(); Geometry debug = new Geometry( "debug tangents geom", TangentBinormalGenerator.genNormalLines(m, 0.1f) ); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.setLocalTransform(g.getWorldTransform()); debugTangents.attachChild(debug); } }); }
/** * 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); }
/** * 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); }
@Override public void simpleInitApp() { viewPort.setBackgroundColor(ColorRGBA.Gray); cam.setLocation(new Vector3f(-5.6310086f, 5.0892987f, -13.000479f)); cam.setRotation(new Quaternion(0.1779095f, 0.20036356f, -0.03702727f, 0.96272093f)); cam.update(); cam.setFrustumFar(300); flyCam.setMoveSpeed(30); rootNode.setCullHint(CullHint.Never); setupLighting(); setupModel(); setupFilters(); }
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(-32.295086f, 54.80136f, 79.59805f)); cam.setRotation(new Quaternion(0.074364014f, 0.92519957f, -0.24794696f, 0.27748522f)); cam.update(); cam.setFrustumFar(300); flyCam.setMoveSpeed(30); rootNode.setCullHint(CullHint.Never); setupBasicShadow(); setupHdr(); setupLighting(); setupSkyBox(); // setupTerrain(); setupFloor(); // setupRobotGuy(); setupSignpost(); }
result.setCullHint(visible ? CullHint.Always : CullHint.Inherit); if (parent instanceof Node) { ((Node) parent).attachChild(result);
guiNode.setCullHint(CullHint.Never); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode);
debugTangents.setCullHint(CullHint.Always); rootNode.attachChild(debugTangents);
public void setVisible(boolean visible) { node.setCullHint(visible ? CullHint.Never : CullHint.Always); }
public void readScenes(JsonPrimitive defaultScene, Node rootNode) throws IOException { if (scenes == null) { //no scene... lets handle this later... throw new AssetLoadException("Gltf files with no scene is not yet supported"); } for (JsonElement scene : scenes) { Node sceneNode = new Node(); //specs says that only the default scene should be rendered, // if there are several scenes, they are attached to the rootScene, but they are culled sceneNode.setCullHint(Spatial.CullHint.Always); sceneNode.setName(getAsString(scene.getAsJsonObject(), "name")); JsonArray sceneNodes = scene.getAsJsonObject().getAsJsonArray("nodes"); sceneNode = customContentManager.readExtensionAndExtras("scene", scene, sceneNode); rootNode.attachChild(sceneNode); for (JsonElement node : sceneNodes) { readChild(sceneNode, node); } } //Setting the default scene cul hint to inherit. int activeChild = 0; if (defaultScene != null) { activeChild = defaultScene.getAsInt(); } rootNode.getChild(activeChild).setCullHint(Spatial.CullHint.Inherit); }
@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); }
/** * 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); }
@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; }
public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); // TODO: Fix frustum culling for parallel projection cameras. rootNode.setCullHint(CullHint.Never); rootNode.addLight(dl); rootNode.attachChild(teaGeom); flyCam.setDragToRotate(true); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-30, 30, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); // TODO: Fix frustum culling for parallel projection cameras. rootNode.setCullHint(CullHint.Never); rootNode.addLight(dl); rootNode.attachChild(teaGeom); flyCam.setDragToRotate(true); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-30, 30, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
@Override public void initialize() { super.initialize(); guiNode.setQueueBucket(Bucket.Gui); guiNode.setCullHint(CullHint.Never); loadFPSText(); loadStatsView(); viewPort.attachScene(rootNode); guiViewPort.attachScene(guiNode); if (inputManager != null) { flyCam = new FlyByCamera(cam); flyCam.setMoveSpeed(1f); flyCam.registerWithInput(inputManager); if (context.getType() == Type.Display) { inputManager.addMapping(INPUT_MAPPING_EXIT, new KeyTrigger(KeyInput.KEY_ESCAPE)); } inputManager.addMapping(INPUT_MAPPING_CAMERA_POS, new KeyTrigger(KeyInput.KEY_C)); inputManager.addMapping(INPUT_MAPPING_MEMORY, new KeyTrigger(KeyInput.KEY_M)); inputManager.addMapping(INPUT_MAPPING_HIDE_STATS, new KeyTrigger(KeyInput.KEY_F5)); inputManager.addListener(actionListener, INPUT_MAPPING_EXIT, INPUT_MAPPING_CAMERA_POS, INPUT_MAPPING_MEMORY, INPUT_MAPPING_HIDE_STATS); } // call user code simpleInitApp(); }