* SimpleTextured, SolidColor, VertexColor, and WireColor are now obsolete. Using those materials will crash your application.
* Additional javadocs for Material * Added TestMusicStreaming git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7591 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
34c98682c1
commit
d03683deca
@ -80,11 +80,11 @@ public class SimpleTexturedTest extends SimpleApplication {
|
|||||||
material.setBoolean("LowQuality", true);
|
material.setBoolean("LowQuality", true);
|
||||||
material.setTexture("DiffuseMap", texture);
|
material.setTexture("DiffuseMap", texture);
|
||||||
} else {
|
} else {
|
||||||
material = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setTexture("ColorMap", texture);
|
material.setTexture("ColorMap", texture);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
material = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setColor("Color", ColorRGBA.Red);
|
material.setColor("Color", ColorRGBA.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -372,7 +372,7 @@ public class DataRepository {
|
|||||||
*/
|
*/
|
||||||
public synchronized Material getDefaultMaterial() {
|
public synchronized Material getDefaultMaterial() {
|
||||||
if(blenderKey.getDefaultMaterial() == null) {
|
if(blenderKey.getDefaultMaterial() == null) {
|
||||||
Material defaultMaterial = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material defaultMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
defaultMaterial.setColor("Color", ColorRGBA.DarkGray);
|
defaultMaterial.setColor("Color", ColorRGBA.DarkGray);
|
||||||
blenderKey.setDefaultMaterial(defaultMaterial);
|
blenderKey.setDefaultMaterial(defaultMaterial);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,13 +167,17 @@ public abstract class PhysicsCollisionObject implements Savable {
|
|||||||
* @param manager AssetManager to load the default wireframe material for the debug shape
|
* @param manager AssetManager to load the default wireframe material for the debug shape
|
||||||
*/
|
*/
|
||||||
protected Spatial attachDebugShape(AssetManager manager) {
|
protected Spatial attachDebugShape(AssetManager manager) {
|
||||||
debugMaterialBlue = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialBlue = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialBlue.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialBlue.setColor("Color", ColorRGBA.Blue);
|
debugMaterialBlue.setColor("Color", ColorRGBA.Blue);
|
||||||
debugMaterialGreen = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialGreen = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialGreen.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialGreen.setColor("Color", ColorRGBA.Green);
|
debugMaterialGreen.setColor("Color", ColorRGBA.Green);
|
||||||
debugMaterialRed = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialRed = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialRed.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialRed.setColor("Color", ColorRGBA.Red);
|
debugMaterialRed.setColor("Color", ColorRGBA.Red);
|
||||||
debugMaterialYellow = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialYellow = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialYellow.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialYellow.setColor("Color", ColorRGBA.Yellow);
|
debugMaterialYellow.setColor("Color", ColorRGBA.Yellow);
|
||||||
debugArrow = new Arrow(Vector3f.UNIT_XYZ);
|
debugArrow = new Arrow(Vector3f.UNIT_XYZ);
|
||||||
debugArrowGeom = new Geometry("DebugArrow", debugArrow);
|
debugArrowGeom = new Geometry("DebugArrow", debugArrow);
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
|
|
||||||
#ifdef HAS_GLOWMAP
|
#ifdef HAS_GLOWMAP
|
||||||
#if defined(NEED_TEXCOORD1)
|
#if defined(NEED_TEXCOORD1)
|
||||||
gl_FragColor = texture2D(m_GlowMap, texCoord1);
|
gl_FragColor = texture2D(m_GlowMap, texCoord1);
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
Exception SimpleTextured.j3md has been marked as obsolete. Please use Unshaded.j3md instead.
|
||||||
|
|
||||||
MaterialDef Plain Texture {
|
MaterialDef Plain Texture {
|
||||||
|
|
||||||
MaterialParameters {
|
MaterialParameters {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
Exception SolidColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.
|
||||||
|
|
||||||
MaterialDef Solid Color {
|
MaterialDef Solid Color {
|
||||||
|
|
||||||
MaterialParameters {
|
MaterialParameters {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
Exception VertexColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.
|
||||||
|
|
||||||
MaterialDef Vertex Color {
|
MaterialDef Vertex Color {
|
||||||
|
|
||||||
Technique {
|
Technique {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
Exception WireColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.
|
||||||
|
|
||||||
MaterialDef Wire Color {
|
MaterialDef Wire Color {
|
||||||
|
|
||||||
MaterialParameters {
|
MaterialParameters {
|
||||||
|
|||||||
@ -34,6 +34,7 @@ package com.jme3.material.plugins;
|
|||||||
|
|
||||||
import com.jme3.asset.AssetInfo;
|
import com.jme3.asset.AssetInfo;
|
||||||
import com.jme3.asset.AssetKey;
|
import com.jme3.asset.AssetKey;
|
||||||
|
import com.jme3.asset.AssetLoadException;
|
||||||
import com.jme3.material.*;
|
import com.jme3.material.*;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
@ -507,6 +508,9 @@ public class J3MLoader implements AssetLoader {
|
|||||||
extending = true;
|
extending = true;
|
||||||
}else if (word.equals("MaterialDef")){
|
}else if (word.equals("MaterialDef")){
|
||||||
extending = false;
|
extending = false;
|
||||||
|
}else if (word.equals("Exception")){
|
||||||
|
String exception = scan.nextLine();
|
||||||
|
throw new AssetLoadException(exception);
|
||||||
}else{
|
}else{
|
||||||
throw new IOException("Specified file is not a Material file");
|
throw new IOException("Specified file is not a Material file");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,7 +152,8 @@ public class MotionPath implements Savable {
|
|||||||
|
|
||||||
private Geometry CreateLinearPath() {
|
private Geometry CreateLinearPath() {
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
mat.setColor("Color", ColorRGBA.Blue);
|
mat.setColor("Color", ColorRGBA.Blue);
|
||||||
Geometry lineGeometry = new Geometry("line", new Curve(spline, 0));
|
Geometry lineGeometry = new Geometry("line", new Curve(spline, 0));
|
||||||
lineGeometry.setMaterial(mat);
|
lineGeometry.setMaterial(mat);
|
||||||
@ -161,7 +162,8 @@ public class MotionPath implements Savable {
|
|||||||
|
|
||||||
private Geometry CreateCatmullRomPath() {
|
private Geometry CreateCatmullRomPath() {
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
mat.setColor("Color", ColorRGBA.Blue);
|
mat.setColor("Color", ColorRGBA.Blue);
|
||||||
Geometry lineGeometry = new Geometry("line", new Curve(spline, 10));
|
Geometry lineGeometry = new Geometry("line", new Curve(spline, 10));
|
||||||
lineGeometry.setMaterial(mat);
|
lineGeometry.setMaterial(mat);
|
||||||
|
|||||||
@ -41,8 +41,6 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.shader.VarType;
|
|
||||||
import com.jme3.texture.Texture;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a font within jME that is generated with the AngelCode Bitmap Font Generator
|
* Represents a font within jME that is generated with the AngelCode Bitmap Font Generator
|
||||||
|
|||||||
@ -69,5 +69,5 @@ public enum FixedFuncBinding {
|
|||||||
*
|
*
|
||||||
* Same as GL_SHININESS for OpenGL.
|
* Same as GL_SHININESS for OpenGL.
|
||||||
*/
|
*/
|
||||||
Shininess
|
MaterialShininess
|
||||||
}
|
}
|
||||||
|
|||||||
67
engine/src/core/com/jme3/material/MatParamTexture.java
Normal file
67
engine/src/core/com/jme3/material/MatParamTexture.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package com.jme3.material;
|
||||||
|
|
||||||
|
import com.jme3.export.InputCapsule;
|
||||||
|
import com.jme3.export.JmeExporter;
|
||||||
|
import com.jme3.export.JmeImporter;
|
||||||
|
import com.jme3.export.OutputCapsule;
|
||||||
|
import com.jme3.renderer.Renderer;
|
||||||
|
import com.jme3.shader.VarType;
|
||||||
|
import com.jme3.texture.Texture;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class MatParamTexture extends MatParam {
|
||||||
|
|
||||||
|
private Texture texture;
|
||||||
|
private int unit;
|
||||||
|
|
||||||
|
public MatParamTexture(VarType type, String name, Texture texture, int unit) {
|
||||||
|
super(type, name, texture, null);
|
||||||
|
this.texture = texture;
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MatParamTexture() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture getTextureValue() {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextureValue(Texture value) {
|
||||||
|
this.value = value;
|
||||||
|
this.texture = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(int unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(Renderer r, Technique technique) {
|
||||||
|
TechniqueDef techDef = technique.getDef();
|
||||||
|
r.setTexture(getUnit(), getTextureValue());
|
||||||
|
if (techDef.isUsingShaders()) {
|
||||||
|
technique.updateUniformParam(getName(), getVarType(), getUnit(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(JmeExporter ex) throws IOException {
|
||||||
|
super.write(ex);
|
||||||
|
OutputCapsule oc = ex.getCapsule(this);
|
||||||
|
oc.write(unit, "texture_unit", -1);
|
||||||
|
oc.write(texture, "texture", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(JmeImporter im) throws IOException {
|
||||||
|
super.read(im);
|
||||||
|
InputCapsule ic = im.getCapsule(this);
|
||||||
|
unit = ic.readInt("texture_unit", -1);
|
||||||
|
texture = (Texture) ic.readSavable("texture", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -53,7 +53,10 @@ import com.jme3.math.Vector4f;
|
|||||||
import com.jme3.renderer.Caps;
|
import com.jme3.renderer.Caps;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.Renderer;
|
import com.jme3.renderer.Renderer;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.shader.Shader;
|
import com.jme3.shader.Shader;
|
||||||
import com.jme3.shader.Uniform;
|
import com.jme3.shader.Uniform;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
@ -68,6 +71,16 @@ import java.util.Map;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>Material</code> describes the rendering style for a given
|
||||||
|
* {@link Geometry}.
|
||||||
|
*
|
||||||
|
* <p>A material is essentially a list of {@link MatParam parameters}, those parameters
|
||||||
|
* map to uniforms which are defined in a shader.
|
||||||
|
* Setting the parameters can modify the behavior of a shader.
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class Material implements Cloneable, Savable, Comparable<Material> {
|
public class Material implements Cloneable, Savable, Comparable<Material> {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Material.class.getName());
|
private static final Logger logger = Logger.getLogger(Material.class.getName());
|
||||||
@ -98,70 +111,10 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
private int sortingId = -1;
|
private int sortingId = -1;
|
||||||
private transient ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
|
private transient ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1);
|
||||||
|
|
||||||
public static class MatParamTexture extends MatParam {
|
|
||||||
|
|
||||||
private Texture texture;
|
|
||||||
private int unit;
|
|
||||||
// private transient TextureKey key;
|
|
||||||
|
|
||||||
public MatParamTexture(VarType type, String name, Texture texture, int unit) {
|
|
||||||
super(type, name, texture, null);
|
|
||||||
this.texture = texture;
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MatParamTexture() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Texture getTextureValue() {
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextureValue(Texture value) {
|
|
||||||
this.value = value;
|
|
||||||
this.texture = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnit(int unit) {
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUnit() {
|
|
||||||
return unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(Renderer r, Technique technique) {
|
|
||||||
TechniqueDef techDef = technique.getDef();
|
|
||||||
r.setTexture(getUnit(), getTextureValue());
|
|
||||||
if (techDef.isUsingShaders()) {
|
|
||||||
technique.updateUniformParam(getName(), getVarType(), getUnit(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(JmeExporter ex) throws IOException {
|
|
||||||
super.write(ex);
|
|
||||||
OutputCapsule oc = ex.getCapsule(this);
|
|
||||||
oc.write(unit, "texture_unit", -1);
|
|
||||||
oc.write(texture, "texture", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(JmeImporter im) throws IOException {
|
|
||||||
super.read(im);
|
|
||||||
InputCapsule ic = im.getCapsule(this);
|
|
||||||
unit = ic.readInt("texture_unit", -1);
|
|
||||||
texture = (Texture) ic.readSavable("texture", null);
|
|
||||||
// key = texture.getTextureKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material(MaterialDef def) {
|
public Material(MaterialDef def) {
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
throw new NullPointerException("Material definition cannot be null");
|
throw new NullPointerException("Material definition cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.def = def;
|
this.def = def;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +128,36 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
public Material() {
|
public Material() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the asset key name of the asset from which this material was loaded.
|
||||||
|
*
|
||||||
|
* <p>This value will be <code>null</code> unless this material was loaded
|
||||||
|
* from a .j3m file.
|
||||||
|
*
|
||||||
|
* @return Asset key name of the j3m file
|
||||||
|
*/
|
||||||
public String getAssetName() {
|
public String getAssetName() {
|
||||||
return assetName;
|
return assetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the asset key name. This is used internally by the j3m material loader.
|
||||||
|
*
|
||||||
|
* @param assetName the asset key name
|
||||||
|
*/
|
||||||
public void setAssetName(String assetName) {
|
public void setAssetName(String assetName) {
|
||||||
this.assetName = assetName;
|
this.assetName = assetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the sorting ID or sorting index for this material.
|
||||||
|
*
|
||||||
|
* <p>The sorting ID is used internally by the system to sort rendering
|
||||||
|
* of geometries. It sorted to reduce shader switches, if the shaders
|
||||||
|
* are equal, then it is sorted by textures.
|
||||||
|
*
|
||||||
|
* @return The sorting ID used for sorting geometries for rendering.
|
||||||
|
*/
|
||||||
public int getSortId() {
|
public int getSortId() {
|
||||||
Technique t = getActiveTechnique();
|
Technique t = getActiveTechnique();
|
||||||
if (sortingId == -1 && t != null && t.getShader() != null) {
|
if (sortingId == -1 && t != null && t.getShader() != null) {
|
||||||
@ -204,14 +179,28 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return sortingId;
|
return sortingId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the sorting ID for each material to compare them.
|
||||||
|
*
|
||||||
|
* @param m The other material to compare to.
|
||||||
|
*
|
||||||
|
* @return zero if the materials are equal, returns a negative value
|
||||||
|
* if <code>this</code> has a lower sorting ID than <code>m</code>,
|
||||||
|
* otherwise returns a positive value.
|
||||||
|
*/
|
||||||
public int compareTo(Material m) {
|
public int compareTo(Material m) {
|
||||||
return m.getSortId() - getSortId();
|
return m.getSortId() - getSortId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones this material. The result
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Material clone() {
|
public Material clone() {
|
||||||
try {
|
try {
|
||||||
Material mat = (Material) super.clone();
|
Material mat = (Material) super.clone();
|
||||||
|
|
||||||
if (additionalState != null) {
|
if (additionalState != null) {
|
||||||
mat.additionalState = additionalState.clone();
|
mat.additionalState = additionalState.clone();
|
||||||
}
|
}
|
||||||
@ -234,30 +223,62 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return technique;
|
return technique;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Should only be used in Technique.makeCurrent()
|
|
||||||
* @param tech
|
|
||||||
*/
|
|
||||||
public void setActiveTechnique(Technique tech) {
|
|
||||||
technique = tech;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTransparent() {
|
public boolean isTransparent() {
|
||||||
return transparent;
|
return transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the transparent value marker.
|
||||||
|
*
|
||||||
|
* <p>This value is merely a marker, by itself it does nothing.
|
||||||
|
* Generally model loaders will use this marker to indicate further
|
||||||
|
* up that the material is transparent and therefore any geometries
|
||||||
|
* using it should be put into the {@link Bucket#Transparent transparent
|
||||||
|
* bucket}.
|
||||||
|
*
|
||||||
|
* @param transparent the transparent value marker.
|
||||||
|
*/
|
||||||
public void setTransparent(boolean transparent) {
|
public void setTransparent(boolean transparent) {
|
||||||
this.transparent = transparent;
|
this.transparent = transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the material should receive shadows or not.
|
||||||
|
*
|
||||||
|
* @return True if the material should receive shadows.
|
||||||
|
*
|
||||||
|
* @see Material#setReceivesShadows(boolean)
|
||||||
|
*/
|
||||||
public boolean isReceivesShadows() {
|
public boolean isReceivesShadows() {
|
||||||
return receivesShadows;
|
return receivesShadows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the material should receive shadows or not.
|
||||||
|
*
|
||||||
|
* <p>This value is merely a marker, by itself it does nothing.
|
||||||
|
* Generally model loaders will use this marker to indicate
|
||||||
|
* the material should receive shadows and therefore any
|
||||||
|
* geometries using it should have the {@link ShadowMode#Receive} set
|
||||||
|
* on them.
|
||||||
|
*
|
||||||
|
* @param receivesShadows if the material should receive shadows or not.
|
||||||
|
*/
|
||||||
public void setReceivesShadows(boolean receivesShadows) {
|
public void setReceivesShadows(boolean receivesShadows) {
|
||||||
this.receivesShadows = receivesShadows;
|
this.receivesShadows = receivesShadows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquire the additional {@link RenderState render state} to apply
|
||||||
|
* for this material.
|
||||||
|
*
|
||||||
|
* <p>The first call to this method will create an additional render
|
||||||
|
* state which can be modified by the user to apply any render
|
||||||
|
* states in addition to the ones used by the renderer. Only render
|
||||||
|
* states which are modified in the additional render state will be applied.
|
||||||
|
*
|
||||||
|
* @return The additional render state.
|
||||||
|
*/
|
||||||
public RenderState getAdditionalRenderState() {
|
public RenderState getAdditionalRenderState() {
|
||||||
if (additionalState == null) {
|
if (additionalState == null) {
|
||||||
additionalState = RenderState.ADDITIONAL.clone();
|
additionalState = RenderState.ADDITIONAL.clone();
|
||||||
@ -265,15 +286,16 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return additionalState;
|
return additionalState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the material definition (j3md file info) that <code>this</code>
|
||||||
|
* material is implementing.
|
||||||
|
*
|
||||||
|
* @return the material definition this material implements.
|
||||||
|
*/
|
||||||
public MaterialDef getMaterialDef() {
|
public MaterialDef getMaterialDef() {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void updateUniformLinks(){
|
|
||||||
// for (MatParam param : paramValues.values()){
|
|
||||||
// param.uniform = technique.getShader().getUniform(param.name);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
public MatParam getParam(String name) {
|
public MatParam getParam(String name) {
|
||||||
MatParam param = paramValues.get(name);
|
MatParam param = paramValues.get(name);
|
||||||
if (param instanceof MatParam) {
|
if (param instanceof MatParam) {
|
||||||
@ -924,7 +946,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
|
|
||||||
// the texture failed to load for this param
|
// the texture failed to load for this param
|
||||||
// do not add to param values
|
// do not add to param values
|
||||||
if (texVal.texture == null || texVal.texture.getImage() == null) {
|
if (texVal.getTextureValue() == null || texVal.getTextureValue().getImage() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1047,6 +1047,6 @@ public class RenderState implements Cloneable, Savable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RenderState[" + "pointSprite=" + pointSprite + "applyPointSprite=" + applyPointSprite + "wireframe=" + wireframe + "applyWireFrame=" + applyWireFrame + "cullMode=" + cullMode + "applyCullMode=" + applyCullMode + "depthWrite=" + depthWrite + "applyDepthWrite=" + applyDepthWrite + "depthTest=" + depthTest + "applyDepthTest=" + applyDepthTest + "colorWrite=" + colorWrite + "applyColorWrite=" + applyColorWrite + "blendMode=" + blendMode + "applyBlendMode=" + applyBlendMode + "alphaTest=" + alphaTest + "applyAlphaTest=" + applyAlphaTest + "alphaFallOff=" + alphaFallOff + "applyAlphaFallOff=" + applyAlphaFallOff + "offsetEnabled=" + offsetEnabled + "applyPolyOffset=" + applyPolyOffset + "offsetFactor=" + offsetFactor + "offsetUnits=" + offsetUnits + ']';
|
return "RenderState[\n" + "pointSprite=" + pointSprite + "\napplyPointSprite=" + applyPointSprite + "\nwireframe=" + wireframe + "\napplyWireFrame=" + applyWireFrame + "\ncullMode=" + cullMode + "\napplyCullMode=" + applyCullMode + "\ndepthWrite=" + depthWrite + "\napplyDepthWrite=" + applyDepthWrite + "\ndepthTest=" + depthTest + "\napplyDepthTest=" + applyDepthTest + "\ncolorWrite=" + colorWrite + "\napplyColorWrite=" + applyColorWrite + "\nblendMode=" + blendMode + "\napplyBlendMode=" + applyBlendMode + "\nalphaTest=" + alphaTest + "\napplyAlphaTest=" + applyAlphaTest + "\nalphaFallOff=" + alphaFallOff + "\napplyAlphaFallOff=" + applyAlphaFallOff + "\noffsetEnabled=" + offsetEnabled + "\napplyPolyOffset=" + applyPolyOffset + "\noffsetFactor=" + offsetFactor + "\noffsetUnits=" + offsetUnits + "\n]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -246,7 +246,9 @@ public class PssmShadowRenderer implements SceneProcessor {
|
|||||||
Geometry frustumMdl = new Geometry("f", frustum);
|
Geometry frustumMdl = new Geometry("f", frustum);
|
||||||
frustumMdl.setCullHint(Spatial.CullHint.Never);
|
frustumMdl.setCullHint(Spatial.CullHint.Never);
|
||||||
frustumMdl.setShadowMode(ShadowMode.Off);
|
frustumMdl.setShadowMode(ShadowMode.Off);
|
||||||
frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md"));
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
|
frustumMdl.setMaterial(mat);
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink);
|
frustumMdl.getMaterial().setColor("Color", ColorRGBA.Pink);
|
||||||
|
|||||||
@ -75,8 +75,8 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
private float speed, coreTime,coreTime2;
|
private float speed, coreTime,coreTime2;
|
||||||
private float camAngle = 0;
|
private float camAngle = 0;
|
||||||
private BitmapText fpsScoreText, pressStart;
|
private BitmapText fpsScoreText, pressStart;
|
||||||
private String boxSolid;
|
|
||||||
|
|
||||||
|
private boolean solidBox = true;
|
||||||
private Material playerMaterial;
|
private Material playerMaterial;
|
||||||
private Material floorMaterial;
|
private Material floorMaterial;
|
||||||
|
|
||||||
@ -133,7 +133,6 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
obstacleColors.add(ColorRGBA.Red);
|
obstacleColors.add(ColorRGBA.Red);
|
||||||
obstacleColors.add(ColorRGBA.Yellow);
|
obstacleColors.add(ColorRGBA.Yellow);
|
||||||
renderer.setBackgroundColor(ColorRGBA.White);
|
renderer.setBackgroundColor(ColorRGBA.White);
|
||||||
boxSolid = "Common/MatDefs/Misc/SolidColor.j3md";
|
|
||||||
speed = lowCap / 400f;
|
speed = lowCap / 400f;
|
||||||
coreTime = 20.0f;
|
coreTime = 20.0f;
|
||||||
coreTime2 = 10.0f;
|
coreTime2 = 10.0f;
|
||||||
@ -186,8 +185,10 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
|
|
||||||
// playerX+difficulty+30,playerX+difficulty+90
|
// playerX+difficulty+30,playerX+difficulty+90
|
||||||
|
|
||||||
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
Material mat = new Material(assetManager, boxSolid);
|
if (!solidBox){
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
|
}
|
||||||
mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1)));
|
mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1)));
|
||||||
cube.setMaterial(mat);
|
cube.setMaterial(mat);
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
Box b = new Box(loc, 1, 1, 1);
|
Box b = new Box(loc, 1, 1, 1);
|
||||||
|
|
||||||
Geometry geom = new Geometry("Box", b);
|
Geometry geom = new Geometry("Box", b);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.Blue);
|
mat.setColor("Color", ColorRGBA.Blue);
|
||||||
geom.setMaterial(mat);
|
geom.setMaterial(mat);
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
Dome b = new Dome(Vector3f.ZERO, 10, 100, 1);
|
Dome b = new Dome(Vector3f.ZERO, 10, 100, 1);
|
||||||
Geometry playerMesh = new Geometry("Box", b);
|
Geometry playerMesh = new Geometry("Box", b);
|
||||||
|
|
||||||
playerMaterial = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
playerMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
playerMaterial.setColor("Color", ColorRGBA.Red);
|
playerMaterial.setColor("Color", ColorRGBA.Red);
|
||||||
playerMesh.setMaterial(playerMaterial);
|
playerMesh.setMaterial(playerMaterial);
|
||||||
playerMesh.setName("player");
|
playerMesh.setName("player");
|
||||||
@ -221,7 +222,7 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
playerMesh.getLocalTranslation().getY() - 1, 0), 100, 0, 100);
|
playerMesh.getLocalTranslation().getY() - 1, 0), 100, 0, 100);
|
||||||
Geometry floorMesh = new Geometry("Box", floor);
|
Geometry floorMesh = new Geometry("Box", floor);
|
||||||
|
|
||||||
floorMaterial = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
floorMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
||||||
floorMesh.setMaterial(floorMaterial);
|
floorMesh.setMaterial(floorMaterial);
|
||||||
floorMesh.setName("floor");
|
floorMesh.setName("floor");
|
||||||
@ -335,7 +336,7 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
switch (colorInt){
|
switch (colorInt){
|
||||||
case 1:
|
case 1:
|
||||||
obstacleColors.clear();
|
obstacleColors.clear();
|
||||||
boxSolid(false);
|
solidBox = false;
|
||||||
obstacleColors.add(ColorRGBA.Green);
|
obstacleColors.add(ColorRGBA.Green);
|
||||||
renderer.setBackgroundColor(ColorRGBA.Black);
|
renderer.setBackgroundColor(ColorRGBA.Black);
|
||||||
playerMaterial.setColor("Color", ColorRGBA.White);
|
playerMaterial.setColor("Color", ColorRGBA.White);
|
||||||
@ -343,7 +344,7 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
obstacleColors.set(0, ColorRGBA.Black);
|
obstacleColors.set(0, ColorRGBA.Black);
|
||||||
boxSolid(true);
|
solidBox = true;
|
||||||
renderer.setBackgroundColor(ColorRGBA.White);
|
renderer.setBackgroundColor(ColorRGBA.White);
|
||||||
playerMaterial.setColor("Color", ColorRGBA.Gray);
|
playerMaterial.setColor("Color", ColorRGBA.Gray);
|
||||||
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
||||||
@ -361,12 +362,12 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
case 5:
|
case 5:
|
||||||
obstacleColors.remove(0);
|
obstacleColors.remove(0);
|
||||||
renderer.setBackgroundColor(ColorRGBA.Pink);
|
renderer.setBackgroundColor(ColorRGBA.Pink);
|
||||||
boxSolid(false);
|
solidBox = false;
|
||||||
playerMaterial.setColor("Color", ColorRGBA.White);
|
playerMaterial.setColor("Color", ColorRGBA.White);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
obstacleColors.set(0, ColorRGBA.White);
|
obstacleColors.set(0, ColorRGBA.White);
|
||||||
boxSolid(true);
|
solidBox = true;
|
||||||
renderer.setBackgroundColor(ColorRGBA.Black);
|
renderer.setBackgroundColor(ColorRGBA.Black);
|
||||||
playerMaterial.setColor("Color", ColorRGBA.Gray);
|
playerMaterial.setColor("Color", ColorRGBA.Gray);
|
||||||
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
floorMaterial.setColor("Color", ColorRGBA.LightGray);
|
||||||
@ -410,17 +411,4 @@ public class CubeField extends SimpleApplication implements AnalogListener {
|
|||||||
txt.setText(text);
|
txt.setText(text);
|
||||||
guiNode.attachChild(txt);
|
guiNode.attachChild(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the boolean variable boxSolid
|
|
||||||
* @param solid the boolean to determine if the boxes will be solid or wireFrame
|
|
||||||
*/
|
|
||||||
private void boxSolid(boolean solid) {
|
|
||||||
if (solid == false){
|
|
||||||
boxSolid = "Common/MatDefs/Misc/WireColor.j3md";
|
|
||||||
}else{
|
|
||||||
boxSolid = "Common/MatDefs/Misc/SolidColor.j3md";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -164,13 +164,17 @@ public abstract class PhysicsCollisionObject implements Savable {
|
|||||||
* @param manager AssetManager to load the default wireframe material for the debug shape
|
* @param manager AssetManager to load the default wireframe material for the debug shape
|
||||||
*/
|
*/
|
||||||
protected Spatial attachDebugShape(AssetManager manager) {
|
protected Spatial attachDebugShape(AssetManager manager) {
|
||||||
debugMaterialBlue = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialBlue = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialBlue.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialBlue.setColor("Color", ColorRGBA.Blue);
|
debugMaterialBlue.setColor("Color", ColorRGBA.Blue);
|
||||||
debugMaterialGreen = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialGreen = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialGreen.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialGreen.setColor("Color", ColorRGBA.Green);
|
debugMaterialGreen.setColor("Color", ColorRGBA.Green);
|
||||||
debugMaterialRed = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialRed = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialRed.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialRed.setColor("Color", ColorRGBA.Red);
|
debugMaterialRed.setColor("Color", ColorRGBA.Red);
|
||||||
debugMaterialYellow = new Material(manager, "Common/MatDefs/Misc/WireColor.j3md");
|
debugMaterialYellow = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
debugMaterialYellow.getAdditionalRenderState().setWireframe(true);
|
||||||
debugMaterialYellow.setColor("Color", ColorRGBA.Yellow);
|
debugMaterialYellow.setColor("Color", ColorRGBA.Yellow);
|
||||||
debugArrow = new Arrow(Vector3f.UNIT_XYZ);
|
debugArrow = new Arrow(Vector3f.UNIT_XYZ);
|
||||||
debugArrowGeom = new Geometry("DebugArrow", debugArrow);
|
debugArrowGeom = new Geometry("DebugArrow", debugArrow);
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import java.nio.IntBuffer;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import jme3tools.converters.MipMapGenerator;
|
import jme3tools.converters.MipMapGenerator;
|
||||||
|
import org.lwjgl.opengl.GL12;
|
||||||
import org.lwjgl.opengl.GLContext;
|
import org.lwjgl.opengl.GLContext;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
import static org.lwjgl.opengl.GL11.*;
|
||||||
@ -54,6 +55,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
private int maxCubeTexSize;
|
private int maxCubeTexSize;
|
||||||
private int maxVertCount;
|
private int maxVertCount;
|
||||||
private int maxTriCount;
|
private int maxTriCount;
|
||||||
|
private boolean gl12 = false;
|
||||||
private final Statistics statistics = new Statistics();
|
private final Statistics statistics = new Statistics();
|
||||||
private int vpX, vpY, vpW, vpH;
|
private int vpX, vpY, vpW, vpH;
|
||||||
private int clipX, clipY, clipW, clipH;
|
private int clipX, clipY, clipW, clipH;
|
||||||
@ -95,6 +97,10 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
+ "support non-power-of-2 textures. "
|
+ "support non-power-of-2 textures. "
|
||||||
+ "Some features might not work.");
|
+ "Some features might not work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GLContext.getCapabilities().OpenGL12){
|
||||||
|
gl12 = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidateState() {
|
public void invalidateState() {
|
||||||
@ -150,6 +156,15 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
glMaterial(GL_FRONT_AND_BACK, type, fb16);
|
glMaterial(GL_FRONT_AND_BACK, type, fb16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setMaterialFloat(int type, float value){
|
||||||
|
if (!materialSet) {
|
||||||
|
materialSet = true;
|
||||||
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
glMaterialf(GL_FRONT_AND_BACK, type, value);
|
||||||
|
}
|
||||||
|
|
||||||
public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) {
|
public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) {
|
||||||
switch (ffBinding) {
|
switch (ffBinding) {
|
||||||
case Color:
|
case Color:
|
||||||
@ -169,6 +184,11 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
ColorRGBA specular = (ColorRGBA) val;
|
ColorRGBA specular = (ColorRGBA) val;
|
||||||
setMaterialColor(GL_SPECULAR, specular);
|
setMaterialColor(GL_SPECULAR, specular);
|
||||||
break;
|
break;
|
||||||
|
case MaterialShininess:
|
||||||
|
float shiny = (Float) val;
|
||||||
|
setMaterialFloat(GL_SPECULAR, shiny);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,9 +423,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// glEnable(GL_LIGHTING);
|
//glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
//TODO: ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int convertTextureType(Texture.Type type) {
|
private int convertTextureType(Texture.Type type) {
|
||||||
@ -455,6 +473,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
switch (mode) {
|
switch (mode) {
|
||||||
case EdgeClamp:
|
case EdgeClamp:
|
||||||
case Clamp:
|
case Clamp:
|
||||||
|
case BorderClamp:
|
||||||
return GL_CLAMP;
|
return GL_CLAMP;
|
||||||
case Repeat:
|
case Repeat:
|
||||||
return GL_REPEAT;
|
return GL_REPEAT;
|
||||||
@ -611,7 +630,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
setupTextureParams(tex);
|
setupTextureParams(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTexturingUsed() {
|
private void clearTextureUnits() {
|
||||||
Image[] textures = context.boundTextures;
|
Image[] textures = context.boundTextures;
|
||||||
if (textures[0] != null) {
|
if (textures[0] != null) {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
@ -866,8 +885,10 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
} else {
|
} else {
|
||||||
glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
|
glDrawArrays(convertElementMode(mesh.getMode()), 0, mesh.getVertexCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Fix these to use IDList??
|
||||||
clearVertexAttribs();
|
clearVertexAttribs();
|
||||||
checkTexturingUsed();
|
clearTextureUnits();
|
||||||
clearSetFixedFuncBindings();
|
clearSetFixedFuncBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,7 +908,7 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
|||||||
|
|
||||||
boolean dynamic = false;
|
boolean dynamic = false;
|
||||||
if (mesh.getBuffer(Type.InterleavedData) != null) {
|
if (mesh.getBuffer(Type.InterleavedData) != null) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException("Interleaved meshes are not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.getNumLodLevels() == 0) {
|
if (mesh.getNumLodLevels() == 0) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Material HDR Picture : Common/MatDefs/Misc/SimpleTextured.j3md {
|
Material HDR Picture : Common/MatDefs/Misc/Unshaded.j3md {
|
||||||
MaterialParameters {
|
MaterialParameters {
|
||||||
ColorMap : Flip Textures/HdrTest/Memorial.hdr
|
ColorMap : Flip Textures/HdrTest/Memorial.hdr
|
||||||
}
|
}
|
||||||
|
|||||||
55
engine/src/test/jme3test/audio/TestMusicStreaming.java
Normal file
55
engine/src/test/jme3test/audio/TestMusicStreaming.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2010 jMonkeyEngine
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package jme3test.audio;
|
||||||
|
|
||||||
|
import com.jme3.asset.plugins.UrlLocator;
|
||||||
|
import com.jme3.audio.AudioNode;
|
||||||
|
|
||||||
|
public class TestMusicStreaming extends AudioApp {
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
TestMusicStreaming test = new TestMusicStreaming();
|
||||||
|
test.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateAudioApp(float tpf){
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initAudioApp(){
|
||||||
|
assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class);
|
||||||
|
AudioNode src = new AudioNode(audioRenderer, assetManager, "Lumme-Badloop.ogg", true);
|
||||||
|
audioRenderer.playSource(src);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -61,7 +61,7 @@ public class TestSafeCanvas extends SimpleApplication {
|
|||||||
|
|
||||||
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
||||||
Geometry geom = new Geometry("Box", b);
|
Geometry geom = new Geometry("Box", b);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
geom.setMaterial(mat);
|
geom.setMaterial(mat);
|
||||||
rootNode.attachChild(geom);
|
rootNode.attachChild(geom);
|
||||||
|
|||||||
@ -22,8 +22,8 @@ public class Pivot extends Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assignPoints(AssetManager assetManager) {
|
private void assignPoints(AssetManager assetManager) {
|
||||||
Material defaultMaterial = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material defaultMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
defaultMaterial.setColor("m_Color", ColorRGBA.DarkGray);
|
defaultMaterial.setColor("Color", ColorRGBA.DarkGray);
|
||||||
for(int i = -10; i <= 10; ++i) {
|
for(int i = -10; i <= 10; ++i) {
|
||||||
Geometry g = new Geometry("", new Sphere(3, 3, 0.05f));
|
Geometry g = new Geometry("", new Sphere(3, 3, 0.05f));
|
||||||
g.setLocalTranslation(i, 0, 0);
|
g.setLocalTranslation(i, 0, 0);
|
||||||
@ -44,8 +44,8 @@ public class Pivot extends Node {
|
|||||||
|
|
||||||
private Geometry getAxis(String name, Vector3f endPoint, ColorRGBA color, AssetManager assetManager) {
|
private Geometry getAxis(String name, Vector3f endPoint, ColorRGBA color, AssetManager assetManager) {
|
||||||
Line axis = new Line(new Vector3f(0, 0, 0), endPoint);
|
Line axis = new Line(new Vector3f(0, 0, 0), endPoint);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("m_Color", color);
|
mat.setColor("Color", color);
|
||||||
Geometry geom = new Geometry(name, axis);
|
Geometry geom = new Geometry(name, axis);
|
||||||
geom.setMaterial(mat);
|
geom.setMaterial(mat);
|
||||||
return geom;
|
return geom;
|
||||||
|
|||||||
@ -19,11 +19,11 @@ public class VisibleBone extends Node {
|
|||||||
private Vector3f globalPosition;
|
private Vector3f globalPosition;
|
||||||
|
|
||||||
public VisibleBone(Bone bone, Vector3f parentLocation, Quaternion parentRotation, AssetManager assetManager) {
|
public VisibleBone(Bone bone, Vector3f parentLocation, Quaternion parentRotation, AssetManager assetManager) {
|
||||||
Material redMat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material redMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
redMat.setColor("m_Color", ColorRGBA.Red);
|
redMat.setColor("Color", ColorRGBA.Red);
|
||||||
|
|
||||||
Material whiteMat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material whiteMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
whiteMat.setColor("m_Color", ColorRGBA.White);
|
whiteMat.setColor("Color", ColorRGBA.White);
|
||||||
|
|
||||||
Geometry g = new Geometry(bone.getName(), new Sphere(9, 9, 0.01f));
|
Geometry g = new Geometry(bone.getName(), new Sphere(9, 9, 0.01f));
|
||||||
globalPosition = bone.getLocalPosition().add(parentLocation);
|
globalPosition = bone.getLocalPosition().add(parentLocation);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class PhysicsTestHelper {
|
|||||||
light.setColor(ColorRGBA.LightGray);
|
light.setColor(ColorRGBA.LightGray);
|
||||||
rootNode.addLight(light);
|
rootNode.addLight(light);
|
||||||
|
|
||||||
Material material = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
|
|
||||||
Box floorBox = new Box(140, 0.25f, 140);
|
Box floorBox = new Box(140, 0.25f, 140);
|
||||||
@ -85,7 +85,7 @@ public class PhysicsTestHelper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Geometry createPhysicsTestBox(AssetManager assetManager) {
|
public static Geometry createPhysicsTestBox(AssetManager assetManager) {
|
||||||
Material material = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
Box box = new Box(0.25f, 0.25f, 0.25f);
|
Box box = new Box(0.25f, 0.25f, 0.25f);
|
||||||
Geometry boxGeometry = new Geometry("Box", box);
|
Geometry boxGeometry = new Geometry("Box", box);
|
||||||
@ -101,7 +101,7 @@ public class PhysicsTestHelper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Geometry createPhysicsTestSphere(AssetManager assetManager) {
|
public static Geometry createPhysicsTestSphere(AssetManager assetManager) {
|
||||||
Material material = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
Sphere sphere = new Sphere(8, 8, 0.25f);
|
Sphere sphere = new Sphere(8, 8, 0.25f);
|
||||||
Geometry boxGeometry = new Geometry("Sphere", sphere);
|
Geometry boxGeometry = new Geometry("Sphere", sphere);
|
||||||
@ -137,7 +137,7 @@ public class PhysicsTestHelper {
|
|||||||
public void onAction(String name, boolean keyPressed, float tpf) {
|
public void onAction(String name, boolean keyPressed, float tpf) {
|
||||||
Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
|
Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||||
bullet.setTextureMode(TextureMode.Projected);
|
bullet.setTextureMode(TextureMode.Projected);
|
||||||
Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||||
key2.setGenerateMips(true);
|
key2.setGenerateMips(true);
|
||||||
Texture tex2 = app.getAssetManager().loadTexture(key2);
|
Texture tex2 = app.getAssetManager().loadTexture(key2);
|
||||||
|
|||||||
@ -127,7 +127,8 @@ public class TestAttachDriver extends SimpleApplication implements ActionListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildPlayer() {
|
private void buildPlayer() {
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
mat.setColor("Color", ColorRGBA.Red);
|
mat.setColor("Color", ColorRGBA.Red);
|
||||||
|
|
||||||
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
|
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
|
||||||
|
|||||||
@ -97,10 +97,6 @@ public class TestAttachGhostObject extends SimpleApplication implements AnalogLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupJoint() {
|
public void setupJoint() {
|
||||||
|
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat.setColor("Color", ColorRGBA.Gray);
|
|
||||||
|
|
||||||
Node holderNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.1f, .1f, .1f)), 0);
|
Node holderNode = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(.1f, .1f, .1f)), 0);
|
||||||
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, 0, 0f));
|
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, 0, 0f));
|
||||||
rootNode.attachChild(holderNode);
|
rootNode.attachChild(holderNode);
|
||||||
|
|||||||
@ -112,7 +112,8 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
//debug view
|
//debug view
|
||||||
AnimControl control = model.getControl(AnimControl.class);
|
AnimControl control = model.getControl(AnimControl.class);
|
||||||
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
|
SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
|
||||||
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
Material mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat2.getAdditionalRenderState().setWireframe(true);
|
||||||
mat2.setColor("Color", ColorRGBA.Green);
|
mat2.setColor("Color", ColorRGBA.Green);
|
||||||
mat2.getAdditionalRenderState().setDepthTest(false);
|
mat2.getAdditionalRenderState().setDepthTest(false);
|
||||||
skeletonDebug.setMaterial(mat2);
|
skeletonDebug.setMaterial(mat2);
|
||||||
@ -238,7 +239,7 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
|
|||||||
|
|
||||||
public void initMaterial() {
|
public void initMaterial() {
|
||||||
|
|
||||||
matBullet = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
matBullet = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||||
key2.setGenerateMips(true);
|
key2.setGenerateMips(true);
|
||||||
Texture tex2 = assetManager.loadTexture(key2);
|
Texture tex2 = assetManager.loadTexture(key2);
|
||||||
|
|||||||
@ -190,19 +190,19 @@ public class TestBrickTower extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initMaterial() {
|
public void initMaterial() {
|
||||||
mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
||||||
key.setGenerateMips(true);
|
key.setGenerateMips(true);
|
||||||
Texture tex = assetManager.loadTexture(key);
|
Texture tex = assetManager.loadTexture(key);
|
||||||
mat.setTexture("ColorMap", tex);
|
mat.setTexture("ColorMap", tex);
|
||||||
|
|
||||||
mat2 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||||
key2.setGenerateMips(true);
|
key2.setGenerateMips(true);
|
||||||
Texture tex2 = assetManager.loadTexture(key2);
|
Texture tex2 = assetManager.loadTexture(key2);
|
||||||
mat2.setTexture("ColorMap", tex2);
|
mat2.setTexture("ColorMap", tex2);
|
||||||
|
|
||||||
mat3 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
||||||
key3.setGenerateMips(true);
|
key3.setGenerateMips(true);
|
||||||
Texture tex3 = assetManager.loadTexture(key3);
|
Texture tex3 = assetManager.loadTexture(key3);
|
||||||
|
|||||||
@ -164,19 +164,19 @@ public class TestBrickWall extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initMaterial() {
|
public void initMaterial() {
|
||||||
mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
||||||
key.setGenerateMips(true);
|
key.setGenerateMips(true);
|
||||||
Texture tex = assetManager.loadTexture(key);
|
Texture tex = assetManager.loadTexture(key);
|
||||||
mat.setTexture("ColorMap", tex);
|
mat.setTexture("ColorMap", tex);
|
||||||
|
|
||||||
mat2 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||||
key2.setGenerateMips(true);
|
key2.setGenerateMips(true);
|
||||||
Texture tex2 = assetManager.loadTexture(key2);
|
Texture tex2 = assetManager.loadTexture(key2);
|
||||||
mat2.setTexture("ColorMap", tex2);
|
mat2.setTexture("ColorMap", tex2);
|
||||||
|
|
||||||
mat3 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
||||||
key3.setGenerateMips(true);
|
key3.setGenerateMips(true);
|
||||||
Texture tex3 = assetManager.loadTexture(key3);
|
Texture tex3 = assetManager.loadTexture(key3);
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package jme3test.bullet;
|
package jme3test.bullet;
|
||||||
|
|
||||||
import com.jme3.bullet.BulletAppState;
|
import com.jme3.bullet.BulletAppState;
|
||||||
@ -57,7 +56,7 @@ import com.jme3.scene.shape.Sphere.TextureMode;
|
|||||||
*
|
*
|
||||||
* @author normenhansen
|
* @author normenhansen
|
||||||
*/
|
*/
|
||||||
public class TestCcd extends SimpleApplication implements ActionListener{
|
public class TestCcd extends SimpleApplication implements ActionListener {
|
||||||
|
|
||||||
private Material mat;
|
private Material mat;
|
||||||
private Material mat2;
|
private Material mat2;
|
||||||
@ -87,17 +86,19 @@ public class TestCcd extends SimpleApplication implements ActionListener{
|
|||||||
bulletCollisionShape = new SphereCollisionShape(0.1f);
|
bulletCollisionShape = new SphereCollisionShape(0.1f);
|
||||||
setupKeys();
|
setupKeys();
|
||||||
|
|
||||||
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
mat.setColor("Color", ColorRGBA.Green);
|
mat.setColor("Color", ColorRGBA.Green);
|
||||||
|
|
||||||
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat2.getAdditionalRenderState().setWireframe(true);
|
||||||
mat2.setColor("Color", ColorRGBA.Red);
|
mat2.setColor("Color", ColorRGBA.Red);
|
||||||
|
|
||||||
// An obstacle mesh, does not move (mass=0)
|
// An obstacle mesh, does not move (mass=0)
|
||||||
Node node2 = new Node();
|
Node node2 = new Node();
|
||||||
node2.setName("mesh");
|
node2.setName("mesh");
|
||||||
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
|
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
|
||||||
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO,4,4,0.1f)), 0));
|
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO, 4, 4, 0.1f)), 0));
|
||||||
rootNode.attachChild(node2);
|
rootNode.attachChild(node2);
|
||||||
getPhysicsSpace().add(node2);
|
getPhysicsSpace().add(node2);
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ public class TestCcd extends SimpleApplication implements ActionListener{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PhysicsSpace getPhysicsSpace(){
|
private PhysicsSpace getPhysicsSpace() {
|
||||||
return bulletAppState.getPhysicsSpace();
|
return bulletAppState.getPhysicsSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,8 +137,7 @@ public class TestCcd extends SimpleApplication implements ActionListener{
|
|||||||
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
||||||
rootNode.attachChild(bulletg);
|
rootNode.attachChild(bulletg);
|
||||||
getPhysicsSpace().add(bulletg);
|
getPhysicsSpace().add(bulletg);
|
||||||
}
|
} else if (binding.equals("shoot2") && !value) {
|
||||||
else if(binding.equals("shoot2") && !value) {
|
|
||||||
Geometry bulletg = new Geometry("bullet", bullet);
|
Geometry bulletg = new Geometry("bullet", bullet);
|
||||||
bulletg.setMaterial(mat2);
|
bulletg.setMaterial(mat2);
|
||||||
bulletg.setName("bullet");
|
bulletg.setName("bullet");
|
||||||
@ -149,5 +149,4 @@ public class TestCcd extends SimpleApplication implements ActionListener{
|
|||||||
getPhysicsSpace().add(bulletg);
|
getPhysicsSpace().add(bulletg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,11 +64,7 @@ public class TestCollisionGroups extends SimpleApplication {
|
|||||||
bulletAppState = new BulletAppState();
|
bulletAppState = new BulletAppState();
|
||||||
stateManager.attach(bulletAppState);
|
stateManager.attach(bulletAppState);
|
||||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat.setColor("Color", ColorRGBA.Red);
|
|
||||||
Material mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat2.setColor("Color", ColorRGBA.Magenta);
|
|
||||||
|
|
||||||
// Add a physics sphere to the world
|
// Add a physics sphere to the world
|
||||||
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||||
physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
|
physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
|
||||||
|
|||||||
@ -51,7 +51,6 @@ import com.jme3.scene.shape.Sphere.TextureMode;
|
|||||||
public class TestCollisionListener extends SimpleApplication implements PhysicsCollisionListener {
|
public class TestCollisionListener extends SimpleApplication implements PhysicsCollisionListener {
|
||||||
|
|
||||||
private BulletAppState bulletAppState;
|
private BulletAppState bulletAppState;
|
||||||
private Material mat;
|
|
||||||
private Sphere bullet;
|
private Sphere bullet;
|
||||||
private SphereCollisionShape bulletCollisionShape;
|
private SphereCollisionShape bulletCollisionShape;
|
||||||
|
|
||||||
@ -72,9 +71,6 @@ public class TestCollisionListener extends SimpleApplication implements PhysicsC
|
|||||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||||
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
|
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
|
||||||
|
|
||||||
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat.setColor("Color", ColorRGBA.Red);
|
|
||||||
|
|
||||||
// add ourselves as collision listener
|
// add ourselves as collision listener
|
||||||
getPhysicsSpace().addCollisionListener(this);
|
getPhysicsSpace().addCollisionListener(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,8 +105,6 @@ public class TestGhostObject extends SimpleApplication {
|
|||||||
|
|
||||||
private void initGhostObject() {
|
private void initGhostObject() {
|
||||||
Vector3f halfExtents = new Vector3f(3, 4.2f, 1);
|
Vector3f halfExtents = new Vector3f(3, 4.2f, 1);
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat.setColor("Color", ColorRGBA.Red);
|
|
||||||
ghostControl = new GhostControl(new BoxCollisionShape(halfExtents));
|
ghostControl = new GhostControl(new BoxCollisionShape(halfExtents));
|
||||||
Node node=new Node("Ghost Object");
|
Node node=new Node("Ghost Object");
|
||||||
node.addControl(ghostControl);
|
node.addControl(ghostControl);
|
||||||
|
|||||||
@ -81,7 +81,6 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
|
|||||||
private Spatial spaceCraft;
|
private Spatial spaceCraft;
|
||||||
TerrainQuad terrain;
|
TerrainQuad terrain;
|
||||||
Material matRock;
|
Material matRock;
|
||||||
Material matWire;
|
|
||||||
boolean wireframe = false;
|
boolean wireframe = false;
|
||||||
protected BitmapText hintText;
|
protected BitmapText hintText;
|
||||||
PointLight pl;
|
PointLight pl;
|
||||||
@ -281,8 +280,6 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
|
|||||||
matRock.setTexture("NormalMap_1", normalMap2);
|
matRock.setTexture("NormalMap_1", normalMap2);
|
||||||
matRock.setTexture("NormalMap_2", normalMap2);
|
matRock.setTexture("NormalMap_2", normalMap2);
|
||||||
|
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
||||||
|
|||||||
@ -95,7 +95,8 @@ public class TestPhysicsCar extends SimpleApplication implements ActionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildPlayer() {
|
private void buildPlayer() {
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.getAdditionalRenderState().setWireframe(true);
|
||||||
mat.setColor("Color", ColorRGBA.Red);
|
mat.setColor("Color", ColorRGBA.Red);
|
||||||
|
|
||||||
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
|
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
|
||||||
|
|||||||
@ -88,10 +88,6 @@ public class TestPhysicsHingeJoint extends SimpleApplication implements AnalogLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupJoint() {
|
public void setupJoint() {
|
||||||
|
|
||||||
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
mat.setColor("Color", ColorRGBA.Yellow);
|
|
||||||
|
|
||||||
Node holderNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
|
Node holderNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
|
||||||
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f));
|
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f));
|
||||||
rootNode.attachChild(holderNode);
|
rootNode.attachChild(holderNode);
|
||||||
|
|||||||
@ -98,7 +98,6 @@ public class TestWalkingChar extends SimpleApplication implements ActionListener
|
|||||||
RigidBodyControl terrainPhysicsNode;
|
RigidBodyControl terrainPhysicsNode;
|
||||||
//Materials
|
//Materials
|
||||||
Material matRock;
|
Material matRock;
|
||||||
Material matWire;
|
|
||||||
Material matBullet;
|
Material matBullet;
|
||||||
//animation
|
//animation
|
||||||
AnimChannel animationChannel;
|
AnimChannel animationChannel;
|
||||||
@ -202,7 +201,7 @@ public class TestWalkingChar extends SimpleApplication implements ActionListener
|
|||||||
bullet = new Sphere(32, 32, 0.4f, true, false);
|
bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||||
bullet.setTextureMode(TextureMode.Projected);
|
bullet.setTextureMode(TextureMode.Projected);
|
||||||
bulletCollisionShape = new SphereCollisionShape(0.4f);
|
bulletCollisionShape = new SphereCollisionShape(0.4f);
|
||||||
matBullet = new Material(getAssetManager(), "Common/MatDefs/Misc/SolidColor.j3md");
|
matBullet = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
matBullet.setColor("Color", ColorRGBA.Green);
|
matBullet.setColor("Color", ColorRGBA.Green);
|
||||||
matBullet.setColor("m_GlowColor", ColorRGBA.Green);
|
matBullet.setColor("m_GlowColor", ColorRGBA.Green);
|
||||||
getPhysicsSpace().addCollisionListener(this);
|
getPhysicsSpace().addCollisionListener(this);
|
||||||
@ -272,8 +271,6 @@ public class TestWalkingChar extends SimpleApplication implements ActionListener
|
|||||||
matRock.setTexture("NormalMap", normalMap0);
|
matRock.setTexture("NormalMap", normalMap0);
|
||||||
matRock.setTexture("NormalMap_1", normalMap2);
|
matRock.setTexture("NormalMap_1", normalMap2);
|
||||||
matRock.setTexture("NormalMap_2", normalMap2);
|
matRock.setTexture("NormalMap_2", normalMap2);
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
|
||||||
|
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public class TestMousePick extends SimpleApplication {
|
|||||||
protected Geometry makeCube(String name, float x, float y, float z) {
|
protected Geometry makeCube(String name, float x, float y, float z) {
|
||||||
Box box = new Box(new Vector3f(x, y, z), 1, 1, 1);
|
Box box = new Box(new Vector3f(x, y, z), 1, 1, 1);
|
||||||
Geometry cube = new Geometry(name, box);
|
Geometry cube = new Geometry(name, box);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.randomColor());
|
mat1.setColor("Color", ColorRGBA.randomColor());
|
||||||
cube.setMaterial(mat1);
|
cube.setMaterial(mat1);
|
||||||
return cube;
|
return cube;
|
||||||
@ -120,7 +120,7 @@ public class TestMousePick extends SimpleApplication {
|
|||||||
protected Geometry makeFloor() {
|
protected Geometry makeFloor() {
|
||||||
Box box = new Box(new Vector3f(0, -4, -5), 15, .2f, 15);
|
Box box = new Box(new Vector3f(0, -4, -5), 15, .2f, 15);
|
||||||
Geometry floor = new Geometry("the Floor", box);
|
Geometry floor = new Geometry("the Floor", box);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.Gray);
|
mat1.setColor("Color", ColorRGBA.Gray);
|
||||||
floor.setMaterial(mat1);
|
floor.setMaterial(mat1);
|
||||||
return floor;
|
return floor;
|
||||||
@ -134,7 +134,7 @@ public class TestMousePick extends SimpleApplication {
|
|||||||
//Sphere sphere = new Sphere(30, 30, 0.2f);
|
//Sphere sphere = new Sphere(30, 30, 0.2f);
|
||||||
mark = new Geometry("BOOM!", arrow);
|
mark = new Geometry("BOOM!", arrow);
|
||||||
//mark = new Geometry("BOOM!", sphere);
|
//mark = new Geometry("BOOM!", sphere);
|
||||||
Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mark_mat.setColor("Color", ColorRGBA.Red);
|
mark_mat.setColor("Color", ColorRGBA.Red);
|
||||||
mark.setMaterial(mark_mat);
|
mark.setMaterial(mark_mat);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class TestTriangleCollision extends SimpleApplication {
|
|||||||
Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f);
|
Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f);
|
||||||
geom1 = new Geometry("Box", mesh1);
|
geom1 = new Geometry("Box", mesh1);
|
||||||
geom1.move(2, 2, -.5f);
|
geom1.move(2, 2, -.5f);
|
||||||
Material m1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material m1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
m1.setColor("Color", ColorRGBA.Blue);
|
m1.setColor("Color", ColorRGBA.Blue);
|
||||||
geom1.setMaterial(m1);
|
geom1.setMaterial(m1);
|
||||||
rootNode.attachChild(geom1);
|
rootNode.attachChild(geom1);
|
||||||
|
|||||||
@ -74,10 +74,10 @@ public class TestMipMapGen extends SimpleApplication {
|
|||||||
MipMapGenerator.generateMipMaps(imageCustomMip);
|
MipMapGenerator.generateMipMaps(imageCustomMip);
|
||||||
texCustomMip.setImage(imageCustomMip);
|
texCustomMip.setImage(imageCustomMip);
|
||||||
|
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setTexture("ColorMap", tex);
|
mat1.setTexture("ColorMap", tex);
|
||||||
|
|
||||||
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat2.setTexture("ColorMap", texCustomMip);
|
mat2.setTexture("ColorMap", texCustomMip);
|
||||||
|
|
||||||
quad1.setMaterial(mat1);
|
quad1.setMaterial(mat1);
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public class HelloAssets extends SimpleApplication {
|
|||||||
/** Create a wall (Box with material and texture from test-data) */
|
/** Create a wall (Box with material and texture from test-data) */
|
||||||
Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f);
|
Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f);
|
||||||
Spatial wall = new Geometry("Box", box );
|
Spatial wall = new Geometry("Box", box );
|
||||||
Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
|
mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
|
||||||
wall.setMaterial(mat_brick);
|
wall.setMaterial(mat_brick);
|
||||||
wall.setLocalTranslation(2.0f,-2.5f,0.0f);
|
wall.setLocalTranslation(2.0f,-2.5f,0.0f);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class HelloAudio extends SimpleApplication {
|
|||||||
/** just a blue box floating in space */
|
/** just a blue box floating in space */
|
||||||
Box box1 = new Box(Vector3f.ZERO, 1, 1, 1);
|
Box box1 = new Box(Vector3f.ZERO, 1, 1, 1);
|
||||||
player = new Geometry("Player", box1);
|
player = new Geometry("Player", box1);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.Blue);
|
mat1.setColor("Color", ColorRGBA.Blue);
|
||||||
player.setMaterial(mat1);
|
player.setMaterial(mat1);
|
||||||
rootNode.attachChild(player);
|
rootNode.attachChild(player);
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class HelloInput extends SimpleApplication {
|
|||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
||||||
player = new Geometry("Player", b);
|
player = new Geometry("Player", b);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.Blue);
|
mat.setColor("Color", ColorRGBA.Blue);
|
||||||
player.setMaterial(mat);
|
player.setMaterial(mat);
|
||||||
rootNode.attachChild(player);
|
rootNode.attachChild(player);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class HelloJME3 extends SimpleApplication {
|
|||||||
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape
|
||||||
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
|
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
|
||||||
Material mat = new Material(assetManager,
|
Material mat = new Material(assetManager,
|
||||||
"Common/MatDefs/Misc/SolidColor.j3md"); // create a simple material
|
"Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material
|
||||||
mat.setColor("Color", ColorRGBA.Blue); // set color of material to blue
|
mat.setColor("Color", ColorRGBA.Blue); // set color of material to blue
|
||||||
geom.setMaterial(mat); // set the cube's material
|
geom.setMaterial(mat); // set the cube's material
|
||||||
rootNode.attachChild(geom); // make the cube appear in the scene
|
rootNode.attachChild(geom); // make the cube appear in the scene
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public class HelloLoop extends SimpleApplication {
|
|||||||
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
|
||||||
player = new Geometry("blue cube", b);
|
player = new Geometry("blue cube", b);
|
||||||
Material mat = new Material(assetManager,
|
Material mat = new Material(assetManager,
|
||||||
"Common/MatDefs/Misc/SolidColor.j3md");
|
"Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.Blue);
|
mat.setColor("Color", ColorRGBA.Blue);
|
||||||
player.setMaterial(mat);
|
player.setMaterial(mat);
|
||||||
rootNode.attachChild(player);
|
rootNode.attachChild(player);
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class HelloMaterial extends SimpleApplication {
|
|||||||
/** A simple textured cube -- in good MIP map quality. */
|
/** A simple textured cube -- in good MIP map quality. */
|
||||||
Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f);
|
Box boxshape1 = new Box(new Vector3f(-3f,1.1f,0f), 1f,1f,1f);
|
||||||
Geometry cube = new Geometry("My Textured Box", boxshape1);
|
Geometry cube = new Geometry("My Textured Box", boxshape1);
|
||||||
Material mat_stl = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat_stl = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
Texture tex_ml = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
|
Texture tex_ml = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
|
||||||
mat_stl.setTexture("ColorMap", tex_ml);
|
mat_stl.setTexture("ColorMap", tex_ml);
|
||||||
cube.setMaterial(mat_stl);
|
cube.setMaterial(mat_stl);
|
||||||
@ -70,7 +70,7 @@ public class HelloMaterial extends SimpleApplication {
|
|||||||
/** A translucent/transparent texture, similar to a window frame. */
|
/** A translucent/transparent texture, similar to a window frame. */
|
||||||
Box boxshape3 = new Box(new Vector3f(0f,0f,0f), 1f,1f,0.01f);
|
Box boxshape3 = new Box(new Vector3f(0f,0f,0f), 1f,1f,0.01f);
|
||||||
Geometry window_frame = new Geometry("window frame", boxshape3);
|
Geometry window_frame = new Geometry("window frame", boxshape3);
|
||||||
Material mat_tt = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat_tt = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat_tt.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
|
mat_tt.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
|
||||||
mat_tt.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency
|
mat_tt.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); // activate transparency
|
||||||
window_frame.setQueueBucket(Bucket.Transparent);
|
window_frame.setQueueBucket(Bucket.Transparent);
|
||||||
|
|||||||
@ -56,14 +56,14 @@ public class HelloNode extends SimpleApplication {
|
|||||||
/** create a blue box at coordinates (1,-1,1) */
|
/** create a blue box at coordinates (1,-1,1) */
|
||||||
Box box1 = new Box( new Vector3f(1,-1,1), 1,1,1);
|
Box box1 = new Box( new Vector3f(1,-1,1), 1,1,1);
|
||||||
Geometry blue = new Geometry("Box", box1);
|
Geometry blue = new Geometry("Box", box1);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.Blue);
|
mat1.setColor("Color", ColorRGBA.Blue);
|
||||||
blue.setMaterial(mat1);
|
blue.setMaterial(mat1);
|
||||||
|
|
||||||
/** create a red box straight above the blue one at (1,3,1) */
|
/** create a red box straight above the blue one at (1,3,1) */
|
||||||
Box box2 = new Box( new Vector3f(1,3,1), 1,1,1);
|
Box box2 = new Box( new Vector3f(1,3,1), 1,1,1);
|
||||||
Geometry red = new Geometry("Box", box2);
|
Geometry red = new Geometry("Box", box2);
|
||||||
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat2.setColor("Color", ColorRGBA.Red);
|
mat2.setColor("Color", ColorRGBA.Red);
|
||||||
red.setMaterial(mat2);
|
red.setMaterial(mat2);
|
||||||
|
|
||||||
|
|||||||
@ -133,19 +133,19 @@ public class HelloPhysics extends SimpleApplication {
|
|||||||
|
|
||||||
/** Initialize the materials used in this scene. */
|
/** Initialize the materials used in this scene. */
|
||||||
public void initMaterials() {
|
public void initMaterials() {
|
||||||
wall_mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
wall_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
|
||||||
key.setGenerateMips(true);
|
key.setGenerateMips(true);
|
||||||
Texture tex = assetManager.loadTexture(key);
|
Texture tex = assetManager.loadTexture(key);
|
||||||
wall_mat.setTexture("ColorMap", tex);
|
wall_mat.setTexture("ColorMap", tex);
|
||||||
|
|
||||||
stone_mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
stone_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
|
||||||
key2.setGenerateMips(true);
|
key2.setGenerateMips(true);
|
||||||
Texture tex2 = assetManager.loadTexture(key2);
|
Texture tex2 = assetManager.loadTexture(key2);
|
||||||
stone_mat.setTexture("ColorMap", tex2);
|
stone_mat.setTexture("ColorMap", tex2);
|
||||||
|
|
||||||
floor_mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.png");
|
||||||
key3.setGenerateMips(true);
|
key3.setGenerateMips(true);
|
||||||
Texture tex3 = assetManager.loadTexture(key3);
|
Texture tex3 = assetManager.loadTexture(key3);
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public class HelloPicking extends SimpleApplication {
|
|||||||
protected Geometry makeCube(String name, float x, float y, float z) {
|
protected Geometry makeCube(String name, float x, float y, float z) {
|
||||||
Box box = new Box(new Vector3f(x, y, z), 1, 1, 1);
|
Box box = new Box(new Vector3f(x, y, z), 1, 1, 1);
|
||||||
Geometry cube = new Geometry(name, box);
|
Geometry cube = new Geometry(name, box);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.randomColor());
|
mat1.setColor("Color", ColorRGBA.randomColor());
|
||||||
cube.setMaterial(mat1);
|
cube.setMaterial(mat1);
|
||||||
return cube;
|
return cube;
|
||||||
@ -138,7 +138,7 @@ public class HelloPicking extends SimpleApplication {
|
|||||||
protected Geometry makeFloor() {
|
protected Geometry makeFloor() {
|
||||||
Box box = new Box(new Vector3f(0, -4, -5), 15, .2f, 15);
|
Box box = new Box(new Vector3f(0, -4, -5), 15, .2f, 15);
|
||||||
Geometry floor = new Geometry("the Floor", box);
|
Geometry floor = new Geometry("the Floor", box);
|
||||||
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat1.setColor("Color", ColorRGBA.Gray);
|
mat1.setColor("Color", ColorRGBA.Gray);
|
||||||
floor.setMaterial(mat1);
|
floor.setMaterial(mat1);
|
||||||
return floor;
|
return floor;
|
||||||
@ -148,7 +148,7 @@ public class HelloPicking extends SimpleApplication {
|
|||||||
protected void initMark() {
|
protected void initMark() {
|
||||||
Sphere sphere = new Sphere(30, 30, 0.2f);
|
Sphere sphere = new Sphere(30, 30, 0.2f);
|
||||||
mark = new Geometry("BOOM!", sphere);
|
mark = new Geometry("BOOM!", sphere);
|
||||||
Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mark_mat.setColor("Color", ColorRGBA.Red);
|
mark_mat.setColor("Color", ColorRGBA.Red);
|
||||||
mark.setMaterial(mark_mat);
|
mark.setMaterial(mark_mat);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class TestChaseCamera extends SimpleApplication implements AnalogListener
|
|||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
|
||||||
teaGeom.setMaterial(mat);
|
teaGeom.setMaterial(mat);
|
||||||
pivot.attachChild(teaGeom);
|
pivot.attachChild(teaGeom);
|
||||||
mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
Geometry ground = new Geometry("ground", new Quad(50, 50));
|
Geometry ground = new Geometry("ground", new Quad(50, 50));
|
||||||
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
|
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class TestPssmShadow extends SimpleApplication implements ActionListener
|
|||||||
|
|
||||||
public void loadScene(){
|
public void loadScene(){
|
||||||
Material mat = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
|
Material mat = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
|
||||||
Material matSoil = new Material(assetManager,"Common/MatDefs/Misc/SolidColor.j3md");
|
Material matSoil = new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
matSoil.setColor("Color", ColorRGBA.Cyan);
|
matSoil.setColor("Color", ColorRGBA.Cyan);
|
||||||
|
|
||||||
teapot = new Geometry("sphere", new Sphere(30, 30, 2));
|
teapot = new Geometry("sphere", new Sphere(30, 30, 2));
|
||||||
|
|||||||
@ -102,7 +102,8 @@ public class TestShadow extends SimpleApplication {
|
|||||||
frustumMdl = new Geometry("f", frustum);
|
frustumMdl = new Geometry("f", frustum);
|
||||||
frustumMdl.setCullHint(Spatial.CullHint.Never);
|
frustumMdl.setCullHint(Spatial.CullHint.Never);
|
||||||
frustumMdl.setShadowMode(ShadowMode.Off);
|
frustumMdl.setShadowMode(ShadowMode.Off);
|
||||||
frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md"));
|
frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
|
||||||
|
frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true);
|
||||||
frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
|
frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
|
||||||
rootNode.attachChild(frustumMdl);
|
rootNode.attachChild(frustumMdl);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ import com.jme3.light.PointLight;
|
|||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Quaternion;
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.shape.Sphere;
|
import com.jme3.scene.shape.Sphere;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public class BoxEntity extends Geometry implements SyncEntity {
|
|||||||
|
|
||||||
public BoxEntity(AssetManager assetManager, ColorRGBA color){
|
public BoxEntity(AssetManager assetManager, ColorRGBA color){
|
||||||
super("Box", new Box(1,1,1));
|
super("Box", new Box(1,1,1));
|
||||||
setMaterial(new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md"));
|
setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
|
||||||
getMaterial().setColor("Color", color);
|
getMaterial().setColor("Color", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,6 @@ public class TestDepthOfField extends SimpleApplication {
|
|||||||
private Vector3f lightDir = new Vector3f(-4.9236743f, -1.27054665f, 5.896916f);
|
private Vector3f lightDir = new Vector3f(-4.9236743f, -1.27054665f, 5.896916f);
|
||||||
TerrainQuad terrain;
|
TerrainQuad terrain;
|
||||||
Material matRock;
|
Material matRock;
|
||||||
Material matWire;
|
|
||||||
DepthOfFieldFilter dofFilter;
|
DepthOfFieldFilter dofFilter;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -172,8 +171,6 @@ public class TestDepthOfField extends SimpleApplication {
|
|||||||
matRock.setTexture("NormalMap_1", normalMap2);
|
matRock.setTexture("NormalMap_1", normalMap2);
|
||||||
matRock.setTexture("NormalMap_2", normalMap2);
|
matRock.setTexture("NormalMap_2", normalMap2);
|
||||||
|
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class TestHDR extends SimpleApplication {
|
|||||||
// Material mat = assetManager.loadMaterial("Textures/HdrTest/Memorial.j3m");
|
// Material mat = assetManager.loadMaterial("Textures/HdrTest/Memorial.j3m");
|
||||||
// box.setMaterial(mat);
|
// box.setMaterial(mat);
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", assetManager.loadTexture("Textures/HdrTest/Memorial.hdr"));
|
mat.setTexture("ColorMap", assetManager.loadTexture("Textures/HdrTest/Memorial.hdr"));
|
||||||
box.setMaterial(mat);
|
box.setMaterial(mat);
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public class TestLightScattering extends SimpleApplication {
|
|||||||
// fpp.addFilter(ssaoFilter);
|
// fpp.addFilter(ssaoFilter);
|
||||||
|
|
||||||
|
|
||||||
// Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
// Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
// mat2.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
// mat2.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
//
|
//
|
||||||
// Sphere lite=new Sphere(8, 8, 10.0f);
|
// Sphere lite=new Sphere(8, 8, 10.0f);
|
||||||
|
|||||||
@ -114,7 +114,7 @@ public class TestRenderToTexture extends SimpleApplication implements ActionList
|
|||||||
|
|
||||||
Texture offTex = setupOffscreenView();
|
Texture offTex = setupOffscreenView();
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", offTex);
|
mat.setTexture("ColorMap", offTex);
|
||||||
quad.setMaterial(mat);
|
quad.setMaterial(mat);
|
||||||
rootNode.attachChild(quad);
|
rootNode.attachChild(quad);
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package jme3test.terrain;
|
package jme3test.terrain;
|
||||||
|
|
||||||
import jme3tools.converters.ImageToAwt;
|
import jme3tools.converters.ImageToAwt;
|
||||||
@ -77,153 +76,152 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TerrainTest extends SimpleApplication {
|
public class TerrainTest extends SimpleApplication {
|
||||||
|
|
||||||
private TerrainQuad terrain;
|
private TerrainQuad terrain;
|
||||||
Material matRock;
|
Material matRock;
|
||||||
Material matWire;
|
Material matWire;
|
||||||
boolean wireframe = false;
|
boolean wireframe = false;
|
||||||
boolean triPlanar = false;
|
boolean triPlanar = false;
|
||||||
protected BitmapText hintText;
|
protected BitmapText hintText;
|
||||||
PointLight pl;
|
PointLight pl;
|
||||||
Geometry lightMdl;
|
Geometry lightMdl;
|
||||||
private float grassScale = 64;
|
private float grassScale = 64;
|
||||||
private float dirtScale = 16;
|
private float dirtScale = 16;
|
||||||
private float rockScale = 128;
|
private float rockScale = 128;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TerrainTest app = new TerrainTest();
|
TerrainTest app = new TerrainTest();
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
loadHintText();
|
loadHintText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
setupKeys();
|
setupKeys();
|
||||||
|
|
||||||
// First, we load up our textures and the heightmap texture for the terrain
|
// First, we load up our textures and the heightmap texture for the terrain
|
||||||
|
|
||||||
// TERRAIN TEXTURE material
|
// TERRAIN TEXTURE material
|
||||||
matRock = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
|
matRock = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md");
|
||||||
matRock.setBoolean("useTriPlanarMapping", false);
|
matRock.setBoolean("useTriPlanarMapping", false);
|
||||||
|
|
||||||
// ALPHA map (for splat textures)
|
// ALPHA map (for splat textures)
|
||||||
matRock.setTexture("Alpha", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
matRock.setTexture("Alpha", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
||||||
|
|
||||||
// HEIGHTMAP image (for the terrain heightmap)
|
// HEIGHTMAP image (for the terrain heightmap)
|
||||||
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
||||||
|
|
||||||
// GRASS texture
|
|
||||||
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
|
||||||
grass.setWrap(WrapMode.Repeat);
|
|
||||||
matRock.setTexture("Tex1", grass);
|
|
||||||
matRock.setFloat("Tex1Scale", grassScale);
|
|
||||||
|
|
||||||
// DIRT texture
|
// GRASS texture
|
||||||
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
||||||
dirt.setWrap(WrapMode.Repeat);
|
grass.setWrap(WrapMode.Repeat);
|
||||||
matRock.setTexture("Tex2", dirt);
|
matRock.setTexture("Tex1", grass);
|
||||||
matRock.setFloat("Tex2Scale", dirtScale);
|
matRock.setFloat("Tex1Scale", grassScale);
|
||||||
|
|
||||||
// ROCK texture
|
// DIRT texture
|
||||||
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
||||||
rock.setWrap(WrapMode.Repeat);
|
dirt.setWrap(WrapMode.Repeat);
|
||||||
matRock.setTexture("Tex3", rock);
|
matRock.setTexture("Tex2", dirt);
|
||||||
matRock.setFloat("Tex3Scale", rockScale);
|
matRock.setFloat("Tex2Scale", dirtScale);
|
||||||
|
|
||||||
// WIREFRAME material
|
// ROCK texture
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
||||||
|
rock.setWrap(WrapMode.Repeat);
|
||||||
|
matRock.setTexture("Tex3", rock);
|
||||||
|
matRock.setFloat("Tex3Scale", rockScale);
|
||||||
|
|
||||||
|
// WIREFRAME material
|
||||||
|
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
matWire.getAdditionalRenderState().setWireframe(true);
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
matWire.setColor("Color", ColorRGBA.Green);
|
||||||
|
|
||||||
|
// CREATE HEIGHTMAP
|
||||||
|
AbstractHeightMap heightmap = null;
|
||||||
|
try {
|
||||||
|
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
||||||
|
|
||||||
// CREATE HEIGHTMAP
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
||||||
AbstractHeightMap heightmap = null;
|
heightmap.load();
|
||||||
try {
|
|
||||||
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
|
||||||
|
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
} catch (Exception e) {
|
||||||
heightmap.load();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
/*
|
||||||
e.printStackTrace();
|
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
|
||||||
}
|
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Optimal terrain patch size is 65 (64x64).
|
||||||
|
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
|
||||||
|
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
|
||||||
|
*/
|
||||||
|
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
|
||||||
|
List<Camera> cameras = new ArrayList<Camera>();
|
||||||
|
cameras.add(getCamera());
|
||||||
|
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
||||||
|
terrain.addControl(control);
|
||||||
|
terrain.setMaterial(matRock);
|
||||||
|
terrain.setModelBound(new BoundingBox());
|
||||||
|
terrain.updateModelBound();
|
||||||
|
terrain.setLocalTranslation(0, -100, 0);
|
||||||
|
terrain.setLocalScale(2f, 1f, 2f);
|
||||||
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
/*
|
|
||||||
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
|
|
||||||
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Optimal terrain patch size is 65 (64x64).
|
|
||||||
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
|
|
||||||
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
|
|
||||||
*/
|
|
||||||
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
|
|
||||||
List<Camera> cameras = new ArrayList<Camera>();
|
|
||||||
cameras.add(getCamera());
|
|
||||||
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
|
||||||
terrain.addControl(control);
|
|
||||||
terrain.setMaterial(matRock);
|
|
||||||
terrain.setModelBound(new BoundingBox());
|
|
||||||
terrain.updateModelBound();
|
|
||||||
terrain.setLocalTranslation(0, -100, 0);
|
|
||||||
terrain.setLocalScale(2f, 1f, 2f);
|
|
||||||
rootNode.attachChild(terrain);
|
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
light.setDirection((new Vector3f(-0.5f,-1f, -0.5f)).normalize());
|
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
|
||||||
rootNode.addLight(light);
|
rootNode.addLight(light);
|
||||||
|
|
||||||
getCamera().getLocation().y = 10;
|
getCamera().getLocation().y = 10;
|
||||||
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadHintText() {
|
public void loadHintText() {
|
||||||
hintText = new BitmapText(guiFont, false);
|
hintText = new BitmapText(guiFont, false);
|
||||||
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
||||||
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
||||||
hintText.setText("Hit T to switch to wireframe, P to switch to tri-planar texturing");
|
hintText.setText("Hit T to switch to wireframe, P to switch to tri-planar texturing");
|
||||||
guiNode.attachChild(hintText);
|
guiNode.attachChild(hintText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupKeys() {
|
private void setupKeys() {
|
||||||
flyCam.setMoveSpeed(50);
|
flyCam.setMoveSpeed(50);
|
||||||
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
||||||
inputManager.addListener(actionListener, "wireframe");
|
inputManager.addListener(actionListener, "wireframe");
|
||||||
inputManager.addMapping("triPlanar", new KeyTrigger(KeyInput.KEY_P));
|
inputManager.addMapping("triPlanar", new KeyTrigger(KeyInput.KEY_P));
|
||||||
inputManager.addListener(actionListener, "triPlanar");
|
inputManager.addListener(actionListener, "triPlanar");
|
||||||
}
|
}
|
||||||
|
private ActionListener actionListener = new ActionListener() {
|
||||||
|
|
||||||
private ActionListener actionListener = new ActionListener() {
|
public void onAction(String name, boolean pressed, float tpf) {
|
||||||
|
if (name.equals("wireframe") && !pressed) {
|
||||||
public void onAction(String name, boolean pressed, float tpf) {
|
wireframe = !wireframe;
|
||||||
if (name.equals("wireframe") && !pressed) {
|
if (!wireframe) {
|
||||||
wireframe = !wireframe;
|
terrain.setMaterial(matWire);
|
||||||
if (!wireframe) {
|
} else {
|
||||||
terrain.setMaterial(matWire);
|
terrain.setMaterial(matRock);
|
||||||
} else {
|
}
|
||||||
terrain.setMaterial(matRock);
|
} else if (name.equals("triPlanar") && !pressed) {
|
||||||
}
|
|
||||||
} else if (name.equals("triPlanar") && !pressed) {
|
|
||||||
triPlanar = !triPlanar;
|
triPlanar = !triPlanar;
|
||||||
if (triPlanar) {
|
if (triPlanar) {
|
||||||
matRock.setBoolean("useTriPlanarMapping", true);
|
matRock.setBoolean("useTriPlanarMapping", true);
|
||||||
// planar textures don't use the mesh's texture coordinates but real world coordinates,
|
// planar textures don't use the mesh's texture coordinates but real world coordinates,
|
||||||
// so we need to convert these texture coordinate scales into real world scales so it looks
|
// so we need to convert these texture coordinate scales into real world scales so it looks
|
||||||
// the same when we switch to/from tr-planar mode
|
// the same when we switch to/from tr-planar mode
|
||||||
matRock.setFloat("Tex1Scale", 1f/(float)(512f/grassScale));
|
matRock.setFloat("Tex1Scale", 1f / (float) (512f / grassScale));
|
||||||
matRock.setFloat("Tex2Scale", 1f/(float)(512f/dirtScale));
|
matRock.setFloat("Tex2Scale", 1f / (float) (512f / dirtScale));
|
||||||
matRock.setFloat("Tex3Scale", 1f/(float)(512f/rockScale));
|
matRock.setFloat("Tex3Scale", 1f / (float) (512f / rockScale));
|
||||||
} else {
|
} else {
|
||||||
matRock.setBoolean("useTriPlanarMapping", false);
|
matRock.setBoolean("useTriPlanarMapping", false);
|
||||||
matRock.setFloat("Tex1Scale", grassScale);
|
matRock.setFloat("Tex1Scale", grassScale);
|
||||||
matRock.setFloat("Tex2Scale", dirtScale);
|
matRock.setFloat("Tex2Scale", dirtScale);
|
||||||
matRock.setFloat("Tex3Scale", rockScale);
|
matRock.setFloat("Tex3Scale", rockScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package jme3test.terrain;
|
package jme3test.terrain;
|
||||||
|
|
||||||
import jme3tools.converters.ImageToAwt;
|
import jme3tools.converters.ImageToAwt;
|
||||||
@ -67,69 +66,69 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TerrainTestAdvanced extends SimpleApplication {
|
public class TerrainTestAdvanced extends SimpleApplication {
|
||||||
|
|
||||||
private TerrainQuad terrain;
|
private TerrainQuad terrain;
|
||||||
Material matTerrain;
|
Material matTerrain;
|
||||||
Material matWire;
|
Material matWire;
|
||||||
boolean wireframe = false;
|
boolean wireframe = false;
|
||||||
boolean triPlanar = false;
|
boolean triPlanar = false;
|
||||||
boolean wardiso = false;
|
boolean wardiso = false;
|
||||||
boolean minnaert = false;
|
boolean minnaert = false;
|
||||||
protected BitmapText hintText;
|
protected BitmapText hintText;
|
||||||
PointLight pl;
|
PointLight pl;
|
||||||
Geometry lightMdl;
|
Geometry lightMdl;
|
||||||
private float grassScale = 64;
|
private float grassScale = 64;
|
||||||
private float dirtScale = 16;
|
private float dirtScale = 16;
|
||||||
private float rockScale = 128;
|
private float rockScale = 128;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TerrainTestAdvanced app = new TerrainTestAdvanced();
|
TerrainTestAdvanced app = new TerrainTestAdvanced();
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
loadHintText();
|
loadHintText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
setupKeys();
|
setupKeys();
|
||||||
|
|
||||||
// First, we load up our textures and the heightmap texture for the terrain
|
// First, we load up our textures and the heightmap texture for the terrain
|
||||||
|
|
||||||
// TERRAIN TEXTURE material
|
// TERRAIN TEXTURE material
|
||||||
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
|
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
|
||||||
matTerrain.setBoolean("useTriPlanarMapping", false);
|
matTerrain.setBoolean("useTriPlanarMapping", false);
|
||||||
matTerrain.setBoolean("WardIso", true);
|
matTerrain.setBoolean("WardIso", true);
|
||||||
|
|
||||||
// ALPHA map (for splat textures)
|
// ALPHA map (for splat textures)
|
||||||
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
||||||
|
|
||||||
// HEIGHTMAP image (for the terrain heightmap)
|
// HEIGHTMAP image (for the terrain heightmap)
|
||||||
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
||||||
|
|
||||||
// GRASS texture
|
// GRASS texture
|
||||||
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
||||||
grass.setWrap(WrapMode.Repeat);
|
grass.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap", grass);
|
matTerrain.setTexture("DiffuseMap", grass);
|
||||||
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
||||||
|
|
||||||
|
|
||||||
// DIRT texture
|
|
||||||
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
|
||||||
dirt.setWrap(WrapMode.Repeat);
|
|
||||||
matTerrain.setTexture("DiffuseMap_1", dirt);
|
|
||||||
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
|
||||||
|
|
||||||
// ROCK texture
|
// DIRT texture
|
||||||
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
||||||
rock.setWrap(WrapMode.Repeat);
|
dirt.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap_2", rock);
|
matTerrain.setTexture("DiffuseMap_1", dirt);
|
||||||
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
||||||
|
|
||||||
|
// ROCK texture
|
||||||
|
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
||||||
|
rock.setWrap(WrapMode.Repeat);
|
||||||
|
matTerrain.setTexture("DiffuseMap_2", rock);
|
||||||
|
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
|
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
|
||||||
normalMap0.setWrap(WrapMode.Repeat);
|
normalMap0.setWrap(WrapMode.Repeat);
|
||||||
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
|
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
|
||||||
@ -140,106 +139,106 @@ public class TerrainTestAdvanced extends SimpleApplication {
|
|||||||
matTerrain.setTexture("NormalMap_1", normalMap2);
|
matTerrain.setTexture("NormalMap_1", normalMap2);
|
||||||
matTerrain.setTexture("NormalMap_2", normalMap2);
|
matTerrain.setTexture("NormalMap_2", normalMap2);
|
||||||
|
|
||||||
// WIREFRAME material
|
// WIREFRAME material
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
matWire.getAdditionalRenderState().setWireframe(true);
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
matWire.setColor("Color", ColorRGBA.Green);
|
||||||
|
|
||||||
createSky();
|
createSky();
|
||||||
|
|
||||||
// CREATE HEIGHTMAP
|
// CREATE HEIGHTMAP
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
||||||
|
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
||||||
heightmap.load();
|
heightmap.load();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
|
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
|
||||||
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
|
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Optimal terrain patch size is 65 (64x64).
|
* Optimal terrain patch size is 65 (64x64).
|
||||||
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
|
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
|
||||||
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
|
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
|
||||||
*/
|
*/
|
||||||
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
|
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
|
||||||
List<Camera> cameras = new ArrayList<Camera>();
|
List<Camera> cameras = new ArrayList<Camera>();
|
||||||
cameras.add(getCamera());
|
cameras.add(getCamera());
|
||||||
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
||||||
terrain.addControl(control);
|
terrain.addControl(control);
|
||||||
terrain.setMaterial(matTerrain);
|
terrain.setMaterial(matTerrain);
|
||||||
terrain.setModelBound(new BoundingBox());
|
terrain.setModelBound(new BoundingBox());
|
||||||
terrain.updateModelBound();
|
terrain.updateModelBound();
|
||||||
terrain.setLocalTranslation(0, -100, 0);
|
terrain.setLocalTranslation(0, -100, 0);
|
||||||
terrain.setLocalScale(1f, 1f, 1f);
|
terrain.setLocalScale(1f, 1f, 1f);
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
light.setDirection((new Vector3f(-0.5f,-1f, -0.5f)).normalize());
|
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
|
||||||
rootNode.addLight(light);
|
rootNode.addLight(light);
|
||||||
|
|
||||||
AmbientLight ambLight = new AmbientLight();
|
AmbientLight ambLight = new AmbientLight();
|
||||||
ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
|
ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
|
||||||
rootNode.addLight(ambLight);
|
rootNode.addLight(ambLight);
|
||||||
|
|
||||||
getCamera().getLocation().y = 10;
|
getCamera().getLocation().y = 10;
|
||||||
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadHintText() {
|
public void loadHintText() {
|
||||||
hintText = new BitmapText(guiFont, false);
|
hintText = new BitmapText(guiFont, false);
|
||||||
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
||||||
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
||||||
hintText.setText("Hit T to switch to wireframe, P to switch to tri-planar texturing");
|
hintText.setText("Hit T to switch to wireframe, P to switch to tri-planar texturing");
|
||||||
guiNode.attachChild(hintText);
|
guiNode.attachChild(hintText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupKeys() {
|
private void setupKeys() {
|
||||||
flyCam.setMoveSpeed(50);
|
flyCam.setMoveSpeed(50);
|
||||||
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
||||||
inputManager.addListener(actionListener, "wireframe");
|
inputManager.addListener(actionListener, "wireframe");
|
||||||
inputManager.addMapping("triPlanar", new KeyTrigger(KeyInput.KEY_P));
|
inputManager.addMapping("triPlanar", new KeyTrigger(KeyInput.KEY_P));
|
||||||
inputManager.addListener(actionListener, "triPlanar");
|
inputManager.addListener(actionListener, "triPlanar");
|
||||||
inputManager.addMapping("WardIso", new KeyTrigger(KeyInput.KEY_9));
|
inputManager.addMapping("WardIso", new KeyTrigger(KeyInput.KEY_9));
|
||||||
inputManager.addListener(actionListener, "WardIso");
|
inputManager.addListener(actionListener, "WardIso");
|
||||||
inputManager.addMapping("Minnaert", new KeyTrigger(KeyInput.KEY_0));
|
inputManager.addMapping("Minnaert", new KeyTrigger(KeyInput.KEY_0));
|
||||||
inputManager.addListener(actionListener, "Minnaert");
|
inputManager.addListener(actionListener, "Minnaert");
|
||||||
}
|
}
|
||||||
|
private ActionListener actionListener = new ActionListener() {
|
||||||
|
|
||||||
private ActionListener actionListener = new ActionListener() {
|
public void onAction(String name, boolean pressed, float tpf) {
|
||||||
|
if (name.equals("wireframe") && !pressed) {
|
||||||
public void onAction(String name, boolean pressed, float tpf) {
|
wireframe = !wireframe;
|
||||||
if (name.equals("wireframe") && !pressed) {
|
if (!wireframe) {
|
||||||
wireframe = !wireframe;
|
terrain.setMaterial(matWire);
|
||||||
if (!wireframe) {
|
} else {
|
||||||
terrain.setMaterial(matWire);
|
terrain.setMaterial(matTerrain);
|
||||||
} else {
|
}
|
||||||
terrain.setMaterial(matTerrain);
|
} else if (name.equals("triPlanar") && !pressed) {
|
||||||
}
|
|
||||||
} else if (name.equals("triPlanar") && !pressed) {
|
|
||||||
triPlanar = !triPlanar;
|
triPlanar = !triPlanar;
|
||||||
if (triPlanar) {
|
if (triPlanar) {
|
||||||
matTerrain.setBoolean("useTriPlanarMapping", true);
|
matTerrain.setBoolean("useTriPlanarMapping", true);
|
||||||
// planar textures don't use the mesh's texture coordinates but real world coordinates,
|
// planar textures don't use the mesh's texture coordinates but real world coordinates,
|
||||||
// so we need to convert these texture coordinate scales into real world scales so it looks
|
// so we need to convert these texture coordinate scales into real world scales so it looks
|
||||||
// the same when we switch to/from tr-planar mode
|
// the same when we switch to/from tr-planar mode
|
||||||
matTerrain.setFloat("DiffuseMap_0_scale", 1f/(float)(512f/grassScale));
|
matTerrain.setFloat("DiffuseMap_0_scale", 1f / (float) (512f / grassScale));
|
||||||
matTerrain.setFloat("DiffuseMap_1_scale", 1f/(float)(512f/dirtScale));
|
matTerrain.setFloat("DiffuseMap_1_scale", 1f / (float) (512f / dirtScale));
|
||||||
matTerrain.setFloat("DiffuseMap_2_scale", 1f/(float)(512f/rockScale));
|
matTerrain.setFloat("DiffuseMap_2_scale", 1f / (float) (512f / rockScale));
|
||||||
} else {
|
} else {
|
||||||
matTerrain.setBoolean("useTriPlanarMapping", false);
|
matTerrain.setBoolean("useTriPlanarMapping", false);
|
||||||
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
||||||
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
||||||
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void createSky() {
|
private void createSky() {
|
||||||
Texture west = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_west.jpg");
|
Texture west = assetManager.loadTexture("Textures/Sky/Lagoon/lagoon_west.jpg");
|
||||||
|
|||||||
@ -125,14 +125,16 @@ public class TerrainTestCollision extends SimpleApplication {
|
|||||||
rock.setWrap(WrapMode.Repeat);
|
rock.setWrap(WrapMode.Repeat);
|
||||||
matRock.setTexture("Tex3", rock);
|
matRock.setTexture("Tex3", rock);
|
||||||
matRock.setFloat("Tex3Scale", 128f);
|
matRock.setFloat("Tex3Scale", 128f);
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
matWire.getAdditionalRenderState().setWireframe(true);
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
matWire.setColor("Color", ColorRGBA.Green);
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
||||||
heightmap.load();
|
heightmap.load();
|
||||||
|
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
|
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
|
||||||
List<Camera> cameras = new ArrayList<Camera>();
|
List<Camera> cameras = new ArrayList<Camera>();
|
||||||
@ -158,18 +160,18 @@ public class TerrainTestCollision extends SimpleApplication {
|
|||||||
// let them drop from the sky
|
// let them drop from the sky
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
float r = (float) (8 * Math.random());
|
float r = (float) (8 * Math.random());
|
||||||
Geometry sphere = new Geometry("cannonball",new Sphere(10, 10, r) );
|
Geometry sphere = new Geometry("cannonball", new Sphere(10, 10, r));
|
||||||
sphere.setMaterial(matWire);
|
sphere.setMaterial(matWire);
|
||||||
float x = (float) (20 * Math.random()) - 40; // random position
|
float x = (float) (20 * Math.random()) - 40; // random position
|
||||||
float y = (float) (20 * Math.random()) - 40; // random position
|
float y = (float) (20 * Math.random()) - 40; // random position
|
||||||
float z = (float) (20 * Math.random()) - 40; // random position
|
float z = (float) (20 * Math.random()) - 40; // random position
|
||||||
sphere.setLocalTranslation(new Vector3f(x, 100 + y, z));
|
sphere.setLocalTranslation(new Vector3f(x, 100 + y, z));
|
||||||
sphere.addControl(new RigidBodyControl(new SphereCollisionShape(r),2));
|
sphere.addControl(new RigidBodyControl(new SphereCollisionShape(r), 2));
|
||||||
rootNode.attachChild(sphere);
|
rootNode.attachChild(sphere);
|
||||||
bulletAppState.getPhysicsSpace().add(sphere);
|
bulletAppState.getPhysicsSpace().add(sphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
collisionBox = new Geometry("collisionBox",new Box(2, 2, 2));
|
collisionBox = new Geometry("collisionBox", new Box(2, 2, 2));
|
||||||
collisionBox.setModelBound(new BoundingBox());
|
collisionBox.setModelBound(new BoundingBox());
|
||||||
collisionBox.setLocalTranslation(new Vector3f(20, 95, 30));
|
collisionBox.setLocalTranslation(new Vector3f(20, 95, 30));
|
||||||
collisionBox.setMaterial(matWire);
|
collisionBox.setMaterial(matWire);
|
||||||
@ -236,7 +238,7 @@ public class TerrainTestCollision extends SimpleApplication {
|
|||||||
Sphere s = new Sphere(6, 6, 1);
|
Sphere s = new Sphere(6, 6, 1);
|
||||||
collisionMarker = new Geometry("collisionMarker");
|
collisionMarker = new Geometry("collisionMarker");
|
||||||
collisionMarker.setMesh(s);
|
collisionMarker.setMesh(s);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.Orange);
|
mat.setColor("Color", ColorRGBA.Orange);
|
||||||
collisionMarker.setMaterial(mat);
|
collisionMarker.setMaterial(mat);
|
||||||
rootNode.attachChild(collisionMarker);
|
rootNode.attachChild(collisionMarker);
|
||||||
@ -268,38 +270,32 @@ public class TerrainTestCollision extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
Vector2f loc = new Vector2f(hit.getContactPoint().x, hit.getContactPoint().z);
|
Vector2f loc = new Vector2f(hit.getContactPoint().x, hit.getContactPoint().z);
|
||||||
float height = terrain.getHeight(loc);
|
float height = terrain.getHeight(loc);
|
||||||
System.out.println("collide " + hit.getContactPoint() + ", height: " + height+", distance: "+hit.getDistance());
|
System.out.println("collide " + hit.getContactPoint() + ", height: " + height + ", distance: " + hit.getDistance());
|
||||||
collisionMarker.setLocalTranslation(new Vector3f(hit.getContactPoint().x, height, hit.getContactPoint().z));
|
collisionMarker.setLocalTranslation(new Vector3f(hit.getContactPoint().x, height, hit.getContactPoint().z));
|
||||||
}
|
}
|
||||||
} else if (binding.equals("cameraDown") && !keyPressed) {
|
} else if (binding.equals("cameraDown") && !keyPressed) {
|
||||||
getCamera().setDirection(new Vector3f(0,-1,0));
|
getCamera().setDirection(new Vector3f(0, -1, 0));
|
||||||
}
|
} else if (binding.equals("Lefts") && !keyPressed) {
|
||||||
else if (binding.equals("Lefts") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(-0.5f, 0, 0);
|
selectedCollisionObject.move(-0.5f, 0, 0);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
}
|
} else if (binding.equals("Rights") && !keyPressed) {
|
||||||
else if (binding.equals("Rights") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(0.5f, 0, 0);
|
selectedCollisionObject.move(0.5f, 0, 0);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
}
|
} else if (binding.equals("Forwards") && !keyPressed) {
|
||||||
else if (binding.equals("Forwards") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(0, 0, 0.5f);
|
selectedCollisionObject.move(0, 0, 0.5f);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
}
|
} else if (binding.equals("Backs") && !keyPressed) {
|
||||||
else if (binding.equals("Backs") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(0, 0, -0.5f);
|
selectedCollisionObject.move(0, 0, -0.5f);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
}
|
} else if (binding.equals("Ups") && !keyPressed) {
|
||||||
else if (binding.equals("Ups") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(0, 0.5f, 0);
|
selectedCollisionObject.move(0, 0.5f, 0);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
}
|
} else if (binding.equals("Downs") && !keyPressed) {
|
||||||
else if (binding.equals("Downs") && !keyPressed) {
|
|
||||||
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
Vector3f oldLoc = selectedCollisionObject.getLocalTranslation().clone();
|
||||||
selectedCollisionObject.move(0, -0.5f, 0);
|
selectedCollisionObject.move(0, -0.5f, 0);
|
||||||
testCollision(oldLoc);
|
testCollision(oldLoc);
|
||||||
@ -309,7 +305,8 @@ public class TerrainTestCollision extends SimpleApplication {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void testCollision(Vector3f oldLoc) {
|
private void testCollision(Vector3f oldLoc) {
|
||||||
if (terrain.collideWith(selectedCollisionObject.getWorldBound(), new CollisionResults()) > 0)
|
if (terrain.collideWith(selectedCollisionObject.getWorldBound(), new CollisionResults()) > 0) {
|
||||||
selectedCollisionObject.setLocalTranslation(oldLoc);
|
selectedCollisionObject.setLocalTranslation(oldLoc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package jme3test.terrain;
|
package jme3test.terrain;
|
||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
@ -65,13 +64,13 @@ import jme3tools.converters.ImageToAwt;
|
|||||||
public class TerrainTestModifyHeight extends SimpleApplication {
|
public class TerrainTestModifyHeight extends SimpleApplication {
|
||||||
|
|
||||||
private TerrainQuad terrain;
|
private TerrainQuad terrain;
|
||||||
Material matTerrain;
|
Material matTerrain;
|
||||||
Material matWire;
|
Material matWire;
|
||||||
boolean wireframe = false;
|
boolean wireframe = false;
|
||||||
boolean triPlanar = false;
|
boolean triPlanar = false;
|
||||||
boolean wardiso = false;
|
boolean wardiso = false;
|
||||||
boolean minnaert = false;
|
boolean minnaert = false;
|
||||||
protected BitmapText hintText;
|
protected BitmapText hintText;
|
||||||
private float grassScale = 64;
|
private float grassScale = 64;
|
||||||
private float dirtScale = 16;
|
private float dirtScale = 16;
|
||||||
private float rockScale = 128;
|
private float rockScale = 128;
|
||||||
@ -81,96 +80,96 @@ public class TerrainTestModifyHeight extends SimpleApplication {
|
|||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
loadHintText();
|
loadHintText();
|
||||||
initCrossHairs();
|
initCrossHairs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
updateHintText();
|
updateHintText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
setupKeys();
|
setupKeys();
|
||||||
|
|
||||||
// First, we load up our textures and the heightmap texture for the terrain
|
// First, we load up our textures and the heightmap texture for the terrain
|
||||||
|
|
||||||
// TERRAIN TEXTURE material
|
// TERRAIN TEXTURE material
|
||||||
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
|
matTerrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
|
||||||
matTerrain.setBoolean("useTriPlanarMapping", false);
|
matTerrain.setBoolean("useTriPlanarMapping", false);
|
||||||
matTerrain.setBoolean("WardIso", true);
|
matTerrain.setBoolean("WardIso", true);
|
||||||
|
|
||||||
// ALPHA map (for splat textures)
|
// ALPHA map (for splat textures)
|
||||||
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
||||||
|
|
||||||
// GRASS texture
|
// GRASS texture
|
||||||
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
||||||
grass.setWrap(WrapMode.Repeat);
|
grass.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap", grass);
|
matTerrain.setTexture("DiffuseMap", grass);
|
||||||
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
||||||
|
|
||||||
// DIRT texture
|
// DIRT texture
|
||||||
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
||||||
dirt.setWrap(WrapMode.Repeat);
|
dirt.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap_1", dirt);
|
matTerrain.setTexture("DiffuseMap_1", dirt);
|
||||||
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
||||||
|
|
||||||
// ROCK texture
|
// ROCK texture
|
||||||
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
||||||
rock.setWrap(WrapMode.Repeat);
|
rock.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap_2", rock);
|
matTerrain.setTexture("DiffuseMap_2", rock);
|
||||||
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
||||||
|
|
||||||
// WIREFRAME material
|
// WIREFRAME material
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
matWire.getAdditionalRenderState().setWireframe(true);
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
matWire.setColor("Color", ColorRGBA.Green);
|
||||||
|
|
||||||
// CREATE THE TERRAIN
|
// CREATE THE TERRAIN
|
||||||
terrain = new TerrainQuad("terrain", 65, 513, null);
|
terrain = new TerrainQuad("terrain", 65, 513, null);
|
||||||
List<Camera> cameras = new ArrayList<Camera>();
|
List<Camera> cameras = new ArrayList<Camera>();
|
||||||
cameras.add(getCamera());
|
cameras.add(getCamera());
|
||||||
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
|
||||||
terrain.addControl(control);
|
terrain.addControl(control);
|
||||||
terrain.setMaterial(matTerrain);
|
terrain.setMaterial(matTerrain);
|
||||||
terrain.setModelBound(new BoundingBox());
|
terrain.setModelBound(new BoundingBox());
|
||||||
terrain.updateModelBound();
|
terrain.updateModelBound();
|
||||||
terrain.setLocalTranslation(0, -100, 0);
|
terrain.setLocalTranslation(0, -100, 0);
|
||||||
terrain.setLocalScale(2f, 1f, 2f);
|
terrain.setLocalScale(2f, 1f, 2f);
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
light.setDirection((new Vector3f(-0.5f,-1f, -0.5f)).normalize());
|
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
|
||||||
rootNode.addLight(light);
|
rootNode.addLight(light);
|
||||||
|
|
||||||
AmbientLight ambLight = new AmbientLight();
|
AmbientLight ambLight = new AmbientLight();
|
||||||
ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
|
ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
|
||||||
rootNode.addLight(ambLight);
|
rootNode.addLight(ambLight);
|
||||||
|
|
||||||
getCamera().getLocation().y = 10;
|
getCamera().getLocation().y = 10;
|
||||||
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
getCamera().setDirection(new Vector3f(0, -1.5f, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadHintText() {
|
public void loadHintText() {
|
||||||
hintText = new BitmapText(guiFont, false);
|
hintText = new BitmapText(guiFont, false);
|
||||||
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
hintText.setSize(guiFont.getCharSet().getRenderedSize());
|
||||||
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
hintText.setLocalTranslation(0, getCamera().getHeight(), 0);
|
||||||
hintText.setText("Hit 1 to raise terrain, hit 2 to lower terrain");
|
hintText.setText("Hit 1 to raise terrain, hit 2 to lower terrain");
|
||||||
guiNode.attachChild(hintText);
|
guiNode.attachChild(hintText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHintText() {
|
public void updateHintText() {
|
||||||
int x = (int) getCamera().getLocation().x;
|
int x = (int) getCamera().getLocation().x;
|
||||||
int y = (int) getCamera().getLocation().y;
|
int y = (int) getCamera().getLocation().y;
|
||||||
int z = (int) getCamera().getLocation().z;
|
int z = (int) getCamera().getLocation().z;
|
||||||
hintText.setText("Hit 1 to raise terrain, hit 2 to lower terrain. "+x+","+y+","+z);
|
hintText.setText("Hit 1 to raise terrain, hit 2 to lower terrain. " + x + "," + y + "," + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initCrossHairs() {
|
protected void initCrossHairs() {
|
||||||
@ -184,27 +183,26 @@ public class TerrainTestModifyHeight extends SimpleApplication {
|
|||||||
guiNode.attachChild(ch);
|
guiNode.attachChild(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupKeys() {
|
private void setupKeys() {
|
||||||
flyCam.setMoveSpeed(100);
|
flyCam.setMoveSpeed(100);
|
||||||
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
|
||||||
inputManager.addListener(actionListener, "wireframe");
|
inputManager.addListener(actionListener, "wireframe");
|
||||||
inputManager.addMapping("Raise", new KeyTrigger(KeyInput.KEY_1));
|
inputManager.addMapping("Raise", new KeyTrigger(KeyInput.KEY_1));
|
||||||
inputManager.addListener(actionListener, "Raise");
|
inputManager.addListener(actionListener, "Raise");
|
||||||
inputManager.addMapping("Lower", new KeyTrigger(KeyInput.KEY_2));
|
inputManager.addMapping("Lower", new KeyTrigger(KeyInput.KEY_2));
|
||||||
inputManager.addListener(actionListener, "Lower");
|
inputManager.addListener(actionListener, "Lower");
|
||||||
}
|
}
|
||||||
|
private ActionListener actionListener = new ActionListener() {
|
||||||
|
|
||||||
private ActionListener actionListener = new ActionListener() {
|
public void onAction(String name, boolean pressed, float tpf) {
|
||||||
|
if (name.equals("wireframe") && !pressed) {
|
||||||
public void onAction(String name, boolean pressed, float tpf) {
|
wireframe = !wireframe;
|
||||||
if (name.equals("wireframe") && !pressed) {
|
if (!wireframe) {
|
||||||
wireframe = !wireframe;
|
terrain.setMaterial(matWire);
|
||||||
if (!wireframe) {
|
} else {
|
||||||
terrain.setMaterial(matWire);
|
terrain.setMaterial(matTerrain);
|
||||||
} else {
|
}
|
||||||
terrain.setMaterial(matTerrain);
|
} else if (name.equals("Raise")) {
|
||||||
}
|
|
||||||
} else if (name.equals("Raise")) {
|
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
Vector3f intersection = getWorldIntersection();
|
Vector3f intersection = getWorldIntersection();
|
||||||
if (intersection != null) {
|
if (intersection != null) {
|
||||||
@ -219,53 +217,54 @@ public class TerrainTestModifyHeight extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void adjustHeight(Vector3f loc, float radius, float height) {
|
private void adjustHeight(Vector3f loc, float radius, float height) {
|
||||||
|
|
||||||
// offset it by radius because in the loop we iterate through 2 radii
|
// offset it by radius because in the loop we iterate through 2 radii
|
||||||
int radiusStepsX = (int) (radius / terrain.getLocalScale().x);
|
int radiusStepsX = (int) (radius / terrain.getLocalScale().x);
|
||||||
int radiusStepsZ = (int) (radius / terrain.getLocalScale().z);
|
int radiusStepsZ = (int) (radius / terrain.getLocalScale().z);
|
||||||
|
|
||||||
float xStepAmount = terrain.getLocalScale().x;
|
float xStepAmount = terrain.getLocalScale().x;
|
||||||
float zStepAmount = terrain.getLocalScale().z;
|
float zStepAmount = terrain.getLocalScale().z;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
for (int z=-radiusStepsZ; z<radiusStepsZ; z++) {
|
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
|
||||||
for (int x=-radiusStepsZ; x<radiusStepsX; x++) {
|
for (int x = -radiusStepsZ; x < radiusStepsX; x++) {
|
||||||
|
|
||||||
float locX = loc.x + (x*xStepAmount);
|
float locX = loc.x + (x * xStepAmount);
|
||||||
float locZ = loc.z + (z*zStepAmount);
|
float locZ = loc.z + (z * zStepAmount);
|
||||||
|
|
||||||
if (isInRadius(locX-loc.x,locZ-loc.z,radius)) {
|
if (isInRadius(locX - loc.x, locZ - loc.z, radius)) {
|
||||||
// see if it is in the radius of the tool
|
// see if it is in the radius of the tool
|
||||||
float h = calculateHeight(radius, height, locX-loc.x, locZ-loc.z);
|
float h = calculateHeight(radius, height, locX - loc.x, locZ - loc.z);
|
||||||
|
|
||||||
// increase the height
|
// increase the height
|
||||||
terrain.adjustHeight(new Vector2f(locX, locZ), h);
|
terrain.adjustHeight(new Vector2f(locX, locZ), h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("took: "+(System.currentTimeMillis()-start));
|
System.out.println("took: " + (System.currentTimeMillis() - start));
|
||||||
terrain.updateModelBound();
|
terrain.updateModelBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInRadius(float x, float y, float radius) {
|
private boolean isInRadius(float x, float y, float radius) {
|
||||||
Vector2f point = new Vector2f(x,y);
|
Vector2f point = new Vector2f(x, y);
|
||||||
// return true if the distance is less than equal to the radius
|
// return true if the distance is less than equal to the radius
|
||||||
return point.length() <= radius;
|
return point.length() <= radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float calculateHeight(float radius, float heightFactor, float x, float z) {
|
private float calculateHeight(float radius, float heightFactor, float x, float z) {
|
||||||
// find percentage for each 'unit' in radius
|
// find percentage for each 'unit' in radius
|
||||||
Vector2f point = new Vector2f(x,z);
|
Vector2f point = new Vector2f(x, z);
|
||||||
float val = point.length() / radius;
|
float val = point.length() / radius;
|
||||||
val = 1 - val;
|
val = 1 - val;
|
||||||
if (val <= 0)
|
if (val <= 0) {
|
||||||
val = 0;
|
val = 0;
|
||||||
|
}
|
||||||
return heightFactor * val;
|
return heightFactor * val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3f getWorldIntersection() {
|
private Vector3f getWorldIntersection() {
|
||||||
Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f);
|
Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f);
|
||||||
|
|||||||
@ -103,30 +103,30 @@ public class TerrainTestReadWrite extends SimpleApplication {
|
|||||||
matTerrain.setBoolean("useTriPlanarMapping", false);
|
matTerrain.setBoolean("useTriPlanarMapping", false);
|
||||||
matTerrain.setBoolean("WardIso", true);
|
matTerrain.setBoolean("WardIso", true);
|
||||||
|
|
||||||
// ALPHA map (for splat textures)
|
// ALPHA map (for splat textures)
|
||||||
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
matTerrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
|
||||||
|
|
||||||
// HEIGHTMAP image (for the terrain heightmap)
|
// HEIGHTMAP image (for the terrain heightmap)
|
||||||
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
|
||||||
|
|
||||||
// GRASS texture
|
// GRASS texture
|
||||||
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
|
||||||
grass.setWrap(WrapMode.Repeat);
|
grass.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap", grass);
|
matTerrain.setTexture("DiffuseMap", grass);
|
||||||
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
matTerrain.setFloat("DiffuseMap_0_scale", grassScale);
|
||||||
|
|
||||||
|
|
||||||
// DIRT texture
|
// DIRT texture
|
||||||
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
|
||||||
dirt.setWrap(WrapMode.Repeat);
|
dirt.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap_1", dirt);
|
matTerrain.setTexture("DiffuseMap_1", dirt);
|
||||||
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
matTerrain.setFloat("DiffuseMap_1_scale", dirtScale);
|
||||||
|
|
||||||
// ROCK texture
|
// ROCK texture
|
||||||
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
|
||||||
rock.setWrap(WrapMode.Repeat);
|
rock.setWrap(WrapMode.Repeat);
|
||||||
matTerrain.setTexture("DiffuseMap_2", rock);
|
matTerrain.setTexture("DiffuseMap_2", rock);
|
||||||
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
matTerrain.setFloat("DiffuseMap_2_scale", rockScale);
|
||||||
|
|
||||||
|
|
||||||
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
|
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
|
||||||
@ -139,21 +139,22 @@ public class TerrainTestReadWrite extends SimpleApplication {
|
|||||||
matTerrain.setTexture("NormalMap_1", normalMap2);
|
matTerrain.setTexture("NormalMap_1", normalMap2);
|
||||||
matTerrain.setTexture("NormalMap_2", normalMap2);
|
matTerrain.setTexture("NormalMap_2", normalMap2);
|
||||||
|
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
matWire.getAdditionalRenderState().setWireframe(true);
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
matWire.setColor("Color", ColorRGBA.Green);
|
||||||
|
|
||||||
|
|
||||||
// CREATE HEIGHTMAP
|
// CREATE HEIGHTMAP
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
|
||||||
|
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);
|
||||||
heightmap.load();
|
heightmap.load();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new File("terrainsave.jme").exists()) {
|
if (new File("terrainsave.jme").exists()) {
|
||||||
loadTerrain();
|
loadTerrain();
|
||||||
@ -171,9 +172,9 @@ public class TerrainTestReadWrite extends SimpleApplication {
|
|||||||
terrain.setLocalScale(2f, 1f, 2f);
|
terrain.setLocalScale(2f, 1f, 2f);
|
||||||
rootNode.attachChild(terrain);
|
rootNode.attachChild(terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectionalLight light = new DirectionalLight();
|
DirectionalLight light = new DirectionalLight();
|
||||||
light.setDirection((new Vector3f(-0.5f,-1f, -0.5f)).normalize());
|
light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
|
||||||
rootNode.addLight(light);
|
rootNode.addLight(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ public class TerrainTestReadWrite extends SimpleApplication {
|
|||||||
*/
|
*/
|
||||||
private void createControls() {
|
private void createControls() {
|
||||||
flyCam.setMoveSpeed(50);
|
flyCam.setMoveSpeed(50);
|
||||||
cam.setLocation(new Vector3f(0,100,0));
|
cam.setLocation(new Vector3f(0, 100, 0));
|
||||||
|
|
||||||
inputManager.addMapping("save", new KeyTrigger(KeyInput.KEY_T));
|
inputManager.addMapping("save", new KeyTrigger(KeyInput.KEY_T));
|
||||||
inputManager.addListener(saveActionListener, "save");
|
inputManager.addListener(saveActionListener, "save");
|
||||||
@ -274,7 +275,6 @@ public class TerrainTestReadWrite extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionListener loadActionListener = new ActionListener() {
|
private ActionListener loadActionListener = new ActionListener() {
|
||||||
|
|
||||||
public void onAction(String name, boolean pressed, float tpf) {
|
public void onAction(String name, boolean pressed, float tpf) {
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class TestNormalLatc extends SimpleApplication {
|
|||||||
TextureKey key = new TextureKey(texName, true);
|
TextureKey key = new TextureKey(texName, true);
|
||||||
key.setGenerateMips(false);
|
key.setGenerateMips(false);
|
||||||
Texture tex = assetManager.loadTexture(key);
|
Texture tex = assetManager.loadTexture(key);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", tex);
|
mat.setTexture("ColorMap", tex);
|
||||||
// mat.setBoolean("Normalize", true);
|
// mat.setBoolean("Normalize", true);
|
||||||
if (latc)
|
if (latc)
|
||||||
|
|||||||
@ -48,7 +48,6 @@ public class TestPostWater extends SimpleApplication {
|
|||||||
private WaterFilter water;
|
private WaterFilter water;
|
||||||
TerrainQuad terrain;
|
TerrainQuad terrain;
|
||||||
Material matRock;
|
Material matRock;
|
||||||
Material matWire;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TestPostWater app = new TestPostWater();
|
TestPostWater app = new TestPostWater();
|
||||||
@ -224,8 +223,6 @@ public class TestPostWater extends SimpleApplication {
|
|||||||
matRock.setTexture("NormalMap_1", normalMap2);
|
matRock.setTexture("NormalMap_1", normalMap2);
|
||||||
matRock.setTexture("NormalMap_2", normalMap2);
|
matRock.setTexture("NormalMap_2", normalMap2);
|
||||||
|
|
||||||
matWire = new Material(assetManager, "Common/MatDefs/Misc/WireColor.j3md");
|
|
||||||
matWire.setColor("Color", ColorRGBA.Green);
|
|
||||||
AbstractHeightMap heightmap = null;
|
AbstractHeightMap heightmap = null;
|
||||||
try {
|
try {
|
||||||
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
|
||||||
|
|||||||
@ -93,7 +93,7 @@ public class TestSceneWater extends SimpleApplication {
|
|||||||
sun.setColor(ColorRGBA.White.clone().multLocal(2));
|
sun.setColor(ColorRGBA.White.clone().multLocal(2));
|
||||||
scene.addLight(sun);
|
scene.addLight(sun);
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
//add lightPos Geometry
|
//add lightPos Geometry
|
||||||
Sphere lite=new Sphere(8, 8, 3.0f);
|
Sphere lite=new Sphere(8, 8, 3.0f);
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class TestSimpleWater extends SimpleApplication implements ActionListener
|
|||||||
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
|
||||||
//init scene
|
//init scene
|
||||||
sceneNode = new Node("Scene");
|
sceneNode = new Node("Scene");
|
||||||
mat = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
|
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
|
||||||
Box b = new Box(1, 1, 1);
|
Box b = new Box(1, 1, 1);
|
||||||
Geometry geom = new Geometry("Box", b);
|
Geometry geom = new Geometry("Box", b);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user