improve formatting & rm trailing whitespace (5 files in com.jme3.scene)

master
Stephen Gold 5 years ago
parent bee3d36f16
commit 851793cde6
  1. 31
      jme3-core/src/main/java/com/jme3/scene/Geometry.java
  2. 61
      jme3-core/src/main/java/com/jme3/scene/Mesh.java
  3. 59
      jme3-core/src/main/java/com/jme3/scene/Node.java
  4. 27
      jme3-core/src/main/java/com/jme3/scene/Spatial.java
  5. 71
      jme3-core/src/main/java/com/jme3/scene/VertexBuffer.java

@ -61,7 +61,6 @@ import java.util.logging.Logger;
* @author Kirill Vainer
*/
public class Geometry extends Spatial {
// Version #1: removed shared meshes.
// models loaded with shared mesh will be automatically fixed.
public static final int SAVABLE_VERSION = 1;
@ -74,19 +73,16 @@ public class Geometry extends Spatial {
*/
protected boolean ignoreTransform = false;
protected transient Matrix4f cachedWorldMat = new Matrix4f();
/**
* Specifies which {@link GeometryGroupNode} this <code>Geometry</code>
* is managed by.
*/
protected GeometryGroupNode groupNode;
/**
* The start index of this <code>Geometry's</code> inside
* the {@link GeometryGroupNode}.
*/
protected int startIndex = -1;
/**
* Morph state variable for morph animation
*/
@ -391,8 +387,7 @@ public class Geometry extends Spatial {
}
}
/**
/*
* Indicate that the transform of this spatial has changed and that
* a refresh is required.
*/
@ -624,6 +619,7 @@ public class Geometry extends Spatial {
/**
* returns true if the morph state has changed on the last frame.
*
* @return true if changed, otherwise false
*/
public boolean isDirtyMorph() {
@ -633,6 +629,7 @@ public class Geometry extends Spatial {
/**
* Seting this to true will stop this geometry morph buffer to be updated,
* unless the morph state changes
*
* @param dirtyMorph
*/
public void setDirtyMorph(boolean dirtyMorph) {
@ -642,6 +639,7 @@ public class Geometry extends Spatial {
/**
* returns the morph state of this Geometry.
* Used internally by the MorphControl.
*
* @return an array
*/
public float[] getMorphState() {
@ -653,6 +651,7 @@ public class Geometry extends Spatial {
/**
* Get the state of a morph
*
* @param morphTarget the name of the morph to get the state of
* @return the state of the morph, or -1 if the morph is not found
*/
@ -666,10 +665,13 @@ public class Geometry extends Spatial {
}
/**
* Return the number of morph targets that can be handled on the GPU simultaneously for this geometry.
* Return the number of morph targets that can be handled
* on the GPU simultaneously for this geometry.
* Note that it depends on the material set on this geometry.
* This number is computed and set by the MorphControl, so it might be available only after the first frame.
* This number is computed and set by the MorphControl,
* so it might be available only after the first frame.
* Else it's set to -1.
*
* @return the number of simultaneous morph targets handled on the GPU
*/
public int getNbSimultaneousGPUMorph() {
@ -677,11 +679,15 @@ public class Geometry extends Spatial {
}
/**
* Sets the number of morph targets that can be handled on the GPU simultaneously for this geometry.
* Sets the number of morph targets that can be handled
* on the GPU simultaneously for this geometry.
* Note that it depends on the material set on this geometry.
* This number is computed and set by the MorphControl, so it might be available only after the first frame.
* This number is computed and set by the MorphControl,
* so it might be available only after the first frame.
* Else it's set to -1.
* WARNING: setting this manually might crash the shader compilation if set too high. Do it at your own risk.
* WARNING: setting this manually might crash the shader compilation if set too high.
* Do it at your own risk.
*
* @param nbSimultaneousGPUMorph the number of simultaneous morph targets to be handled on the GPU.
*/
public void setNbSimultaneousGPUMorph(int nbSimultaneousGPUMorph) {
@ -723,7 +729,8 @@ public class Geometry extends Spatial {
material = im.getAssetManager().loadMaterial(matName);
} catch (AssetNotFoundException ex) {
// Cannot find J3M file.
logger.log(Level.FINE, "Cannot locate {0} for geometry {1}", new Object[]{matName, key});
logger.log(Level.FINE, "Cannot locate {0} for geometry {1}",
new Object[]{matName, key});
}
}
// If material is NULL, try to load it from the geometry

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -46,7 +46,6 @@ import com.jme3.util.*;
import com.jme3.util.IntMap.Entry;
import com.jme3.util.clone.Cloner;
import com.jme3.util.clone.JmeCloneable;
import java.io.IOException;
import java.nio.*;
import java.util.ArrayList;
@ -79,50 +78,46 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
* determined via the vertex shader's <code>gl_PointSize</code> output.
*/
Points(true),
/**
* A primitive is a line segment. Every two vertices specify
* a single line. {@link Material#getAdditionalRenderState()} and {@link RenderState#setLineWidth(float)} can be used
* a single line. {@link Material#getAdditionalRenderState()}
* and {@link RenderState#setLineWidth(float)} can be used
* to set the width of the lines.
*/
Lines(true),
/**
* A primitive is a line segment. The first two vertices specify
* a single line, while subsequent vertices are combined with the
* previous vertex to make a line. {@link Material#getAdditionalRenderState()} and {@link RenderState#setLineWidth(float)} can
* previous vertex to make a line. {@link Material#getAdditionalRenderState()}
* and {@link RenderState#setLineWidth(float)} can
* be used to set the width of the lines.
*/
LineStrip(false),
/**
* Identical to {@link #LineStrip} except that at the end
* the last vertex is connected with the first to form a line.
* {@link Material#getAdditionalRenderState()} and {@link RenderState#setLineWidth(float)} can be used
* {@link Material#getAdditionalRenderState()}
* and {@link RenderState#setLineWidth(float)} can be used
* to set the width of the lines.
*/
LineLoop(false),
/**
* A primitive is a triangle. Each 3 vertices specify a single
* triangle.
*/
Triangles(true),
/**
* Similar to {@link #Triangles}, the first 3 vertices
* specify a triangle, while subsequent vertices are combined with
* the previous two to form a triangle.
*/
TriangleStrip(false),
/**
* Similar to {@link #Triangles}, the first 3 vertices
* specify a triangle, each 2 subsequent vertices are combined
* with the very first vertex to make a triangle.
*/
TriangleFan(false),
/**
* A combination of various triangle modes. It is best to avoid
* using this mode as it may not be supported by all renderers.
@ -315,7 +310,6 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
*/
@Override
public void cloneFields(Cloner cloner, Object original) {
// Probably could clone this now but it will get regenerated anyway.
this.collisionTree = null;
@ -445,29 +439,34 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
VertexBuffer indices = getBuffer(Type.BoneIndex);
if (indices.getFormat() == Format.UnsignedByte) {
ByteBuffer originalIndex = (ByteBuffer) indices.getData();
ByteBuffer directIndex = BufferUtils.createByteBuffer(originalIndex.capacity());
ByteBuffer directIndex
= BufferUtils.createByteBuffer(originalIndex.capacity());
originalIndex.clear();
directIndex.put(originalIndex);
result = directIndex;
} else {
//bone indices can be stored in an UnsignedShort buffer
ShortBuffer originalIndex = (ShortBuffer) indices.getData();
ShortBuffer directIndex = BufferUtils.createShortBuffer(originalIndex.capacity());
ShortBuffer directIndex
= BufferUtils.createShortBuffer(originalIndex.capacity());
originalIndex.clear();
directIndex.put(originalIndex);
result = directIndex;
}
indicesHW.setupData(Usage.Static, indices.getNumComponents(), indices.getFormat(), result);
indicesHW.setupData(Usage.Static, indices.getNumComponents(),
indices.getFormat(), result);
}
VertexBuffer weightsHW = getBuffer(Type.HWBoneWeight);
if (weightsHW.getData() == null) {
VertexBuffer weights = getBuffer(Type.BoneWeight);
FloatBuffer originalWeight = (FloatBuffer) weights.getData();
FloatBuffer directWeight = BufferUtils.createFloatBuffer(originalWeight.capacity());
FloatBuffer directWeight
= BufferUtils.createFloatBuffer(originalWeight.capacity());
originalWeight.clear();
directWeight.put(originalWeight);
weightsHW.setupData(Usage.Static, weights.getNumComponents(), weights.getFormat(), directWeight);
weightsHW.setupData(Usage.Static, weights.getNumComponents(),
weights.getFormat(), directWeight);
}
// position, normal, and tanget buffers to be in "Static" mode
@ -636,7 +635,8 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
* Returns the line width for line meshes.
*
* @return the line width
* @deprecated use {@link Material#getAdditionalRenderState()} and {@link RenderState#getLineWidth()}
* @deprecated use {@link Material#getAdditionalRenderState()}
* and {@link RenderState#getLineWidth()}
*/
@Deprecated
public float getLineWidth() {
@ -649,7 +649,8 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
* the default value is 1.0.
*
* @param lineWidth The line width
* @deprecated use {@link Material#getAdditionalRenderState()} and {@link RenderState#setLineWidth(float)}
* @deprecated use {@link Material#getAdditionalRenderState()}
* and {@link RenderState#setLineWidth(float)}
*/
@Deprecated
public void setLineWidth(float lineWidth) {
@ -1311,8 +1312,10 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
if (oldVb.getData() != null) {
// Create a new vertex buffer with similar configuration, but
// with the capacity of number of unique vertices
Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(), oldVb.getNumComponents(), newNumVerts);
newVb.setupData(oldVb.getUsage(), oldVb.getNumComponents(), oldVb.getFormat(), buffer);
Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(),
oldVb.getNumComponents(), newNumVerts);
newVb.setupData(oldVb.getUsage(), oldVb.getNumComponents(),
oldVb.getFormat(), buffer);
// Copy the vertex data from the old buffer into the new buffer
for (int i = 0; i < newNumVerts; i++) {
@ -1338,8 +1341,8 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
}
/**
* Scales the texture coordinate buffer on this mesh by the given
* scale factor.
* Scales the texture coordinate buffer on this mesh by the given scale
* factor.
* <p>
* Note that values above 1 will cause the
* texture to tile, while values below 1 will cause the texture
@ -1449,8 +1452,8 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
* @return true if the mesh uses bone animation, false otherwise
*/
public boolean isAnimated() {
return getBuffer(Type.BoneIndex) != null ||
getBuffer(Type.HWBoneIndex) != null;
return getBuffer(Type.BoneIndex) != null
|| getBuffer(Type.HWBoneIndex) != null;
}
/**
@ -1504,6 +1507,7 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
/**
* Sets the count of vertices used for each tessellation patch
*
* @param patchVertexCount
*/
public void setPatchVertexCount(int patchVertexCount) {
@ -1512,13 +1516,13 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
/**
* Gets the amount of vertices used for each patch;
*
* @return the count (&ge;0)
*/
public int getPatchVertexCount() {
return patchVertexCount;
}
public void addMorphTarget(MorphTarget target) {
if (morphTargets == null) {
morphTargets = new SafeArrayList<>(MorphTarget.class);
@ -1540,7 +1544,6 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
* @return an array
*/
public String[] getMorphTargetNames() {
MorphTarget[] nbMorphTargets = getMorphTargets();
if (nbMorphTargets.length == 0) {
return new String[0];
@ -1559,6 +1562,7 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
/**
* Get the index of the morph that has the given name.
*
* @param morphName The name of the morph to search for
* @return The index of the morph, or -1 if not found.
*/
@ -1662,5 +1666,4 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
morphTargets = new SafeArrayList(MorphTarget.class, l);
}
}
}

@ -47,7 +47,6 @@ import java.util.Queue;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* <code>Node</code> defines an internal node of a scene graph. The internal
* node maintains a collection of children and handles merging said children
@ -59,14 +58,11 @@ import java.util.logging.Logger;
* @author Joshua Slack
*/
public class Node extends Spatial {
private static final Logger logger = Logger.getLogger(Node.class.getName());
/**
* This node's children.
*/
protected SafeArrayList<Spatial> children = new SafeArrayList<Spatial>(Spatial.class);
/**
* If this node is a root, this list will contain the current
* set of children (and children of children) that require
@ -105,7 +101,6 @@ public class Node extends Spatial {
}
/**
*
* <code>getQuantity</code> returns the number of children this node
* maintains.
*
@ -119,8 +114,9 @@ public class Node extends Spatial {
protected void setTransformRefresh() {
super.setTransformRefresh();
for (Spatial child : children.getArray()) {
if ((child.refreshFlags & RF_TRANSFORM) != 0)
if ((child.refreshFlags & RF_TRANSFORM) != 0) {
continue;
}
child.setTransformRefresh();
}
@ -130,8 +126,9 @@ public class Node extends Spatial {
protected void setLightListRefresh() {
super.setLightListRefresh();
for (Spatial child : children.getArray()) {
if ((child.refreshFlags & RF_LIGHTLIST) != 0)
if ((child.refreshFlags & RF_LIGHTLIST) != 0) {
continue;
}
child.setLightListRefresh();
}
@ -297,6 +294,7 @@ public class Node extends Spatial {
return count;
}
/**
* <code>getVertexCount</code> returns the number of vertices contained
* in all sub-branches of this node that contain geometry.
@ -330,8 +328,8 @@ public class Node extends Spatial {
public int attachChild(Spatial child) {
return attachChildAt(child, children.size());
}
/**
*
* <code>attachChildAt</code> attaches a child to this node at an index. This node
* becomes the child's parent. The current number of children maintained is
* returned.
@ -380,8 +378,9 @@ public class Node extends Spatial {
* @return the index the child was at. -1 if the child was not in the list.
*/
public int detachChild(Spatial child) {
if (child == null)
if (child == null) {
throw new NullPointerException();
}
if (child.getParent() == this) {
int index = children.indexOf(child);
@ -404,8 +403,9 @@ public class Node extends Spatial {
* @return the index the child was at. -1 if the child was not in the list.
*/
public int detachChildNamed(String childName) {
if (childName == null)
if (childName == null) {
throw new NullPointerException();
}
for (int x = 0, max = children.size(); x < max; x++) {
Spatial child = children.get(x);
@ -418,7 +418,6 @@ public class Node extends Spatial {
}
/**
*
* <code>detachChildAt</code> removes a child at a given index. That child
* is returned for saving purposes.
*
@ -450,7 +449,6 @@ public class Node extends Spatial {
}
/**
*
* <code>detachAllChildren</code> removes all children attached to this
* node.
*/
@ -469,8 +467,7 @@ public class Node extends Spatial {
* in this node's list of children.
* @param sp
* The spatial to look up
* @return
* The index of the spatial in the node's children, or -1
* @return The index of the spatial in the node's children, or -1
* if the spatial is not attached to this node
*/
public int getChildIndex(Spatial sp) {
@ -492,11 +489,9 @@ public class Node extends Spatial {
}
/**
*
* <code>getChild</code> returns a child at a given index.
*
* @param i
* the index to retrieve the child from.
* @param i the index to retrieve the child from.
* @return the child at a specified index.
*/
public Spatial getChild(int i) {
@ -514,8 +509,9 @@ public class Node extends Spatial {
* @return the child if found, or null.
*/
public Spatial getChild(String name) {
if (name == null)
if (name == null) {
return null;
}
for (Spatial child : children.getArray()) {
if (name.equals(child.getName())) {
@ -529,6 +525,7 @@ public class Node extends Spatial {
}
return null;
}
/**
* determines if the provided Spatial is contained in the children list of
* this node.
@ -538,13 +535,15 @@ public class Node extends Spatial {
* @return true if the object is contained, false otherwise.
*/
public boolean hasChild(Spatial spat) {
if (children.contains(spat))
if (children.contains(spat)) {
return true;
}
for (Spatial child : children.getArray()) {
if (child instanceof Node && ((Node) child).hasChild(spat))
if (child instanceof Node && ((Node) child).hasChild(spat)) {
return true;
}
}
return false;
}
@ -578,8 +577,10 @@ public class Node extends Spatial {
public int collideWith(Collidable other, CollisionResults results) {
int total = 0;
// optimization: try collideWith BoundingVolume to avoid possibly redundant tests on children
// number 4 in condition is somewhat arbitrary. When there is only one child, the boundingVolume test is redundant at all.
// The idea is when there are few children, it can be too expensive to test boundingVolume first.
// number 4 in condition is somewhat arbitrary.
// When there is only one child, the boundingVolume test is redundant at all.
// The idea is when there are few children,
// it can be too expensive to test boundingVolume first.
/*
I'm removing this change until some issues can be addressed and I really
think it needs to be implemented a better way anyway.
@ -643,7 +644,8 @@ public class Node extends Spatial {
* Null causes all Spatials to qualify.
* @param nameRegex Regular expression to match Spatial name against.
* Null causes all Names to qualify.
* @return Non-null, but possibly 0-element, list of matching Spatials (also Instances extending Spatials).
* @return Non-null, but possibly 0-element, list of matching Spatials
* (also Instances extending Spatials).
*
* @see java.util.regex.Pattern
* @see Spatial#matches(java.lang.Class, java.lang.String)
@ -652,14 +654,18 @@ public class Node extends Spatial {
public <T extends Spatial> List<T> descendantMatches(
Class<T> spatialSubclass, String nameRegex) {
List<T> newList = new ArrayList<T>();
if (getQuantity() < 1) return newList;
if (getQuantity() < 1) {
return newList;
}
for (Spatial child : getChildren()) {
if (child.matches(spatialSubclass, nameRegex))
if (child.matches(spatialSubclass, nameRegex)) {
newList.add((T) child);
if (child instanceof Node)
}
if (child instanceof Node) {
newList.addAll(((Node) child).descendantMatches(
spatialSubclass, nameRegex));
}
}
return newList;
}
@ -734,6 +740,7 @@ public class Node extends Spatial {
// cloning this list is fine.
this.updateList = cloner.clone(updateList);
}
@Override
@SuppressWarnings("unchecked")
public void write(JmeExporter e) throws IOException {

@ -68,8 +68,8 @@ import java.util.logging.Logger;
* @author Joshua Slack
* @version $Revision: 4075 $, $Data$
*/
public abstract class Spatial implements Savable, Cloneable, Collidable, CloneableSmartAsset, JmeCloneable, HasLocalTransform {
public abstract class Spatial implements Savable, Cloneable, Collidable,
CloneableSmartAsset, JmeCloneable, HasLocalTransform {
private static final Logger logger = Logger.getLogger(Spatial.class.getName());
/**
@ -77,7 +77,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
* this spatial.
*/
public enum CullHint {
/**
* Do whatever our parent does. If no parent, default to {@link #Dynamic}.
*/
@ -104,7 +103,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
* Specifies if this spatial should be batched
*/
public enum BatchHint {
/**
* Do whatever our parent does. If no parent, default to {@link #Always}.
*/
@ -121,7 +119,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Refresh flag types
*/
protected static final int RF_TRANSFORM = 0x01, // need light resort + combine transforms
protected static final int
RF_TRANSFORM = 0x01, // need light resort + combine transforms
RF_BOUND = 0x02,
RF_LIGHTLIST = 0x04, // changes in light lists
RF_CHILD_LIGHTLIST = 0x08, // some child need geometry update
@ -147,7 +146,8 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
*/
protected String name;
// scale values
protected transient Camera.FrustumIntersect frustrumIntersects = Camera.FrustumIntersect.Intersects;
protected transient Camera.FrustumIntersect frustrumIntersects
= Camera.FrustumIntersect.Intersects;
protected RenderQueue.Bucket queueBucket = RenderQueue.Bucket.Inherit;
protected ShadowMode shadowMode = RenderQueue.ShadowMode.Inherit;
public transient float queueDistance = Float.NEGATIVE_INFINITY;
@ -232,6 +232,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
boolean requiresUpdates() {
return requiresUpdates | !controls.isEmpty();
}
/**
* Subclasses can call this with true to denote that they require
* updateLogicalState() to be called even if they contain no controls.
@ -325,6 +326,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
p = p.parent;
}
}
/**
* (Internal use only) Forces a refresh of the given types of data.
*
@ -762,6 +764,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Add a control to the list of controls.
*
* @param control The control to add.
*
* @see Spatial#removeControl(java.lang.Class)
@ -1229,6 +1232,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Centers the spatial in the origin of the world bound.
*
* @return The spatial on which this method is called, e.g <code>this</code>.
*/
public Spatial center() {
@ -1342,7 +1346,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
* @see Mesh#cloneForAnim()
*/
public Spatial clone(boolean cloneMaterial) {
// Setup the cloner for the type of cloning we want to do.
Cloner cloner = new Cloner();
@ -1438,7 +1441,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
@Override
@SuppressWarnings("unchecked")
public void cloneFields(Cloner cloner, Object original) {
// Clone all of the fields that need fix-ups and/or potential
// sharing.
this.parent = cloner.clone(parent);
@ -1588,9 +1590,11 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
}
worldOverrides = new SafeArrayList<>(MatParamOverride.class);
//changed for backward compatibility with j3o files generated before the AnimControl/SkeletonControl split
//changed for backward compatibility with j3o files
//generated before the AnimControl/SkeletonControl split
//the AnimControl creates the SkeletonControl for old files and add it to the spatial.
//The SkeletonControl must be the last in the stack so we add the list of all other control before it.
//The SkeletonControl must be the last in the stack
//so we add the list of all other control before it.
//When backward compatibility won't be needed anymore this can be replaced by :
//controls = ic.readSavableArrayList("controlsList", null));
controls.addAll(0, ic.readSavableArrayList("controlsList", null));
@ -1759,6 +1763,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Visit each scene graph element ordered by DFS with the default post order mode.
*
* @param visitor
* @see #depthFirstTraversal(com.jme3.scene.SceneGraphVisitor, com.jme3.scene.Spatial.DFSMode)
*/
@ -1783,6 +1788,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Visit each scene graph element ordered by DFS.
* There are two modes: pre order and post order.
*
* @param visitor
* @param mode the traversal mode: pre order or post order
*/
@ -1790,6 +1796,7 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
/**
* Visit each scene graph element ordered by BFS
*
* @param visitor
*/
public void breadthFirstTraversal(SceneGraphVisitor visitor) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2019 jMonkeyEngine
* Copyright (c) 2009-2020 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -54,7 +54,6 @@ import java.nio.*;
* </ul>
*/
public class VertexBuffer extends NativeObject implements Savable, Cloneable {
/**
* Type of buffer. Specifies the actual attribute it defines.
*/
@ -63,27 +62,22 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* Position of the vertex (3 floats)
*/
Position,
/**
* The size of the point when using point buffers (float).
*/
Size,
/**
* Normal vector, normalized (3 floats).
*/
Normal,
/**
* Texture coordinate (2 float)
*/
TexCoord,
/**
* Color and Alpha (4 floats)
*/
Color,
/**
* Tangent vector, normalized (4 floats) (x,y,z,w). The w component is
* called the binormal parity, is not normalized, and is either 1f or
@ -91,19 +85,16 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* GPU at render time.
*/
Tangent,
/**
* Binormal vector, normalized (3 floats, optional)
*/
Binormal,
/**
* Specifies the source data for various vertex buffers
* when interleaving is used. By default the format is
* byte.
*/
InterleavedData,
/**
* Do not use.
*/
@ -114,7 +105,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* (ubyte, ushort, or uint).
*/
Index,
/**
* Initial vertex position, used with animation.
* Should have the same format and size as {@link Type#Position}.
@ -123,7 +113,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* on the heap.
*/
BindPosePosition,
/**
* Initial vertex normals, used with animation.
* Should have the same format and size as {@link Type#Normal}.
@ -132,7 +121,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* on the heap.
*/
BindPoseNormal,
/**
* Bone weights, used with animation (4 floats).
* Only used for software skinning, the usage should be
@ -140,7 +128,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* on the heap.
*/
BoneWeight,
/**
* Bone indices, used with animation (4 ubytes).
* Only used for software skinning, the usage should be
@ -148,42 +135,34 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* on the heap as a ubytes buffer.
*/
BoneIndex,
/**
* Texture coordinate #2
*/
TexCoord2,
/**
* Texture coordinate #3
*/
TexCoord3,
/**
* Texture coordinate #4
*/
TexCoord4,
/**
* Texture coordinate #5
*/
TexCoord5,
/**
* Texture coordinate #6
*/
TexCoord6,
/**
* Texture coordinate #7
*/
TexCoord7,
/**
* Texture coordinate #8
*/
TexCoord8,
/**
* Initial vertex tangents, used with animation.
* Should have the same format and size as {@link Type#Tangent}.
@ -192,20 +171,17 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* on the heap.
*/
BindPoseTangent,
/**
* Bone weights, used with animation (4 floats).
* for Hardware Skinning only
*/
HWBoneWeight,
/**
* Bone indices, used with animation (4 ubytes).
* for Hardware Skinning only
* either an int or float buffer due to shader attribute types restrictions.
*/
HWBoneIndex,
/**
* Information about this instance.
*
@ -213,7 +189,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* should be 16.
*/
InstanceData,
/**
* Morph animations targets.
* Supports up tp 14 morph target buffers at the same time
@ -225,11 +200,15 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* 7 simultaneous POSITION and NORMAL targets
* 4 simultaneous POSTION, NORMAL and TANGENT targets.
* <p>
* Note that the MorphControl will find how many buffers can be supported for each mesh/material combination.
* Note that all buffers have 3 components (Vector3f) even the Tangent buffer that
* does not contain the w (handedness) component that will not be interpolated for morph animation.
* Note that the MorphControl will find how many buffers
* can be supported for each mesh/material combination.
* Note that all buffers have 3 components (Vector3f)
* even the Tangent buffer that
* does not contain the w (handedness) component
* that will not be interpolated for morph animation.
* <p>
* Note that those buffers contain the difference between the base buffer (POSITION, NORMAL or TANGENT) and the target value
* Note that those buffers contain the difference between
* the base buffer (POSITION, NORMAL or TANGENT) and the target value
* So that you can interpolate with a MADD operation in the vertex shader
* position = weight * diffPosition + basePosition;
*/
@ -247,7 +226,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
MorphTarget11,
MorphTarget12,
MorphTarget13,
}
/**
@ -256,22 +234,18 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* or held in video memory, but no guarantees are made- it's only a hint.
*/
public static enum Usage {
/**
* Mesh data is sent once and very rarely updated.
*/
Static,
/**
* Mesh data is updated occasionally (once per frame or less).
*/
Dynamic,
/**
* Mesh data is updated every frame.
*/
Stream,
/**
* Mesh data is <em>not</em> sent to GPU at all. It is only
* used by the CPU.
@ -289,49 +263,38 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
*/
public static enum Format {
/**
* Half precision floating point.
* 2 bytes, signed.
* Half precision floating point. 2 bytes, signed.
*/
Half(2),
/**
* Single precision floating point.
* 4 bytes, signed
* Single precision floating point. 4 bytes, signed
*/
Float(4),
/**
* Double precision floating point.
* 8 bytes, signed. May not
* be supported by all GPUs.
* Double precision floating point. 8 bytes, signed. May not be
* supported by all GPUs.
*/
Double(8),
/**
* 1 byte integer, signed.
*/
Byte(1),
/**
* 1 byte integer, unsigned.
*/
UnsignedByte(1),
/**
* 2 byte integer, signed.
*/
Short(2),
/**
* 2 byte integer, unsigned.
*/
UnsignedShort(2),
/**
* 4 byte integer, signed.
*/
Int(4),
/**
* 4 byte integer, unsigned.
*/
@ -507,7 +470,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
* that is safe to read from a separate thread from other readers.
*/
public Buffer getDataReadOnly() {
if (data == null) {
return null;
}
@ -515,7 +477,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
// Create a read-only duplicate(). Note: this does not copy
// the underlying memory, it just creates a new read-only wrapper
// with its own buffer position state.
// Unfortunately, this is not 100% straight forward since Buffer
// does not have an asReadOnlyBuffer() method.
Buffer result;
@ -707,7 +668,8 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
/**
* Called to update the data in the buffer with new data. Can only
* be called after {@link VertexBuffer#setupData(com.jme3.scene.VertexBuffer.Usage, int, com.jme3.scene.VertexBuffer.Format, java.nio.Buffer) }
* be called after {@link VertexBuffer#setupData(
* com.jme3.scene.VertexBuffer.Usage, int, com.jme3.scene.VertexBuffer.Format, java.nio.Buffer) }
* has been called. Note that it is fine to call this method on the
* data already set, e.g. vb.updateData(vb.getData()), this will just
* set the proper update flag indicating the data should be sent to the GPU
@ -743,6 +705,7 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
/**
* Returns true if the data size of the VertexBuffer has changed.
* Internal use only.
*
* @return true if the data size has changed
*/
public boolean hasDataSizeChanged() {
@ -1145,7 +1108,6 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(components, "components", 0);
oc.write(usage, "usage", Usage.Dynamic);
@ -1215,5 +1177,4 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
throw new IOException("Unsupported import buffer format: " + format);
}
}
}

Loading…
Cancel
Save