public class StlRenderer extends java.lang.Object implements Renderer
stlRenderer.begin(fileName, true); // open as binary //... render scene stlRenderer.end() // close file
Renderer.AxisDrawStyle, Renderer.ColorInterpolation, Renderer.ColorMixing, Renderer.DrawMode, Renderer.FaceStyle, Renderer.HighlightStyle, Renderer.LineStyle, Renderer.PointStyle, Renderer.Shading
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_AXIS_RADIUS_RATIO |
HIGHLIGHT, SORT_FACES
Constructor and Description |
---|
StlRenderer() |
Modifier and Type | Method and Description |
---|---|
void |
addVertex(double px,
double py,
double pz)
Adds a vertex to a primitive being drawn while in draw mode.
|
void |
addVertex(float[] pnt)
Adds a vertex to a primitive being drawn while in draw mode.
|
void |
addVertex(float px,
float py,
float pz)
Adds a vertex to a primitive being drawn while in draw mode.
|
void |
addVertex(Vector3d pnt)
Adds a vertex to a primitive being drawn while in draw mode.
|
void |
begin(java.lang.String fileName)
Starts writing an STL file with the given filename, in binary mode
|
void |
begin(java.lang.String fileName,
boolean binary)
Starts writing an STL file
|
boolean |
begin2DRendering()
Puts this Renderer into 2D rendering mode, or returns
false
if 2D rendering is not supported. |
boolean |
begin2DRendering(double w,
double h)
Puts this Renderer into 2D rendering mode, or returns
false
if 2D rendering is not supported. |
void |
beginDraw(Renderer.DrawMode mode)
Begins draw mode.
|
void |
beginSelectionQuery(int qid)
Begins a selection query with the {\it query identifier}
qid . |
void |
beginSubSelection(IsSelectable s,
int qid)
Begins selection for a
IsSelectable
s that
manages its own selection; this call should
be used in place of Renderer.beginSelectionQuery(int) for such objects. |
double |
centerDistancePerPixel()
Returns the displacement distance of the center point, in a plane
parallel to the view plane, that corresponds to a screen displacement of
one pixel.
|
double |
distancePerPixel(Vector3d pnt)
Returns the displacement distance of a point
p , in a plane
parallel to the view plane, that corresponds to a screen displacement
of one pixel. |
void |
draw(RenderObject robj)
Draws all the primitives in the first point, line and triangles groups.
|
void |
drawArrow(float[] pnt0,
float[] pnt1,
double rad,
boolean capped)
Draws a solid arrow between two points in model coordinates,
using the current shading and material.
|
void |
drawArrow(RenderProps props,
float[] pnt0,
float[] pnt1,
boolean capped,
boolean highlight)
Draws an arrow between two points in model coordinates,
using the radius, line color, and shading specified by the
render properties argument
props . |
void |
drawArrow(Vector3d pnt0,
Vector3d pnt1,
double rad,
boolean capped)
Draws a solid arrow between two points in model coordinates,
using the current shading and material.
|
void |
drawArrow(Vector3d pnt,
Vector3d dir,
double scale,
double rad,
boolean capped)
Draws a solid arrow in model coordinates, starting at
pnt and
extending along dir , with a length given by the length of dir times scale , using the current shading and material. |
void |
drawAxes(RigidTransform3d X,
double[] lens,
int width,
boolean highlight)
Draws a set of coordinate axes representing a rigid coordinate frame
X . |
void |
drawAxes(RigidTransform3d X,
double len,
int width,
boolean highlight)
Draws a set of coordinate axes representing a rigid coordinate frame
X . |
void |
drawAxes(RigidTransform3d X,
Renderer.AxisDrawStyle style,
double[] lens,
int width,
double rad,
boolean highlight)
Draws a solid set of coordinate axes representing a rigid coordinate
frame
X . |
void |
drawAxes(RigidTransform3d X,
Renderer.AxisDrawStyle style,
double len,
int width,
double rad,
boolean highlight)
Draws a solid set of coordinate axes representing a rigid coordinate
frame
X . |
void |
drawBox(float[] pnt,
double wx,
double wy,
double wz)
Draws an axis-aligned box in model coordinates, using the current
shading and material.
|
void |
drawBox(RigidTransform3d TBM,
Vector3d widths)
Draws a box centered on the specified transform in model coordinates,
using the current shading and material.
|
void |
drawBox(Vector3d pnt,
Vector3d widths)
Draws an axis-aligned box in model coordinates, using the current
shading and material.
|
void |
drawCone(float[] pnt0,
float[] pnt1,
double rad0,
double rad1,
boolean capped)
Draws a cone between two points in model coordinates,
using the current shading and material.
|
void |
drawCone(Vector3d pnt0,
Vector3d pnt1,
double rad0,
double rad1,
boolean capped)
Draws a cone between two points in model coordinates,
using the current shading and material.
|
void |
drawCube(float[] pnt,
double w)
Draws an axis-aligned cube with a specified width centered at a point
in model coordinates, using the current shading and material.
|
void |
drawCube(Vector3d pnt,
double w)
Draws an axis-aligned cube with a specified width centered at a point
in model coordinates, using the current shading and material.
|
void |
drawCylinder(float[] pnt0,
float[] pnt1,
double rad,
boolean capped)
Draws a cylinder between two points in model coordinates,
using the current shading and material.
|
void |
drawCylinder(Vector3d pnt0,
Vector3d pnt1,
double rad,
boolean capped)
Draws a cylinder between two points in model coordinates,
using the current shading and material.
|
void |
drawLine(double px0,
double py0,
double pz0,
double px1,
double py1,
double pz1)
Draws a single line between two points in model coordinates,
using the current line width, material, and shading.
|
void |
drawLine(float[] pnt0,
float[] pnt1)
Draws a single line between two points in model coordinates,
using the current line width, material, and shading.
|
void |
drawLine(RenderProps props,
float[] pnt0,
float[] pnt1,
boolean highlight)
Draws a single line between two points in model coordinates, using the
line style, radius, line color, and shading specified by the render
properties argument
props . |
void |
drawLine(RenderProps props,
float[] pnt0,
float[] pnt1,
boolean capped,
boolean highlight)
Draws a single line between two points in model coordinates, using the
line style, radius, line color, and shading specified by the render
properties argument
props . |
void |
drawLine(RenderProps props,
float[] pnt0,
float[] pnt1,
float[] color,
boolean capped,
boolean highlight)
Draws a single line between two points in model coordinates, using the
line style, radius, line color, and shading specified by the render
properties argument
props . |
void |
drawLine(RenderProps props,
Vector3d pnt0,
Vector3d pnt1,
boolean highlight)
Draws a single line between two points in model coordinates,
using the line style, radius, line color, and shading specified by the
render properties argument
props . |
void |
drawLine(Vector3d pnt0,
Vector3d pnt1)
Draws a single line between two points in model coordinates,
using the current line width, material, and shading.
|
void |
drawLines(RenderObject robj)
Draws all the lines in the first line group of the
specified render object, using the current material and shading.
|
void |
drawLines(RenderObject robj,
int gidx)
Draws all the lines in the specified line group of the
render object, using the current material and shading.
|
void |
drawLines(RenderObject robj,
int gidx,
int offset,
int count,
Renderer.LineStyle style,
double rad)
Draws a selection of lines in the specified line group of the supplied
render object, using the current material and shading.
|
void |
drawLines(RenderObject robj,
int gidx,
Renderer.LineStyle style,
double rad)
Draws all the lines in the specified line group of the supplied
render object, using the current material and shading.
|
void |
drawLines(RenderObject robj,
int gidx,
RenderInstances rinst)
Draws the specified group of lines, repeated for each instance
in rinst.
|
void |
drawLines(RenderObject robj,
Renderer.LineStyle style,
double rad)
Draws all the lines in the first line group of the specified
render object, using the current material and shading.
|
void |
drawLineStrip(RenderProps props,
java.lang.Iterable<float[]> pnts,
Renderer.LineStyle style,
boolean highlight)
Draws a line strip between a series of points in model coordinates,
using the radius, line color, and shading specified by the
render properties argument
props , and the line
style specified by style . |
void |
drawPoint(double px,
double py,
double pz)
Draws a single point located at
px , py and
pz in model coordinates, using the current point size,
material, and shading. |
void |
drawPoint(float[] pnt)
Draws a single point located at
pnt in model coordinates,
using the current point size, material, and shading. |
void |
drawPoint(RenderProps props,
float[] pnt,
boolean highlight)
Draws a single point located at
pnt in model coordinates,
using the point style, size, point color, and shading specified by the
render properties argument props . |
void |
drawPoint(RenderProps props,
Vector3d pnt,
boolean highlight)
Draws a single point located at
pnt in model coordinates,
using the point style, size, point color, and shading specified by the
render properties argument props . |
void |
drawPoint(Vector3d pnt)
Draws a single point located at
pnt in model coordinates,
using the current point size, material, and shading. |
void |
drawPoints(RenderObject robj)
Draws all the points in the first point group of the
specified render object, using the current material and shading.
|
void |
drawPoints(RenderObject robj,
int gidx)
Draws all the points in the specified point group of the
supplied render object, using the current material and shading.
|
void |
drawPoints(RenderObject robj,
int gidx,
int offset,
int count,
Renderer.PointStyle style,
double rad)
Draws a selection of points in the specified point group of the supplied
render object, using the current material and shading.
|
void |
drawPoints(RenderObject robj,
int gidx,
Renderer.PointStyle style,
double rad)
Draws all the points in the specified point group of the supplied
render object, using the current material and shading.
|
void |
drawPoints(RenderObject robj,
int gidx,
RenderInstances rinst)
Draws the specified group of points, repeated for each instance
in rinst.
|
void |
drawPoints(RenderObject robj,
Renderer.PointStyle style,
double rad)
Draws all the points in the first point group of the specified
render object, using the current material and shading.
|
void |
drawRay(RenderProps props,
Vector3d pnt,
Vector3d dir,
double scale,
boolean highlight)
Draws a ray from an origin point along a specified direction, in model
coordinates, using the line style, radius, line color, and shading
specified by the render properties argument
props . |
void |
drawSolidAxes(RigidTransform3d X,
double[] lens,
double rad,
boolean highlight)
Draws a solid set of coordinate axes representing a rigid coordinate
frame
X . |
void |
drawSolidAxes(RigidTransform3d X,
double len,
double rad,
boolean highlight)
Draws a solid set of coordinate axes representing a rigid coordinate
frame
X . |
void |
drawSphere(float[] pnt,
double rad)
Draws a sphere with a specified radius centered at a point
in model coordinates, using the current shading and material.
|
void |
drawSphere(Vector3d pnt,
double rad)
Draws a sphere with a specified radius centered at a point
in model coordinates, using the current shading and material.
|
void |
drawSpindle(float[] pnt0,
float[] pnt1,
double rad)
Draws a spindle between two points in model coordinates,
using the current shading and material.
|
void |
drawSpindle(Vector3d pnt0,
Vector3d pnt1,
double rad)
Draws a spindle between two points in model coordinates,
using the current shading and material.
|
double |
drawText(java.awt.Font font,
java.lang.String str,
float[] pos,
double emSize)
Draws text in the x-y plane in model coordinates.
|
double |
drawText(java.awt.Font font,
java.lang.String str,
Vector3d pos,
double emSize)
Draws text in the x-y plane in model coordinates.
|
double |
drawText(java.lang.String str,
float[] pos,
double emSize)
Draws text in the x-y plane in model coordinates.
|
double |
drawText(java.lang.String str,
Vector3d pos,
double emSize)
Draws text in the x-y plane in model coordinates.
|
void |
drawTriangle(float[] pnt0,
float[] pnt1,
float[] pnt2)
Draws a single triangular face specified by three points, using the
current shading, lighting and material.
|
void |
drawTriangle(Vector3d pnt0,
Vector3d pnt1,
Vector3d pnt2)
Draws a single triangular face specified by three points, using the
current shading, lighting and material.
|
void |
drawTriangles(RenderObject robj)
Draws all the triangles in the first triangle group of the
specified render object, using the current material and shading.
|
void |
drawTriangles(RenderObject robj,
int gidx)
Draws all the triangles in the specified triangle group of the
render object, using the current material and shading.
|
void |
drawTriangles(RenderObject robj,
int gidx,
int offset,
int count)
Draws a selection of triangles in the specified triangle group of the
render object, using the current material and shading.
|
void |
drawTriangles(RenderObject robj,
int gidx,
RenderInstances rinst)
Draws the specified group of triangles, repeated for each instance
in rinst.
|
void |
drawVertices(RenderObject robj,
Renderer.DrawMode mode)
Draws all the vertices associated with the specified RenderObject,
using a specified drawing mode and the current material and shading.
|
void |
drawVertices(RenderObject robj,
VertexIndexArray idxs,
int offset,
int count,
Renderer.DrawMode mode)
Draws a selection of vertices associated with the specified RenderObject,
using a specified drawing mode and the current material and shading.
|
void |
drawVertices(RenderObject robj,
VertexIndexArray idxs,
Renderer.DrawMode mode)
Draws a selection of vertices associated with the specified RenderObject,
using a specified drawing mode and the current material and shading.
|
void |
end()
Closes the STL rendering file
|
void |
end2DRendering()
Take this Renderer out of 2D rendering mode, by reenabling the depth
buffer and restoring the model and projection matrices to the values they
had when 2D rendering mode was first entered.
|
void |
endDraw()
Ends draw mode.
|
void |
endSelectionQuery()
Ends a selection query that was initiated with a call to
Renderer.beginSelectionQuery(int) . |
void |
endSubSelection()
Ends object sub-selection that was initiated with a call
to
Renderer.beginSubSelection(maspack.render.IsSelectable, int) . |
double |
getAxisRadiusRatio()
Returns the axis radius ratio.
|
float[] |
getBackColor(float[] rgba)
Returns the RGB or RGBA values for the back color as a float array,
or
null if no back color is set. |
BumpMapProps |
getBumpMap()
Returns the most recently set bump mapping properties, or
null if no bump mapping has been set or bump mapping
is not supported. |
Point3d |
getCenter()
Returns the current center point
|
Renderer.ColorInterpolation |
getColorInterpolation()
Returns the color interpolation currently being used by this Renderer.
|
ColorMapProps |
getColorMap()
Returns the properties for the most recently set color map, or
null if no color map is currently set or color mapping
is not supported. |
java.awt.Font |
getDefaultFont()
Retrieves the default font.
|
int |
getDepthOffset()
The current depth offset level.
|
float[] |
getEmission(float[] rgb)
Returns the RGB values for the emission color as a float array.
|
Vector3d |
getEyeZDirection()
Gives the direction, in world coordinates, of a vector that
is perpendicular to the screen and points towards the viewer.
|
Renderer.FaceStyle |
getFaceStyle()
Returns the current mode for rendering faces.
|
double |
getFarPlaneDistance()
Returns the distance, in model coordinates, from the eye to the far clip
plane.
|
float[] |
getFrontColor(float[] rgba)
Returns the RGB or RGBA values for the front color as a float array.
|
void |
getHighlightColor(float[] rgba)
Returns the color that is used to highlight objects when
the highlighting method is
Renderer.HighlightStyle.COLOR . |
boolean |
getHighlighting()
Queries whether or not highlighting is enabled.
|
Renderer.HighlightStyle |
getHighlightStyle()
Returns the highlight style used by this renderer.
|
float |
getLineWidth()
Returns the current width for rendering lines, in pixels.
|
AffineTransform3dBase |
getModelMatrix()
Gets the current model matrix.
|
void |
getModelMatrix(AffineTransform3d X)
Gets the current model matrix.
|
NormalMapProps |
getNormalMap()
Returns the most recently set normal mapping properties, or
null if no normal mapping has been set or normal mapping
is not supported. |
float |
getPointSize()
Returns the current size for rendering points, in pixels.
|
int |
getScreenHeight()
Returns the screen height, in pixels
|
int |
getScreenWidth()
Returns the screen width, in pixels
|
Renderer.Shading |
getShading()
Returns the current shading model used by this renderer.
|
float |
getShininess()
Returns the current shininess parameter.
|
float[] |
getSpecular(float[] rgb)
Returns the RGB values for the specular color as a float array.
|
int |
getSurfaceResolution()
Returns the resolution used for creating mesh representations
of curved solids.
|
java.awt.geom.Rectangle2D |
getTextBounds(java.awt.Font font,
java.lang.String str,
double emSize)
Computes and returns the logical bounding box of the supplied
text.
|
AffineTransform2dBase |
getTextureMatrix()
Gets the current texture matrix.
|
void |
getTextureMatrix(AffineTransform2d X)
Gets the current texture matrix.
|
Renderer.ColorMixing |
getVertexColorMixing()
Returns the method used for combining vertex coloring and material
coloring.
|
RigidTransform3d |
getViewMatrix()
Gets the current view matrix.
|
void |
getViewMatrix(RigidTransform3d TWE)
Gets the current view matrix.
|
double |
getViewPlaneDistance()
Returns the distance, in model coordinates, from the eye to view plane
(which corresponds to the far clip plane).
|
double |
getViewPlaneHeight()
Returns the height of the view plane, in model coordinates.
|
double |
getViewPlaneWidth()
Returns the width of the view plane, in model coordinates.
|
boolean |
has2DRendering()
Returns
true if this Renderer supports 2D rendering mode. |
boolean |
hasBumpMapping()
Queries whether or not this renderer supports bump mapping.
|
boolean |
hasColorMapMixing(Renderer.ColorMixing cmix)
Queries whether or not a specified method for combining color
map and material coloring is supported by this Renderer.
|
boolean |
hasColorMapping()
Queries whether or not this renderer supports color mapping.
|
boolean |
hasNormalMapping()
Queries whether or not this renderer supports normal mapping.
|
boolean |
hasSelection()
Queries whether or not this Renderer supports selection.
|
boolean |
hasTextRendering()
Queries whether or not this renderer supports text rendering.
|
boolean |
hasVertexColorMixing(Renderer.ColorMixing cmix)
Queries whether or not a specified method for combining vertex coloring
and material coloring is supported by this Renderer.
|
boolean |
is2DRendering()
Check whether the Renderer is currently in 2D rendering mode.
|
boolean |
isOrthogonal()
Returns
true if this renderer is currently configured for
orthogonal projection. |
boolean |
isSelectable(IsSelectable s)
Returns true if
s is selectable in the current selection
context. |
boolean |
isSelecting()
Returns true if the renderer is currently performing a selection
render.
|
void |
mulModelMatrix(AffineTransform3dBase trans)
Post-multiplies the model matrix by the specified transform X,
which may be either a
RigidTransform3d or an
AffineTransform3d . |
boolean |
popModelMatrix()
Restores the model matrix by popping it off the model matrix stack
|
void |
pushModelMatrix()
Saves the model matrix by pushing it onto the model matrix stack.
|
void |
restoreDefaultState(boolean strictChecking)
Restores the renderer to its default state.
|
void |
rotateModelMatrix(double zdeg,
double ydeg,
double xdeg)
Rotates the model frame.
|
void |
scaleModelMatrix(double s)
Scales the current model matrix.
|
void |
scaleModelMatrix(double sx,
double sy,
double sz) |
void |
setAxisRadiusRatio(double ratio)
Sets a ratio which can be used to determine the radius for an axis when
the radius is not explicitly specified.
|
void |
setBackColor(float[] rgba)
Optionally sets the diffuse and ambient colors used for the subsequent
rendering of the back faces of triangles.
|
BumpMapProps |
setBumpMap(BumpMapProps props)
If bump mapping is supported, sets up bump mapping according
to the properties specified by
props , or removes
bump mapping if props is null . |
void |
setColor(java.awt.Color color)
Sets the diffuse and ambient colors to be used for subsequent rendering
of primitives.
|
void |
setColor(float[] rgba)
Sets the diffuse and ambient colors to the value specified by
rgba . |
void |
setColor(float[] rgba,
boolean highlight)
Sets the diffuse and ambient colors to the value specified by
rgba , and enables or disables highlighting
according to the value of highlight . |
void |
setColor(float r,
float g,
float b)
Sets the diffuse and ambient colors to be used for subsequent rendering
of primitives.
|
void |
setColor(float r,
float g,
float b,
float a)
Sets the diffuse and ambient colors to be used for subsequent rendering
of primitives.
|
Renderer.ColorInterpolation |
setColorInterpolation(Renderer.ColorInterpolation interp)
Sets the color interpolation to be used by this renderer.
|
ColorMapProps |
setColorMap(ColorMapProps props)
If color mapping is supported, sets up a color map according
to the properties specified by
props , or removes
any color map if props is null . |
void |
setDefaultFont(java.awt.Font font)
Sets default font for text rendering
|
void |
setDepthOffset(int offset)
Set a depth offset for the projection matrix.
|
void |
setEdgeColoring(RenderProps props,
boolean highlight)
Sets the diffuse and ambient colors to the edge color in
props , and enables or disables highlighting
according to the value of highlight . |
void |
setEmission(float[] rgb)
Sets the emission color to be used for subsequent rendering
of primitives.
|
void |
setFaceColoring(RenderProps props,
boolean highlight)
Sets the diffuse and ambient colors to the face color in
props , and enables or disables highlighting
according to the value of highlight . |
void |
setFaceColoring(RenderProps props,
float[] rgba,
boolean highlight)
Sets the diffuse and ambient colors to
rgba , and enables or
disables highlighting according to the value of
highlight . |
Renderer.FaceStyle |
setFaceStyle(Renderer.FaceStyle style)
Sets the style for rendering faces.
|
void |
setFrontAlpha(float a)
Sets the alpha value for the front material.
|
void |
setFrontColor(float[] rgba)
Sets the diffuse and ambient colors to be used for subsequent rendering
of primitives.
|
boolean |
setHighlighting(boolean enable)
Enables or disables highlighting.
|
void |
setLineColoring(RenderProps props,
boolean highlight)
Sets the diffuse and ambient colors to the line color in
props , and enables or disables highlighting
according to the value of highlight . |
Renderer.Shading |
setLineShading(RenderProps props)
Sets the shading appropriate to the line style specified in
props . |
void |
setLineWidth(float width)
Sets the width for rendering lines, in pixels.
|
void |
setModelMatrix(AffineTransform3dBase X)
Sets the model matrix to the specified transform.
|
void |
setModelMatrix2d(double left,
double right,
double bottom,
double top)
Sets the model matrix to perform scaling and translation in the
x-y plane so that the model coordinates (left,bottom) and
(right,top) map onto (-1,1) and (1,1) in world coordinates.
|
void |
setNormal(double nx,
double ny,
double nz)
Sets the normal to be associated with the next vertex to be
added while in draw mode.
|
void |
setNormal(float nx,
float ny,
float nz)
Sets the normal to be associated with the next vertex to be
added while in draw mode.
|
void |
setNormal(Vector3d nrm)
Sets the normal to be associated with the next vertex to be
added while in draw mode.
|
NormalMapProps |
setNormalMap(NormalMapProps props)
If normal mapping is supported, sets up a normal map according
to the properties specified by
props , or removes
normal mapping if props is null . |
void |
setPointColoring(RenderProps props,
boolean highlight)
Sets the diffuse and ambient colors to the point color in
props , and enables or disables highlighting
according to the value of highlight . |
Renderer.Shading |
setPointShading(RenderProps props)
Sets the shading appropriate to the point style specified in
props . |
void |
setPointSize(float size)
Sets the size for rendering points, in pixels.
|
void |
setPropsColoring(RenderProps props,
float[] rgba,
boolean highlight)
Sets the diffuse and ambient colors to
rgba , and enables or
disables highlighting according to the value of
highlight . |
Renderer.Shading |
setPropsShading(RenderProps props)
Sets the shading to that shading specified by
props.getShading() . |
Renderer.Shading |
setShading(Renderer.Shading shading)
Sets the shading model used by this renderer.
|
void |
setShininess(float s)
Sets the shininess parameter to be used for subsequent rendering
of primitives (see
Renderer.getShininess() . |
void |
setSpecular(float[] rgb)
Sets the specular color to be used for subsequent rendering
of primitives.
|
int |
setSurfaceResolution(int nsegs)
Sets the resolution used for creating mesh representations
of curved solids.
|
void |
setTextureCoord(double tx,
double ty)
Sets the texture coordinate to be associated with the next vertex to be
added while in draw mode.
|
void |
setTextureCoord(float tx,
float ty)
Sets the texture coordinate to be associated with the next vertex to be
added while in draw mode.
|
void |
setTextureCoord(Vector2d tex)
Sets the texture coordinate to be associated with the next vertex to be
added while in draw mode.
|
void |
setTextureMatrix(AffineTransform2dBase T)
Sets the texture coordinate transformation matrix to the specified
transform.
|
Renderer.ColorMixing |
setVertexColorMixing(Renderer.ColorMixing cmix)
Sets the method used for combining vertex coloring and material coloring.
|
void |
translateModelMatrix(double tx,
double ty,
double tz)
Translates the model frame.
|
public void begin(java.lang.String fileName)
fileName
- STL file namepublic void begin(java.lang.String fileName, boolean binary)
fileName
- STL file namebinary
- if true, writes in binary file format, otherwise in ASCIIpublic void end()
public int getScreenHeight()
Renderer
getScreenHeight
in interface Renderer
public int getScreenWidth()
Renderer
getScreenWidth
in interface Renderer
public double getViewPlaneHeight()
Renderer
getViewPlaneHeight
in interface Renderer
public double getViewPlaneWidth()
Renderer
getViewPlaneWidth
in interface Renderer
public double distancePerPixel(Vector3d pnt)
Renderer
p
, in a plane
parallel to the view plane, that corresponds to a screen displacement
of one pixel. Both p
and the displacement are given with
respect to model coordinates.distancePerPixel
in interface Renderer
pnt
- point undergoing the displacementpublic double centerDistancePerPixel()
Renderer
centerDistancePerPixel
in interface Renderer
public Point3d getCenter()
Renderer
public boolean isOrthogonal()
Renderer
true
if this renderer is currently configured for
orthogonal projection.isOrthogonal
in interface Renderer
true
if projection is orthogonalpublic double getViewPlaneDistance()
Renderer
getViewPlaneDistance
in interface Renderer
Renderer.getFarPlaneDistance()
public double getFarPlaneDistance()
Renderer
getFarPlaneDistance
in interface Renderer
Renderer.getViewPlaneDistance()
public float getPointSize()
Renderer
getPointSize
in interface Renderer
Renderer.setPointSize(float)
public void setPointSize(float size)
Renderer
setPointSize
in interface Renderer
size
- new point size (in pixels).Renderer.getPointSize()
public float getLineWidth()
Renderer
getLineWidth
in interface Renderer
Renderer.setLineWidth(float)
public void setLineWidth(float width)
Renderer
setLineWidth
in interface Renderer
width
- new line width (in pixels).Renderer.getLineWidth()
public Renderer.FaceStyle getFaceStyle()
Renderer
getFaceStyle
in interface Renderer
Renderer.setFaceStyle(maspack.render.Renderer.FaceStyle)
public Renderer.FaceStyle setFaceStyle(Renderer.FaceStyle style)
Renderer
Renderer.FaceStyle.FRONT
.setFaceStyle
in interface Renderer
style
- new face styleRenderer.getFaceStyle()
public Renderer.ColorInterpolation getColorInterpolation()
Renderer
getColorInterpolation
in interface Renderer
public Renderer.ColorInterpolation setColorInterpolation(Renderer.ColorInterpolation interp)
Renderer
Renderer.ColorInterpolation.RGB
, but
Renderer.ColorInterpolation.HSV
is often more appropriate for
displaying information that is purely color-based.setColorInterpolation
in interface Renderer
interp
- new color interpolation modepublic boolean hasVertexColorMixing(Renderer.ColorMixing cmix)
Renderer
hasVertexColorMixing
in interface Renderer
true
if the color mixing method is supportedpublic Renderer.ColorMixing getVertexColorMixing()
Renderer
getVertexColorMixing
in interface Renderer
public Renderer.ColorMixing setVertexColorMixing(Renderer.ColorMixing cmix)
Renderer
Renderer.hasVertexColorMixing(maspack.render.Renderer.ColorMixing)
to test whether a method is suuported.setVertexColorMixing
in interface Renderer
cmix
- new color mixing methodpublic Renderer.Shading getShading()
Renderer
Renderer.Shading.NONE
turns off lighting and causes primitives to be
rendered in solid colors, using the current diffuse color.getShading
in interface Renderer
public Renderer.Shading setShading(Renderer.Shading shading)
Renderer
Renderer.Shading.FLAT
, in which one normal is used per primitive. A shading
model of Renderer.Shading.NONE
turns off lighting and causes primitives to
be rendered in solid colors, using the current diffuse color.setShading
in interface Renderer
shading
- new shading model to be usedpublic double getAxisRadiusRatio()
Renderer.setAxisRadiusRatio(double)
for
more information.getAxisRadiusRatio
in interface Renderer
public void setAxisRadiusRatio(double ratio)
setAxisRadiusRatio
in interface Renderer
ratio
- new axis render ratiopublic void drawPoint(Vector3d pnt)
Renderer
pnt
in model coordinates,
using the current point size, material, and shading. Since no normal is
specified, this method should generally be called with either lighting
disabled or with shading set to Renderer.Shading.NONE
.public void drawPoint(double px, double py, double pz)
Renderer
px
, py
and
pz
in model coordinates, using the current point size,
material, and shading. This method is functionally equivalent to
Renderer.drawPoint(Vector3d)
.public void drawPoint(float[] pnt)
Renderer
pnt
in model coordinates,
using the current point size, material, and shading. This method
is functionally equivalent to Renderer.drawPoint(Vector3d)
.public void drawLine(Vector3d pnt0, Vector3d pnt1)
Renderer
Renderer.Shading.NONE
.public void drawLine(double px0, double py0, double pz0, double px1, double py1, double pz1)
Renderer
Renderer.drawLine(Vector3d,Vector3d)
.public void drawLine(float[] pnt0, float[] pnt1)
Renderer
Renderer.drawLine(Vector3d,Vector3d)
.public void drawTriangle(Vector3d pnt0, Vector3d pnt1, Vector3d pnt2)
Renderer
Renderer.Shading.NONE
, the shading will be effectively flat.drawTriangle
in interface Renderer
pnt0
- first pointpnt1
- second pointpnt2
- third pointpublic void drawTriangle(float[] pnt0, float[] pnt1, float[] pnt2)
Renderer
Renderer.drawTriangle(Vector3d,Vector3d,Vector3d)
.drawTriangle
in interface Renderer
pnt0
- first pointpnt1
- second pointpnt2
- third pointpublic int getSurfaceResolution()
Renderer
getSurfaceResolution
in interface Renderer
Renderer.setSurfaceResolution(int)
public int setSurfaceResolution(int nsegs)
Renderer
setSurfaceResolution
in interface Renderer
nsegs
- resolution for curved surfacespublic void drawSphere(Vector3d pnt, double rad)
Renderer
Renderer.getSurfaceResolution()
.drawSphere
in interface Renderer
pnt
- center of the sphererad
- radius of the spherepublic void drawSphere(float[] pnt, double rad)
Renderer
Renderer.drawSphere(Vector3d,double)
.drawSphere
in interface Renderer
pnt
- center of the sphererad
- radius of the spherepublic void drawCube(Vector3d pnt, double w)
Renderer
public void drawCube(float[] pnt, double w)
Renderer
public void drawBox(float[] pnt, double wx, double wy, double wz)
Renderer
public void drawBox(Vector3d pnt, Vector3d widths)
Renderer
public void drawBox(RigidTransform3d TBM, Vector3d widths)
Renderer
public void drawSpindle(Vector3d pnt0, Vector3d pnt1, double rad)
Renderer
Renderer.getSurfaceResolution()
.drawSpindle
in interface Renderer
pnt0
- first end pointpnt1
- second end pointrad
- radius of the spindlepublic void drawSpindle(float[] pnt0, float[] pnt1, double rad)
Renderer
Renderer.getSurfaceResolution()
.drawSpindle
in interface Renderer
pnt0
- first end pointpnt1
- second end pointrad
- radius of the spindlepublic void drawCylinder(Vector3d pnt0, Vector3d pnt1, double rad, boolean capped)
Renderer
Renderer.getSurfaceResolution()
.drawCylinder
in interface Renderer
pnt0
- first end pointpnt1
- second end pointrad
- radius of the cylindercapped
- if true
, indicates that the cylinder
should have a solid cap on each endpublic void drawCylinder(float[] pnt0, float[] pnt1, double rad, boolean capped)
Renderer
Renderer.getSurfaceResolution()
.drawCylinder
in interface Renderer
pnt0
- first end pointpnt1
- second end pointrad
- radius of the cylindercapped
- if true
, indicates that the cylinder
should have a solid cap on each endpublic void drawCone(Vector3d pnt0, Vector3d pnt1, double rad0, double rad1, boolean capped)
Renderer
Renderer.getSurfaceResolution()
.public void drawCone(float[] pnt0, float[] pnt1, double rad0, double rad1, boolean capped)
Renderer
Renderer.getSurfaceResolution()
.public void drawArrow(Vector3d pnt0, Vector3d pnt1, double rad, boolean capped)
Renderer
rad
, topped with a conical arrow
head pointing towards the second end point. The arrow head has
a base radius of 3*rad
and length given by
min (6*rad, len/2)
wherelen
is the distance between the two end points.
The resolution is specified by Renderer.getSurfaceResolution()
.public void drawArrow(float[] pnt0, float[] pnt1, double rad, boolean capped)
Renderer
Renderer.drawArrow(Vector3d,Vector3d,double,boolean)
except that the points are specified using float[]
.public void drawArrow(Vector3d pnt, Vector3d dir, double scale, double rad, boolean capped)
Renderer
pnt
and
extending along dir
, with a length given by the length of dir
times scale
, using the current shading and material. The
arrow is rendered as described for Renderer.drawArrow(Vector3d,Vector3d,double,boolean)
.public void drawAxes(RigidTransform3d X, Renderer.AxisDrawStyle style, double len, int width, double rad, boolean highlight)
Renderer
X
. The origin point for the axes is X.p
,
and the directions for each axis are given by the three columns of
X.R
. The manner in which the axes are rendered is specified
by style
, which is an instance of Renderer.AxisDrawStyle
. By
default, the x, y, and z axes are drawn using the colors red, green, and
blue, unless highlight
is true
and the
highlight style is Renderer.HighlightStyle.COLOR
, in which case all axes
are drawn using the renderer's highlight color.drawAxes
in interface Renderer
X
- coordinate frame defining the axesstyle
- manner in which the axes should be rendered (e.g.,
pixel-based lines or solid arrows)len
- length of the axeswidth
- for pixel-based rendering, specifies the line width in
pixelsrad
- if >
0, specifies the radius of each axis when using
solid rendering. Otherwise, the radius is determined by multiplying the
axis length by the ratio returned by Renderer.getAxisRadiusRatio()
.highlight
- if true
, indicates that the axes should be
highlighted.public void drawAxes(RigidTransform3d X, Renderer.AxisDrawStyle style, double[] lens, int width, double rad, boolean highlight)
Renderer
X
. This method is identical to
Renderer.drawAxes(RigidTransform3d,AxisDrawStyle,double,int,double,boolean)
,
except that the length of each axis can be specified separately.drawAxes
in interface Renderer
X
- coordinate frame defining the axesstyle
- manner in which the axes should be rendered (e.g.,
pixel-based lines or solid arrows)lens
- lengths of each axiswidth
- for pixel-based rendering, specifies the line width in
pixelsrad
- if >
0, specifies the radius of each axis when using
solid rendering. Otherwise, the radius is determined by multiplying the
maximum axis length by the ratio returned by Renderer.getAxisRadiusRatio()
.highlight
- if true
, indicates that the axes should be
highlighted.public void drawAxes(RigidTransform3d X, double len, int width, boolean highlight)
Renderer
X
. The origin point for the axes is X.p
, and
the directions for each axis are given by the three columns of
X.R
. Each axis is drawn as a pixel-based line with a length
len
and a width width
. By default, the x, y,
and z axes are drawn using the colors red, green, and blue, unless
highlight
is true
and the highlight style is
Renderer.HighlightStyle.COLOR
, in which case all axes are drawn using the
renderer's highlight color.public void drawSolidAxes(RigidTransform3d X, double[] lens, double rad, boolean highlight)
Renderer
X
. This method is functionally equivalent to Renderer.drawSolidAxes(RigidTransform3d,double,double,boolean)
, except that the
lengths for each axis are individually specified. Axes with a
a specified length of 0 will not be drawn.drawSolidAxes
in interface Renderer
X
- coordinate frame defining the axeslens
- lengths for each axisrad
- axis cylinder radius. If , the radius is determined
automatically using the value returned by Renderer.getAxisRadiusRatio()
.highlight
- if true
, indicates that the axes should be
highlighted.public void drawSolidAxes(RigidTransform3d X, double len, double rad, boolean highlight)
Renderer
X
. The origin point for the axes is X.p
,
and the directions for each axis are given by the three columns of
X.R
. Each axis is drawn an arrow-tipped cylinder with a
length len
and cylinder radius rad
. By default,
the x, y, and z axes are drawn using the colors red, green, and blue,
unless highlight
is true
and the highlight
style is Renderer.HighlightStyle.COLOR
, in which case all axes are drawn
using the renderer's highlight color.drawSolidAxes
in interface Renderer
X
- coordinate frame defining the axeslen
- axis lengthrad
- axis cylinder radius. If , the radius is determined
automatically using the value returned by Renderer.getAxisRadiusRatio()
.highlight
- if true
, indicates that the axes should be
highlighted.public void drawAxes(RigidTransform3d X, double[] lens, int width, boolean highlight)
Renderer
X
. This method is functionally equivalent to Renderer.drawAxes(RigidTransform3d,double,int,boolean)
, except that the
lengths for each axis are individually specified. Axes with a
a specified length of 0 will not be drawn.public void drawPoint(RenderProps props, float[] pnt, boolean highlight)
Renderer
pnt
in model coordinates,
using the point style, size, point color, and shading specified by the
render properties argument props
. This method is
functionally equivalent to Renderer.drawPoint(RenderProps,Vector3d,boolean)
except that the point is
specified using float[]
.public void drawPoint(RenderProps props, Vector3d pnt, boolean highlight)
Renderer
pnt
in model coordinates,
using the point style, size, point color, and shading specified by the
render properties argument props
.
If props.getPointStyle()
specifies a point style of Renderer.PointStyle.POINT
, then the
point is drawn as a pixel-based point with a size given by
props.getPointSize()
. Otherwise, if the point style
is Renderer.PointStyle.CUBE
or Renderer.PointStyle.SPHERE
, then the
point is drawn as a solid with a radius given by
props.getPointRadius()
. If highlight
is true
and the highlight style is
Renderer.HighlightStyle.COLOR
, then the point will
be drawn using the highlight color rather than the point color
specified in props
.
public void drawLine(RenderProps props, float[] pnt0, float[] pnt1, boolean highlight)
Renderer
props
. This method is functionally
equivalent to Renderer.drawLine(RenderProps,Vector3d,Vector3d,boolean)
except that the points are specified using float[]
.public void drawLine(RenderProps props, Vector3d pnt0, Vector3d pnt1, boolean highlight)
Renderer
props
.
If props.getLineStyle()
specifies a line style of Renderer.LineStyle.LINE
, then the
line is drawn as a pixel-based line with a width given by
props.getLineWidth()
. For other line styles,
the line is drawn as a solid with a nominal radius given by
props.getLineRadius()
. If highlight
is true
and the highlight style is
Renderer.HighlightStyle.COLOR
, then the line will
be drawn using the highlight color rather than the line color
specified in props
.
public void drawRay(RenderProps props, Vector3d pnt, Vector3d dir, double scale, boolean highlight)
Renderer
props
. The
length of the ray is given by the length of dir
, scaled by
scale
.
If props.getLineStyle()
specifies a line style of Renderer.LineStyle.LINE
, then the ray is drawn as a pixel-based line with a width
given by props.getLineWidth()
. For other line styles, the
ray is drawn as a solid with a nominal radius given by
props.getLineRadius()
. If highlight
is
true
and the highlight style is Renderer.HighlightStyle.COLOR
, then the ray will be drawn using the highlight
color rather than the line color specified in props
.
public void drawLine(RenderProps props, float[] pnt0, float[] pnt1, float[] color, boolean capped, boolean highlight)
Renderer
props
. This method is functionally
equivalent to Renderer.drawLine(RenderProps,float[],float[],boolean)
,
except for the additional control provided by the arguments
color
and capped
.drawLine
in interface Renderer
props
- render properties used for drawing the linepnt0
- first pointpnt1
- second pointcolor
- if not null
, specifies an alternate
color that should be used in place of the line color specified
in props
capped
- if true
, specifies that the line
should have a solid cap on its ends for
styles such as Renderer.LineStyle.CYLINDER
and @link LineStyle#ARROW}highlight
- if true
, indicates that highlighting, if
enabled, should be applied to the linepublic void drawLine(RenderProps props, float[] pnt0, float[] pnt1, boolean capped, boolean highlight)
Renderer
props
. This method is functionally
equivalent to Renderer.drawLine(RenderProps,float[],float[],boolean)
,
except for the additional control provided by the argument
capped
.drawLine
in interface Renderer
props
- render properties used for drawing the linepnt0
- first pointpnt1
- second pointcapped
- if true
, specifies that the line
should have a solid cap on its ends for
styles such as Renderer.LineStyle.CYLINDER
and @link LineStyle#ARROW}highlight
- if true
, indicates that highlighting, if
enabled, should be applied to the linepublic void drawArrow(RenderProps props, float[] pnt0, float[] pnt1, boolean capped, boolean highlight)
Renderer
props
. The method
behaves similarly to
Renderer.drawArrow(float[],float[],double,boolean)
,
with the cylinder radius determine instead by
props.getLineRadius()
.drawArrow
in interface Renderer
props
- render properties used for drawing the arrowpnt0
- first pointpnt1
- second pointcapped
- if true
, specifies that the arrow
should have a solid cap on the bottomhighlight
- if true
, indicates that highlighting, if
enabled, should be applied to the arrowpublic void drawLineStrip(RenderProps props, java.lang.Iterable<float[]> pnts, Renderer.LineStyle style, boolean highlight)
Renderer
props
, and the line
style specified by style
.
If the line style is Renderer.LineStyle.LINE
, then the
strip is drawn using pixel-based lines with a width given by
props.getLineWidth()
. For other line styles,
the strip is drawn as solids with a nominal radius given by
props.getLineRadius()
. If highlight
is true
and the highlight style is
Renderer.HighlightStyle.COLOR
, then the strip will
be drawn using the highlight color rather than the line color
specified in props
.
drawLineStrip
in interface Renderer
props
- render properties used for drawing the strippnts
- list of points used for drawing the stripstyle
- line style to be used for the striphighlight
- if true
, indicates that highlighting, if
enabled, should be applied to the strippublic java.awt.geom.Rectangle2D getTextBounds(java.awt.Font font, java.lang.String str, double emSize)
Renderer
getTextBounds
in interface Renderer
font
- font to use for sizingstr
- String of which to compute the bounding boxemSize
- size of the 'em' unitpublic void setDefaultFont(java.awt.Font font)
Renderer
setDefaultFont
in interface Renderer
font
- default font. The font size largely impacts
the resolution of the renderer characters. A value of at least
32pt is recommended.public java.awt.Font getDefaultFont()
Renderer
getDefaultFont
in interface Renderer
public boolean hasTextRendering()
Renderer
hasTextRendering
in interface Renderer
true
if text rendering is supported.public double drawText(java.lang.String str, float[] pos, double emSize)
Renderer
public double drawText(java.awt.Font font, java.lang.String str, float[] pos, double emSize)
Renderer
drawText
in interface Renderer
font
- the font to use. The font size largely impacts
the resolution of the renderer characters. A value of at least
32pt is recommended.str
- string to renderpos
- position of the lower left of the text box (model coordinates)emSize
- size of an `em' unit in model coordinatespublic double drawText(java.lang.String str, Vector3d pos, double emSize)
Renderer
public double drawText(java.awt.Font font, java.lang.String str, Vector3d pos, double emSize)
Renderer
drawText
in interface Renderer
font
- the font to use. The font size largely impacts
the resolution of the renderer characters. A value of at least
32pt is recommended.str
- string to renderpos
- position of the lower left of the text box (model coordinates)emSize
- size of an `em' unit in model coordinatespublic Vector3d getEyeZDirection()
Renderer
getEyeZDirection
in interface Renderer
public boolean begin2DRendering()
Renderer
false
if 2D rendering is not supported. This method behaves identically
to Renderer.begin2DRendering(double,double)
, only with the existing
screen width and height used for w
and h
.begin2DRendering
in interface Renderer
true
if 2D rendering is supportedRenderer.getScreenWidth()
,
Renderer.getScreenHeight()
,
Renderer.has2DRendering()
public boolean begin2DRendering(double w, double h)
Renderer
false
if 2D rendering is not supported. If 2D rendering is supported, then the
depth buffer is disabled, the model and view matrices are set to the
identity, and the projection matrix is redefined to provide an
orthographic projection with the world frame located at the bottom
left corner of the screen with the x axis horizontal and
pointing to the right, and the y axis vertical. The scaling is
set so that the width and height of the screen map to
the ranges (0, w) and (0, h), respectively. If 2D rendering is not
supported, then no changes are made to any of the matrices and this
method will have no effect.begin2DRendering
in interface Renderer
w
- width of the screen coordinatesh
- height of the screen coordinatestrue
if 2D rendering is supportedRenderer.has2DRendering()
public boolean has2DRendering()
Renderer
true
if this Renderer supports 2D rendering mode.has2DRendering
in interface Renderer
true
if 2D rendering is supportedRenderer.is2DRendering()
public void end2DRendering()
Renderer
end2DRendering
in interface Renderer
public boolean is2DRendering()
Renderer
is2DRendering
in interface Renderer
true
if in 2D rendering mode.public void setColor(float[] rgba, boolean highlight)
Renderer
rgba
, and enables or disables highlighting
according to the value of highlight
.
If highlighting is requested and the highlight style is
Renderer.HighlightStyle.COLOR
, the highlight color will override
the diffuse/ambient color settings. This method also clears any
back color that may be present. It is therefore equivalent to calling
setFrontColor (rgba); setBackColor (null); setHighlighting (highlight);
public void setColor(float[] rgba)
Renderer
rgba
. This method also clears any back color that may be
present, and is therefore equivalent to calling
setFrontColor (rgba); setBackColor (null);
public void setColor(java.awt.Color color)
Renderer
Renderer.setColor(float[])
, with the RGBA values being obtained
from the color components of color
.public void setColor(float r, float g, float b)
Renderer
Renderer.setColor(float[])
, only with alpha assumed to be 1.public void setColor(float r, float g, float b, float a)
Renderer
Renderer.setColor(float[])
.public void setFrontColor(float[] rgba)
Renderer
Renderer.Shading.NONE
. By default, this color is used for both the
front and back faces of triangles, but an alternative color
can be specified for back faces using Renderer.setBackColor(float[])
.setFrontColor
in interface Renderer
rgba
- array of length 3 or 4 specifying RGB or RGBA values in
the range [0,1]. Alpha is only applied to the diffuse color
and is assumed to be 1.0 if not specified.public float[] getFrontColor(float[] rgba)
Renderer
rgba
. Otherwise, Otherwise, if rgba
is
null
, an array of length 4 will be allocated for returning
the RGBA values. The default RGBA values for the front color are
(1, 1, 1, 1)
.getFrontColor
in interface Renderer
rgba
- optional storage of length 3 or 4 for returning either
the RGB or RGBA values.public void setBackColor(float[] rgba)
Renderer
rgba
is set to
null
, then the back color is cleared and back faces
will be rendered using the front color. By default, the back color is
null
.setBackColor
in interface Renderer
rgba
- null
to clear back coloring, or
an array of length 3 or 4 specifying RGB or RGBA values in
the range [0,1]. Alpha is only applied to the diffuse color
and is assumed to be 1.0 if not specified.public float[] getBackColor(float[] rgba)
Renderer
null
if no back color is set.
The application may supply the array via the argument rgba
. Otherwise,
Otherwise, if rgba
is null
and the back color is set,
an array of length 4 will be allocated for returning the RGBA values.getBackColor
in interface Renderer
rgba
- optional storage of length 3 or 4 for returning either
the RGB or RGBA values.null
if no back color is set.public void setEmission(float[] rgb)
Renderer
(0, 0, 0)
.setEmission
in interface Renderer
rgb
- array of length 3 specifying RGB values in
the range [0,1].public float[] getEmission(float[] rgb)
Renderer
rgb
.
Otherwise, if rgb
is null
,
an array will be allocated for returning the RGB values.getEmission
in interface Renderer
rgb
- optional storage for returning the RGB values.public void setSpecular(float[] rgb)
Renderer
(0.1, 0.1, 0.1)
.setSpecular
in interface Renderer
rgb
- array of length 3 specifying RGB values in
the range [0,1].public float[] getSpecular(float[] rgb)
Renderer
rgb
.
Otherwise, if rgb
is null
,
an array will be allocated for returning the RGB values.getSpecular
in interface Renderer
rgb
- optional storage for returning the RGB values.public void setShininess(float s)
Renderer
Renderer.getShininess()
. This should be in the
range [0,128], and the default value is 32.setShininess
in interface Renderer
s
- shininess parameterpublic float getShininess()
Renderer
getShininess
in interface Renderer
public void setFrontAlpha(float a)
Renderer
setFrontAlpha
in interface Renderer
a
- alpha value, in the range [0,1].public void setPointColoring(RenderProps props, boolean highlight)
Renderer
props
, and enables or disables highlighting
according to the value of highlight
. The back color is set
to null
, and the emission, shininess, and specular values
are set either from props
or from default values.
The resulting behavior is equivalent to Renderer.setPropsColoring(maspack.render.RenderProps, float[], boolean)
with
props.getPointColor()
supplying the rgba
value.
If highlighting is requested and the highlight method equals
Renderer.HighlightStyle.COLOR
, the highlight color will override the
diffuse/ambient color settings.
setPointColoring
in interface Renderer
props
- supplies the shininess and point color valueshighlight
- if true
, enables highlightingpublic void setLineColoring(RenderProps props, boolean highlight)
Renderer
props
, and enables or disables highlighting
according to the value of highlight
. The back color is set
to null
, and the emission, shininess, and specular values
are set either from props
or from default values.
The resulting behavior is equivalent to Renderer.setPropsColoring(maspack.render.RenderProps, float[], boolean)
with
props.getLineColor()
supplying the rgba
value.
If highlighting is requested and the highlight method equals
Renderer.HighlightStyle.COLOR
, the highlight color will override the
diffuse/ambient color settings.
setLineColoring
in interface Renderer
props
- supplies the shininess and line color valueshighlight
- if true
, enables highlightingpublic void setEdgeColoring(RenderProps props, boolean highlight)
Renderer
props
, and enables or disables highlighting
according to the value of highlight
. If the edge color is
null
then the line color in props
is used
instead. The back color is set to null
, and the emission,
shininess, and specular values are set either from props
or
from default values.
The resulting behavior is equivalent to Renderer.setPropsColoring(maspack.render.RenderProps, float[], boolean)
with
props.getEdgeColor()
or props.getLineColor()
supplying the rgba
value. If highlighting is
requested and the highlight method equals Renderer.HighlightStyle.COLOR
,
the highlight color will override the diffuse/ambient color settings.
setEdgeColoring
in interface Renderer
props
- supplies the shininess and edge (or line) color valueshighlight
- if true
, enables highlightingpublic void setFaceColoring(RenderProps props, boolean highlight)
Renderer
props
, and enables or disables highlighting
according to the value of highlight
. The back color will also
be set to the (possibly null
) value of the back color in
props
. If the back color is not null
, then this
will be used to provide the coloring for back faces when they are
visible. The emission, shininess, and specular values are set either from
props
or from default values.
The resulting behavior is equivalent to Renderer.setPropsColoring(maspack.render.RenderProps, float[], boolean)
with
props.getFaceColor()
supplying the rgba
value,
except that the back color is set from props.getBackColor()
instead of being set to null
. If highlighting is
requested and the highlight method equals Renderer.HighlightStyle.COLOR
,
the highlight color will override the diffuse/ambient color settings.
setFaceColoring
in interface Renderer
props
- supplies the shininess and front and back color valueshighlight
- if true
, enables highlightingpublic void setFaceColoring(RenderProps props, float[] rgba, boolean highlight)
Renderer
rgba
, and enables or
disables highlighting according to the value of
highlight
. The back color will also be set to the (possibly
null
) value of the back color in props
. If the
back color is not null
, then this will be used to provide
the coloring for back faces when they are visible. The emission,
shininess, and specular values are set either from props
or
from default values.
The resulting behavior is equivalent to Renderer.setPropsColoring(maspack.render.RenderProps, float[], boolean)
,
except that the back color is set from props.getBackColor()
instead of being set to null
. If highlighting is
requested and the highlight method equals Renderer.HighlightStyle.COLOR
,
the highlight color will override the diffuse/ambient color settings.
setFaceColoring
in interface Renderer
props
- supplies the shininess and back color valuesrgba
- an array of length 3 or 4 specifying RGB or RGBA values
for the color the range [0,1]. Alpha is only applied to the diffuse
color and is set to props.getAlpha()
if not specified.highlight
- if true
, enables highlightingpublic void setPropsColoring(RenderProps props, float[] rgba, boolean highlight)
Renderer
rgba
, and enables or
disables highlighting according to the value of
highlight
. If rgba
only has a length of 3 then
the front alpha value is supplied by props.getAlpha()
. The
shininess is set to props.getShininess()
, while the back
color is set to null
, the emission color is set to its
default value, and the specular color is set to either
props.getSpecular()
, or to its default value if the former
is null
. This behavior is equivalent to the following:
setFrontColor (rgba); if (rgba.length == 3) { setFrontAlpha (props.getAlpha()); } setBackColor (null); setShininess (props.getShininess()); setEmission (DEFAULT_EMISSION_VALUE); specular = props.getSpecular(); setSpecular (specular != null ? specular : DEFAULT_SPECULAR_VALUE); setHighlighting (highlight)If highlighting is requested and the highlight method equals
Renderer.HighlightStyle.COLOR
, the highlight
color will override the diffuse/ambient color settings.setPropsColoring
in interface Renderer
props
- supplies the shininess valuergba
- an array of length 3 or 4 specifying RGB or RGBA values for
the color the range [0,1]. Alpha is only applied to the diffuse color and
is set to props.getAlpha()
if not specified.highlight
- if true
, enables highlightingpublic Renderer.Shading setPointShading(RenderProps props)
Renderer
props
. If props.getPointStyle()
is Renderer.PointStyle.POINT
, then shading is set to Renderer.Shading.NONE
;
otherwise, it is set to props.getShading()
.setPointShading
in interface Renderer
props
- properties giving the shading and point stylepublic Renderer.Shading setLineShading(RenderProps props)
Renderer
props
. If props.getLineStyle()
is Renderer.LineStyle.LINE
, then shading is set to Renderer.Shading.NONE
;
otherwise, it is set to props.getShading()
.setLineShading
in interface Renderer
props
- properties giving the shading and line stylepublic Renderer.Shading setPropsShading(RenderProps props)
Renderer
props.getShading()
.setPropsShading
in interface Renderer
props
- properties giving the shadingpublic boolean hasColorMapping()
Renderer
hasColorMapping
in interface Renderer
true
if color mapping is supported.public boolean hasColorMapMixing(Renderer.ColorMixing cmix)
Renderer
hasColorMapMixing
in interface Renderer
true
if the color mixing method is supportedpublic ColorMapProps setColorMap(ColorMapProps props)
Renderer
props
, or removes
any color map if props
is null
.
Once a color map is set, it will be applied to any subsequent
draw operation for which the vertices contain texture coordinates.setColorMap
in interface Renderer
props
- properties for the color map, or null
to disablepublic ColorMapProps getColorMap()
Renderer
null
if no color map is currently set or color mapping
is not supported.getColorMap
in interface Renderer
Renderer.setColorMap(maspack.render.ColorMapProps)
public boolean hasNormalMapping()
Renderer
hasNormalMapping
in interface Renderer
true
if normal mapping is supported.public NormalMapProps setNormalMap(NormalMapProps props)
Renderer
props
, or removes
normal mapping if props
is null
.
Once normal mapping is set, it will be applied to any subsequent
draw operation for which the vertices contain texture coordinates.
At present, texture coordinates can only be specified for draw
operations involving a RenderObject
.
For normal mapping to work, shading must not be set to Renderer.Shading.NONE
or Renderer.Shading.FLAT
.
setNormalMap
in interface Renderer
props
- properties for the normal mapping, or null
to disablepublic NormalMapProps getNormalMap()
Renderer
null
if no normal mapping has been set or normal mapping
is not supported.getNormalMap
in interface Renderer
Renderer.setNormalMap(maspack.render.NormalMapProps)
public boolean hasBumpMapping()
Renderer
hasBumpMapping
in interface Renderer
true
if bump mapping is supported.public BumpMapProps setBumpMap(BumpMapProps props)
Renderer
props
, or removes
bump mapping if props
is null
.
Once bump mapping is set, it will be applied to any subsequent
draw operation for which the vertices contain texture coordinates.
At present, texture coordinates can only be specified for draw
operations involving a RenderObject
.
For bump mapping to work, shading must not be set to Renderer.Shading.NONE
or Renderer.Shading.FLAT
.
setBumpMap
in interface Renderer
props
- properties for the bump mapping, or null
to disablepublic BumpMapProps getBumpMap()
Renderer
null
if no bump mapping has been set or bump mapping
is not supported.getBumpMap
in interface Renderer
Renderer.setBumpMap(maspack.render.BumpMapProps)
public void drawTriangles(RenderObject robj)
Renderer
drawTriangles
in interface Renderer
robj
- render objectpublic void drawTriangles(RenderObject robj, int gidx)
Renderer
drawTriangles
in interface Renderer
robj
- render objectgidx
- triangle group indexpublic void drawTriangles(RenderObject robj, int gidx, int offset, int count)
Renderer
drawTriangles
in interface Renderer
robj
- render objectgidx
- triangle group indexoffset
- triangle offset at which to start renderingcount
- number of triangles to drawpublic void drawLines(RenderObject robj)
Renderer
public void drawLines(RenderObject robj, int gidx)
Renderer
public void drawLines(RenderObject robj, Renderer.LineStyle style, double rad)
Renderer
Renderer.LineStyle.LINE
, the argument rad
gives the line width,
whereas for solid primitives (Renderer.LineStyle.CYLINDER
, Renderer.LineStyle.SOLID_ARROW
, Renderer.LineStyle.SPINDLE
), it gives
the nominal radius.public void drawLines(RenderObject robj, int gidx, Renderer.LineStyle style, double rad)
Renderer
Renderer.LineStyle.LINE
, the argument rad
gives the line width,
whereas for solid primitives (Renderer.LineStyle.CYLINDER
, Renderer.LineStyle.SOLID_ARROW
, Renderer.LineStyle.SPINDLE
), it gives
the nominal radius.public void drawLines(RenderObject robj, int gidx, int offset, int count, Renderer.LineStyle style, double rad)
Renderer
Renderer.LineStyle.LINE
, the argument rad
gives the line width,
whereas for solid primitives (Renderer.LineStyle.CYLINDER
, Renderer.LineStyle.SOLID_ARROW
, Renderer.LineStyle.SPINDLE
), it gives
the nominal radius.public void drawPoints(RenderObject robj)
Renderer
drawPoints
in interface Renderer
robj
- render objectpublic void drawPoints(RenderObject robj, int gidx)
Renderer
drawPoints
in interface Renderer
robj
- render objectgidx
- point group indexpublic void drawPoints(RenderObject robj, Renderer.PointStyle style, double rad)
Renderer
Renderer.PointStyle.POINT
, the argument rad
gives the point size,
whereas for Renderer.PointStyle.CUBE
it gives the cube half-width,
and for Renderer.PointStyle.SPHERE
it gives the sphere radius.drawPoints
in interface Renderer
robj
- render objectstyle
- point style to use for drawingrad
- radius for spheres or width for pixel-based pointspublic void drawPoints(RenderObject robj, int gidx, Renderer.PointStyle style, double rad)
Renderer
Renderer.PointStyle.POINT
, the argument rad
gives the point size,
whereas for Renderer.PointStyle.CUBE
it gives the cube half-width, and for
Renderer.PointStyle.SPHERE
it gives the sphere radius.drawPoints
in interface Renderer
robj
- render objectgidx
- point group indexstyle
- point style to use for drawingrad
- radius for spheres or width for pixel-based pointspublic void drawPoints(RenderObject robj, int gidx, int offset, int count, Renderer.PointStyle style, double rad)
Renderer
Renderer.PointStyle.POINT
, the argument rad
gives the point size,
whereas for Renderer.PointStyle.CUBE
it gives the cube half-width, and for
Renderer.PointStyle.SPHERE
it gives the sphere radius.drawPoints
in interface Renderer
robj
- render objectgidx
- point group indexoffset
- point offset at which to begin within the point groupcount
- number of points to drawstyle
- point style to use for drawingrad
- radius for spheres or width for pixel-based pointspublic void drawVertices(RenderObject robj, Renderer.DrawMode mode)
Renderer
drawVertices
in interface Renderer
robj
- render objectmode
- drawing mode to be used for drawing the verticespublic void drawVertices(RenderObject robj, VertexIndexArray idxs, Renderer.DrawMode mode)
Renderer
VertexIndexArray
can detect whether or not it has been modified,
which allows for caching.drawVertices
in interface Renderer
robj
- render objectidxs
- vertex indicesmode
- drawing mode to be used for drawing the verticespublic void drawVertices(RenderObject robj, VertexIndexArray idxs, int offset, int count, Renderer.DrawMode mode)
Renderer
VertexIndexArray
can detect whether or not it has been modified,
which allows for caching. Additionally, this method allows specification of
an offset and vertex count.drawVertices
in interface Renderer
robj
- render objectidxs
- vertex indicesoffset
- index offsetcount
- index countmode
- drawing mode to be used for drawing the verticespublic void draw(RenderObject robj)
Renderer
public void drawTriangles(RenderObject robj, int gidx, RenderInstances rinst)
Renderer
drawTriangles
in interface Renderer
robj
- object to drawgidx
- triangle group to drawrinst
- instance to drawpublic void drawLines(RenderObject robj, int gidx, RenderInstances rinst)
Renderer
Renderer.LineStyle.LINE
and use the
current line-width, as determined by Renderer.getLineWidth()
.public void drawPoints(RenderObject robj, int gidx, RenderInstances rinst)
Renderer
Renderer.PointStyle.POINT
and use the
current point-size, as determined by Renderer.getPointSize()
.drawPoints
in interface Renderer
robj
- object to drawgidx
- point group to drawrinst
- instance to drawpublic void pushModelMatrix()
Renderer
pushModelMatrix
in interface Renderer
public AffineTransform3dBase getModelMatrix()
Renderer
RigidTransform3d
;
otherwise, it is a more general AffineTransform3d
.getModelMatrix
in interface Renderer
public void getModelMatrix(AffineTransform3d X)
Renderer
getModelMatrix
in interface Renderer
X
- returns the current model matrix valuepublic void translateModelMatrix(double tx, double ty, double tz)
Renderer
[ M p ] [ ] [ 0 1 ]where
M
is a 3 X 3 matrix and p
is a 3 X 1
translation vector, and if t
is the translation vector,
then this method sets the model matrix to
[ M M t + p ] [ ] [ 0 1 ]
translateModelMatrix
in interface Renderer
tx
- translation along xty
- translation along ytz
- translation along zpublic void rotateModelMatrix(double zdeg, double ydeg, double xdeg)
Renderer
zdeg
degrees about the z
axis, followed by a rotation of ydeg
degrees about the
new y axis, and finally a rotation of xdeg
degrees about
the new x axis. If the model matrix is described by the affine transform
[ M p ] [ ] [ 0 1 ]where
M
is a 3 X 3 matrix and p
is a 3 X 1
translation vector, and if R
is the rotation matrix,
then this method sets the model matrix to
[ M R p ] [ ] [ 0 1 ]
rotateModelMatrix
in interface Renderer
zdeg
- rotation about z axis (degrees)ydeg
- rotation about new y axis (degrees)xdeg
- rotation about new x axis (degrees)public void scaleModelMatrix(double s)
Renderer
[ M p ] [ ] [ 0 1 ]where
M
is a 3 X 3 matrix and p
is a 3 X 1
translation vector, and s
is the scale factor, then
this method sets the model matrix to
[ s M p ] [ ] [ 0 1 ]
scaleModelMatrix
in interface Renderer
s
- scale factorpublic void scaleModelMatrix(double sx, double sy, double sz)
public void mulModelMatrix(AffineTransform3dBase trans)
Renderer
RigidTransform3d
or an
AffineTransform3d
. If the model matrix is described
by the affine transform
[ M p ] [ ] [ 0 1 ]where
M
is a 3 X 3 matrix and p
is a 3 X 1
translation vector, and the transform X is described by
[ A b ] [ ] [ 0 1 ]then this method sets the model matrix to
[ M A M b + p ] [ ] [ 0 1 ]
mulModelMatrix
in interface Renderer
trans
- transform to multiply the model matrix bypublic void setModelMatrix(AffineTransform3dBase X)
Renderer
setModelMatrix
in interface Renderer
X
- new model matrix valuepublic void setModelMatrix2d(double left, double right, double bottom, double top)
Renderer
setModelMatrix2d
in interface Renderer
left
- x value corresponding to -1 in world coordinatesright
- x value corresponding to 1 in world coordinatesbottom
- y value corresponding to -1 in world coordinatestop
- y value corresponding to 1 in world coordinatesRenderer.is2DRendering()
public boolean popModelMatrix()
Renderer
popModelMatrix
in interface Renderer
false
if the model matrix stack is emptypublic RigidTransform3d getViewMatrix()
Renderer
getViewMatrix
in interface Renderer
public void getViewMatrix(RigidTransform3d TWE)
Renderer
getViewMatrix
in interface Renderer
TWE
- returns the current transform from world to eye coordinatespublic void setDepthOffset(int offset)
Renderer
Depth offsets are used to help resolve z-fighting, in which overlapping primitives drawn in the same plane compete for visibility. If the plane has a considerable tilt with respect to the viewer, then an offset larger than one may be needed to resolve the issue.
setDepthOffset
in interface Renderer
offset
- new depth offset valuepublic int getDepthOffset()
Renderer
Renderer.setDepthOffset(int)
for
a description. The default value is 0.getDepthOffset
in interface Renderer
public void setTextureMatrix(AffineTransform2dBase T)
Renderer
setTextureMatrix
in interface Renderer
T
- new texture transform matrixpublic AffineTransform2dBase getTextureMatrix()
Renderer
RigidTransform2d
;
otherwise, it is a more general AffineTransform2d
.getTextureMatrix
in interface Renderer
public void getTextureMatrix(AffineTransform2d X)
Renderer
getTextureMatrix
in interface Renderer
X
- returns the current texture matrix valueRenderer.setTextureMatrix(AffineTransform2dBase)
public boolean hasSelection()
Renderer
hasSelection
in interface Renderer
true
if selection is supported.public boolean isSelecting()
Renderer
isSelecting
in interface Renderer
public Renderer.HighlightStyle getHighlightStyle()
Renderer
Renderer.HighlightStyle.NONE
indicates that
highlighting is deactivated.getHighlightStyle
in interface Renderer
public void getHighlightColor(float[] rgba)
Renderer
Renderer.HighlightStyle.COLOR
.getHighlightColor
in interface Renderer
rgba
- array of length 3 or 4 in which the RGB or RGBA components
of the highlight color are returned.public boolean setHighlighting(boolean enable)
Renderer
Renderer.HighlightStyle
. If the
style is Renderer.HighlightStyle.COLOR
, highlighting is
done by setting the effective color to the highlight color.setHighlighting
in interface Renderer
enable
- if true
, enable highlighting.Renderer.getHighlightColor(float[])
public boolean getHighlighting()
Renderer
getHighlighting
in interface Renderer
true
if highlighting is enabledpublic void beginSelectionQuery(int qid)
Renderer
qid
. If the rendering that occurs between this call and the
subsequent call to Renderer.endSelectionQuery()
results in anything being
rendered within the selection window, a {\it selection hit} will be
generated for qid
.
If called within the render
method for a IsSelectable
, then qid
must lie in the
range 0 to numq
-1, where numq
is the value
returned by
IsSelectable.numSelectionQueriesNeeded()
. Selection queries cannot be
nested. If a query identifier is used more than once, it is assumed
as part of the same query.beginSelectionQuery
in interface Renderer
qid
- identifier for the selection queryRenderer.endSelectionQuery()
public void endSelectionQuery()
Renderer
Renderer.beginSelectionQuery(int)
.endSelectionQuery
in interface Renderer
Renderer.beginSelectionQuery(int)
public void beginSubSelection(IsSelectable s, int qid)
Renderer
IsSelectable
s
that
manages its own selection; this call should
be used in place of Renderer.beginSelectionQuery(int)
for such objects.
Selectables that manage their own selection are identified by
having a value numq >= 0
, where numq
is the value returned by
IsSelectable.numSelectionQueriesNeeded()
IsSelectable#numSelectionQueriesNeeded{}}.
The argument qid
is the current selection query identifier,
which after the call should be increased by numq
.beginSubSelection
in interface Renderer
s
- Selectable that is managing its own sub-selectionqid
- current selection query identifierpublic void endSubSelection()
Renderer
Renderer.beginSubSelection(maspack.render.IsSelectable, int)
.endSubSelection
in interface Renderer
Renderer.endSubSelection()
public boolean isSelectable(IsSelectable s)
Renderer
s
is selectable in the current selection
context. This will be the case if s.isSelectable()
returns
true
, and s
also passes whatever selection
filter might currently be set in the renderer.isSelectable
in interface Renderer
public void beginDraw(Renderer.DrawMode mode)
Renderer
glBegin()
in the
old GL specification. Once in draw mode, the application can specify
the vertices (and if necessary, normals) that are used to draw the
primitive that is specified by the mode parameter.public void addVertex(float px, float py, float pz)
Renderer
addVertex
in interface Renderer
px
- vertex x coordinatepy
- vertex y coordinatepz
- vertex z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void addVertex(double px, double py, double pz)
Renderer
addVertex
in interface Renderer
px
- vertex x coordinatepy
- vertex y coordinatepz
- vertex z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void addVertex(Vector3d pnt)
Renderer
addVertex
in interface Renderer
pnt
- coordinates for the vertexRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void addVertex(float[] pnt)
Renderer
addVertex
in interface Renderer
pnt
- coordinates for the vertexRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setNormal(float nx, float ny, float nz)
Renderer
setNormal
call. The normal does not
need to be normalized.setNormal
in interface Renderer
nx
- normal x coordinateny
- normal y coordinatenz
- normal z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setNormal(double nx, double ny, double nz)
Renderer
Renderer.setNormal(float,float,float)
.setNormal
in interface Renderer
nx
- normal x coordinateny
- normal y coordinatenz
- normal z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setNormal(Vector3d nrm)
Renderer
Renderer.setNormal(float,float,float)
.setNormal
in interface Renderer
nrm
- normal coordinatesRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setTextureCoord(float tx, float ty)
Renderer
setTexcoord
call. The coordinate should
be within the range [0, 1]setTextureCoord
in interface Renderer
tx
- texture x coordinatety
- texture y coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setTextureCoord(double tx, double ty)
Renderer
Renderer.setTextureCoord(float,float)
.setTextureCoord
in interface Renderer
tx
- texture x coordinatety
- texture y coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void setTextureCoord(Vector2d tex)
Renderer
Renderer.setTextureCoord(float,float)
.setTextureCoord
in interface Renderer
tex
- texture coordinatesRenderer.beginDraw(maspack.render.Renderer.DrawMode)
public void endDraw()
Renderer
glEnd()
in the old
GL specification.public void restoreDefaultState(boolean strictChecking)
Renderer
restoreDefaultState
in interface Renderer
strictChecking
- if true
, enables strict
checking.