Package org.jzy3d.plot3d.primitives
Class Geometry
- java.lang.Object
-
- org.jzy3d.plot3d.primitives.Drawable
-
- org.jzy3d.plot3d.primitives.Wireframeable
-
- org.jzy3d.plot3d.primitives.Geometry
-
- All Implemented Interfaces:
IMultiColorable,ISingleColorable,IGLRenderer,ISortableDraw
public abstract class Geometry extends Wireframeable implements ISingleColorable, IMultiColorable
-
-
Field Summary
Fields Modifier and Type Field Description protected Coord3dcenterprotected Colorcolorprotected ColorMappermapperstatic booleanNORMAL_AUTO_DEFAULTDefault setting ofsetNormalProcessingAutomatic(boolean).static ColorNORMAL_END_COLORstatic intNORMAL_LINE_WIDTHstatic intNORMAL_POINT_WIDTHstatic ColorNORMAL_START_COLORstatic booleanNORMALIZE_NORMAL_DEFAULTDefault setting ofsetNormalizeNormals(boolean).protected booleannormalizeNormalsprotected Normal.NormalPernormalPerprotected booleannormalProcessingAutomaticprotected List<Coord3d>normalsprotected List<Point>pointsprotected PolygonModepolygonModestatic booleanSHOW_NORMALSA flag to show normals for debugging lightingstatic booleanSPLIT_TRIANGLE_DEFAULTDefault setting ofsetSplitInTriangles(boolean).protected booleansplitInTriangles-
Fields inherited from class org.jzy3d.plot3d.primitives.Wireframeable
depthFunctionChangeForWireframe, faceDisplayed, materialAmbiantReflection, materialDiffuseReflection, materialEmission, materialShininess, materialSpecularReflection, NO_OVERLAP_DEPTH_RATIO, polygonOffsetFactor, polygonOffsetFillEnable, polygonOffsetUnit, polygonWireframeDepthTrick, reflectLight, wireframeColor, wireframeColorFromPolygonPoints, wireframeDisplayed, wireframeWidth, wireframeWithLineLoop
-
Fields inherited from class org.jzy3d.plot3d.primitives.Drawable
bbox, boundingBoxColor, boundingBoxDisplayed, displayed, hasListeners, legend, legendDisplayed, listeners, spaceTransformer, transform, transformBefore
-
-
Constructor Summary
Constructors Constructor Description Geometry()Initializes an emptyGeometrywith face status defaulting to true, and wireframe status defaulting to false.Geometry(int n)Geometry(List<Point> points)Geometry(Color wireframeColor, boolean wireframeDisplayed, Point... points)Geometry(Color wireframeColor, Color faceColor, Coord3d... points)Geometry(Color wireframeColor, Point... points)Geometry(Point... points)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(float x, float y, float z)voidadd(List<Point> points)voidadd(Color faceColor, Coord3d... coords)voidadd(Coord3d coord)voidadd(Coord3d coord, Color color, boolean updateBounds)voidadd(Point point)voidadd(Point... points)voidadd(Point point, boolean updateBounds)Add a point to the polygon.voidapplyGeometryTransform(Transform transform)protected voidapplyPointOrMapperColor(IPainter painter, Point p)Apply mapper color if a mapper is defined and store the result in the point color, or use point color if mapper is undefined.protected abstract voidbegin(IPainter painter)Invoke GL begin with the actual geometry typeGL#GL_POINTS,GL#GL_LINES,GL#GL_TRIANGLES,GL2#GL_POLYGON...protected voidcallPointForWireframe(IPainter painter)Drawing the point list in wireframe modeprotected voidcallPointsForFace(IPainter painter)Drawing the point list in face mode (polygon content)protected voidcallPointsForFace_NoSplit(IPainter painter)protected voidcallPointsForFace_NoSplit_NoNormal(IPainter painter)protected voidcallPointsForFace_NoSplit_NormalAuto(IPainter painter)protected voidcallPointsForFace_NoSplit_NormalSupplied(IPainter painter)protected voidcallPointsForFace_SplitInTriangle(IPainter painter)protected voidcallPointsForFace_SplitInTriangle_NormalAuto(IPainter painter, Point p1, Point p2, Point p3)protected voidcallPointsForFace_SplitInTriangle_NormalSupplied(IPainter painter, Point p1, Point p2, Point p3, int t)protected Coord3dcomputeNormalAutomatic(List<Point> points)protected Coord3dcomputeNormalAutomatic(Point p1, Point p2, Point p3)voiddraw(IPainter painter)Call OpenGL2 routines for rendering the object.protected voiddrawFace(IPainter painter)protected voiddrawNormal(IPainter painter, Coord3d start, Coord3d end)protected voiddrawPolygonNormal(IPainter painter, List<Point> points, List<Coord3d> normal)protected voiddrawPolygonNormal(IPainter painter, List<Point> points, Coord3d normal)protected voiddrawTriangleNormal(IPainter painter, Point p1, Point p2, Point p3, Coord3d normal)protected voiddrawTriangleNormal(IPainter painter, Point p1, Point p2, Point p3, Coord3d n1, Coord3d n2, Coord3d n3)protected voiddrawWireframe(IPainter painter)booleanequals(Object obj)Pointget(int p)Coord3dgetBarycentre()Return the barycentre of this object, which is computed as the center of its bounding box.ColorgetColor()Get the color.ColorMappergetColorMapper()Get the colormapper.Coord3d[]getCoordArray()Returns an array of the mutable coordinates held by this polygon points.List<Coord3d>getCoordList()Returns a list of the mutable coordinates held by this polygon points.Set<Coord3d>getCoordSet()Returns a set of the mutable coordinates held by this polygon points.doublegetDistance(Camera camera)Return the distance of the object center to theCamera's eye.doublegetLongestDistance(Camera camera)List<Coord3d>getNormals()List<Point>getPoints()Returns the list of the mutable points held by this polygon.Set<Point>getPointSet()Returns a set of the mutable points held by this polygon.PolygonModegetPolygonMode()doublegetShortestDistance(Camera camera)inthashCode()booleanisNormalizeNormals()booleanisNormalProcessingAutomatic()Normal processing is false by default, and becomes true as soon as one provide normals throughsetNormals(List, NormalPer)booleanisSplitInTriangles()voidsetColor(Color color)Set the color.voidsetColorMapper(ColorMapper mapper)Set the colormapper that will be used by the Drawable, instead of using precomputed colors.voidsetNormal(Coord3d normals)voidsetNormalizeNormals(boolean normalizeNormals)Normalizing normals is usefull to ensure that polygons of different sizes will have a consistent light reflection.voidsetNormalProcessingAutomatic(boolean normalProcessingAutomatic)Set normal processing to be automatic or not.voidsetNormals(List<Coord3d> normals, Normal.NormalPer normalPer)Provides normals for this geometry.voidsetPolygonMode(PolygonMode polygonMode)A null polygonMode imply no any call to gl.glPolygonMode(...) at renderingvoidsetReflectLight(boolean reflectLight)If true, drawing this object will set ambient, diffuse, specular and shininess parameters.voidsetSplitInTriangles(boolean splitInTriangles)Splitting a polygon in multiple triangles is said to be better to adress complex rendering issues in OpenGL, but has a (very small) overhead.intsize()StringtoString(int depth)voidupdateBounds()-
Methods inherited from class org.jzy3d.plot3d.primitives.Wireframeable
applyDepthRangeDefault, applyDepthRangeForOverlying, applyDepthRangeForUnderlying, applyMaterial, doDrawBoundsIfDisplayed, getMaterialAmbiantReflection, getMaterialDiffuseReflection, getMaterialEmission, getMaterialShininess, getMaterialSpecularReflection, getPolygonOffsetFactor, getPolygonOffsetUnit, getWireframeColor, getWireframeWidth, isFaceDisplayed, isPolygonOffsetFillEnable, isPolygonWireframeDepthTrick, isReflectLight, isWireframeColorFromPolygonPoints, isWireframeDisplayed, polygonOffsetFillDisable, polygonOffsetFillEnable, polygonOffsetLineDisable, polygonOffsetLineEnable, setFaceDisplayed, setMaterialAmbiantReflection, setMaterialDiffuseReflection, setMaterialEmission, setMaterialShininess, setMaterialSpecularReflection, setPolygonOffsetFactor, setPolygonOffsetFillEnable, setPolygonOffsetUnit, setPolygonWireframeDepthTrick, setWireframeColor, setWireframeColorFromPolygonPoints, setWireframeDisplayed, setWireframeWidth
-
Methods inherited from class org.jzy3d.plot3d.primitives.Drawable
addDrawableListener, asWireframeable, dispose, doTransform, fireDrawableChanged, fireDrawableChanged, getBoundingBoxColor, getBounds, getLegend, getSpaceTransformer, getTransform, getTransformBefore, hasLegend, isBoundingBoxDisplayed, isDisplayed, isLegendDisplayed, removeDrawableListener, setBoundingBoxColor, setBoundingBoxDisplayed, setDisplayed, setLegend, setLegendDisplayed, setSpaceTransformer, setTransform, setTransformBefore, toString
-
-
-
-
Field Detail
-
NORMAL_AUTO_DEFAULT
public static boolean NORMAL_AUTO_DEFAULT
Default setting ofsetNormalProcessingAutomatic(boolean). Can be globally changed to avoid setting it geometry-wise.
-
SPLIT_TRIANGLE_DEFAULT
public static boolean SPLIT_TRIANGLE_DEFAULT
Default setting ofsetSplitInTriangles(boolean). Can be globally changed to avoid setting it geometry-wise.
-
NORMALIZE_NORMAL_DEFAULT
public static boolean NORMALIZE_NORMAL_DEFAULT
Default setting ofsetNormalizeNormals(boolean). Can be globally changed to avoid setting it geometry-wise.
-
SHOW_NORMALS
public static boolean SHOW_NORMALS
A flag to show normals for debugging lighting
-
NORMAL_LINE_WIDTH
public static int NORMAL_LINE_WIDTH
-
NORMAL_POINT_WIDTH
public static int NORMAL_POINT_WIDTH
-
NORMAL_END_COLOR
public static Color NORMAL_END_COLOR
-
NORMAL_START_COLOR
public static Color NORMAL_START_COLOR
-
polygonMode
protected PolygonMode polygonMode
-
mapper
protected ColorMapper mapper
-
color
protected Color color
-
center
protected Coord3d center
-
normalProcessingAutomatic
protected boolean normalProcessingAutomatic
-
splitInTriangles
protected boolean splitInTriangles
-
normalizeNormals
protected boolean normalizeNormals
-
normalPer
protected Normal.NormalPer normalPer
-
-
Method Detail
-
setReflectLight
public void setReflectLight(boolean reflectLight)
Description copied from class:WireframeableIf true, drawing this object will set ambient, diffuse, specular and shininess parameters. If the drawable has no normal defined, then the normal will be automatically processed.- Overrides:
setReflectLightin classWireframeable
-
setNormals
public void setNormals(List<Coord3d> normals, Normal.NormalPer normalPer)
Provides normals for this geometry. Manually setting normals will disable automatic normal processing. Not providing normals will keep the default automatic normal processing active. You may more simply set a single normal for this geometry by callingsetNormal(Coord3d)- Parameters:
normals-normalPer- indicate if the supplied normals are given per vertex or per geometry. The ability to provide a list is kept for the case where one wishes to {@link #setSplitInTriangles(true)}.
-
setNormal
public void setNormal(Coord3d normals)
-
isNormalProcessingAutomatic
public boolean isNormalProcessingAutomatic()
Normal processing is false by default, and becomes true as soon as one provide normals throughsetNormals(List, NormalPer)- Returns:
-
setNormalProcessingAutomatic
public void setNormalProcessingAutomatic(boolean normalProcessingAutomatic)
Set normal processing to be automatic or not.- Parameters:
normalProcessingAutomatic-
-
draw
public void draw(IPainter painter)
Description copied from class:DrawableCall OpenGL2 routines for rendering the object.- Specified by:
drawin interfaceIGLRenderer- Specified by:
drawin classDrawable
-
drawFace
protected void drawFace(IPainter painter)
-
callPointsForFace
protected void callPointsForFace(IPainter painter)
Drawing the point list in face mode (polygon content)
-
callPointsForFace_NoSplit
protected void callPointsForFace_NoSplit(IPainter painter)
-
callPointsForFace_NoSplit_NormalSupplied
protected void callPointsForFace_NoSplit_NormalSupplied(IPainter painter)
-
callPointsForFace_NoSplit_NormalAuto
protected void callPointsForFace_NoSplit_NormalAuto(IPainter painter)
-
callPointsForFace_NoSplit_NoNormal
protected void callPointsForFace_NoSplit_NoNormal(IPainter painter)
-
callPointsForFace_SplitInTriangle
protected void callPointsForFace_SplitInTriangle(IPainter painter)
-
callPointsForFace_SplitInTriangle_NormalSupplied
protected void callPointsForFace_SplitInTriangle_NormalSupplied(IPainter painter, Point p1, Point p2, Point p3, int t)
-
callPointsForFace_SplitInTriangle_NormalAuto
protected void callPointsForFace_SplitInTriangle_NormalAuto(IPainter painter, Point p1, Point p2, Point p3)
-
applyPointOrMapperColor
protected void applyPointOrMapperColor(IPainter painter, Point p)
Apply mapper color if a mapper is defined and store the result in the point color, or use point color if mapper is undefined.
-
drawPolygonNormal
protected void drawPolygonNormal(IPainter painter, List<Point> points, Coord3d normal)
-
drawPolygonNormal
protected void drawPolygonNormal(IPainter painter, List<Point> points, List<Coord3d> normal)
-
drawTriangleNormal
protected void drawTriangleNormal(IPainter painter, Point p1, Point p2, Point p3, Coord3d normal)
-
drawTriangleNormal
protected void drawTriangleNormal(IPainter painter, Point p1, Point p2, Point p3, Coord3d n1, Coord3d n2, Coord3d n3)
-
drawWireframe
protected void drawWireframe(IPainter painter)
-
callPointForWireframe
protected void callPointForWireframe(IPainter painter)
Drawing the point list in wireframe mode
-
begin
protected abstract void begin(IPainter painter)
Invoke GL begin with the actual geometry typeGL#GL_POINTS,GL#GL_LINES,GL#GL_TRIANGLES,GL2#GL_POLYGON...
-
add
public void add(float x, float y, float z)
-
add
public void add(Coord3d coord)
-
add
public void add(Point point)
-
add
public void add(Point point, boolean updateBounds)
Add a point to the polygon.
-
add
public void add(Point... points)
-
applyGeometryTransform
public void applyGeometryTransform(Transform transform)
- Specified by:
applyGeometryTransformin classDrawable
-
updateBounds
public void updateBounds()
- Specified by:
updateBoundsin classDrawable
-
getBarycentre
public Coord3d getBarycentre()
Description copied from class:DrawableReturn the barycentre of this object, which is computed as the center of its bounding box. If the bounding box is not available, the returned value isCoord3d.INVALID- Overrides:
getBarycentrein classDrawable- Returns:
- the center of the bounding box, or
Coord3d.INVALID.
-
get
public Point get(int p)
-
getPoints
public List<Point> getPoints()
Returns the list of the mutable points held by this polygon.
-
getPointSet
public Set<Point> getPointSet()
Returns a set of the mutable points held by this polygon.
-
getCoordSet
public Set<Coord3d> getCoordSet()
Returns a set of the mutable coordinates held by this polygon points.
-
getCoordList
public List<Coord3d> getCoordList()
Returns a list of the mutable coordinates held by this polygon points.
-
getCoordArray
public Coord3d[] getCoordArray()
Returns an array of the mutable coordinates held by this polygon points.
-
size
public int size()
-
getDistance
public double getDistance(Camera camera)
Description copied from class:DrawableReturn the distance of the object center to theCamera's eye.- Specified by:
getDistancein interfaceISortableDraw- Overrides:
getDistancein classDrawable
-
getShortestDistance
public double getShortestDistance(Camera camera)
- Specified by:
getShortestDistancein interfaceISortableDraw- Overrides:
getShortestDistancein classDrawable
-
getLongestDistance
public double getLongestDistance(Camera camera)
- Specified by:
getLongestDistancein interfaceISortableDraw- Overrides:
getLongestDistancein classDrawable
-
getPolygonMode
public PolygonMode getPolygonMode()
-
setPolygonMode
public void setPolygonMode(PolygonMode polygonMode)
A null polygonMode imply no any call to gl.glPolygonMode(...) at rendering
-
setColorMapper
public void setColorMapper(ColorMapper mapper)
Description copied from interface:IMultiColorableSet the colormapper that will be used by the Drawable, instead of using precomputed colors.- Specified by:
setColorMapperin interfaceIMultiColorable
-
getColorMapper
public ColorMapper getColorMapper()
Description copied from interface:IMultiColorableGet the colormapper.- Specified by:
getColorMapperin interfaceIMultiColorable
-
setColor
public void setColor(Color color)
Description copied from interface:ISingleColorableSet the color.- Specified by:
setColorin interfaceISingleColorable- Parameters:
color- the color
-
getColor
public Color getColor()
Description copied from interface:ISingleColorableGet the color.- Specified by:
getColorin interfaceISingleColorable- Returns:
- color the color.
-
isSplitInTriangles
public boolean isSplitInTriangles()
-
setSplitInTriangles
public void setSplitInTriangles(boolean splitInTriangles)
Splitting a polygon in multiple triangles is said to be better to adress complex rendering issues in OpenGL, but has a (very small) overhead.
-
isNormalizeNormals
public boolean isNormalizeNormals()
-
setNormalizeNormals
public void setNormalizeNormals(boolean normalizeNormals)
Normalizing normals is usefull to ensure that polygons of different sizes will have a consistent light reflection. Indeed, a large polygon will have a high normal value compared to a small polygon. Normalizing requires a bit more computation though. This setting will only change something as long as- The object is configured to {@link #setReflectLight(true)} and if a
Lightis added to the chart. - The object is configured to {@link #setNormalProcessingAutomatic(true)}. Normals processed externally should be normalized externally.
- The object is configured to {@link #setReflectLight(true)} and if a
-
-