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
sthat
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()
RenderergetScreenHeight in interface Rendererpublic int getScreenWidth()
RenderergetScreenWidth in interface Rendererpublic double getViewPlaneHeight()
RenderergetViewPlaneHeight in interface Rendererpublic double getViewPlaneWidth()
RenderergetViewPlaneWidth in interface Rendererpublic double distancePerPixel(Vector3d pnt)
Rendererp, 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 Rendererpnt - point undergoing the displacementpublic double centerDistancePerPixel()
RenderercenterDistancePerPixel in interface Rendererpublic Point3d getCenter()
Rendererpublic boolean isOrthogonal()
Renderertrue if this renderer is currently configured for
orthogonal projection.isOrthogonal in interface Renderertrue if projection is orthogonalpublic double getViewPlaneDistance()
RenderergetViewPlaneDistance in interface RendererRenderer.getFarPlaneDistance()public double getFarPlaneDistance()
RenderergetFarPlaneDistance in interface RendererRenderer.getViewPlaneDistance()public float getPointSize()
RenderergetPointSize in interface RendererRenderer.setPointSize(float)public void setPointSize(float size)
RenderersetPointSize in interface Renderersize - new point size (in pixels).Renderer.getPointSize()public float getLineWidth()
RenderergetLineWidth in interface RendererRenderer.setLineWidth(float)public void setLineWidth(float width)
RenderersetLineWidth in interface Rendererwidth - new line width (in pixels).Renderer.getLineWidth()public Renderer.FaceStyle getFaceStyle()
RenderergetFaceStyle in interface RendererRenderer.setFaceStyle(maspack.render.Renderer.FaceStyle)public Renderer.FaceStyle setFaceStyle(Renderer.FaceStyle style)
RendererRenderer.FaceStyle.FRONT.setFaceStyle in interface Rendererstyle - new face styleRenderer.getFaceStyle()public Renderer.ColorInterpolation getColorInterpolation()
RenderergetColorInterpolation in interface Rendererpublic Renderer.ColorInterpolation setColorInterpolation(Renderer.ColorInterpolation interp)
RendererRenderer.ColorInterpolation.RGB, but
Renderer.ColorInterpolation.HSV is often more appropriate for
displaying information that is purely color-based.setColorInterpolation in interface Rendererinterp - new color interpolation modepublic boolean hasVertexColorMixing(Renderer.ColorMixing cmix)
RendererhasVertexColorMixing in interface Renderertrue if the color mixing method is supportedpublic Renderer.ColorMixing getVertexColorMixing()
RenderergetVertexColorMixing in interface Rendererpublic Renderer.ColorMixing setVertexColorMixing(Renderer.ColorMixing cmix)
RendererRenderer.hasVertexColorMixing(maspack.render.Renderer.ColorMixing) to test whether a method is suuported.setVertexColorMixing in interface Renderercmix - new color mixing methodpublic Renderer.Shading getShading()
RendererRenderer.Shading.NONE turns off lighting and causes primitives to be
rendered in solid colors, using the current diffuse color.getShading in interface Rendererpublic Renderer.Shading setShading(Renderer.Shading shading)
RendererRenderer.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 Renderershading - new shading model to be usedpublic double getAxisRadiusRatio()
Renderer.setAxisRadiusRatio(double) for
more information.getAxisRadiusRatio in interface Rendererpublic void setAxisRadiusRatio(double ratio)
setAxisRadiusRatio in interface Rendererratio - new axis render ratiopublic void drawPoint(Vector3d pnt)
Rendererpnt 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)
Rendererpx, 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)
Rendererpnt 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)
RendererRenderer.Shading.NONE.public void drawLine(double px0,
double py0,
double pz0,
double px1,
double py1,
double pz1)
RendererRenderer.drawLine(Vector3d,Vector3d).public void drawLine(float[] pnt0,
float[] pnt1)
RendererRenderer.drawLine(Vector3d,Vector3d).public void drawTriangle(Vector3d pnt0, Vector3d pnt1, Vector3d pnt2)
RendererRenderer.Shading.NONE, the shading will be effectively flat.drawTriangle in interface Rendererpnt0 - first pointpnt1 - second pointpnt2 - third pointpublic void drawTriangle(float[] pnt0,
float[] pnt1,
float[] pnt2)
RendererRenderer.drawTriangle(Vector3d,Vector3d,Vector3d).drawTriangle in interface Rendererpnt0 - first pointpnt1 - second pointpnt2 - third pointpublic int getSurfaceResolution()
RenderergetSurfaceResolution in interface RendererRenderer.setSurfaceResolution(int)public int setSurfaceResolution(int nsegs)
RenderersetSurfaceResolution in interface Renderernsegs - resolution for curved surfacespublic void drawSphere(Vector3d pnt, double rad)
RendererRenderer.getSurfaceResolution().drawSphere in interface Rendererpnt - center of the sphererad - radius of the spherepublic void drawSphere(float[] pnt,
double rad)
RendererRenderer.drawSphere(Vector3d,double).drawSphere in interface Rendererpnt - center of the sphererad - radius of the spherepublic void drawCube(Vector3d pnt, double w)
Rendererpublic void drawCube(float[] pnt,
double w)
Rendererpublic void drawBox(float[] pnt,
double wx,
double wy,
double wz)
Rendererpublic void drawBox(Vector3d pnt, Vector3d widths)
Rendererpublic void drawBox(RigidTransform3d TBM, Vector3d widths)
Rendererpublic void drawSpindle(Vector3d pnt0, Vector3d pnt1, double rad)
RendererRenderer.getSurfaceResolution().drawSpindle in interface Rendererpnt0 - first end pointpnt1 - second end pointrad - radius of the spindlepublic void drawSpindle(float[] pnt0,
float[] pnt1,
double rad)
RendererRenderer.getSurfaceResolution().drawSpindle in interface Rendererpnt0 - first end pointpnt1 - second end pointrad - radius of the spindlepublic void drawCylinder(Vector3d pnt0, Vector3d pnt1, double rad, boolean capped)
RendererRenderer.getSurfaceResolution().drawCylinder in interface Rendererpnt0 - 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)
RendererRenderer.getSurfaceResolution().drawCylinder in interface Rendererpnt0 - 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)
RendererRenderer.getSurfaceResolution().public void drawCone(float[] pnt0,
float[] pnt1,
double rad0,
double rad1,
boolean capped)
RendererRenderer.getSurfaceResolution().public void drawArrow(Vector3d pnt0, Vector3d pnt1, double rad, boolean capped)
Rendererrad, 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)
RendererRenderer.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)
Rendererpnt 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)
RendererX. 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 RendererX - 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)
RendererX. 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 RendererX - 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)
RendererX. 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)
RendererX. 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 RendererX - 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)
RendererX. 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 RendererX - 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)
RendererX. 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)
Rendererpnt 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)
Rendererpnt 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)
Rendererprops. 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)
Rendererprops.
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)
Rendererprops. 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)
Rendererprops. 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 Rendererprops - 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 propscapped - 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)
Rendererprops. 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 Rendererprops - 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)
Rendererprops. The method
behaves similarly to
Renderer.drawArrow(float[],float[],double,boolean),
with the cylinder radius determine instead by
props.getLineRadius().drawArrow in interface Rendererprops - 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)
Rendererprops, 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 Rendererprops - 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)
RenderergetTextBounds in interface Rendererfont - font to use for sizingstr - String of which to compute the bounding boxemSize - size of the 'em' unitpublic void setDefaultFont(java.awt.Font font)
RenderersetDefaultFont in interface Rendererfont - 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()
RenderergetDefaultFont in interface Rendererpublic boolean hasTextRendering()
RendererhasTextRendering in interface Renderertrue if text rendering is supported.public double drawText(java.lang.String str,
float[] pos,
double emSize)
Rendererpublic double drawText(java.awt.Font font,
java.lang.String str,
float[] pos,
double emSize)
RendererdrawText in interface Rendererfont - 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)
Rendererpublic double drawText(java.awt.Font font,
java.lang.String str,
Vector3d pos,
double emSize)
RendererdrawText in interface Rendererfont - 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()
RenderergetEyeZDirection in interface Rendererpublic boolean begin2DRendering()
Rendererfalse
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 Renderertrue if 2D rendering is supportedRenderer.getScreenWidth(),
Renderer.getScreenHeight(),
Renderer.has2DRendering()public boolean begin2DRendering(double w,
double h)
Rendererfalse
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 Rendererw - width of the screen coordinatesh - height of the screen coordinatestrue if 2D rendering is supportedRenderer.has2DRendering()public boolean has2DRendering()
Renderertrue if this Renderer supports 2D rendering mode.has2DRendering in interface Renderertrue if 2D rendering is supportedRenderer.is2DRendering()public void end2DRendering()
Rendererend2DRendering in interface Rendererpublic boolean is2DRendering()
Rendereris2DRendering in interface Renderertrue if in 2D rendering mode.public void setColor(float[] rgba,
boolean highlight)
Rendererrgba, 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)
Rendererrgba. 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)
RendererRenderer.setColor(float[]), with the RGBA values being obtained
from the color components of color.public void setColor(float r,
float g,
float b)
RendererRenderer.setColor(float[]), only with alpha assumed to be 1.public void setColor(float r,
float g,
float b,
float a)
RendererRenderer.setColor(float[]).public void setFrontColor(float[] rgba)
RendererRenderer.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 Rendererrgba - 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)
Rendererrgba. 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 Rendererrgba - optional storage of length 3 or 4 for returning either
the RGB or RGBA values.public void setBackColor(float[] rgba)
Rendererrgba 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 Rendererrgba - 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)
Renderernull 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 Rendererrgba - 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 Rendererrgb - array of length 3 specifying RGB values in
the range [0,1].public float[] getEmission(float[] rgb)
Rendererrgb.
Otherwise, if rgb is null,
an array will be allocated for returning the RGB values.getEmission in interface Rendererrgb - optional storage for returning the RGB values.public void setSpecular(float[] rgb)
Renderer(0.1, 0.1, 0.1).setSpecular in interface Rendererrgb - array of length 3 specifying RGB values in
the range [0,1].public float[] getSpecular(float[] rgb)
Rendererrgb.
Otherwise, if rgb is null,
an array will be allocated for returning the RGB values.getSpecular in interface Rendererrgb - optional storage for returning the RGB values.public void setShininess(float s)
RendererRenderer.getShininess(). This should be in the
range [0,128], and the default value is 32.setShininess in interface Renderers - shininess parameterpublic float getShininess()
RenderergetShininess in interface Rendererpublic void setFrontAlpha(float a)
RenderersetFrontAlpha in interface Renderera - alpha value, in the range [0,1].public void setPointColoring(RenderProps props, boolean highlight)
Rendererprops, 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 Rendererprops - supplies the shininess and point color valueshighlight - if true, enables highlightingpublic void setLineColoring(RenderProps props, boolean highlight)
Rendererprops, 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 Rendererprops - supplies the shininess and line color valueshighlight - if true, enables highlightingpublic void setEdgeColoring(RenderProps props, boolean highlight)
Rendererprops, 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 Rendererprops - supplies the shininess and edge (or line) color valueshighlight - if true, enables highlightingpublic void setFaceColoring(RenderProps props, boolean highlight)
Rendererprops, 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 Rendererprops - supplies the shininess and front and back color valueshighlight - if true, enables highlightingpublic void setFaceColoring(RenderProps props, float[] rgba, boolean highlight)
Rendererrgba, 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 Rendererprops - 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)
Rendererrgba, 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 Rendererprops - 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)
Rendererprops. 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 Rendererprops - properties giving the shading and point stylepublic Renderer.Shading setLineShading(RenderProps props)
Rendererprops. 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 Rendererprops - properties giving the shading and line stylepublic Renderer.Shading setPropsShading(RenderProps props)
Rendererprops.getShading().setPropsShading in interface Rendererprops - properties giving the shadingpublic boolean hasColorMapping()
RendererhasColorMapping in interface Renderertrue if color mapping is supported.public boolean hasColorMapMixing(Renderer.ColorMixing cmix)
RendererhasColorMapMixing in interface Renderertrue if the color mixing method is supportedpublic ColorMapProps setColorMap(ColorMapProps props)
Rendererprops, 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 Rendererprops - properties for the color map, or null
to disablepublic ColorMapProps getColorMap()
Renderernull if no color map is currently set or color mapping
is not supported.getColorMap in interface RendererRenderer.setColorMap(maspack.render.ColorMapProps)public boolean hasNormalMapping()
RendererhasNormalMapping in interface Renderertrue if normal mapping is supported.public NormalMapProps setNormalMap(NormalMapProps props)
Rendererprops, 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 Rendererprops - properties for the normal mapping, or null
to disablepublic NormalMapProps getNormalMap()
Renderernull if no normal mapping has been set or normal mapping
is not supported.getNormalMap in interface RendererRenderer.setNormalMap(maspack.render.NormalMapProps)public boolean hasBumpMapping()
RendererhasBumpMapping in interface Renderertrue if bump mapping is supported.public BumpMapProps setBumpMap(BumpMapProps props)
Rendererprops, 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 Rendererprops - properties for the bump mapping, or null
to disablepublic BumpMapProps getBumpMap()
Renderernull if no bump mapping has been set or bump mapping
is not supported.getBumpMap in interface RendererRenderer.setBumpMap(maspack.render.BumpMapProps)public void drawTriangles(RenderObject robj)
RendererdrawTriangles in interface Rendererrobj - render objectpublic void drawTriangles(RenderObject robj, int gidx)
RendererdrawTriangles in interface Rendererrobj - render objectgidx - triangle group indexpublic void drawTriangles(RenderObject robj, int gidx, int offset, int count)
RendererdrawTriangles in interface Rendererrobj - render objectgidx - triangle group indexoffset - triangle offset at which to start renderingcount - number of triangles to drawpublic void drawLines(RenderObject robj)
Rendererpublic void drawLines(RenderObject robj, int gidx)
Rendererpublic void drawLines(RenderObject robj, Renderer.LineStyle style, double rad)
RendererRenderer.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)
RendererRenderer.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)
RendererRenderer.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)
RendererdrawPoints in interface Rendererrobj - render objectpublic void drawPoints(RenderObject robj, int gidx)
RendererdrawPoints in interface Rendererrobj - render objectgidx - point group indexpublic void drawPoints(RenderObject robj, Renderer.PointStyle style, double rad)
RendererRenderer.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 Rendererrobj - 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)
RendererRenderer.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 Rendererrobj - 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)
RendererRenderer.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 Rendererrobj - 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)
RendererdrawVertices in interface Rendererrobj - render objectmode - drawing mode to be used for drawing the verticespublic void drawVertices(RenderObject robj, VertexIndexArray idxs, Renderer.DrawMode mode)
RendererVertexIndexArray can detect whether or not it has been modified,
which allows for caching.drawVertices in interface Rendererrobj - 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)
RendererVertexIndexArray 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 Rendererrobj - render objectidxs - vertex indicesoffset - index offsetcount - index countmode - drawing mode to be used for drawing the verticespublic void draw(RenderObject robj)
Rendererpublic void drawTriangles(RenderObject robj, int gidx, RenderInstances rinst)
RendererdrawTriangles in interface Rendererrobj - object to drawgidx - triangle group to drawrinst - instance to drawpublic void drawLines(RenderObject robj, int gidx, RenderInstances rinst)
RendererRenderer.LineStyle.LINE and use the
current line-width, as determined by Renderer.getLineWidth().public void drawPoints(RenderObject robj, int gidx, RenderInstances rinst)
RendererRenderer.PointStyle.POINT and use the
current point-size, as determined by Renderer.getPointSize().drawPoints in interface Rendererrobj - object to drawgidx - point group to drawrinst - instance to drawpublic void pushModelMatrix()
RendererpushModelMatrix in interface Rendererpublic AffineTransform3dBase getModelMatrix()
RendererRigidTransform3d;
otherwise, it is a more general AffineTransform3d.getModelMatrix in interface Rendererpublic void getModelMatrix(AffineTransform3d X)
RenderergetModelMatrix in interface RendererX - 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 Renderertx - translation along xty - translation along ytz - translation along zpublic void rotateModelMatrix(double zdeg,
double ydeg,
double xdeg)
Rendererzdeg 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 Rendererzdeg - 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 Renderers - scale factorpublic void scaleModelMatrix(double sx,
double sy,
double sz)
public void mulModelMatrix(AffineTransform3dBase trans)
RendererRigidTransform3d 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 Renderertrans - transform to multiply the model matrix bypublic void setModelMatrix(AffineTransform3dBase X)
RenderersetModelMatrix in interface RendererX - new model matrix valuepublic void setModelMatrix2d(double left,
double right,
double bottom,
double top)
RenderersetModelMatrix2d in interface Rendererleft - 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()
RendererpopModelMatrix in interface Rendererfalse if the model matrix stack is emptypublic RigidTransform3d getViewMatrix()
RenderergetViewMatrix in interface Rendererpublic void getViewMatrix(RigidTransform3d TWE)
RenderergetViewMatrix in interface RendererTWE - returns the current transform from world to eye coordinatespublic void setDepthOffset(int offset)
RendererDepth 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 Rendereroffset - new depth offset valuepublic int getDepthOffset()
RendererRenderer.setDepthOffset(int) for
a description. The default value is 0.getDepthOffset in interface Rendererpublic void setTextureMatrix(AffineTransform2dBase T)
RenderersetTextureMatrix in interface RendererT - new texture transform matrixpublic AffineTransform2dBase getTextureMatrix()
RendererRigidTransform2d;
otherwise, it is a more general AffineTransform2d.getTextureMatrix in interface Rendererpublic void getTextureMatrix(AffineTransform2d X)
RenderergetTextureMatrix in interface RendererX - returns the current texture matrix valueRenderer.setTextureMatrix(AffineTransform2dBase)public boolean hasSelection()
RendererhasSelection in interface Renderertrue if selection is supported.public boolean isSelecting()
RendererisSelecting in interface Rendererpublic Renderer.HighlightStyle getHighlightStyle()
RendererRenderer.HighlightStyle.NONE indicates that
highlighting is deactivated.getHighlightStyle in interface Rendererpublic void getHighlightColor(float[] rgba)
RendererRenderer.HighlightStyle.COLOR.getHighlightColor in interface Rendererrgba - array of length 3 or 4 in which the RGB or RGBA components
of the highlight color are returned.public boolean setHighlighting(boolean enable)
RendererRenderer.HighlightStyle. If the
style is Renderer.HighlightStyle.COLOR, highlighting is
done by setting the effective color to the highlight color.setHighlighting in interface Rendererenable - if true, enable highlighting.Renderer.getHighlightColor(float[])public boolean getHighlighting()
RenderergetHighlighting in interface Renderertrue if highlighting is enabledpublic void beginSelectionQuery(int qid)
Rendererqid. 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 Rendererqid - identifier for the selection queryRenderer.endSelectionQuery()public void endSelectionQuery()
RendererRenderer.beginSelectionQuery(int).endSelectionQuery in interface RendererRenderer.beginSelectionQuery(int)public void beginSubSelection(IsSelectable s, int qid)
RendererIsSelectable
sthat
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 Renderers - Selectable that is managing its own sub-selectionqid - current selection query identifierpublic void endSubSelection()
RendererRenderer.beginSubSelection(maspack.render.IsSelectable, int).endSubSelection in interface RendererRenderer.endSubSelection()public boolean isSelectable(IsSelectable s)
Renderers 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 Rendererpublic void beginDraw(Renderer.DrawMode mode)
RendererglBegin() 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)
RendereraddVertex in interface Rendererpx - vertex x coordinatepy - vertex y coordinatepz - vertex z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void addVertex(double px,
double py,
double pz)
RendereraddVertex in interface Rendererpx - vertex x coordinatepy - vertex y coordinatepz - vertex z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void addVertex(Vector3d pnt)
RendereraddVertex in interface Rendererpnt - coordinates for the vertexRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void addVertex(float[] pnt)
RendereraddVertex in interface Rendererpnt - coordinates for the vertexRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setNormal(float nx,
float ny,
float nz)
RenderersetNormal call. The normal does not
need to be normalized.setNormal in interface Renderernx - normal x coordinateny - normal y coordinatenz - normal z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setNormal(double nx,
double ny,
double nz)
RendererRenderer.setNormal(float,float,float).setNormal in interface Renderernx - normal x coordinateny - normal y coordinatenz - normal z coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setNormal(Vector3d nrm)
RendererRenderer.setNormal(float,float,float).setNormal in interface Renderernrm - normal coordinatesRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setTextureCoord(float tx,
float ty)
RenderersetTexcoord call. The coordinate should
be within the range [0, 1]setTextureCoord in interface Renderertx - texture x coordinatety - texture y coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setTextureCoord(double tx,
double ty)
RendererRenderer.setTextureCoord(float,float).setTextureCoord in interface Renderertx - texture x coordinatety - texture y coordinateRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void setTextureCoord(Vector2d tex)
RendererRenderer.setTextureCoord(float,float).setTextureCoord in interface Renderertex - texture coordinatesRenderer.beginDraw(maspack.render.Renderer.DrawMode)public void endDraw()
RendererglEnd() in the old
GL specification.public void restoreDefaultState(boolean strictChecking)
RendererrestoreDefaultState in interface RendererstrictChecking - if true, enables strict
checking.