* Initial docs for com.jme3.scene.debug, com.jme3.scene.shape, com.jme3.scene.control
* Javadocs for com.jme3.scene.mesh * Formatting for com.jme3.terrain classes * Terrain updating thread now called "jME3 Terrain Thread" git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7667 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
d62952a16e
commit
a6300ba55b
@ -36,7 +36,8 @@ import com.jme3.scene.control.CameraControl;
|
|||||||
import com.jme3.scene.control.CameraControl.ControlDirection;
|
import com.jme3.scene.control.CameraControl.ControlDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Node is a shorthand for using a CameraControl.
|
* <code>CameraNode</code> simply uses {@link CameraControl} to implement
|
||||||
|
* linking of camera and node data.
|
||||||
*
|
*
|
||||||
* @author Tim8Dev
|
* @author Tim8Dev
|
||||||
*/
|
*/
|
||||||
@ -45,7 +46,7 @@ public class CameraNode extends Node {
|
|||||||
private CameraControl camControl;
|
private CameraControl camControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for IO purpose
|
* Serialization only. Do not use.
|
||||||
*/
|
*/
|
||||||
public CameraNode() {
|
public CameraNode() {
|
||||||
}
|
}
|
||||||
|
17
engine/src/core/com/jme3/scene/control/package.html
Normal file
17
engine/src/core/com/jme3/scene/control/package.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
The <code>com.jme3.control</code> package provides
|
||||||
|
{@link com.jme3.scene.control.Control controls}.
|
||||||
|
Controls represent the "logical" programming of scene graph elements, containing
|
||||||
|
callbacks for when a {@link com.jme3.scene.Spatial} is rendered or updated
|
||||||
|
by the engine.
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -37,9 +37,17 @@ import com.jme3.scene.Mesh;
|
|||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The <code>Arrow</code> debug shape represents an arrow.
|
||||||
|
* An arrow is simply a line going from the original toward an extent
|
||||||
|
* and at the tip there will be triangle-like shape.
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class Arrow extends Mesh {
|
public class Arrow extends Mesh {
|
||||||
Quaternion tempQuat = new Quaternion();
|
|
||||||
Vector3f tempVec = new Vector3f();
|
private Quaternion tempQuat = new Quaternion();
|
||||||
|
private Vector3f tempVec = new Vector3f();
|
||||||
|
|
||||||
private static final float[] positions = new float[]{
|
private static final float[] positions = new float[]{
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
@ -50,15 +58,25 @@ public class Arrow extends Mesh {
|
|||||||
0, -0.05f, 0.9f, // tip buttom
|
0, -0.05f, 0.9f, // tip buttom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialization only. Do not use.
|
||||||
|
*/
|
||||||
public Arrow() {
|
public Arrow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an arrow mesh with the given extent.
|
||||||
|
* The arrow will start at the origin (0,0,0) and finish
|
||||||
|
* at the given extent.
|
||||||
|
*
|
||||||
|
* @param extent Extent of the arrow from origin
|
||||||
|
*/
|
||||||
public Arrow(Vector3f extent) {
|
public Arrow(Vector3f extent) {
|
||||||
float len = extent.length();
|
float len = extent.length();
|
||||||
Vector3f dir = extent.normalize();
|
Vector3f dir = extent.normalize();
|
||||||
|
|
||||||
tempQuat.lookAt(dir, Vector3f.UNIT_Y);
|
tempQuat.lookAt(dir, Vector3f.UNIT_Y);
|
||||||
tempQuat.normalize();
|
tempQuat.normalizeLocal();
|
||||||
|
|
||||||
float[] newPositions = new float[positions.length];
|
float[] newPositions = new float[positions.length];
|
||||||
for (int i = 0; i < positions.length; i += 3) {
|
for (int i = 0; i < positions.length; i += 3) {
|
||||||
@ -87,12 +105,18 @@ public class Arrow extends Mesh {
|
|||||||
updateCounts();
|
updateCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the arrow's extent.
|
||||||
|
* This will modify the buffers on the mesh.
|
||||||
|
*
|
||||||
|
* @param extent the arrow's extent.
|
||||||
|
*/
|
||||||
public void setArrowExtent(Vector3f extent) {
|
public void setArrowExtent(Vector3f extent) {
|
||||||
float len = extent.length();
|
float len = extent.length();
|
||||||
// Vector3f dir = extent.normalize();
|
// Vector3f dir = extent.normalize();
|
||||||
|
|
||||||
tempQuat.lookAt(extent, Vector3f.UNIT_Y);
|
tempQuat.lookAt(extent, Vector3f.UNIT_Y);
|
||||||
tempQuat.normalize();
|
tempQuat.normalizeLocal();
|
||||||
|
|
||||||
FloatBuffer buffer = getFloatBuffer(Type.Position);
|
FloatBuffer buffer = getFloatBuffer(Type.Position);
|
||||||
buffer.rewind();
|
buffer.rewind();
|
||||||
|
@ -39,8 +39,19 @@ import com.jme3.util.BufferUtils;
|
|||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple grid shape.
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class Grid extends Mesh {
|
public class Grid extends Mesh {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a grid debug shape.
|
||||||
|
* @param xLines
|
||||||
|
* @param yLines
|
||||||
|
* @param lineDist
|
||||||
|
*/
|
||||||
public Grid(int xLines, int yLines, float lineDist){
|
public Grid(int xLines, int yLines, float lineDist){
|
||||||
xLines -= 2;
|
xLines -= 2;
|
||||||
yLines -= 2;
|
yLines -= 2;
|
||||||
@ -90,4 +101,5 @@ public class Grid extends Mesh {
|
|||||||
updateBound();
|
updateBound();
|
||||||
updateCounts();
|
updateCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,35 @@ import java.nio.Buffer;
|
|||||||
* @author lex
|
* @author lex
|
||||||
*/
|
*/
|
||||||
public abstract class IndexBuffer {
|
public abstract class IndexBuffer {
|
||||||
|
/**
|
||||||
|
* Returns the vertex index for the given index in the index buffer.
|
||||||
|
*
|
||||||
|
* @param i The index inside the index buffer
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract int get(int i);
|
public abstract int get(int i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts the vertex index at the index buffer's index.
|
||||||
|
* Implementations may throw an {@link UnsupportedOperationException}
|
||||||
|
* if modifying the IndexBuffer is not supported (e.g. virtual index
|
||||||
|
* buffers).
|
||||||
|
*/
|
||||||
public abstract void put(int i, int value);
|
public abstract void put(int i, int value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the index buffer.
|
||||||
|
*
|
||||||
|
* @return the size of the index buffer.
|
||||||
|
*/
|
||||||
public abstract int size();
|
public abstract int size();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the underlying data-type specific {@link Buffer}.
|
||||||
|
* Implementations may return null if there's no underlying
|
||||||
|
* buffer.
|
||||||
|
*
|
||||||
|
* @return the underlying {@link Buffer}.
|
||||||
|
*/
|
||||||
public abstract Buffer getBuffer();
|
public abstract Buffer getBuffer();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import java.nio.Buffer;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* IndexBuffer implementation for {@link ByteBuffer}s.
|
||||||
*
|
*
|
||||||
* @author lex
|
* @author lex
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,7 @@ import java.nio.Buffer;
|
|||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* IndexBuffer implementation for {@link IntBuffer}s.
|
||||||
*
|
*
|
||||||
* @author lex
|
* @author lex
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,7 @@ import java.nio.Buffer;
|
|||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* IndexBuffer implementation for {@link ShortBuffer}s.
|
||||||
*
|
*
|
||||||
* @author lex
|
* @author lex
|
||||||
*/
|
*/
|
||||||
|
@ -3,6 +3,22 @@ package com.jme3.scene.mesh;
|
|||||||
import com.jme3.scene.Mesh.Mode;
|
import com.jme3.scene.Mesh.Mode;
|
||||||
import java.nio.Buffer;
|
import java.nio.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IndexBuffer implementation that generates vertex indices sequentially
|
||||||
|
* based on a specific Mesh {@link Mode}.
|
||||||
|
* The generated indices are as if the mesh is in the given mode
|
||||||
|
* but contains no index buffer, thus this implementation will
|
||||||
|
* return the indices if the index buffer was there and contained sequential
|
||||||
|
* triangles.
|
||||||
|
* Example:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link Mode#Triangles}: 0, 1, 2 | 3, 4, 5 | 6, 7, 8 | ...</li>
|
||||||
|
* <li>{@link Mode#TriangleStrip}: 0, 1, 2 | 2, 1, 3 | 2, 3, 4 | ...</li>
|
||||||
|
* <li>{@link Mode#TriangleFan}: 0, 1, 2 | 0, 2, 3 | 0, 3, 4 | ...</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class VirtualIndexBuffer extends IndexBuffer {
|
public class VirtualIndexBuffer extends IndexBuffer {
|
||||||
|
|
||||||
protected int numVerts = 0;
|
protected int numVerts = 0;
|
||||||
|
@ -9,9 +9,12 @@ import java.nio.IntBuffer;
|
|||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>WrappedIndexBuffer</code> converts from one representation of mesh
|
* <code>WrappedIndexBuffer</code> converts vertex indices from a non list based
|
||||||
* data to another. For example it can be used to read TriangleStrip data
|
* mesh mode such as {@link Mode#TriangleStrip} or {@link Mode#LineLoop}
|
||||||
* as if it was in Triangle format.
|
* into a list based mode such as {@link Mode#Triangles} or {@link Mode#Lines}.
|
||||||
|
* As it is often more convenient to read vertex data in list format
|
||||||
|
* than in a non-list format, using this class is recommended to avoid
|
||||||
|
* convoluting classes used to process mesh data from an external source.
|
||||||
*
|
*
|
||||||
* @author Kirill Vainer
|
* @author Kirill Vainer
|
||||||
*/
|
*/
|
||||||
|
25
engine/src/core/com/jme3/scene/mesh/package.html
Normal file
25
engine/src/core/com/jme3/scene/mesh/package.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
The <code>com.jme3.scene.mesh</code> package contains utilities
|
||||||
|
for reading from {@link com.jme3.scene.mesh.IndexBuffer index buffers}.
|
||||||
|
Several implementations are provided of the {@link com.jme3.scene.mesh.IndexBuffer}
|
||||||
|
class:
|
||||||
|
<ul>
|
||||||
|
<li>{@link com.jme3.scene.mesh.IndexByteBuffer} - For reading 8-bit index buffers</li>
|
||||||
|
<li>{@link com.jme3.scene.mesh.IndexShortBuffer} - For reading 16-bit index buffers</li>
|
||||||
|
<li>{@link com.jme3.scene.mesh.IndexIntBuffer} - For reading 32-bit index buffers</li>
|
||||||
|
<li>{@link com.jme3.scene.mesh.VirtualIndexBuffer} - For reading "virtual indices", for
|
||||||
|
those meshes that do not have an index buffer</li>
|
||||||
|
<li>{@link com.jme3.scene.mesh.WrappedIndexBuffer} - For converting from
|
||||||
|
non-list based mode indices to list based</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
26
engine/src/core/com/jme3/scene/package.html
Normal file
26
engine/src/core/com/jme3/scene/package.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
The <code>com.jme3.input</code> package contains the scene graph implementation
|
||||||
|
in jMonkeyEngine.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The scene graph is the most important package in jME, as it is the API
|
||||||
|
used to manage scene elements so that they can be rendered.
|
||||||
|
The {@link com.jme3.scene.Spatial} class provides a common base class
|
||||||
|
for all scene graph elements. The {@link com.jme3.scene.Node} class provides
|
||||||
|
the "branches" in the graph, used to organize elements in a tree
|
||||||
|
hierarchy. The {@link com.jme3.scene.Geometry} is the leaf class that
|
||||||
|
will contain a {@link com.jme3.scene.Mesh} object (geometry data
|
||||||
|
such as vertex positions, normals, etc) and a {@link com.jme3.scene.Material}
|
||||||
|
object containing information on how the geometry should be shaded.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -48,7 +48,7 @@ import java.io.IOException;
|
|||||||
* a way as to generate an axis-aligned box.
|
* a way as to generate an axis-aligned box.
|
||||||
* <p>
|
* <p>
|
||||||
* This class does not control how the geometry data is generated, see {@link Box}
|
* This class does not control how the geometry data is generated, see {@link Box}
|
||||||
* and {@link StripBox} for that.
|
* for that.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:ianp@ianp.org">Ian Phillips</a>
|
* @author <a href="mailto:ianp@ianp.org">Ian Phillips</a>
|
||||||
* @version $Revision: 4131 $, $Date: 2009-03-19 16:15:28 -0400 (Thu, 19 Mar 2009) $
|
* @version $Revision: 4131 $, $Date: 2009-03-19 16:15:28 -0400 (Thu, 19 Mar 2009) $
|
||||||
@ -87,7 +87,7 @@ public abstract class AbstractBox extends Mesh {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the indices into the list of vertices that define the box's tri-mesh.
|
* Convert the indices into the list of vertices that define the box's geometry.
|
||||||
*/
|
*/
|
||||||
protected abstract void duUpdateGeometryIndices();
|
protected abstract void duUpdateGeometryIndices();
|
||||||
|
|
||||||
@ -111,22 +111,30 @@ public abstract class AbstractBox extends Mesh {
|
|||||||
*/
|
*/
|
||||||
protected abstract void duUpdateGeometryVertices();
|
protected abstract void duUpdateGeometryVertices();
|
||||||
|
|
||||||
/** Get the centre point of this box. */
|
/**
|
||||||
|
* Get the center point of this box.
|
||||||
|
*/
|
||||||
public final Vector3f getCenter() {
|
public final Vector3f getCenter() {
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the x-axis size (extent) of this box. */
|
/**
|
||||||
|
* Get the x-axis size (extent) of this box.
|
||||||
|
*/
|
||||||
public final float getXExtent() {
|
public final float getXExtent() {
|
||||||
return xExtent;
|
return xExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the y-axis size (extent) of this box. */
|
/**
|
||||||
|
* Get the y-axis size (extent) of this box.
|
||||||
|
*/
|
||||||
public final float getYExtent() {
|
public final float getYExtent() {
|
||||||
return yExtent;
|
return yExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the z-axis size (extent) of this box. */
|
/**
|
||||||
|
* Get the z-axis size (extent) of this box.
|
||||||
|
*/
|
||||||
public final float getZExtent() {
|
public final float getZExtent() {
|
||||||
return zExtent;
|
return zExtent;
|
||||||
}
|
}
|
||||||
@ -180,6 +188,7 @@ public abstract class AbstractBox extends Mesh {
|
|||||||
updateGeometry(center, x, y, z);
|
updateGeometry(center, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void read(JmeImporter e) throws IOException {
|
public void read(JmeImporter e) throws IOException {
|
||||||
super.read(e);
|
super.read(e);
|
||||||
InputCapsule capsule = e.getCapsule(this);
|
InputCapsule capsule = e.getCapsule(this);
|
||||||
@ -189,6 +198,7 @@ public abstract class AbstractBox extends Mesh {
|
|||||||
center.set((Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone()));
|
center.set((Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(JmeExporter e) throws IOException {
|
public void write(JmeExporter e) throws IOException {
|
||||||
super.write(e);
|
super.write(e);
|
||||||
OutputCapsule capsule = e.getCapsule(this);
|
OutputCapsule capsule = e.getCapsule(this);
|
||||||
|
@ -39,6 +39,10 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A <code>Curve</code> is a visual, line-based representation of a {@link Spline}.
|
||||||
|
* The underlying Spline will be sampled N times where N is the number of
|
||||||
|
* segments as specified in the constructor. Each segment will represent
|
||||||
|
* one line in the generated mesh.
|
||||||
*
|
*
|
||||||
* @author Nehon
|
* @author Nehon
|
||||||
*/
|
*/
|
||||||
@ -48,8 +52,15 @@ public class Curve extends Mesh {
|
|||||||
private Vector3f temp = new Vector3f();
|
private Vector3f temp = new Vector3f();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a curve mesh
|
* Serialization only. Do not use.
|
||||||
|
*/
|
||||||
|
public Curve(){
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a curve mesh.
|
||||||
* Use a CatmullRom spline model that does not cycle.
|
* Use a CatmullRom spline model that does not cycle.
|
||||||
|
*
|
||||||
* @param controlPoints the control points to use to create this curve
|
* @param controlPoints the control points to use to create this curve
|
||||||
* @param nbSubSegments the number of subsegments between the control points
|
* @param nbSubSegments the number of subsegments between the control points
|
||||||
*/
|
*/
|
||||||
@ -59,6 +70,7 @@ public class Curve extends Mesh {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a curve mesh from a Spline
|
* Create a curve mesh from a Spline
|
||||||
|
*
|
||||||
* @param spline the spline to use
|
* @param spline the spline to use
|
||||||
* @param nbSubSegments the number of subsegments between the control points
|
* @param nbSubSegments the number of subsegments between the control points
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ public class Dome extends Mesh {
|
|||||||
private boolean outsideView = true;
|
private boolean outsideView = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a dome. By default the dome has not geometry data or center.
|
* Serialization only. Do not use.
|
||||||
*/
|
*/
|
||||||
public Dome() {
|
public Dome() {
|
||||||
}
|
}
|
||||||
@ -140,25 +140,29 @@ public class Dome extends Mesh {
|
|||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the number of planar segments along the z-axis of the dome. */
|
/**
|
||||||
|
* Get the number of planar segments along the z-axis of the dome.
|
||||||
|
*/
|
||||||
public int getPlanes() {
|
public int getPlanes() {
|
||||||
return planes;
|
return planes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the number of samples radially around the main axis of the dome. */
|
/**
|
||||||
|
* Get the number of samples radially around the main axis of the dome.
|
||||||
|
*/
|
||||||
public int getRadialSamples() {
|
public int getRadialSamples() {
|
||||||
return radialSamples;
|
return radialSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the radius of the dome. */
|
/**
|
||||||
|
* Get the radius of the dome.
|
||||||
|
*/
|
||||||
public float getRadius() {
|
public float getRadius() {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Are the triangles connected in such a way as to present a view out from the dome or not.
|
* Are the triangles connected in such a way as to present a view out from the dome or not.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isOutsideView() {
|
public boolean isOutsideView() {
|
||||||
return outsideView;
|
return outsideView;
|
||||||
@ -298,6 +302,7 @@ public class Dome extends Mesh {
|
|||||||
updateBound();
|
updateBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void read(JmeImporter e) throws IOException {
|
public void read(JmeImporter e) throws IOException {
|
||||||
super.read(e);
|
super.read(e);
|
||||||
InputCapsule capsule = e.getCapsule(this);
|
InputCapsule capsule = e.getCapsule(this);
|
||||||
@ -307,9 +312,7 @@ public class Dome extends Mesh {
|
|||||||
center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone());
|
center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Generates the connections
|
|
||||||
*/
|
|
||||||
public void write(JmeExporter e) throws IOException {
|
public void write(JmeExporter e) throws IOException {
|
||||||
super.write(e);
|
super.write(e);
|
||||||
OutputCapsule capsule = e.getCapsule(this);
|
OutputCapsule capsule = e.getCapsule(this);
|
||||||
|
@ -40,7 +40,6 @@ import com.jme3.math.Vector3f;
|
|||||||
import com.jme3.scene.Mesh;
|
import com.jme3.scene.Mesh;
|
||||||
import com.jme3.scene.VertexBuffer;
|
import com.jme3.scene.VertexBuffer;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
import com.jme3.util.BufferUtils;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ import static com.jme3.util.BufferUtils.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,24 +32,48 @@
|
|||||||
|
|
||||||
package com.jme3.scene.shape;
|
package com.jme3.scene.shape;
|
||||||
|
|
||||||
import com.jme3.scene.*;
|
import com.jme3.scene.Mesh;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>Quad</code> represents a rectangular plane in space
|
||||||
|
* defined by 4 vertices. The quad's lower-left side is contained
|
||||||
|
* at the local space origin (0, 0, 0), while the upper-right
|
||||||
|
* side is located at the width/height coordinates (width, height, 0).
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class Quad extends Mesh {
|
public class Quad extends Mesh {
|
||||||
|
|
||||||
private float width;
|
private float width;
|
||||||
private float height;
|
private float height;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use this constructor. Serialization purposes only.
|
* Serialization only. Do not use.
|
||||||
*/
|
*/
|
||||||
public Quad(){
|
public Quad(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a quad with the given width and height. The quad
|
||||||
|
* is always created in the XY plane.
|
||||||
|
*
|
||||||
|
* @param width The X extent or width
|
||||||
|
* @param height The Y extent or width
|
||||||
|
*/
|
||||||
public Quad(float width, float height){
|
public Quad(float width, float height){
|
||||||
updateGeometry(width, height);
|
updateGeometry(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a quad with the given width and height. The quad
|
||||||
|
* is always created in the XY plane.
|
||||||
|
*
|
||||||
|
* @param width The X extent or width
|
||||||
|
* @param height The Y extent or width
|
||||||
|
* @param flipCoords If true, the texture coordinates will be flipped
|
||||||
|
* along the Y axis.
|
||||||
|
*/
|
||||||
public Quad(float width, float height, boolean flipCoords){
|
public Quad(float width, float height, boolean flipCoords){
|
||||||
updateGeometry(width, height, flipCoords);
|
updateGeometry(width, height, flipCoords);
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,16 @@ import java.nio.ShortBuffer;
|
|||||||
public class Sphere extends Mesh {
|
public class Sphere extends Mesh {
|
||||||
|
|
||||||
public enum TextureMode {
|
public enum TextureMode {
|
||||||
/** Wrap texture radially and along z-axis */
|
/**
|
||||||
|
* Wrap texture radially and along z-axis
|
||||||
|
*/
|
||||||
Original,
|
Original,
|
||||||
/** Wrap texure radially, but spherically project along z-axis */
|
/**
|
||||||
|
* Wrap texure radially, but spherically project along z-axis
|
||||||
|
*/
|
||||||
Projected,
|
Projected,
|
||||||
/** Apply texture to each pole. Eliminates polar distortion,
|
/**
|
||||||
|
* Apply texture to each pole. Eliminates polar distortion,
|
||||||
* but mirrors the texture across the equator
|
* but mirrors the texture across the equator
|
||||||
*/
|
*/
|
||||||
Polar
|
Polar
|
||||||
@ -86,7 +91,7 @@ public class Sphere extends Mesh {
|
|||||||
protected TextureMode textureMode = TextureMode.Original;
|
protected TextureMode textureMode = TextureMode.Original;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor for serialization only, do not use.
|
* Serialization only. Do not use.
|
||||||
*/
|
*/
|
||||||
public Sphere(){
|
public Sphere(){
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -54,7 +55,7 @@ public class MapUtils {
|
|||||||
public static void saveImage(BufferedImage im, File file) {
|
public static void saveImage(BufferedImage im, File file) {
|
||||||
try {
|
try {
|
||||||
ImageIO.write(im, "PNG", file);
|
ImageIO.write(im, "PNG", file);
|
||||||
Logger.getLogger(MapUtils.class.getCanonicalName()).info("Saved image as : " + file.getAbsolutePath());
|
Logger.getLogger(MapUtils.class.getCanonicalName()).log(Level.INFO, "Saved image as : {0}", file.getAbsolutePath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -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 com.jme3.terrain;
|
package com.jme3.terrain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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 com.jme3.terrain;
|
package com.jme3.terrain;
|
||||||
|
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
@ -162,7 +161,6 @@ public interface Terrain {
|
|||||||
*/
|
*/
|
||||||
public void generateEntropy(ProgressMonitor monitor);
|
public void generateEntropy(ProgressMonitor monitor);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the material that this terrain uses.
|
* Returns the material that this terrain uses.
|
||||||
* This does not necessarily have to guarantee the material
|
* This does not necessarily have to guarantee the material
|
||||||
@ -195,5 +193,4 @@ public interface Terrain {
|
|||||||
* texture scales.
|
* texture scales.
|
||||||
*/
|
*/
|
||||||
public float getTextureCoordinateScale();
|
public float getTextureCoordinateScale();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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 com.jme3.terrain.geomipmap;
|
package com.jme3.terrain.geomipmap;
|
||||||
|
|
||||||
import com.jme3.export.InputCapsule;
|
import com.jme3.export.InputCapsule;
|
||||||
@ -67,7 +66,8 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class LODGeomap extends BufferGeomap {
|
public class LODGeomap extends BufferGeomap {
|
||||||
|
|
||||||
public LODGeomap() {}
|
public LODGeomap() {
|
||||||
|
}
|
||||||
|
|
||||||
public LODGeomap(int size, FloatBuffer heightMap) {
|
public LODGeomap(int size, FloatBuffer heightMap) {
|
||||||
super(heightMap, null, size, size, 1);
|
super(heightMap, null, size, size, 1);
|
||||||
@ -93,21 +93,22 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void removeNormalBuffer() {
|
protected void removeNormalBuffer() {
|
||||||
ndata = null;
|
ndata = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatBuffer writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) {
|
public FloatBuffer writeTexCoordArray(FloatBuffer store, Vector2f offset, Vector2f scale, float offsetAmount, int totalSize) {
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
if (store.remaining() < getWidth()*getHeight()*2)
|
if (store.remaining() < getWidth() * getHeight() * 2) {
|
||||||
throw new BufferUnderflowException();
|
throw new BufferUnderflowException();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 2);
|
store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset == null)
|
if (offset == null) {
|
||||||
offset = new Vector2f();
|
offset = new Vector2f();
|
||||||
|
}
|
||||||
|
|
||||||
Vector2f tcStore = new Vector2f();
|
Vector2f tcStore = new Vector2f();
|
||||||
|
|
||||||
@ -150,8 +151,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
IntBuffer buffer2 = store;
|
IntBuffer buffer2 = store;
|
||||||
int numIndexes = calculateNumIndexesLodDiff(lod);
|
int numIndexes = calculateNumIndexesLodDiff(lod);
|
||||||
if (store == null)
|
if (store == null) {
|
||||||
buffer2 = BufferUtils.createIntBuffer(numIndexes);
|
buffer2 = BufferUtils.createIntBuffer(numIndexes);
|
||||||
|
}
|
||||||
VerboseIntBuffer buffer = new VerboseIntBuffer(buffer2);
|
VerboseIntBuffer buffer = new VerboseIntBuffer(buffer2);
|
||||||
|
|
||||||
|
|
||||||
@ -200,7 +202,6 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
idx = (row - lod) * getWidth() - 1;
|
idx = (row - lod) * getWidth() - 1;
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -224,8 +225,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
// top (the order gets reversed here so the diagonals line up)
|
// top (the order gets reversed here so the diagonals line up)
|
||||||
if (topLod) { // if lower LOD
|
if (topLod) { // if lower LOD
|
||||||
if (rightLod)
|
if (rightLod) {
|
||||||
buffer.put(getWidth() - 1);
|
buffer.put(getWidth() - 1);
|
||||||
|
}
|
||||||
for (int col = getWidth() - 1; col >= lod; col -= 2 * lod) {
|
for (int col = getWidth() - 1; col >= lod; col -= 2 * lod) {
|
||||||
int idx = (lod * getWidth()) + col - lod; // next row
|
int idx = (lod * getWidth()) + col - lod; // next row
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
@ -237,12 +239,12 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
idx = col - 2 * lod;
|
idx = col - 2 * lod;
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rightLod)
|
if (rightLod) {
|
||||||
buffer.put(getWidth() - 1);
|
buffer.put(getWidth() - 1);
|
||||||
|
}
|
||||||
for (int col = getWidth() - 1 - lod; col > 0; col -= lod) {
|
for (int col = getWidth() - 1 - lod; col > 0; col -= lod) {
|
||||||
int idx = col + (lod * getWidth());
|
int idx = col + (lod * getWidth());
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
@ -260,8 +262,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
// left
|
// left
|
||||||
if (leftLod) { // if lower LOD
|
if (leftLod) { // if lower LOD
|
||||||
if (topLod)
|
if (topLod) {
|
||||||
buffer.put(0);
|
buffer.put(0);
|
||||||
|
}
|
||||||
for (int row = 0; row < getWidth() - lod; row += 2 * lod) {
|
for (int row = 0; row < getWidth() - lod; row += 2 * lod) {
|
||||||
int idx = (row + lod) * getWidth() + lod;
|
int idx = (row + lod) * getWidth() + lod;
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
@ -273,12 +276,12 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
idx = (row + 2 * lod) * getWidth();
|
idx = (row + 2 * lod) * getWidth();
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!topLod)
|
if (!topLod) {
|
||||||
buffer.put(0);
|
buffer.put(0);
|
||||||
|
}
|
||||||
//buffer.put(getWidth()+1); // degenerate
|
//buffer.put(getWidth()+1); // degenerate
|
||||||
//buffer.put(0); // degenerate winding-flip
|
//buffer.put(0); // degenerate winding-flip
|
||||||
for (int row = lod; row < getWidth() - lod; row += lod) {
|
for (int row = lod; row < getWidth() - lod; row += lod) {
|
||||||
@ -300,8 +303,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
// bottom
|
// bottom
|
||||||
if (bottomLod) { // if lower LOD
|
if (bottomLod) { // if lower LOD
|
||||||
if (leftLod)
|
if (leftLod) {
|
||||||
buffer.put(getWidth() * (getWidth() - 1));
|
buffer.put(getWidth() * (getWidth() - 1));
|
||||||
|
}
|
||||||
// there was a slight bug here when really high LOD near maxLod
|
// there was a slight bug here when really high LOD near maxLod
|
||||||
// far right has extra index one row up and all the way to the right, need to skip last index entered
|
// far right has extra index one row up and all the way to the right, need to skip last index entered
|
||||||
// seemed to be fixed by making "getWidth()-1-2-lod" this: "getWidth()-1-2*lod", which seems more correct
|
// seemed to be fixed by making "getWidth()-1-2-lod" this: "getWidth()-1-2*lod", which seems more correct
|
||||||
@ -316,7 +320,6 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
idx = getWidth() * (getWidth() - 1) + col + 2 * lod;
|
idx = getWidth() * (getWidth() - 1) + col + 2 * lod;
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -340,8 +343,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
//System.out.println("\nBuffer size: "+buffer.getCount());
|
//System.out.println("\nBuffer size: "+buffer.getCount());
|
||||||
|
|
||||||
// fill in the rest of the buffer with degenerates, there should only be a couple
|
// fill in the rest of the buffer with degenerates, there should only be a couple
|
||||||
for (int i=buffer.getCount(); i<numIndexes; i++)
|
for (int i = buffer.getCount(); i < numIndexes; i++) {
|
||||||
buffer.put(getWidth() * getWidth() - 1);
|
buffer.put(getWidth() * getWidth() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
return buffer.delegate;
|
return buffer.delegate;
|
||||||
}
|
}
|
||||||
@ -350,8 +354,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
IntBuffer buffer2 = store;
|
IntBuffer buffer2 = store;
|
||||||
int numIndexes = calculateNumIndexesLodDiff(lod);
|
int numIndexes = calculateNumIndexesLodDiff(lod);
|
||||||
if (store == null)
|
if (store == null) {
|
||||||
buffer2 = BufferUtils.createIntBuffer(numIndexes);
|
buffer2 = BufferUtils.createIntBuffer(numIndexes);
|
||||||
|
}
|
||||||
VerboseIntBuffer buffer = new VerboseIntBuffer(buffer2);
|
VerboseIntBuffer buffer = new VerboseIntBuffer(buffer2);
|
||||||
|
|
||||||
|
|
||||||
@ -457,8 +462,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rightLod>lod)
|
if (rightLod > lod) {
|
||||||
buffer.put(getWidth() - 1);
|
buffer.put(getWidth() - 1);
|
||||||
|
}
|
||||||
for (int col = getWidth() - 1 - lod; col > 0; col -= lod) {
|
for (int col = getWidth() - 1 - lod; col > 0; col -= lod) {
|
||||||
int idx = col + (lod * getWidth());
|
int idx = col + (lod * getWidth());
|
||||||
buffer.put(idx);
|
buffer.put(idx);
|
||||||
@ -568,8 +574,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
//System.out.println("\nBuffer size: "+buffer.getCount());
|
//System.out.println("\nBuffer size: "+buffer.getCount());
|
||||||
|
|
||||||
// fill in the rest of the buffer with degenerates, there should only be a couple
|
// fill in the rest of the buffer with degenerates, there should only be a couple
|
||||||
for (int i=buffer.getCount(); i<numIndexes; i++)
|
for (int i = buffer.getCount(); i < numIndexes; i++) {
|
||||||
buffer.put(getWidth() * getWidth() - 1);
|
buffer.put(getWidth() * getWidth() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
return buffer.delegate;
|
return buffer.delegate;
|
||||||
}
|
}
|
||||||
@ -586,14 +593,14 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
System.out.println("Index buffer size: "+num);
|
System.out.println("Index buffer size: "+num);
|
||||||
return num;
|
return num;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calculate how many indexes there will be.
|
* calculate how many indexes there will be.
|
||||||
* This isn't that precise and there might be a couple extra.
|
* This isn't that precise and there might be a couple extra.
|
||||||
*/
|
*/
|
||||||
private int calculateNumIndexesLodDiff(int lod) {
|
private int calculateNumIndexesLodDiff(int lod) {
|
||||||
if (lod == 0)
|
if (lod == 0) {
|
||||||
lod = 1;
|
lod = 1;
|
||||||
|
}
|
||||||
int length = getWidth() - 1; // make it even for lod calc
|
int length = getWidth() - 1; // make it even for lod calc
|
||||||
int side = (length / lod) + 1 - (2);
|
int side = (length / lod) + 1 - (2);
|
||||||
//System.out.println("side: "+side);
|
//System.out.println("side: "+side);
|
||||||
@ -618,12 +625,14 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FloatBuffer writeNormalArray(FloatBuffer store, Vector3f scale) {
|
public FloatBuffer writeNormalArray(FloatBuffer store, Vector3f scale) {
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
if (store != null) {
|
if (store != null) {
|
||||||
if (store.remaining() < getWidth()*getHeight()*3)
|
if (store.remaining() < getWidth() * getHeight() * 3) {
|
||||||
throw new BufferUnderflowException();
|
throw new BufferUnderflowException();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3);
|
store = BufferUtils.createFloatBuffer(getWidth() * getHeight() * 3);
|
||||||
}
|
}
|
||||||
@ -714,22 +723,22 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
|
|
||||||
private Vector3f getNormal(Vector3f firstPoint, Vector3f rootPoint, Vector3f secondPoint) {
|
private Vector3f getNormal(Vector3f firstPoint, Vector3f rootPoint, Vector3f secondPoint) {
|
||||||
Vector3f normal = new Vector3f();
|
Vector3f normal = new Vector3f();
|
||||||
normal.set(firstPoint).subtractLocal(rootPoint)
|
normal.set(firstPoint).subtractLocal(rootPoint).crossLocal(secondPoint.subtract(rootPoint)).normalizeLocal();
|
||||||
.crossLocal(secondPoint.subtract(rootPoint)).normalizeLocal();
|
|
||||||
return normal;
|
return normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps a count of the number of indexes, good for debugging
|
* Keeps a count of the number of indexes, good for debugging
|
||||||
*/
|
*/
|
||||||
public class VerboseIntBuffer {
|
public class VerboseIntBuffer {
|
||||||
|
|
||||||
private IntBuffer delegate;
|
private IntBuffer delegate;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
public VerboseIntBuffer(IntBuffer d) {
|
public VerboseIntBuffer(IntBuffer d) {
|
||||||
delegate = d;
|
delegate = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void put(int value) {
|
public void put(int value) {
|
||||||
try {
|
try {
|
||||||
delegate.put(value);
|
delegate.put(value);
|
||||||
@ -738,6 +747,7 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
//System.out.println("err buffer size: "+delegate.capacity());
|
//System.out.println("err buffer size: "+delegate.capacity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -811,8 +821,9 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
int gridY = (int) z;
|
int gridY = (int) z;
|
||||||
|
|
||||||
int index = findClosestHeightIndex(gridX, gridY);
|
int index = findClosestHeightIndex(gridX, gridY);
|
||||||
if (index < 0)
|
if (index < 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Triangle t = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
|
Triangle t = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
|
||||||
Triangle t2 = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
|
Triangle t2 = new Triangle(new Vector3f(), new Vector3f(), new Vector3f());
|
||||||
@ -848,8 +859,7 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
t2.get(2).x = (gridX + 1);
|
t2.get(2).x = (gridX + 1);
|
||||||
t2.get(2).y = (h2);
|
t2.get(2).y = (h2);
|
||||||
t2.get(2).z = (gridY);
|
t2.get(2).z = (gridY);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// all other grid points
|
// all other grid points
|
||||||
t.get(0).x = (gridX);
|
t.get(0).x = (gridX);
|
||||||
t.get(0).y = (h1);
|
t.get(0).y = (h1);
|
||||||
@ -897,20 +907,21 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
Vector2f t2 = new Vector2f(triangles[0].get2().x, triangles[0].get2().z);
|
Vector2f t2 = new Vector2f(triangles[0].get2().x, triangles[0].get2().z);
|
||||||
Vector2f t3 = new Vector2f(triangles[0].get3().x, triangles[0].get3().z);
|
Vector2f t3 = new Vector2f(triangles[0].get3().x, triangles[0].get3().z);
|
||||||
|
|
||||||
if (0 != FastMath.pointInsideTriangle(t1, t2, t3, point))
|
if (0 != FastMath.pointInsideTriangle(t1, t2, t3, point)) {
|
||||||
return triangles[0];
|
return triangles[0];
|
||||||
|
}
|
||||||
|
|
||||||
t1.set(triangles[1].get1().x, triangles[1].get1().z);
|
t1.set(triangles[1].get1().x, triangles[1].get1().z);
|
||||||
t1.set(triangles[1].get2().x, triangles[1].get2().z);
|
t1.set(triangles[1].get2().x, triangles[1].get2().z);
|
||||||
t1.set(triangles[1].get3().x, triangles[1].get3().z);
|
t1.set(triangles[1].get3().x, triangles[1].get3().z);
|
||||||
|
|
||||||
if (0 != FastMath.pointInsideTriangle(t1, t2, t3, point))
|
if (0 != FastMath.pointInsideTriangle(t1, t2, t3, point)) {
|
||||||
return triangles[1];
|
return triangles[1];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected int findClosestHeightIndex(int x, int z) {
|
protected int findClosestHeightIndex(int x, int z) {
|
||||||
|
|
||||||
if (x < 0 || x >= width - 1) {
|
if (x < 0 || x >= width - 1) {
|
||||||
@ -933,4 +944,3 @@ public class LODGeomap extends BufferGeomap {
|
|||||||
super.read(im);
|
super.read(im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,8 @@ import com.jme3.terrain.heightmap.HeightMapGrid;
|
|||||||
*/
|
*/
|
||||||
public class TerrainGrid extends TerrainQuad {
|
public class TerrainGrid extends TerrainQuad {
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(TerrainGrid.class.getCanonicalName());
|
private static final Logger log = Logger.getLogger(TerrainGrid.class.getCanonicalName());
|
||||||
|
|
||||||
private Vector3f currentCell;
|
private Vector3f currentCell;
|
||||||
private int quarterSize;
|
private int quarterSize;
|
||||||
private int quadSize;
|
private int quadSize;
|
||||||
|
@ -111,6 +111,7 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
protected ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
protected ExecutorService executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread th = new Thread(r);
|
Thread th = new Thread(r);
|
||||||
|
th.setName("jME Terrain Thread");
|
||||||
th.setDaemon(true);
|
th.setDaemon(true);
|
||||||
return th;
|
return th;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user