@ -4,15 +4,11 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer ;
import java.nio.ShortBuffer ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.Collection ;
import java.util.Collections ;
import java.util.HashMap ;
import java.util.HashMap ;
import java.util.HashSet ;
import java.util.LinkedHashMap ;
import java.util.LinkedHashMap ;
import java.util.List ;
import java.util.List ;
import java.util.Map ;
import java.util.Map ;
import java.util.Map.Entry ;
import java.util.Map.Entry ;
import java.util.Set ;
import java.util.logging.Level ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
import java.util.logging.Logger ;
@ -32,7 +28,6 @@ import com.jme3.scene.plugins.blender.BlenderContext.LoadedDataType;
import com.jme3.scene.plugins.blender.file.BlenderFileException ;
import com.jme3.scene.plugins.blender.file.BlenderFileException ;
import com.jme3.scene.plugins.blender.file.Structure ;
import com.jme3.scene.plugins.blender.file.Structure ;
import com.jme3.scene.plugins.blender.materials.MaterialContext ;
import com.jme3.scene.plugins.blender.materials.MaterialContext ;
import com.jme3.scene.plugins.blender.meshes.IndexesLoop.IndexPredicate ;
import com.jme3.scene.plugins.blender.meshes.MeshBuffers.BoneBuffersData ;
import com.jme3.scene.plugins.blender.meshes.MeshBuffers.BoneBuffersData ;
import com.jme3.scene.plugins.blender.modifiers.Modifier ;
import com.jme3.scene.plugins.blender.modifiers.Modifier ;
import com.jme3.scene.plugins.blender.objects.Properties ;
import com.jme3.scene.plugins.blender.objects.Properties ;
@ -123,6 +118,62 @@ public class TemporalMesh extends Geometry {
}
}
}
}
/ * *
* @return the blender context
* /
public BlenderContext getBlenderContext ( ) {
return blenderContext ;
}
/ * *
* @return the vertices of the mesh
* /
public List < Vector3f > getVertices ( ) {
return vertices ;
}
/ * *
* @return the normals of the mesh
* /
public List < Vector3f > getNormals ( ) {
return normals ;
}
/ * *
* @return all faces
* /
public List < Face > getFaces ( ) {
return faces ;
}
/ * *
* @return all edges
* /
public List < Edge > getEdges ( ) {
return edges ;
}
/ * *
* @return all points ( do not mistake it with vertices )
* /
public List < Point > getPoints ( ) {
return points ;
}
/ * *
* @return all vertices colors
* /
public List < byte [ ] > getVerticesColors ( ) {
return verticesColors ;
}
/ * *
* @return all vertex groups for the vertices ( each map has groups for the proper vertex )
* /
public List < Map < String , Float > > getVertexGroups ( ) {
return vertexGroups ;
}
@Override
@Override
public TemporalMesh clone ( ) {
public TemporalMesh clone ( ) {
try {
try {
@ -159,20 +210,6 @@ public class TemporalMesh extends Geometry {
return null ;
return null ;
}
}
/ * *
* @return the vertices of the mesh
* /
protected List < Vector3f > getVertices ( ) {
return vertices ;
}
/ * *
* @return the normals of the mesh
* /
protected List < Vector3f > getNormals ( ) {
return normals ;
}
@Override
@Override
public void updateModelBound ( ) {
public void updateModelBound ( ) {
if ( boundingBox = = null ) {
if ( boundingBox = = null ) {
@ -212,7 +249,7 @@ public class TemporalMesh extends Geometry {
public void triangulate ( ) {
public void triangulate ( ) {
LOGGER . fine ( "Triangulating temporal mesh." ) ;
LOGGER . fine ( "Triangulating temporal mesh." ) ;
for ( Face face : faces ) {
for ( Face face : faces ) {
face . triangulate ( vertices , normals ) ;
face . triangulate ( ) ;
}
}
}
}
@ -248,19 +285,6 @@ public class TemporalMesh extends Geometry {
boneIndexes . putAll ( mesh . boneIndexes ) ;
boneIndexes . putAll ( mesh . boneIndexes ) ;
}
}
/ * *
* Translate all vertices by the given vector .
* @param translation
* the translation vector
* @return this mesh after translation ( NO new instance is created )
* /
public TemporalMesh translate ( Vector3f translation ) {
for ( Vector3f v : vertices ) {
v . addLocal ( translation ) ;
}
return this ;
}
/ * *
/ * *
* Sets the properties of the mesh .
* Sets the properties of the mesh .
* @param properties
* @param properties
@ -304,47 +328,6 @@ public class TemporalMesh extends Geometry {
return vertices . size ( ) ;
return vertices . size ( ) ;
}
}
/ * *
* Returns the vertex at the given position .
* @param i
* the vertex position
* @return the vertex at the given position
* /
public Vector3f getVertex ( int i ) {
return vertices . get ( i ) ;
}
/ * *
* Returns the normal at the given position .
* @param i
* the normal position
* @return the normal at the given position
* /
public Vector3f getNormal ( int i ) {
return normals . get ( i ) ;
}
/ * *
* Returns the vertex groups at the given vertex index .
* @param i
* the vertex groups for vertex with a given index
* @return the vertex groups at the given vertex index
* /
public Map < String , Float > getVertexGroups ( int i ) {
return vertexGroups . size ( ) > i ? vertexGroups . get ( i ) : null ;
}
/ * *
* @return a collection of vertex group names for this mesh
* /
public Collection < String > getVertexGroupNames ( ) {
Set < String > result = new HashSet < String > ( ) ;
for ( Map < String , Float > groups : vertexGroups ) {
result . addAll ( groups . keySet ( ) ) ;
}
return result ;
}
/ * *
/ * *
* Removes all vertices from the mesh .
* Removes all vertices from the mesh .
* /
* /
@ -358,86 +341,6 @@ public class TemporalMesh extends Geometry {
points . clear ( ) ;
points . clear ( ) ;
}
}
/ * *
* Every face , edge and point that contains
* the vertex will be removed .
* @param index
* the index of a vertex to be removed
* @throws IndexOutOfBoundsException
* thrown when given index is negative or beyond the count of vertices
* /
public void removeVertexAt ( final int index ) {
if ( index < 0 | | index > = vertices . size ( ) ) {
throw new IndexOutOfBoundsException ( "The given index is out of bounds: " + index ) ;
}
vertices . remove ( index ) ;
normals . remove ( index ) ;
if ( vertexGroups . size ( ) > 0 ) {
vertexGroups . remove ( index ) ;
}
if ( verticesColors . size ( ) > 0 ) {
verticesColors . remove ( index ) ;
}
IndexPredicate shiftPredicate = new IndexPredicate ( ) {
@Override
public boolean execute ( Integer i ) {
return i > index ;
}
} ;
for ( int i = faces . size ( ) - 1 ; i > = 0 ; - - i ) {
Face face = faces . get ( i ) ;
if ( face . getIndexes ( ) . indexOf ( index ) > = 0 ) {
faces . remove ( i ) ;
} else {
face . getIndexes ( ) . shiftIndexes ( - 1 , shiftPredicate ) ;
}
}
for ( int i = edges . size ( ) - 1 ; i > = 0 ; - - i ) {
Edge edge = edges . get ( i ) ;
if ( edge . getFirstIndex ( ) = = index | | edge . getSecondIndex ( ) = = index ) {
edges . remove ( i ) ;
} else {
edge . shiftIndexes ( - 1 , shiftPredicate ) ;
}
}
for ( int i = points . size ( ) - 1 ; i > = 0 ; - - i ) {
Point point = points . get ( i ) ;
if ( point . getIndex ( ) = = index ) {
points . remove ( i ) ;
} else {
point . shiftIndexes ( - 1 , shiftPredicate ) ;
}
}
}
/ * *
* Flips the order of the mesh ' s indexes .
* /
public void flipIndexes ( ) {
for ( Face face : faces ) {
face . flipIndexes ( ) ;
}
for ( Edge edge : edges ) {
edge . flipIndexes ( ) ;
}
Collections . reverse ( points ) ;
}
/ * *
* Flips UV coordinates .
* @param u
* indicates if U coords should be flipped
* @param v
* indicates if V coords should be flipped
* /
public void flipUV ( boolean u , boolean v ) {
for ( Face face : faces ) {
face . flipUV ( u , v ) ;
}
}
/ * *
/ * *
* The mesh builds geometries from the mesh . The result is stored in the blender context
* The mesh builds geometries from the mesh . The result is stored in the blender context
* under the mesh ' s OMA .
* under the mesh ' s OMA .
@ -513,7 +416,8 @@ public class TemporalMesh extends Geometry {
}
}
}
}
meshBuffers . append ( face . isSmooth ( ) , tempVerts , tempNormals , face . getUvSets ( ) , tempVertColors , boneBuffers ) ;
Map < String , List < Vector2f > > uvs = meshHelper . selectUVSubset ( face , indexes . toArray ( new Integer [ indexes . size ( ) ] ) ) ;
meshBuffers . append ( face . isSmooth ( ) , tempVerts , tempNormals , uvs , tempVertColors , boneBuffers ) ;
}
}
}
}