org.mt4j.components.visibleComponents.shapes.mesh
Class MTTriangleMesh

java.lang.Object
  extended by org.mt4j.components.MTComponent
      extended by org.mt4j.components.visibleComponents.AbstractVisibleComponent
          extended by org.mt4j.components.visibleComponents.shapes.AbstractShape
              extended by org.mt4j.components.visibleComponents.shapes.mesh.MTTriangleMesh
All Implemented Interfaces:
IMTComponent, IMTComponent3D, IMTInputEventListener, IGestureEventListener
Direct Known Subclasses:
MTCube, MTKey, MTSphere, PhysicsPolygon, VectorFontCharacter

public class MTTriangleMesh
extends AbstractShape

    

A mesh class for drawing triangle meshes.

Author:
Christopher Ruff

Field Summary
 
Fields inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
BOUNDS_CHECK_THEN_GEOMETRY_CHECK, BOUNDS_DONT_USE, BOUNDS_ONLY_CHECK
 
Constructor Summary
MTTriangleMesh(processing.core.PApplet pApplet, GeometryInfo geometryInfo)
          Creates a new triangle mesh.
MTTriangleMesh(processing.core.PApplet pApplet, GeometryInfo geometryInfo, boolean calculateDefaultNormals)
          Creates a new triangle mesh.
 
Method Summary
 void calculateDefaultNormals()
          Calculates default normals for this mesh if the mesh's geometryInfo doesent yet contain normals.
protected  IBoundingShape computeDefaultBounds()
          Computes a default bounding box for the shape.
protected  void destroyComponent()
          
Override this to clean up resources when destroying a component.
protected  void destroyDisplayLists()
          This is called during the shape's destroy() method.
 void drawComponent(javax.media.opengl.GL gl)
          Can be used to draw if the gl context has already been set up and is ready to use.
 void drawComponent(processing.core.PGraphics g)
          Draws this component only (Not its children!).
 void generateDisplayLists()
          Generates 2 openGL display lists for drawing this shape.
 Vector3D getCenterPointLocal()
          Gets the center point in local object space.
 Vector3D getGeometryIntersectionLocal(Ray ray)
          Tests if the ray intersects the shape and where.
 float getHeightXY(TransformSpace transformSpace)
          Get the height of the shape in the XY-Plane.
 Vector3D getHeightXYVectObjSpace()
          Gets the height xy vect obj space.
 java.util.List<Vertex[]> getOutlineContours()
          Gets the outline contours.
 int getTriangleCount()
          Gets the triangle count.
 Triangle[] getTriangles()
          The triangles of this triangle mesh.
 float getWidthXY(TransformSpace transformSpace)
          Get the width of the shape in the XY-Plane.
 Vector3D getWidthXYVectObjSpace()
          Gets the width xy vect obj space.
 boolean isCalculateDefaultNormals()
          Checks if default normals should be calculated if a new geometryInfo or new vertices are set on this mesh.
 boolean isDrawNormals()
          Checks if is draw normals.
 boolean isGeometryContainsPointLocal(Vector3D testPoint)
          Tests is the geometry of the shape contains the given point.
 void setCalculateDefaultNormals(boolean calculateDefaultNormals)
          Sets if default normals should be calculated if a new geometryInfo or new vertices are set on this mesh.
 void setDrawNormals(boolean drawNormals)
          Sets the draw normals.
 void setGeometryInfo(GeometryInfo geometryInfo)
          Sets a new geometryInfo with new vertices for this shape.
 void setOutlineContours(java.util.List<Vertex[]> contours)
          Sets the outline contours.
 void setStrokeColor(MTColor strokeColor)
          Sets the stroke color.
 void setVertices(Vertex[] vertices)
          Sets new vertices for that shape.
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
componentContainsPointLocal, destroy, disableAndDeleteDisplayLists, generateAndUseDisplayLists, getBoundingShape, getCenterPointGlobal, getCenterPointRelativeToParent, getConvexHullXYGlobal, getGeometryInfo, getIntersectionLocal, getTexture, getTextureMode, getVertexCount, getVerticesGlobal, getVerticesLocal, isBoundingShapeSet, isBoundsAutoCompute, isContainedIn, isTextureEnabled, isUseDirectGL, isUseDisplayList, isUseVBOs, setBoundingShape, setBoundsAutoCompute, setBoundsBehaviour, setBoundsPickingBehaviour, setDefaultGestureActions, setFillColor, setMatricesDirty, setPositionGlobal, setPositionRelativeToOther, setPositionRelativeToParent, setTexture, setTextureEnabled, setTextureMode, setUseDirectGL, setUseDisplayList, setUseVBOs, tweenTranslate, tweenTranslate, tweenTranslateTo
 
Methods inherited from class org.mt4j.components.visibleComponents.AbstractVisibleComponent
applyStyle, getFillColor, getFillDrawMode, getFillPaint, getLineStipple, getMaterial, getStrokeColor, getStrokeWeight, getStyleInfo, isDrawSmooth, isNoFill, isNoStroke, postDraw, postDrawChildren, preDraw, setDrawSmooth, setFillDrawMode, setFillPaint, setLineStipple, setMaterial, setNoFill, setNoStroke, setStrokeWeight, setStyleInfo
 
Methods inherited from class org.mt4j.components.MTComponent
addChild, addChild, addChildren, addGestureListener, addInputListener, addStateChangeListener, applyLocalMatrix, attachCamera, containsChild, containsDirectChild, containsPointGlobal, fireInputEvent, fireStateChange, fireStateChange, getAttachedCamera, getChildbyID, getChildByIndex, getChildByName, getChildClip, getChildCount, getChildIndexOf, getChildList, getChildren, getClip, getController, getCustomViewportSetting, getDefaultViewportSetting, getGestureListeners, getGlobalInverseMatrix, getGlobalMatrix, getGlobalVecToParentRelativeSpace, getID, getInputListeners, getInputProcessors, getIntersectionGlobal, getLight, getLocalInverseMatrix, getLocalMatrix, getLocalVecToParentRelativeSpace, getName, getParent, getRenderer, getRoot, getTransformToDestinationLocalSpace, getTransformToDestinationParentSpace, getUserData, getViewingCamera, globalToLocal, globalToLocal, hasCustomViewPort, isComposite, isDepthBufferDisabled, isEnabled, isGestureAllowed, isPickable, isVisible, localToGlobal, pick, pick, processGestureEvent, processInputEvent, registerInputProcessor, removeAllChildren, removeAllGestureEventListeners, removeAllGestureEventListeners, removeChild, removeChild, removeFromParent, removeGestureEventListener, removeInputListener, removeStateChangeListener, reOrthogonalize, rotateX, rotateX, rotateXGlobal, rotateY, rotateY, rotateYGlobal, rotateZ, rotateZ, rotateZGlobal, scale, scale, scaleGlobal, sendChildToFront, sendToFront, setChildClip, setClip, setComposite, setController, setDepthBufferDisabled, setEnabled, setGestureAllowance, setLight, setLocalMatrix, setName, setPickable, setUserData, setViewPortSettings, setVisible, toString, transform, translate, translate, translateGlobal, unregisterAllInputProcessors, unregisterInputProcessor, updateComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MTTriangleMesh

public MTTriangleMesh(processing.core.PApplet pApplet,
                      GeometryInfo geometryInfo)
Creates a new triangle mesh.

Important: This mesh expects triangles geometry!


MTTriangleMesh

public MTTriangleMesh(processing.core.PApplet pApplet,
                      GeometryInfo geometryInfo,
                      boolean calculateDefaultNormals)
Creates a new triangle mesh.

Important: This mesh expects triangles geometry!

Method Detail

setGeometryInfo

public void setGeometryInfo(GeometryInfo geometryInfo)
Description copied from class: AbstractShape
Sets a new geometryInfo with new vertices for this shape.
If running in OpenGL mode, this also creates new vertex buffers for openGL use and eventually new Vertex Buffer Objects or Displaylists depending on the objects settings! So DONT create them (buffers or vbos) on the geometryinfo yourself manually, prior to setting it here!
Also calls computeDefaultBounds() if setAutoComputeBounds() is true (default) to recreate the bounding shape.
NOTE: Be aware, that an old geometryinfo of this shape may have created VBOs or displaylists on the gfx card which we should delete if not needed anywhere else!

Overrides:
setGeometryInfo in class AbstractShape
Parameters:
geometryInfo - the geometry info

setVertices

public void setVertices(Vertex[] vertices)
Description copied from class: AbstractShape
Sets new vertices for that shape. and generates new vertex arrays for opengl mode.