astex
Class Renderer

java.lang.Object
  extended by astex.Renderer

public class Renderer
extends java.lang.Object


Field Summary
 boolean analyticalSpheres
          Do we do analytical spheres?
 boolean antialias
          Are we antialiasing.
 double back
          The distance behind the center of the back clip plane.
 int backClip
          The integer back plane.
 boolean backlit
          Are we backlighting back facing triangles.
static int CartoonLightingModel
          The cartoon style.
 double clipIncrement
          The clip increment.
 boolean clipping
          Is clipping enabled?
 boolean clipTriangle
          Does this triangle need clipping?
 boolean colorInitialised
          Have we initialised the single color lookup table?
 boolean colorTriangle
          Are we doing triangle debugging color style.
 double cosWrapAngle
           
 boolean debug
          Is debugging information enabled?
 int[] debugColor
          Contrasting colors for debugging renderer performance.
static int DefaultLightingModel
          The default lighting model.
 boolean depthcue
          Do depth cueing of the final image.
 boolean emulate555
           
static int FinalRenderPass
           
static int FixedBits
          Number of fixed precision bits.
 double front
          The distance in front of the center of the front clip plane.
 int frontClip
          The integer front plane.
 boolean frontFaceOnly
          Do backface removal of triangles.
 boolean lightMapCalculated
          Have we calcualated our light map?
 DynamicArray lights
          The list of lights.
 DynamicArray objects
          The list of objects to render.
 int[] opbuffer
          The original pixel buffer.
 Matrix overallMatrix
           
 int[] pbuffer
          The pixel buffer.
 boolean phong
          Do phong shading.
 int pixelCount
          Number of pixels.
 int pixelHeight
          Height of the renderer.
 int pixelWidth
          Width of the renderer.
static int PostRenderPass
           
 double powFactor
           
static int PreRenderPass
          Different settings for the render passes.
 DynamicArray rendererEventListeners
           
static int RenderPass
           
 boolean rgb
          Do RGB Gouraud shading rather than Phong lookup.
 Matrix rotationMatrix
           
 double scale
          The current scale.
 int shadowMode
          Shadow mode for the renderer.
static int ShadowsAccumulate
           
static int ShadowsOff
          Defines for the shadowing states.
static int ShadowsOn
           
 Texture texture
          The current texture.
 java.util.Hashtable textures
          The list of textures.
 int triangleColor
          The base color for simple color triangle rendering.
 int triangleColorB
           
 int triangleColorG
           
 int triangleColorR
          Components of the triangle color for fast shading
 int[] triangleColors
          Primary colors for specific triangle issues.
 double width
          The width of the view.
 double wrapAngle
           
 boolean wuAntiAlias
          Are we doing wu line antialiasing.
 int[] zbuffer
          The z-buffer.
static double ZFixedBits
          Floating point multiplier for z-buffer interpolation.
 int zmax
          Maximum z-coordinate after transformation.
 int zmin
          Minimum z-coordinate after transformation.
 double zoom
          The current zoom.
 
Constructor Summary
Renderer()
          Default renderer.
 
Method Summary
 void addGraphicalObject(Tmesh tm)
          Add a graphical object.
 void addLight(boolean onOff, double x, double y, double z, int diffuseColor, int specularColor, double power)
          Add a light.
 void addRendererEventListener(RendererEventListener rel)
          Add a listener for renderer events.
 void addTmesh(Tmesh tm)
          Add a tmesh to the renderer.
 void applyTexture(java.lang.String pattern, java.lang.String texName)
          Apply texture to the specified objects.
 void applyTransform(double x, double y, double z, double[] s)
          Apply a transform to a point.
 void applyTransform2(double x, double y, double z, int[] s)
          Apply a transform to a point.
 void applyZoom(double factor)
          Change the zoom for the molecule.
 void buildOverallMatrix()
          Build the overall transformation matrix.
 void decrementClip()
          Decrement the clip plane distance.
 void decrementFrontClip()
          Decrement the clip plane distance.
 void drawAntiAliasedLine(int x0, int y0, int z0, int x1, int y1, int z1, int Colour0, int Colour1)
          Basic Wu antialiased line drawing.
 void drawBox(int xt, int yt, int zt, int width, int c)
          Draw a box in transformed screen coords.
 void drawCylinder(double x1, double y1, double z1, double x2, double y2, double z2, int rgb1, int rgb2, double r)
          Draw a cylinder.
 void drawDirectString(int x, int y, int color, java.lang.String string)
          Draw a string at the specified point.
 void drawDot(int xt, int yt, int zt, int c)
          Draw a dot.
 void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, int rgb1, int rgb2, int pixelWidth)
          World coordinate entry point for drawing lines.
 void drawLine(int x1, int y1, int z1, int x2, int y2, int z2, int rgb1, int rgb2, int lineWidth)
          Main entry point for drawing lines.
 void drawObjects()
          Draw the tmesh objects.
 void drawPixels(double x, double y, double z, int w, int h, int[] pix, int hints)
          Draw an image at the specified location.
 void drawSphere(double x, double y, double z, double r, int rgb)
          Draw a sphere.
 void drawSphere(double x, double y, double z, double r, int rgb, int transp)
           
 void drawString(double x, double y, double z, double zoff, int color, java.lang.String string)
          Draw a string at the specified point.
 void drawString(double x, double y, double z, int color, java.lang.String string)
          Draw a string at the specified point.
 void drawZImage(double x, double y, double z, int[] pix, int w, int h)
           
 int getAmbient()
          Get the ambient component.
 boolean getAntiAlias()
          Return the current antialiasing setting.
 double getBackClip()
           
 int getBackgroundColor()
          Get the background colour.
 double getCartoonNormalCutoff()
          Get the cartoon normal cutoff.
 Point3d getCenter()
          Get the center point.
 double getClip()
          Set the clip.
 double getFrontClip()
           
 Tmesh getGraphicalObject(int i)
          Get the number of graphical objects.
 Tmesh getGraphicalObject(java.lang.String targetName)
          Return a GraphicalObject with the specified name.
 int getGraphicalObjectCount()
          Get the number of graphical objects.
 DynamicArray getGraphicalObjects(java.lang.String pattern)
          Return a DynamicArray of objects that match the pattern.
 int getLightingModel()
           
 java.lang.String getLogo()
          Get the current logo.
 double getOverallScale()
          Return the overall scale.
 int getPixel(int x, int y)
          Get a pixel value checking for on screen.
 double getRadius()
          Get the radius.
 int getSamples()
          Get the number of samples.
 double getScale()
          Get the scale.
 java.lang.String getStatusString()
          Get the current StatusString.
 double getZoom()
          Get the zoom.
 void incrementClip()
          Increment the clip plane distance.
 void incrementFrontClip()
          Increment the clip plane distance.
 void postProcess()
          Post process the buffers.
 void publicRedraw()
          Public redrawing operations that can be overridden.
 void redraw()
          Redraw the image.
 void removeGraphicalObjects(java.lang.String pattern)
          Remove objects that match a pattern.
 void removeGraphicalObjects(Tmesh tm)
          Remove specific graphical object.
 void removeGraphicalObjectsBeginningWith(java.lang.String prefix)
          Remove objects that begin with the specified string.
 void removeRendererEventListener(RendererEventListener rel)
          Remove a listener for renderer events.
 void resetCenterAndRadius()
          Reset the center and radius of the view.
 void rotateX(double degrees)
          Rotate the transform around the x axis.
 void rotateY(double degrees)
          Rotate the transform around the x axis.
 void rotateZ(double degrees)
          Rotate the transform around the x axis.
 void scaleTexture(java.lang.String pattern, int attribute, double value)
          Scale texture to the specified objects.
 void setAmbient(int rgb)
          Set the ambient component of the lighting model.
 void setAntiAlias(boolean b)
          Set the current antialiasing setting.
 void setBackClip(double v)
          Set the back clip plane.
 void setBackClip(double v, boolean fireEvent)
           
 void setBackface(java.lang.String pattern, boolean value)
          Set backface on or off.
 void setBackgroundColor(int c)
          Set the background colour.
 void setCartoonNormalCutoff(double c)
          Set the cartoon normal cutoff.
 void setCenter(Point3d p)
          Set the center point.
 void setClip(double d)
          Set the clip.
 void setClip(double f, double b)
          Set the clip.
 void setClipIncrement(double inc)
          Set the clip increment.
 void setColor(int newc)
          Set the material color.
 void setDisplayStatusString(boolean b)
          Set whether or not to display the status string.
 void setDrawGamma(double d)
           
 void setFrontClip(double v)
          Set the front clip plane.
 void setFrontClip(double v, boolean fireEvent)
           
 void setGradient(boolean b)
          Set top of background colour gradient.
 void setGradientBottom(int c)
          Set top of background colour gradient.
 void setGradientTop(int c)
          Set top of background colour gradient.
 void setGraphicalObjectsColour(java.lang.String pattern, int colour)
          Change the visibility state of GraphicalObjects.
 void setGraphicalObjectsVisibility(java.lang.String pattern, int state)
          Change the visibility state of GraphicalObjects.
 void setLightingModel(int lm)
          Set the lighting model.
 void setLogo(java.lang.String newLogo)
          Set the current logo.
 void setPixel(int x, int y, int c)
          Set a pixel checking for on screen.
 void setPixel(int x, int y, int z, int c)
          Set a pixel checking for on screen and z-buffer.
 void setPowFactor(double d)
           
 void setRadius(double d)
          Set the radius.
 void setSamples(int s)
          Set the number of samples.
 void setScale(double s)
          Set the scale.
 void setSize(int width, int height)
          Resize the renderer.
 void setStatusString(java.lang.String newStatusString)
          Set the current StatusString.
 void setWrapAngle(double d)
           
 void setZoom(double s)
          Set the zoom.
 void transformNormal(double x, double y, double z, double[] s)
          Apply a transform to a point.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shadowMode

public int shadowMode
Shadow mode for the renderer.


ShadowsOff

public static final int ShadowsOff
Defines for the shadowing states.

See Also:
Constant Field Values

ShadowsAccumulate

public static final int ShadowsAccumulate
See Also:
Constant Field Values

ShadowsOn

public static final int ShadowsOn
See Also:
Constant Field Values

PreRenderPass

public static final int PreRenderPass
Different settings for the render passes.

See Also:
Constant Field Values

RenderPass

public static final int RenderPass
See Also:
Constant Field Values

PostRenderPass

public static final int PostRenderPass
See Also:
Constant Field Values

FinalRenderPass

public static final int FinalRenderPass
See Also:
Constant Field Values

pixelWidth

public int pixelWidth
Width of the renderer.


pixelHeight

public int pixelHeight
Height of the renderer.


pixelCount

public int pixelCount
Number of pixels.


pbuffer

public int[] pbuffer
The pixel buffer.


zbuffer

public int[] zbuffer
The z-buffer.


FixedBits

public static final int FixedBits
Number of fixed precision bits.

See Also:
Constant Field Values

ZFixedBits

public static final double ZFixedBits
Floating point multiplier for z-buffer interpolation.

See Also:
Constant Field Values

width

public double width
The width of the view.


back

public double back
The distance behind the center of the back clip plane.


backClip

public int backClip
The integer back plane.


front

public double front
The distance in front of the center of the front clip plane.


frontClip

public int frontClip
The integer front plane.


debug

public boolean debug
Is debugging information enabled?


objects

public DynamicArray objects
The list of objects to render.


DefaultLightingModel

public static final int DefaultLightingModel
The default lighting model.

See Also:
Constant Field Values

CartoonLightingModel

public static final int CartoonLightingModel
The cartoon style.

See Also:
Constant Field Values

lightMapCalculated

public transient boolean lightMapCalculated
Have we calcualated our light map?


colorInitialised

public boolean colorInitialised
Have we initialised the single color lookup table?


lights

public DynamicArray lights
The list of lights.


textures

public java.util.Hashtable textures
The list of textures.


texture

public Texture texture
The current texture.


clipping

public boolean clipping
Is clipping enabled?


clipTriangle

public boolean clipTriangle
Does this triangle need clipping?


rgb

public boolean rgb
Do RGB Gouraud shading rather than Phong lookup.


phong

public boolean phong
Do phong shading.


frontFaceOnly

public boolean frontFaceOnly
Do backface removal of triangles.


backlit

public boolean backlit
Are we backlighting back facing triangles.


depthcue

public boolean depthcue
Do depth cueing of the final image.


analyticalSpheres

public boolean analyticalSpheres
Do we do analytical spheres?


zmin

public int zmin
Minimum z-coordinate after transformation.


zmax

public int zmax
Maximum z-coordinate after transformation.


triangleColor

public int triangleColor
The base color for simple color triangle rendering.


triangleColorR

public int triangleColorR
Components of the triangle color for fast shading


triangleColorG

public int triangleColorG

triangleColorB

public int triangleColorB

colorTriangle

public boolean colorTriangle
Are we doing triangle debugging color style.


scale

public double scale
The current scale.


zoom

public double zoom
The current zoom.


clipIncrement

public double clipIncrement
The clip increment.


debugColor

public int[] debugColor
Contrasting colors for debugging renderer performance.


triangleColors

public int[] triangleColors
Primary colors for specific triangle issues.


rendererEventListeners

public transient DynamicArray rendererEventListeners

antialias

public boolean antialias
Are we antialiasing.


wuAntiAlias

public boolean wuAntiAlias
Are we doing wu line antialiasing.


emulate555

public boolean emulate555

overallMatrix

public Matrix overallMatrix

rotationMatrix

public Matrix rotationMatrix

opbuffer

public int[] opbuffer
The original pixel buffer.


powFactor

public double powFactor

wrapAngle

public double wrapAngle

cosWrapAngle

public double cosWrapAngle
Constructor Detail

Renderer

public Renderer()
Default renderer.

Method Detail

getAntiAlias

public boolean getAntiAlias()
Return the current antialiasing setting.


setAntiAlias

public void setAntiAlias(boolean b)
Set the current antialiasing setting.


setLightingModel

public void setLightingModel(int lm)
Set the lighting model.


getLightingModel

public int getLightingModel()

setCartoonNormalCutoff

public void setCartoonNormalCutoff(double c)
Set the cartoon normal cutoff.


getCartoonNormalCutoff

public double getCartoonNormalCutoff()
Get the cartoon normal cutoff.


setBackgroundColor

public void setBackgroundColor(int c)
Set the background colour.


getBackgroundColor

public int getBackgroundColor()
Get the background colour.


setGradient

public void setGradient(boolean b)
Set top of background colour gradient.


setGradientTop

public void setGradientTop(int c)
Set top of background colour gradient.


setGradientBottom

public void setGradientBottom(int c)
Set top of background colour gradient.


setScale

public void setScale(double s)
Set the scale.


getScale

public double getScale()
Get the scale.


setZoom

public void setZoom(double s)
Set the zoom.


getZoom

public double getZoom()
Get the zoom.


applyZoom

public void applyZoom(double factor)
Change the zoom for the molecule.


setRadius

public void setRadius(double d)
Set the radius.


getRadius

public double getRadius()
Get the radius.


setFrontClip

public void setFrontClip(double v)
Set the front clip plane.


getFrontClip

public double getFrontClip()

setFrontClip

public void setFrontClip(double v,
                         boolean fireEvent)

setBackClip

public void setBackClip(double v)
Set the back clip plane.


getBackClip

public double getBackClip()

setBackClip

public void setBackClip(double v,
                        boolean fireEvent)

setClip

public void setClip(double f,
                    double b)
Set the clip.


setClip

public void setClip(double d)
Set the clip.


getClip

public double getClip()
Set the clip.


setClipIncrement

public void setClipIncrement(double inc)
Set the clip increment.


incrementClip

public void incrementClip()
Increment the clip plane distance.


decrementClip

public void decrementClip()
Decrement the clip plane distance.


incrementFrontClip

public void incrementFrontClip()
Increment the clip plane distance.


decrementFrontClip

public void decrementFrontClip()
Decrement the clip plane distance.


getCenter

public Point3d getCenter()
Get the center point.


setCenter

public void setCenter(Point3d p)
Set the center point.


resetCenterAndRadius

public void resetCenterAndRadius()
Reset the center and radius of the view.


setAmbient

public void setAmbient(int rgb)
Set the ambient component of the lighting model.


getAmbient

public int getAmbient()
Get the ambient component.


addLight

public void addLight(boolean onOff,
                     double x,
                     double y,
                     double z,
                     int diffuseColor,
                     int specularColor,
                     double power)
Add a light.


addRendererEventListener

public void addRendererEventListener(RendererEventListener rel)
Add a listener for renderer events.


removeRendererEventListener

public void removeRendererEventListener(RendererEventListener rel)
Remove a listener for renderer events.


addTmesh

public void addTmesh(Tmesh tm)
Add a tmesh to the renderer.


addGraphicalObject

public void addGraphicalObject(Tmesh tm)
Add a graphical object.


getGraphicalObjectCount

public int getGraphicalObjectCount()
Get the number of graphical objects.


getGraphicalObject

public Tmesh getGraphicalObject(int i)
Get the number of graphical objects.


getGraphicalObject

public Tmesh getGraphicalObject(java.lang.String targetName)
Return a GraphicalObject with the specified name.


getGraphicalObjects

public DynamicArray getGraphicalObjects(java.lang.String pattern)
Return a DynamicArray of objects that match the pattern.


setGraphicalObjectsColour

public void setGraphicalObjectsColour(java.lang.String pattern,
                                      int colour)
Change the visibility state of GraphicalObjects.


setGraphicalObjectsVisibility

public void setGraphicalObjectsVisibility(java.lang.String pattern,
                                          int state)
Change the visibility state of GraphicalObjects.


removeGraphicalObjects

public void removeGraphicalObjects(java.lang.String pattern)
Remove objects that match a pattern.


removeGraphicalObjects

public void removeGraphicalObjects(Tmesh tm)
Remove specific graphical object.


removeGraphicalObjectsBeginningWith

public void removeGraphicalObjectsBeginningWith(java.lang.String prefix)
Remove objects that begin with the specified string.


applyTexture

public void applyTexture(java.lang.String pattern,
                         java.lang.String texName)
Apply texture to the specified objects.


scaleTexture

public void scaleTexture(java.lang.String pattern,
                         int attribute,
                         double value)
Scale texture to the specified objects.


setBackface

public void setBackface(java.lang.String pattern,
                        boolean value)
Set backface on or off.


postProcess

public void postProcess()
Post process the buffers.


drawObjects

public void drawObjects()
Draw the tmesh objects.


getOverallScale

public double getOverallScale()
Return the overall scale.


buildOverallMatrix

public void buildOverallMatrix()
Build the overall transformation matrix.


rotateX

public void rotateX(double degrees)
Rotate the transform around the x axis.


rotateY

public void rotateY(double degrees)
Rotate the transform around the x axis.


rotateZ

public void rotateZ(double degrees)
Rotate the transform around the x axis.


applyTransform2

public void applyTransform2(double x,
                            double y,
                            double z,
                            int[] s)
Apply a transform to a point.


applyTransform

public void applyTransform(double x,
                           double y,
                           double z,
                           double[] s)
Apply a transform to a point.


transformNormal

public void transformNormal(double x,
                            double y,
                            double z,
                            double[] s)
Apply a transform to a point.


drawCylinder

public void drawCylinder(double x1,
                         double y1,
                         double z1,
                         double x2,
                         double y2,
                         double z2,
                         int rgb1,
                         int rgb2,
                         double r)
Draw a cylinder.


drawSphere

public void drawSphere(double x,
                       double y,
                       double z,
                       double r,
                       int rgb)
Draw a sphere.


drawSphere

public void drawSphere(double x,
                       double y,
                       double z,
                       double r,
                       int rgb,
                       int transp)

drawBox

public void drawBox(int xt,
                    int yt,
                    int zt,
                    int width,
                    int c)
Draw a box in transformed screen coords.


drawPixels

public void drawPixels(double x,
                       double y,
                       double z,
                       int w,
                       int h,
                       int[] pix,
                       int hints)
Draw an image at the specified location.


drawDirectString

public void drawDirectString(int x,
                             int y,
                             int color,
                             java.lang.String string)
Draw a string at the specified point.


drawString

public void drawString(double x,
                       double y,
                       double z,
                       int color,
                       java.lang.String string)
Draw a string at the specified point. All strings are drawn using world coordinates.


drawString

public void drawString(double x,
                       double y,
                       double z,
                       double zoff,
                       int color,
                       java.lang.String string)
Draw a string at the specified point. All strings are drawn using world coordinates. zoff controls screen space offseting so that you can force a label to lie in front of other objects.


drawZImage

public void drawZImage(double x,
                       double y,
                       double z,
                       int[] pix,
                       int w,
                       int h)

drawDot

public void drawDot(int xt,
                    int yt,
                    int zt,
                    int c)
Draw a dot.


setPixel

public void setPixel(int x,
                     int y,
                     int z,
                     int c)
Set a pixel checking for on screen and z-buffer.


setPixel

public void setPixel(int x,
                     int y,
                     int c)
Set a pixel checking for on screen.


getPixel

public int getPixel(int x,
                    int y)
Get a pixel value checking for on screen.


drawLine

public void drawLine(double x1,
                     double y1,
                     double z1,
                     double x2,
                     double y2,
                     double z2,
                     int rgb1,
                     int rgb2,
                     int pixelWidth)
World coordinate entry point for drawing lines.


drawLine

public void drawLine(int x1,
                     int y1,
                     int z1,
                     int x2,
                     int y2,
                     int z2,
                     int rgb1,
                     int rgb2,
                     int lineWidth)
Main entry point for drawing lines. This method will detect if the line is entirely in the pixel map and draw it fast or safe accordingly.


setDrawGamma

public void setDrawGamma(double d)

drawAntiAliasedLine

public void drawAntiAliasedLine(int x0,
                                int y0,
                                int z0,
                                int x1,
                                int y1,
                                int z1,
                                int Colour0,
                                int Colour1)
Basic Wu antialiased line drawing. Many problems. 1) Linear sharing of intensities doesn't look quite perfect. 2) No z-buffering 3) Imperfect line endings


publicRedraw

public void publicRedraw()
Public redrawing operations that can be overridden.


redraw

public void redraw()
Redraw the image.


setDisplayStatusString

public void setDisplayStatusString(boolean b)
Set whether or not to display the status string.


setLogo

public void setLogo(java.lang.String newLogo)
Set the current logo.


getLogo

public java.lang.String getLogo()
Get the current logo.


setStatusString

public void setStatusString(java.lang.String newStatusString)
Set the current StatusString.


getStatusString

public java.lang.String getStatusString()
Get the current StatusString.


setSize

public void setSize(int width,
                    int height)
Resize the renderer. Only reallocate the buffers if the window gets bigger.


setSamples

public void setSamples(int s)
Set the number of samples.


getSamples

public int getSamples()
Get the number of samples.


setColor

public void setColor(int newc)
Set the material color.


setPowFactor

public void setPowFactor(double d)

setWrapAngle

public void setWrapAngle(double d)