|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthmi.xml.XMLStructureAdapter
hmi.graphics.scenegraph.GMesh
public class GMesh
A GMesh object defines methods for defining and retrieving mesh data arrays and index arrays, as well as methods for converting between various representation schemes. A GMesh is not dependend on any particular render technology, nor on any particular graphics file format. Rather, it is intended to be an intermediate internal format, for easy and efficient exchange of graphical mesh data. The following schemes can be used to specify mesh data: 1) specify just float data arrays d0, d1, ... dn, without index data. 2) specify float data arrays d0, d1, ..., dn and a single index array i, 3) specify float data arrays d0, d1, ..., dn and similar index arrays i0, i1, ..., in. By the size of a data array for some named attribute, we mean the length of that array divided by the attribute size. For instance, a float array of length 300 defines a data array of size 100 if the attribute size would be 3, like for instance for 3D coordinates or normals. For texture coordinates with attribute size 2, on the other hand, the size would be 300/2=150. (For index arrays, there is no distinction between array length and size of the data.) For case 1) and case 2) above, we require that the sizes of all the data arrays are the same. For case 3), we require that the size of all the index arrays is the same, and of course, the values of the indices within ik should be smaller than the size of dk. The mesh topology can be defined in several ways: the default is to assume a triangulated mesh, where every three consecutive indices (or consecutive attributes for case 1) form a triangle. An alternative is work with polygons, by specifying the vcounts data. The latter is an array specifying, for each polygon, the number of consecutive indices. polygons with "holes" are not supported. Addition for morph targets: In addition to a "base" mesh we can have a number vof named morph targets, each with its own set of attributes. It is allowed and expected that morph targets introduce new vertex positions and normals, but not new tex coords etc.
| Nested Class Summary | |
|---|---|
static class |
GMesh.MeshType
MeshType enumerates the legal mesh geometry, like Triangles, Tristrips, Polygons, etc. |
| Field Summary | |
|---|---|
private ArrayList<VertexAttribute> |
attributeList
|
private static int |
ATTRIBUTELIST_SIZE
|
private static String[] |
attrOrder
|
private String |
id
|
private int[] |
indexData
|
private static int |
INDICESPERLINE
|
private static org.slf4j.Logger |
logger
|
private GMesh.MeshType |
meshType
|
private ArrayList<ArrayList<VertexAttribute>> |
morphAttributeLists
|
private String[] |
morphTargets
|
private int |
nrOfVertices
|
private static boolean |
showGMeshData
|
private static double |
TUPLEINDEX_GROW_GUESTIMATE
|
private boolean |
unifiedIndexData
|
private int[] |
vcounts
|
private static int |
VERTEXCOORD_SIZE
|
private static String |
XMLTAG
|
| Fields inherited from class hmi.xml.XMLStructureAdapter |
|---|
ATTRIBUTE_TOKEN_DELIMITERS, COMMA_SEPARATOR, DECODEDARRAYSIZE, DEFAULT_RECOVER_MODE, NEWLINE, SYSTEMNEWLINE, TAB, TAB_STRING |
| Constructor Summary | |
|---|---|
GMesh()
Default constructor |
|
GMesh(GMesh base)
Creates a clone of the specified base GMesh. |
|
GMesh(XMLTokenizer tokenizer)
Creates a new GMesh and reads the data from the XMLTokenizer. |
|
| Method Summary | |
|---|---|
private void |
addVertexAttribute(int morphTarget,
VertexAttribute attr)
|
void |
affineTransform(float[] mat4x4)
Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order. |
StringBuilder |
appendAttributeString(StringBuilder buf,
XMLFormatting fmt)
appends the XML attributes to buf. |
StringBuilder |
appendContent(StringBuilder buf,
XMLFormatting fmt)
Appends content part of XML encoding |
private int |
attrOrd(String attrName)
|
protected int[] |
calculateTuples()
calculates tuples for all new indices, together with the data remapping tables. |
boolean |
checkIndexIntegrity()
scales the mesh attributes with specific names: VertexCoord, Normal |
boolean |
checkMorphTargetConsistency(int morphTarget,
String attrName)
|
boolean |
checkMorphTargetConsistency(String attrName)
|
boolean |
checkTriangleIntegrity(float minSize)
|
void |
cleanupTriangles(float minSize)
|
void |
decodeAttributes(HashMap<String,String> attrMap,
XMLTokenizer tokenizer)
decodes the XML attributes. |
void |
decodeContent(XMLTokenizer tokenizer)
Decodes content part of XML encoding |
int[] |
getAttributeIndexData(int morphTarget,
String attributeName)
Returns the index int array for a named attribute. |
int[] |
getAttributeIndexData(String attributeName)
Returns the index int array for a named attribute. |
String |
getId()
returns the GMesh id, possibly null |
int[] |
getIndexData()
Returns the common index data array, which could be null. |
GMesh.MeshType |
getMeshType()
Returns the GMesh.MeshType of this GMesh. |
float[][] |
getMorphData(String semantic)
returns the morph data arrays for a specified attribute name. |
String[] |
getMorphTargets()
Returns the String array with morph target names, or null when no morph targets have been defined. |
int |
getNrOfAttributes()
Returns the number of vertex attributes |
int |
getNrOfIndices()
Returns the length of the number of common indices, i.e. the length of the indexData array. |
int |
getNrOfVertices()
Returns the number of distinct vertices. |
int[] |
getVCountData()
Returns the polgon/polylist vertex counts data: Each array element specifies the number of vertices for one polygon. |
VertexAttribute |
getVertexAttribute(int morphTarget,
String attributeName)
Retrieves a named attribute; this could be null if the attribute is not defined for this GMesh. |
VertexAttribute |
getVertexAttribute(String attributeName)
Retrieves a named attribute; this could be null if the attribute is not defined for this GMesh. |
ArrayList<VertexAttribute> |
getVertexAttributeList()
Returns the list with VertexAttributes for this GMesh |
ArrayList<VertexAttribute> |
getVertexAttributeList(int morphTarget)
Returns the list with VertexAttributes for this GMesh |
List<String> |
getVertexAttributeNameList(int morphTarget)
Returns the list with VertexAttribute names for this GMesh |
float[] |
getVertexData(int morphTarget,
String attributeName)
Returns the vertex data float array for a named attribute. |
float[] |
getVertexData(String attributeName)
Returns the vertex data float array for a named attribute. |
String |
getXMLTag()
returns the XML Stag for XML encoding |
boolean |
hasUnifiedIndexData()
returns true when a single, i.e. shared, index is used for all vertexattributes. |
void |
linearTransform(float[] mat3x3)
Transforms the mesh attributes with specific names: VertexCoord, Normal Assumption: transformMatrix is a 4x4 matrix, in row major order. |
int |
morphListSize()
returns the number of morph targets, or 0 when no morph targets have been defined |
private VertexAttribute |
requestVertexAttribute(int morphTarget,
String attributeName)
|
void |
setId(String id)
Defines the GMesh id |
void |
setIndexData(int[] indexData)
Defines the common index data array. |
void |
setIndexedVertexData(int morphTarget,
String attributeName,
int dataElementSize,
float[] vertexData,
int[] vertexIndexData)
Defines the indexed vertex data for a named attribute. |
void |
setIndexedVertexData(String attributeName,
int dataElementSize,
float[] vertexData,
int[] indexData)
Defines the indexed vertex data for a named attribute. |
void |
setMeshType(GMesh.MeshType t)
Sets the GMesh.MeshType of this GMesh, like Undefined, Triangles, etc. |
void |
setMorphTargets(String[] morphTargets)
Defines the names of the morph targets for this GMesh and allocates (empty) vertex attribute lists for each of these. |
void |
setVCountData(int[] counts)
Defines the polgon/polylist vertex counts data: Each array element specifies the number of vertices for one polygon. |
void |
setVertexData(int morphTarget,
String attributeName,
int dataElementSize,
float[] vertexData)
Defines the (non-indexed) vertex data for a named attribute. |
void |
setVertexData(String attributeName,
int dataElementSize,
float[] vertexData)
Defines the (non-indexed) vertex data for a named attribute. |
static void |
showGMeshData(boolean show)
|
void |
triangulate()
Ensures that all polgons are transformed into triangles. |
void |
unifyIndices()
Removes all attribute-specific indices, and replaces them by a single, common, indexData array. |
static String |
xmlTag()
The XML Stag for XML encoding |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final int ATTRIBUTELIST_SIZE
private String id
private GMesh.MeshType meshType
private ArrayList<VertexAttribute> attributeList
private String[] morphTargets
private ArrayList<ArrayList<VertexAttribute>> morphAttributeLists
private int[] vcounts
private int[] indexData
private int nrOfVertices
private boolean unifiedIndexData
private static org.slf4j.Logger logger
private static String[] attrOrder
private static final int VERTEXCOORD_SIZE
private static final double TUPLEINDEX_GROW_GUESTIMATE
private static boolean showGMeshData
private static final int INDICESPERLINE
private static final String XMLTAG
| Constructor Detail |
|---|
public GMesh()
public GMesh(XMLTokenizer tokenizer)
throws IOException
IOExceptionpublic GMesh(GMesh base)
| Method Detail |
|---|
public void setId(String id)
public String getId()
public void setMeshType(GMesh.MeshType t)
public GMesh.MeshType getMeshType()
public void setMorphTargets(String[] morphTargets)
public float[][] getMorphData(String semantic)
public String[] getMorphTargets()
public int morphListSize()
private VertexAttribute requestVertexAttribute(int morphTarget,
String attributeName)
private void addVertexAttribute(int morphTarget,
VertexAttribute attr)
private int attrOrd(String attrName)
public VertexAttribute getVertexAttribute(String attributeName)
public VertexAttribute getVertexAttribute(int morphTarget,
String attributeName)
public ArrayList<VertexAttribute> getVertexAttributeList()
public ArrayList<VertexAttribute> getVertexAttributeList(int morphTarget)
public List<String> getVertexAttributeNameList(int morphTarget)
public boolean checkMorphTargetConsistency(String attrName)
public boolean checkMorphTargetConsistency(int morphTarget,
String attrName)
public void setVertexData(String attributeName,
int dataElementSize,
float[] vertexData)
public void setVertexData(int morphTarget,
String attributeName,
int dataElementSize,
float[] vertexData)
public void setIndexedVertexData(String attributeName,
int dataElementSize,
float[] vertexData,
int[] indexData)
public void setIndexedVertexData(int morphTarget,
String attributeName,
int dataElementSize,
float[] vertexData,
int[] vertexIndexData)
public float[] getVertexData(String attributeName)
public float[] getVertexData(int morphTarget,
String attributeName)
public int[] getAttributeIndexData(String attributeName)
public int[] getAttributeIndexData(int morphTarget,
String attributeName)
public int[] getIndexData()
public void setIndexData(int[] indexData)
public int getNrOfAttributes()
public int getNrOfIndices()
public int getNrOfVertices()
public void setVCountData(int[] counts)
public int[] getVCountData()
public void affineTransform(float[] mat4x4)
public void linearTransform(float[] mat3x3)
public boolean checkIndexIntegrity()
public boolean checkTriangleIntegrity(float minSize)
public void cleanupTriangles(float minSize)
public void triangulate()
public boolean hasUnifiedIndexData()
public void unifyIndices()
protected int[] calculateTuples()
public static void showGMeshData(boolean show)
public StringBuilder appendAttributeString(StringBuilder buf,
XMLFormatting fmt)
appendAttributeString in class XMLStructureAdapter
public void decodeAttributes(HashMap<String,String> attrMap,
XMLTokenizer tokenizer)
decodeAttributes in class XMLStructureAdapter
public StringBuilder appendContent(StringBuilder buf,
XMLFormatting fmt)
appendContent in class XMLStructureAdapter
public void decodeContent(XMLTokenizer tokenizer)
throws IOException
decodeContent in class XMLStructureAdapterIOExceptionpublic static String xmlTag()
public String getXMLTag()
getXMLTag in interface XMLStructuregetXMLTag in class XMLStructureAdapter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||