de.grogra.imp3d.objects
Class GRSMesh

java.lang.Object
  extended by de.grogra.persistence.ShareableBase
      extended by de.grogra.graph.impl.ContextDependentBase
          extended by de.grogra.imp3d.objects.GRSMesh
All Implemented Interfaces:
ContextDependent, Polygons, Polygonization, Manageable, Shareable

public class GRSMesh
extends ContextDependentBase
implements Polygons

A GRSMesh looks for GRSVertex nodes in its object context (see Polygons), interprets them as a graph rotation system, and computes the corresponding polygonal mesh.

The precise semantics is as follows: The object context is represented by a MeshNode. The GRSMesh looks for all GRSVertex nodes which are directly connected by an edge with the MeshNode, the latter being the source of the edge. All found vertices are taken as vertices of the mesh, their location is obtained by the translational component of their transformation (see Null.transform). For each vertex, the list GRSVertex.neighbors defines its cyclic neighborhood, i.e., all vertices which are connected with the current vertex by an edge of a mesh polygon, sorted in counter-clockwise order when seen from above.

When a polygon of a GRSMesh has more than three edges, an additional vertex will be inserted at the center of the polygon vertices. For every polygon edge, a triangle is created using the edge and the additional central vertex.

The implementation of GRSMesh cannot handle neighborhoods of more than 63 vertices. In practice, this should not pose any problem.

Author:
Ole Kniemeyer

Nested Class Summary
static class GRSMesh.Type
           
 
Field Summary
static GRSMesh.Type $TYPE
           
 
Fields inherited from interface de.grogra.imp3d.Polygonization
COMPUTE_NORMALS, COMPUTE_UV
 
Constructor Summary
GRSMesh()
           
 
Method Summary
 boolean dependsOnContext()
          Determines whether this object actually depends on context.
 ManageableType getManageableType()
           
 void polygonize(ContextDependent source, GraphState gs, PolygonArray out, int flags, float flatness)
          Performs the polygonization of the source into polygons.
 void writeStamp(Cache.Entry cache, GraphState gs)
          Writes a stamp of the context into cache.
 
Methods inherited from class de.grogra.persistence.ShareableBase
addReference, appendReferencesTo, fieldModified, getProvider, getStamp, initProvider, manageableReadResolve, manageableWriteReplace, removeReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$TYPE

public static final GRSMesh.Type $TYPE
Constructor Detail

GRSMesh

public GRSMesh()
Method Detail

dependsOnContext

public boolean dependsOnContext()
Description copied from interface: ContextDependent
Determines whether this object actually depends on context.

Specified by:
dependsOnContext in interface ContextDependent
Returns:
true iff this object depends on context

getManageableType

public ManageableType getManageableType()
Specified by:
getManageableType in interface Manageable

polygonize

public void polygonize(ContextDependent source,
                       GraphState gs,
                       PolygonArray out,
                       int flags,
                       float flatness)
Description copied from interface: Polygonization
Performs the polygonization of the source into polygons. The field out.userObject is not modified.

Specified by:
polygonize in interface Polygonization
Parameters:
source - the data source as reported by a previous invocation of Polygonizable.getPolygonizableSource(GraphState) with the same gs
gs - the current graph state
out - the polygons are written to out
flags - combination of bit masks
flatness - a parameter for the degree of flatness, a typical value is 1

writeStamp

public void writeStamp(Cache.Entry cache,
                       GraphState gs)
Description copied from interface: ContextDependent
Writes a stamp of the context into cache. Based on this stamp, a cache detects whether the context of this object has changed or not.

Specified by:
writeStamp in interface ContextDependent
Overrides:
writeStamp in class ContextDependentBase
Parameters:
cache - a cache entry to write the stamp
gs - the current graph state