diff --git a/jme3-examples/src/main/java/jme3test/material/TestGeometryShader.java b/jme3-examples/src/main/java/jme3test/material/TestGeometryShader.java new file mode 100644 index 000000000..6ccedd1c3 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/material/TestGeometryShader.java @@ -0,0 +1,43 @@ +package jme3test.material; + +import com.jme3.app.SimpleApplication; +import com.jme3.bounding.BoundingBox; +import com.jme3.material.Material; +import com.jme3.material.RenderState; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.VertexBuffer; +import com.jme3.scene.shape.Sphere; +import com.jme3.util.BufferUtils; + +/** + * Created by michael on 23.02.15. + */ +public class TestGeometryShader extends SimpleApplication { + @Override + public void simpleInitApp() { + Mesh mesh = new Mesh(); + mesh.setBuffer(VertexBuffer.Type.Index, 1, BufferUtils.createIntBuffer(new int[]{1})); + mesh.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(new float[]{0, 0, 0})); + mesh.setMode(Mesh.Mode.Points); + mesh.setBound(new BoundingBox(new Vector3f(0, 0, 0), 10, 10, 10)); + mesh.updateCounts(); + Geometry geometry = new Geometry("Test", mesh); + geometry.updateGeometricState(); + geometry.setMaterial(new Material(assetManager, "Materials/Geom/SimpleGeom.j3md")); + //geometry.getMaterial().getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off); + //geometry.setMaterial(assetManager.loadMaterial("Materials/Geom/SimpleGeom.j3md")); + rootNode.attachChild(geometry); + + Geometry geometry1 = new Geometry("T1", new Sphere(10, 10, 1)); + geometry1.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md")); + rootNode.attachChild(geometry1); + + } + + public static void main(String[] args) { + TestGeometryShader app = new TestGeometryShader(); + app.start(); + } +} diff --git a/jme3-examples/src/main/java/jme3test/material/TestTesselation.java b/jme3-examples/src/main/java/jme3test/material/TestTesselation.java new file mode 100644 index 000000000..231eb5c41 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/material/TestTesselation.java @@ -0,0 +1,73 @@ +package jme3test.material; + +import com.jme3.app.SimpleApplication; +import com.jme3.light.DirectionalLight; +import com.jme3.material.Material; +import com.jme3.math.*; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.shape.Quad; +import com.jme3.texture.Texture; +import com.jme3.util.SkyFactory; +import com.jme3.util.TangentBinormalGenerator; + + +/** + * Created by michael on 23.02.15. + */ +public class TestTesselation extends SimpleApplication { + private Vector3f lightDir = new Vector3f(-1, -1, .5f).normalizeLocal(); + DirectionalLight dl; + + public void setupSkyBox() { + rootNode.attachChild(SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false)); + } + + + public void setupLighting() { + + dl = new DirectionalLight(); + dl.setDirection(lightDir); + dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); + rootNode.addLight(dl); + } + + void setupParallax() { + Material mat; + mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m"); + mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(Texture.WrapMode.Repeat); + mat.getTextureParam("NormalMap").getTextureValue().setWrap(Texture.WrapMode.Repeat); + + // Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml"); + //Geometry g = ((Geometry) floorGeom.getChild(0)); + //g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10)); + + Node floorGeom = new Node("floorGeom"); + Quad q = new Quad(100, 100); + q.scaleTextureCoordinates(new Vector2f(1, 1)); + Geometry g = new Geometry("geom", q); + g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X)); + floorGeom.attachChild(g); + + + TangentBinormalGenerator.generate(floorGeom); + floorGeom.setLocalTranslation(-50, 22, 60); + //floorGeom.setLocalScale(100); + + floorGeom.setMaterial(mat); + rootNode.attachChild(floorGeom); + } + + @Override + public void simpleInitApp() { + setupLighting(); + setupParallax(); + cam.setLocation(new Vector3f(-15.445636f, 30.162927f, 60.252777f)); + cam.setRotation(new Quaternion(0.05173137f, 0.92363626f, -0.13454558f, 0.35513034f)); + } + + public static void main(String[] args){ + TestTesselation app = new TestTesselation(); + app.start(); + } +}