|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.geometry.MeshBase
public abstract class MeshBase
A "mesh" is a geometric object defined by a set of vertices, which are then connected in some specific way.
Field Summary | |
---|---|
boolean |
isFixed
|
boolean |
myDisplayListValid
|
boolean |
myUseDisplayList
|
boolean |
useVertexColoring
|
RigidTransform3d |
XMeshToWorld
|
Fields inherited from interface maspack.render.GLRenderable |
---|
TRANSLUCENT, TWO_DIMENSIONAL |
Constructor Summary | |
---|---|
MeshBase()
Creates an empty polyline mesh. |
Method Summary | |
---|---|
Vertex3d |
addVertex(double x,
double y,
double z)
Adds a point to the set of vertices associated with this mesh. |
Vertex3d |
addVertex(Point3d pnt)
Adds a point to the set of vertices associated with this mesh. |
Vertex3d |
addVertex(Point3d pnt,
boolean byReference)
Adds a point to the set of vertices associated with this mesh. |
void |
addVertex(Vertex3d vtx)
Adds a vertex to the set of vertices associated with this mesh. |
void |
clear()
Clears this mesh (makes it empty). |
void |
clearDisplayList()
|
void |
clearDisplayList(RenderProps props)
|
double |
computeAverageRadius()
|
void |
computeCentroid(Vector3d centroid)
|
double |
computeRadius()
Returns the radius of this mesh. |
boolean |
containsVertex(Vertex3d vtx)
|
MeshBase |
copy()
Creates a copy of this mesh. |
abstract MeshBase |
copyWithVertices(java.util.ArrayList<? extends Vertex3d> vtxs)
Creates a copy of this mesh using a specific set of vertices. |
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object. |
abstract RenderProps |
createRenderProps(HasProperties host)
Creates an appropriate RenderProps for this Mesh. |
boolean |
epsilonEquals(MeshBase base,
double eps)
Base method for testing if two meshes are equal. |
void |
getLocalBounds(Vector3d pmin,
Vector3d pmax)
Returns the minimum and maximum coordinates for this mesh, in mesh local coordinates. |
RigidTransform3d |
getMeshToWorld()
Returns a pointer to the current mesh to world transform. |
void |
getMeshToWorld(RigidTransform3d X)
Returns the spatial transform this mesh. |
java.lang.String |
getName()
|
abstract Vector3d |
getNormal(int idx)
Returns the idx-th normal in this mesh. |
abstract int |
getNumNormals()
Returns the number of normals in this mesh. |
int |
getNumVertices()
Returns the number of vertices in this mesh. |
double |
getRadius()
Computes an approximate radius for this mesh, determined as half the diagonal of the corners of its bounding box. |
int |
getRenderHints()
Returns a bit code giving rendering hints about this renderable. |
RenderProps |
getRenderProps()
Returns the render properities for this object. |
void |
getSelection(java.util.LinkedList<java.lang.Object> list,
int qid)
Append to list the component (or components) associated with
the qid -th selection query issued by this component's render
method. |
Vertex3d |
getVertex(int idx)
Returns the idx-th vertex in this mesh. |
java.awt.Color |
getVertexColor(int i)
|
float[] |
getVertexColorArray(int i)
|
java.util.ArrayList<Vertex3d> |
getVertices()
Returns this mesh's vertices. |
void |
getWorldBounds(Vector3d pmin,
Vector3d pmax)
Returns the minimum and maximum coordinates for this mesh, in world coordinates. |
void |
inverseTransform(AffineTransform3dBase X)
Applies an inverse affine transformation to the vertices of this mesh. |
boolean |
isDisplayListValid(RenderProps rprops)
|
boolean |
isEmpty()
Returns true if this mesh is empty. |
boolean |
isFastRemoval()
|
boolean |
isFixed()
Returns whether or not this mesh is considered ``fixed'', as described in setFixed . |
boolean |
isRenderBuffered()
|
boolean |
isSelectable()
Returns true if this object is in fact selectable. |
boolean |
isUsingDisplayList()
|
boolean |
isUsingVertexColoring()
Returns whether or not this mesh is using per-vertex coloring, as described in setUseVertexColoring . |
boolean |
meshToWorldIsIdentity()
Returns true if the mesh to world transform is the identity. |
void |
notifyVertexPositionsModified()
Notifies this mesh that vertex positions have been modified, and cached data dependent on these positions should be invalidated. |
int |
numSelectionQueriesNeeded()
If this selectable manages its own selection (by issuing selection queries within its render method), then this method should
return the maximum number of selection queries that will be
required. |
void |
prerender(RenderList list)
Prepare for rendering, and potentially add itself to a list to be drawn by a GLRenderer. |
void |
read(java.io.Reader reader)
Reads the contents of this mesh from a Reader. |
void |
read(java.io.Reader reader,
boolean zeroIndexed)
Reads the contents of this mesh from a Reader. |
abstract void |
read(ReaderTokenizer rtok,
boolean zeroIndexed)
Reads the contents of this mesh from a ReaderTokenizer. |
boolean |
removeVertex(Vertex3d vtx)
Removes a vertex from this mesh. |
boolean |
removeVertices(java.util.Collection<Vertex3d> vertices)
Removes a set of vertices from this mesh, as indicated by a collection. |
void |
render(GLRenderer renderer,
int flags)
Render this object using Open GL via the JOGL. |
abstract void |
render(GLRenderer renderer,
RenderProps props,
int flags)
|
void |
saveRenderInfo()
|
void |
scale(double s)
Scales the vertices of this mesh. |
void |
scale(double sx,
double sy,
double sz)
Scales the vertices of this mesh in the given directions. |
void |
setFastRemoval(boolean set)
|
void |
setFixed(boolean fixed)
Sets whether or not this mesh to is to be considered ``fixed''. |
void |
setMeshToWorld(RigidTransform3d X)
Sets the spatial transform this mesh. |
void |
setName(java.lang.String name)
|
void |
setRenderBuffered(boolean enable)
|
void |
setRenderProps(RenderProps props)
Assigns a new set of render properties to this object. |
void |
setUseDisplayList(boolean set)
Gives control over display lists even if not fixed mesh (for rendering while paused and mesh isn't changing) |
void |
setUseVertexColoring(boolean vertexColoring)
Sets whether or not this mesh to is to use per-vertex coloring. |
void |
setVertexColor(int i,
java.awt.Color color)
|
void |
setVertexColor(int i,
java.awt.Color color,
float alpha)
|
void |
setVertexColor(int i,
double r,
double g,
double b)
|
void |
setVertexColor(int i,
double r,
double g,
double b,
double a)
|
void |
setVertexColor(int i,
float r,
float g,
float b)
|
void |
setVertexColor(int i,
float r,
float g,
float b,
float a)
|
void |
setVertexColorHSV(int i,
double h,
double s,
double b)
|
void |
setVertexColorHSV(int i,
double h,
double s,
double b,
double a)
|
Point3d |
size()
|
void |
transform(AffineTransform3dBase X)
Applies an affine transformation to the vertices of this mesh. |
void |
translate(Vector3d off)
Translates the vertices of this mesh. |
void |
updateBounds(Point3d pmin,
Point3d pmax)
Update the minimum and maximum points for this object. |
abstract void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
boolean zeroIndexed)
Writes this mesh to a PrintWriter. |
void |
write(java.io.PrintWriter pw,
java.lang.String fmtStr)
Writes this mesh to a PrintWriter. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public RigidTransform3d XMeshToWorld
public boolean isFixed
public boolean useVertexColoring
public boolean myUseDisplayList
public boolean myDisplayListValid
Constructor Detail |
---|
public MeshBase()
Method Detail |
---|
public void setName(java.lang.String name)
public java.lang.String getName()
public void notifyVertexPositionsModified()
public void setFixed(boolean fixed)
By default, a mesh is set to be fixed unless the vertices are created
using referenced points (see addVertex
).
fixed
- if true, sets this mesh to be considered fixed.isFixed
public boolean isFixed()
setFixed
.
public void setUseVertexColoring(boolean vertexColoring)
By default, a mesh is set not to use per-vertex coloring.
vertexColoring
- if true, sets this mesh to use per-vertex coloring.isUsingVertexColoring()
public boolean isUsingVertexColoring()
setUseVertexColoring
.
public RenderProps getRenderProps()
getRenderProps
in interface HasRenderProps
public abstract RenderProps createRenderProps(HasProperties host)
host
- if non-null, is used to initialize inherited values
public RenderProps createRenderProps()
createRenderProps
in interface HasRenderProps
public void setRenderProps(RenderProps props)
null
will remove render properties from this object.
setRenderProps
in interface HasRenderProps
props
- new render properties for this objectpublic void getMeshToWorld(RigidTransform3d X)
X
- returns the transform from mesh to world coordinatespublic boolean meshToWorldIsIdentity()
public RigidTransform3d getMeshToWorld()
public void setMeshToWorld(RigidTransform3d X)
meshToWorldIsIdentity
will subsequently
return true.
X
- transform from mesh to world coordinatespublic java.util.ArrayList<Vertex3d> getVertices()
Vertex3d
. Modifying these elements will
modify the mesh.
public int getNumVertices()
public abstract int getNumNormals()
public abstract Vector3d getNormal(int idx)
idx
- index of the desired normal
public Vertex3d getVertex(int idx)
idx
- index of the desired vertex
public void getLocalBounds(Vector3d pmin, Vector3d pmax)
pmin
- (optional) minimum point of the bounding boxpmax
- (optional) maximum point of the bounding boxpublic void getWorldBounds(Vector3d pmin, Vector3d pmax)
pmin
- (optional) minimum point of the bounding boxpmax
- (optional) maximum point of the bounding boxpublic void read(java.io.Reader reader) throws java.io.IOException
reader
- supplies the input description of the mesh
java.io.IOException
public void read(java.io.Reader reader, boolean zeroIndexed) throws java.io.IOException
reader
- supplies the input description of the meshzeroIndexed
- if true, the index numbering for mesh vertices starts at 0. Otherwise,
numbering starts at 1.
java.io.IOException
public abstract void read(ReaderTokenizer rtok, boolean zeroIndexed) throws java.io.IOException
rtok
- tokenizer providing the inputzeroIndexed
- if true, the index numbering for mesh vertices starts at 0. Otherwise,
numbering starts at 1.
java.io.IOException
public void addVertex(Vertex3d vtx)
pnt
field of the vertex should be
non-null. The index of the vertex will be set to reflect it's position in
the list of vertices.
vtx
- vertex to addaddVertex(Point3d,boolean)
,
addVertex(Point3d)
public boolean removeVertex(Vertex3d vtx)
vtx
- vertex to remove
public boolean removeVertices(java.util.Collection<Vertex3d> vertices)
vertices
- Collection of vertices to removepublic boolean containsVertex(Vertex3d vtx)
public Vertex3d addVertex(Point3d pnt)
addVertex(pnt,false)
.
pnt
- vertex point to add
addVertex(Point3d,boolean)
public Vertex3d addVertex(double x, double y, double z)
x
- vertex x coordinatey
- vertex y coordinatez
- vertex z coordinate
public Vertex3d addVertex(Point3d pnt, boolean byReference)
pnt
- vertex point to addbyReference
- if true, then the supplied Point3d argument is not copied but is referred
to directly by the vertex structure. The mesh will track any changes to
this point and isFixed
will return false.
addVertex(Point3d)
public void write(java.io.PrintWriter pw, java.lang.String fmtStr) throws java.io.IOException
printf
style format string contained in the parameter fmtStr
. For a
description of the format string syntax, see NumberFormat
. Good default choices for
fmtStr
are either "%g"
(full precision), or
"%.Ng"
, where N is the number of desired significant
figures.
pw
- PrintWriter to write this mesh tofmtStr
- string specifying the format for writing the vertex coordinates
java.io.IOException
public abstract void write(java.io.PrintWriter pw, NumberFormat fmt, boolean zeroIndexed) throws java.io.IOException
pw
- PrintWriter to write this mesh tofmt
- format for writing the vertex coordinateszeroIndexed
- if true, index numbering for mesh vertices starts at 0. Otherwise,
numbering starts at 1.
java.io.IOException
public void scale(double s)
s
- scale factorpublic void scale(double sx, double sy, double sz)
sx
- scaling factor in the x directionsy
- scaling factor in the y directionsz
- scaling factor in the z directionpublic Point3d size()
public double getRadius()
public void updateBounds(Point3d pmin, Point3d pmax)
updateBounds
in interface GLRenderable
pmin
- minimum pointpmax
- maximum pointpublic void translate(Vector3d off)
off
- offset to add to the mesh verticespublic void transform(AffineTransform3dBase X)
X
- affine transformationpublic void inverseTransform(AffineTransform3dBase X)
X
- affine transformationpublic int getRenderHints()
TRANSLUCENT
.
getRenderHints
in interface GLRenderable
public void clear()
public boolean isEmpty()
public void getSelection(java.util.LinkedList<java.lang.Object> list, int qid)
GLSelectable
list
the component (or components) associated with
the qid
-th selection query issued by this component's render
method. This will only be called if this component manages its own
selection (i.e., the number nums
returned by GLSelectable.numSelectionQueriesNeeded()
is positive), and qid
will in
turn be a number between 0 and nums
-1.
getSelection
in interface GLSelectable
list
- selected objects are appended to the end of this listqid
- index of the selection querypublic boolean isSelectable()
GLSelectable
isSelectable
in interface GLSelectable
public int numSelectionQueriesNeeded()
GLSelectable
render
method), then this method should
return the maximum number of selection queries that will be
required. Otherwise, this method should return -1.
numSelectionQueriesNeeded
in interface GLSelectable
public void prerender(RenderList list)
GLRenderable
prerender
in interface GLRenderable
public void setUseDisplayList(boolean set)
public void clearDisplayList()
public void clearDisplayList(RenderProps props)
public boolean isDisplayListValid(RenderProps rprops)
public boolean isUsingDisplayList()
public void setRenderBuffered(boolean enable)
public boolean isRenderBuffered()
public void saveRenderInfo()
public MeshBase copy()
public abstract MeshBase copyWithVertices(java.util.ArrayList<? extends Vertex3d> vtxs)
public void computeCentroid(Vector3d centroid)
public double computeRadius()
public double computeAverageRadius()
public void render(GLRenderer renderer, int flags)
render
in interface GLRenderable
renderer
- renderer object which is used to perform the rendering. Provides pointers
to GL and GLU, along with helper functions.flags
- supplies flags that may be used to control different
aspects of the rendering. Flags are defined in GLRenderer
and currently include
GLRenderer.SELECTED
,
GLRenderer.VERTEX_COLORING
,
GLRenderer.HSV_COLOR_INTERPOLATION
,
GLRenderer.SORT_FACES
, and
GLRenderer.CLEAR_MESH_DISPLAY_LISTS
.public abstract void render(GLRenderer renderer, RenderProps props, int flags)
public boolean epsilonEquals(MeshBase base, double eps)
eps
. This method, and its overrides, is used
in mesh unit tests.
public void setFastRemoval(boolean set)
public boolean isFastRemoval()
public void setVertexColor(int i, java.awt.Color color)
public void setVertexColor(int i, java.awt.Color color, float alpha)
public void setVertexColor(int i, double r, double g, double b)
public void setVertexColor(int i, double r, double g, double b, double a)
public void setVertexColor(int i, float r, float g, float b)
public void setVertexColor(int i, float r, float g, float b, float a)
public void setVertexColorHSV(int i, double h, double s, double b)
public void setVertexColorHSV(int i, double h, double s, double b, double a)
public java.awt.Color getVertexColor(int i)
public float[] getVertexColorArray(int i)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |