|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object glmodel.GL_Mesh
public class GL_Mesh
Holds a mesh object containing triangles and vertices. Verts and Triangles are stored as ArrayLists for flexibility and also as arrays for speedier processing. The rebuild() function converts the ArrayLists to arrays, assigns neighbor triangles to each vert, and recalculates normals. Handles normal smoothing, and preserves sharp edges. see projectVerts() for setting screen positions (Zdepth) of verts see sortTriangles() for Z depth sorting see regenerateNormals() to calculate smoothed normals oct 2008: added funcs to handle groups sep 2008: changed gluProject() params due to lwjgl 2.0 changes jun 2006: add makeclone()
Field Summary | |
---|---|
java.lang.String |
materialLibeName
|
GLMaterial[] |
materials
|
java.lang.String |
name
|
int |
numTriangles
|
int |
numVertices
|
static int |
SIZE_FLOAT
|
java.util.ArrayList |
triangleData
|
GL_Triangle[] |
triangles
|
java.util.ArrayList |
vertexData
|
GL_Vertex[] |
vertices
|
Constructor Summary | |
---|---|
GL_Mesh()
|
Method Summary | |
---|---|
void |
addTriangle(GL_Triangle newTriangle)
|
void |
addTriangle(GL_Triangle newTriangle,
int groupNum,
int triangleNum)
add triangle to given group. |
void |
addTriangle(GL_Vertex a,
GL_Vertex b,
GL_Vertex c)
|
void |
addTriangle(int v1,
int v2,
int v3)
|
void |
addVertex(float x,
float y,
float z)
|
void |
addVertex(GL_Vertex newVertex)
|
static java.nio.FloatBuffer |
allocFloats(int howmany)
|
void |
calcZDepths()
Calculate the average Z depth of each triangle. |
GL_Vector |
getCenter()
Return the center point of the mesh. |
GL_Vector |
getDimension()
Returns the dimensions of this mesh. |
GL_Triangle[] |
getGroupFaces(int g)
|
java.lang.String |
getGroupMaterialName(int g)
|
java.lang.String |
getGroupName(int g)
|
GL_Triangle |
getTriangle(float x,
float y)
Return the front-most triangle that contains the given screen x,y position, or null if no triangle contains the x,y position. |
static GL_Triangle |
getTriangle(float x,
float y,
GL_Triangle[] _triangles)
Given a screen point and a triangles array, return the front-most triangle that contains the given screen x,y position, or null if no triangle contains the x,y position. |
GL_Vertex[] |
getVertexArray()
return the vertex array |
void |
initGroup(int groupNum,
java.lang.String name,
java.lang.String materialName,
int numTriangles)
allocate triangle array for a group. |
GL_Mesh |
makeClone()
|
void |
makeGroups(int num)
Allocate arrays to hold |
GL_Vector |
max()
Return maximum point in the mesh. |
GL_Vector |
min()
Return minimum point in the mesh. |
int |
numGroups()
|
static boolean |
pointInTriangle(float px,
float py,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Return true if the point px,py is inside the triangle created by the three triangle coordinates. |
void |
projectVerts(GL_Mesh obj,
java.nio.FloatBuffer modelMatrix,
java.nio.FloatBuffer projectionMatrix,
java.nio.IntBuffer viewport)
"Project" the verts to find their screen coords. |
void |
rebuild()
Copy vertex and triangle data into arrays for faster access. |
void |
regenerateNormals()
Recalculate normals for each vertex in each triangle. |
void |
registerSmoothNeighbors(java.util.ArrayList neighborTris,
GL_Vertex v,
GL_Triangle t)
For the given Vert in the given Triangle, make a list of triangles that are neighbors to the given Triangle. |
void |
removeTriangle(GL_Triangle t)
|
void |
removeTriangleAt(int pos)
|
void |
removeVertex(GL_Vertex v)
|
void |
removeVertexAt(int pos)
|
void |
selectGroup(int g)
|
void |
setSmoothingAngle(float maxSmoothingAngle)
the smoothing angle determines how smooth or faceted a model will appear. |
void |
sortTriangles()
Z sort the triangles of this mesh. |
GL_Triangle[] |
sortTriangles(GL_Triangle[] tri,
int L,
int R)
Z sort the given triangle array. |
java.lang.String |
toString()
|
GL_Triangle |
triangle(int id)
|
GL_Vertex |
vertex(int id)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.util.ArrayList vertexData
public java.util.ArrayList triangleData
public GL_Vertex[] vertices
public GL_Triangle[] triangles
public int numVertices
public int numTriangles
public java.lang.String name
public java.lang.String materialLibeName
public GLMaterial[] materials
public static final int SIZE_FLOAT
Constructor Detail |
---|
public GL_Mesh()
Method Detail |
---|
public void setSmoothingAngle(float maxSmoothingAngle)
N1 example: the angle between face normals 1 and 2 | is 90 degrees. If maxSmoothingAngle is 80 _____|___ these faces will have a hard edge. If face1 |___ N2 maxSmoothingAngle is 100 they will be smoothed. | | face2
maxSmoothingAngle
- public GL_Vertex vertex(int id)
public GL_Triangle triangle(int id)
public void addVertex(GL_Vertex newVertex)
public void addTriangle(GL_Triangle newTriangle)
public void addTriangle(int v1, int v2, int v3)
public void addTriangle(GL_Vertex a, GL_Vertex b, GL_Vertex c)
public void removeVertex(GL_Vertex v)
public void removeTriangle(GL_Triangle t)
public void removeVertexAt(int pos)
public void removeTriangleAt(int pos)
public void rebuild()
public void registerSmoothNeighbors(java.util.ArrayList neighborTris, GL_Vertex v, GL_Triangle t)
public void addVertex(float x, float y, float z)
public void regenerateNormals()
rebuild(), registerNeighbors(), setSmoothingAngle()
public GL_Vector min()
public GL_Vector max()
public GL_Vector getCenter()
public GL_Vector getDimension()
public GL_Vertex[] getVertexArray()
public void projectVerts(GL_Mesh obj, java.nio.FloatBuffer modelMatrix, java.nio.FloatBuffer projectionMatrix, java.nio.IntBuffer viewport)
sortTriangles()
public void calcZDepths()
public void sortTriangles()
public GL_Triangle[] sortTriangles(GL_Triangle[] tri, int L, int R)
public GL_Triangle getTriangle(float x, float y)
x
- cursor x (screen coordinates)y
- cursor y (screen coordinates)
projectVerts()
public static GL_Triangle getTriangle(float x, float y, GL_Triangle[] _triangles)
x
- cursor x (screen coordinates)y
- cursor y (screen coordinates)
projectVerts()
public static boolean pointInTriangle(float px, float py, float x1, float y1, float x2, float y2, float x3, float y3)
public GL_Mesh makeClone()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.nio.FloatBuffer allocFloats(int howmany)
public int numGroups()
public java.lang.String getGroupName(int g)
public java.lang.String getGroupMaterialName(int g)
public GL_Triangle[] getGroupFaces(int g)
public void selectGroup(int g)
public void makeGroups(int num)
num
- number of groups to allocateinitGroup()
public void initGroup(int groupNum, java.lang.String name, java.lang.String materialName, int numTriangles)
groupNum
- number of group to initname
- group namematerialName
- group's materialnumTriangles
- number of triangles in the groupmakeGroups()
public void addTriangle(GL_Triangle newTriangle, int groupNum, int triangleNum)
newTriangle
- groupNum
- triangleNum
- makeGroups()
,
setGroup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |