Java Code Examples for com.jme3.scene.Geometry#setCullHint()
The following examples show how to use
com.jme3.scene.Geometry#setCullHint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTangentGen.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void addMesh(String name, Mesh mesh, Vector3f translation) { TangentBinormalGenerator.generate(mesh); Geometry testGeom = new Geometry(name, mesh); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m"); testGeom.setMaterial(mat); testGeom.getLocalTranslation().set(translation); rootNode.attachChild(testGeom); Geometry debug = new Geometry( "Debug " + name, TangentBinormalGenerator.genTbnLines(mesh, 0.08f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(translation); rootNode.attachChild(debug); }
Example 2
Source File: StatsAppState.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); }
Example 3
Source File: TestTangentGen.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void addMesh(String name, Mesh mesh, Vector3f translation) { TangentBinormalGenerator.generate(mesh); Geometry testGeom = new Geometry(name, mesh); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m"); testGeom.setMaterial(mat); testGeom.getLocalTranslation().set(translation); rootNode.attachChild(testGeom); Geometry debug = new Geometry( "Debug " + name, TangentBinormalGenerator.genTbnLines(mesh, 0.08f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(translation); rootNode.attachChild(debug); }
Example 4
Source File: TerrainQuad.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void generateDebugTangents(Material mat) { for (int x = children.size(); --x >= 0;) { Spatial child = children.get(x); if (child instanceof TerrainQuad) { ((TerrainQuad)child).generateDebugTangents(mat); } else if (child instanceof TerrainPatch) { Geometry debug = new Geometry( "Debug " + name, TangentBinormalGenerator.genTbnLines( ((TerrainPatch)child).getMesh(), 0.8f)); attachChild(debug); debug.setLocalTranslation(child.getLocalTranslation()); debug.setCullHint(CullHint.Never); debug.setMaterial(mat); } } }
Example 5
Source File: TestTangentSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void createDebugTangents(Geometry geom) { Geometry debug = new Geometry( "Debug " + geom.getName(), TangentBinormalGenerator.genTbnLines(geom.getMesh(), 0.8f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(geom.getWorldTranslation()); debugNode.attachChild(debug); }
Example 6
Source File: AbstractShadowRendererVR.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * debug function to create a visible frustum */ protected Geometry createFrustum(Vector3f[] pts, int i) { WireFrustum frustum = new WireFrustum(pts); Geometry frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setShadowMode(ShadowMode.Off); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); frustumMdl.setMaterial(mat); switch (i) { case 0: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); break; case 1: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); break; case 2: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); break; case 3: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); break; default: frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); break; } frustumMdl.updateGeometricState(); return frustumMdl; }
Example 7
Source File: AbstractShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * debug function to create a visible frustum */ protected Geometry createFrustum(Vector3f[] pts, int i) { WireFrustum frustum = new WireFrustum(pts); Geometry frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setShadowMode(ShadowMode.Off); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); frustumMdl.setMaterial(mat); switch (i) { case 0: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); break; case 1: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); break; case 2: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); break; case 3: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); break; default: frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); break; } frustumMdl.updateGeometricState(); return frustumMdl; }
Example 8
Source File: PssmShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Geometry createFrustum(Vector3f[] pts, int i) { WireFrustum frustum = new WireFrustum(pts); Geometry frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setShadowMode(ShadowMode.Off); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); frustumMdl.setMaterial(mat); switch (i) { case 0: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); break; case 1: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); break; case 2: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); break; case 3: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); break; default: frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); break; } frustumMdl.updateGeometricState(); return frustumMdl; }
Example 9
Source File: PssmShadowRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private Geometry createFrustum(Vector3f[] pts, int i) { WireFrustum frustum = new WireFrustum(pts); Geometry frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setShadowMode(ShadowMode.Off); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); frustumMdl.setMaterial(mat); switch (i) { case 0: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink); break; case 1: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); break; case 2: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Green); break; case 3: frustumMdl.getMaterial().setColor("Color", ColorRGBA.Blue); break; default: frustumMdl.getMaterial().setColor("Color", ColorRGBA.White); break; } frustumMdl.updateGeometricState(); return frustumMdl; }
Example 10
Source File: TerrainQuad.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void generateDebugTangents(Material mat) { for (int x = children.size(); --x >= 0;) { Spatial child = children.get(x); if (child instanceof TerrainQuad) { ((TerrainQuad)child).generateDebugTangents(mat); } else if (child instanceof TerrainPatch) { Geometry debug = new Geometry( "Debug " + name, TangentBinormalGenerator.genTbnLines( ((TerrainPatch)child).getMesh(), 0.8f)); attachChild(debug); debug.setLocalTranslation(child.getLocalTranslation()); debug.setCullHint(CullHint.Never); debug.setMaterial(mat); } } }
Example 11
Source File: TestShadow.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void simpleInitApp() { // put the camera in a bad position cam.setLocation(new Vector3f(0.7804813f, 1.7502685f, -2.1556435f)); cam.setRotation(new Quaternion(0.1961598f, -0.7213164f, 0.2266092f, 0.6243975f)); cam.setFrustumFar(10); Material mat = assetManager.loadMaterial("Common/Materials/WhiteColor.j3m"); rootNode.setShadowMode(ShadowMode.Off); Box floor = new Box(Vector3f.ZERO, 3, 0.1f, 3); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setLocalTranslation(0,-0.2f,0); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); teapot.setLocalScale(2f); teapot.setMaterial(mat); teapot.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(teapot); // lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); // lightMdl.setMaterial(mat); // // disable shadowing for light representation // lightMdl.setShadowMode(ShadowMode.Off); // rootNode.attachChild(lightMdl); bsr = new BasicShadowRenderer(assetManager, 512); bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal()); viewPort.addProcessor(bsr); frustum = new WireFrustum(bsr.getPoints()); frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setShadowMode(ShadowMode.Off); frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true); frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); rootNode.attachChild(frustumMdl); }
Example 12
Source File: TestTangentGenBadUV.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); if (teapot instanceof Geometry){ Geometry g = (Geometry) teapot; TangentBinormalGenerator.generate(g.getMesh()); }else{ throw new RuntimeException(); } teapot.setLocalScale(2f); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m"); teapot.setMaterial(mat); rootNode.attachChild(teapot); Geometry debug = new Geometry( "Debug Teapot", TangentBinormalGenerator.genTbnLines(((Geometry) teapot).getMesh(), 0.03f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(teapot.getLocalTranslation()); debug.getLocalScale().set(teapot.getLocalScale()); rootNode.attachChild(debug); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal()); dl.setColor(ColorRGBA.White); rootNode.addLight(dl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); //pl.setRadius(3f); rootNode.addLight(pl); }
Example 13
Source File: TestBatchNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { timer = new NanoTimer(); batch = new BatchNode("theBatchNode"); /** * A cube with a color "bleeding" through transparent texture. Uses * Texture from jme3-test-data library! */ Box boxshape4 = new Box(1f, 1f, 1f); cube = new Geometry("cube1", boxshape4); Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); cube.setMaterial(mat); // Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); // mat.setColor("Diffuse", ColorRGBA.Blue); // mat.setBoolean("UseMaterialColors", true); /** * A cube with a color "bleeding" through transparent texture. Uses * Texture from jme3-test-data library! */ Box box = new Box(1f, 1f, 1f); cube2 = new Geometry("cube2", box); cube2.setMaterial(mat); TangentBinormalGenerator.generate(cube); TangentBinormalGenerator.generate(cube2); n = new Node("aNode"); // n.attachChild(cube2); batch.attachChild(cube); // batch.attachChild(cube2); // batch.setMaterial(mat); batch.batch(); rootNode.attachChild(batch); cube.setLocalTranslation(3, 0, 0); cube2.setLocalTranslation(0, 20, 0); updateBoindPoints(points); frustum = new WireFrustum(points); frustumMdl = new Geometry("f", frustum); frustumMdl.setCullHint(Spatial.CullHint.Never); frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true); frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red); rootNode.attachChild(frustumMdl); dl = new DirectionalLight(); dl.setColor(ColorRGBA.White.mult(2)); dl.setDirection(new Vector3f(1, -1, -1)); rootNode.addLight(dl); flyCam.setMoveSpeed(10); }
Example 14
Source File: TestTangentGenBadUV.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void simpleInitApp() { Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj"); if (teapot instanceof Geometry){ Geometry g = (Geometry) teapot; TangentBinormalGenerator.generate(g.getMesh()); }else{ throw new RuntimeException(); } teapot.setLocalScale(2f); Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m"); teapot.setMaterial(mat); rootNode.attachChild(teapot); Geometry debug = new Geometry( "Debug Teapot", TangentBinormalGenerator.genTbnLines(((Geometry) teapot).getMesh(), 0.03f) ); Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m"); debug.setMaterial(debugMat); debug.setCullHint(Spatial.CullHint.Never); debug.getLocalTranslation().set(teapot.getLocalTranslation()); debug.getLocalScale().set(teapot.getLocalScale()); rootNode.attachChild(debug); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal()); dl.setColor(ColorRGBA.White); rootNode.addLight(dl); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m")); lightMdl.getMesh().setStatic(); rootNode.attachChild(lightMdl); pl = new PointLight(); pl.setColor(ColorRGBA.White); //pl.setRadius(3f); rootNode.addLight(pl); }
Example 15
Source File: SkyFactory.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public static Spatial createSky(AssetManager assetManager, Texture west, Texture east, Texture north, Texture south, Texture up, Texture down, Vector3f normalScale, int sphereRadius) { final Sphere sphereMesh = new Sphere(10, 10, sphereRadius, false, true); Geometry sky = new Geometry("Sky", sphereMesh); sky.setQueueBucket(Bucket.Sky); sky.setCullHint(Spatial.CullHint.Never); sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO)); Image westImg = west.getImage(); Image eastImg = east.getImage(); Image northImg = north.getImage(); Image southImg = south.getImage(); Image upImg = up.getImage(); Image downImg = down.getImage(); checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg); Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null); cubeImage.addData(westImg.getData(0)); cubeImage.addData(eastImg.getData(0)); cubeImage.addData(downImg.getData(0)); cubeImage.addData(upImg.getData(0)); cubeImage.addData(southImg.getData(0)); cubeImage.addData(northImg.getData(0)); if (westImg.getEfficentData() != null){ // also consilidate efficient data ArrayList<Object> efficientData = new ArrayList<Object>(6); efficientData.add(westImg.getEfficentData()); efficientData.add(eastImg.getEfficentData()); efficientData.add(downImg.getEfficentData()); efficientData.add(upImg.getEfficentData()); efficientData.add(southImg.getEfficentData()); efficientData.add(northImg.getEfficentData()); cubeImage.setEfficentData(efficientData); } TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(0); cubeMap.setMagFilter(Texture.MagFilter.Bilinear); cubeMap.setMinFilter(Texture.MinFilter.NearestNoMipMaps); cubeMap.setWrap(Texture.WrapMode.EdgeClamp); Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md"); skyMat.setTexture("Texture", cubeMap); skyMat.setVector3("NormalScale", normalScale); sky.setMaterial(skyMat); return sky; }