artofillusion.view
Class SoftwareCanvasDrawer

java.lang.Object
  extended by artofillusion.view.SoftwareCanvasDrawer
All Implemented Interfaces:
CanvasDrawer

public class SoftwareCanvasDrawer
extends java.lang.Object
implements CanvasDrawer

This is a CanvasDrawer which implements a software renderer for generating the contents of a ViewerCanvas.


Constructor Summary
SoftwareCanvasDrawer(ViewerCanvas view)
           
 
Method Summary
 void drawBorder()
          Draw a border around the rendered image.
 void drawBox(int x, int y, int width, int height, java.awt.Color color)
          Draw a filled box in the rendered image.
 void drawBoxes(java.util.List<java.awt.Rectangle> box, java.awt.Color color)
          Draw a set of filled boxes in the rendered image.
 void drawDraggedShape(java.awt.Shape shape)
          Show feedback to the user in response to a mouse drag, by drawing a Shape over the image.
 void drawHRule(int y, java.awt.Color color)
          Draw a horizontal line across the rendered image.
 void drawImage(java.awt.Image image, int x, int y)
          Draw an image onto the canvas.
 void drawLine(java.awt.Point p1, java.awt.Point p2, java.awt.Color color)
          Draw a line into the rendered image.
 void drawShape(java.awt.Shape shape, java.awt.Color color)
          Draw the outline of a Shape into the canvas.
 void drawString(java.lang.String text, int x, int y, java.awt.Color color)
          Draw a piece of text onto the canvas.
 void drawVRule(int x, java.awt.Color color)
          Draw a vertical line across the rendered image.
 void fillShape(java.awt.Shape shape, java.awt.Color color)
          Draw a filled Shape onto the canvas.
 java.awt.image.BufferedImage getImage()
          Get the most recent rendered image.
 void imageChanged(java.awt.Image image)
          This should be called to indicate that a previously drawn image has changed, and cached information for it needs to be discarded.
 void paint(RepaintEvent ev)
           
 void renderBox(int x, int y, int width, int height, double depth, java.awt.Color color)
          Render a filled box at a specified depth in the rendered image.
 void renderBoxes(java.util.List<java.awt.Rectangle> box, java.util.List<java.lang.Double> depth, java.awt.Color color)
          Render a set of filled boxes at specified depths in the rendered image.
 void renderImage(java.awt.Image image, Vec3 p1, Vec3 p2, Vec3 p3, Vec3 p4, Camera camera)
          Render an image onto the canvas.
 void renderLine(Vec2 p1, double zf1, Vec2 p2, double zf2, Camera cam, java.awt.Color color)
          Render a line into the image.
 void renderLine(Vec3 p1, Vec3 p2, Camera cam, java.awt.Color color)
          Render a line into the image.
 void renderMesh(RenderingMesh mesh, VertexShader shader, Camera cam, boolean closed, boolean[] hideFace)
          Render a mesh to the canvas.
 void renderMeshTransparent(RenderingMesh mesh, VertexShader shader, Camera cam, Vec3 viewDir, boolean[] hideFace)
          Render an object with flat shading in subtractive (transparent) mode.
 void renderWireframe(WireframeMesh mesh, Camera cam, java.awt.Color color)
          Render a wireframe object.
 void setTemplateImage(java.awt.Image im)
          Set the template image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftwareCanvasDrawer

public SoftwareCanvasDrawer(ViewerCanvas view)
Method Detail

setTemplateImage

public void setTemplateImage(java.awt.Image im)
Set the template image.

Specified by:
setTemplateImage in interface CanvasDrawer

drawDraggedShape

public void drawDraggedShape(java.awt.Shape shape)
Show feedback to the user in response to a mouse drag, by drawing a Shape over the image. Unlike the other methods of this class, this method may be called at arbitrary times (though always from the event dispatch thread), not during the process of rendering the image.

Specified by:
drawDraggedShape in interface CanvasDrawer

getImage

public java.awt.image.BufferedImage getImage()
Get the most recent rendered image.


paint

public void paint(RepaintEvent ev)

drawBorder

public void drawBorder()
Draw a border around the rendered image.

Specified by:
drawBorder in interface CanvasDrawer

drawHRule

public void drawHRule(int y,
                      java.awt.Color color)
Draw a horizontal line across the rendered image. The parameters are the y coordinate of the line and the line color.

Specified by:
drawHRule in interface CanvasDrawer

drawVRule

public void drawVRule(int x,
                      java.awt.Color color)
Draw a vertical line across the rendered image. The parameters are the x coordinate of the line and the line color.

Specified by:
drawVRule in interface CanvasDrawer

drawBox

public void drawBox(int x,
                    int y,
                    int width,
                    int height,
                    java.awt.Color color)
Draw a filled box in the rendered image.

Specified by:
drawBox in interface CanvasDrawer

drawBoxes

public void drawBoxes(java.util.List<java.awt.Rectangle> box,
                      java.awt.Color color)
Draw a set of filled boxes in the rendered image.

Specified by:
drawBoxes in interface CanvasDrawer

renderBox

public void renderBox(int x,
                      int y,
                      int width,
                      int height,
                      double depth,
                      java.awt.Color color)
Render a filled box at a specified depth in the rendered image.

Specified by:
renderBox in interface CanvasDrawer

renderBoxes

public void renderBoxes(java.util.List<java.awt.Rectangle> box,
                        java.util.List<java.lang.Double> depth,
                        java.awt.Color color)
Render a set of filled boxes at specified depths in the rendered image.

Specified by:
renderBoxes in interface CanvasDrawer

drawLine

public void drawLine(java.awt.Point p1,
                     java.awt.Point p2,
                     java.awt.Color color)
Draw a line into the rendered image.

Specified by:
drawLine in interface CanvasDrawer

renderLine

public void renderLine(Vec3 p1,
                       Vec3 p2,
                       Camera cam,
                       java.awt.Color color)
Render a line into the image.

Specified by:
renderLine in interface CanvasDrawer
Parameters:
p1 - the first endpoint of the line
p2 - the second endpoint of the line
cam - the camera from which to draw the line
color - the line color

renderLine

public void renderLine(Vec2 p1,
                       double zf1,
                       Vec2 p2,
                       double zf2,
                       Camera cam,
                       java.awt.Color color)
Render a line into the image.

Specified by:
renderLine in interface CanvasDrawer
Parameters:
p1 - the first endpoint of the line, in screen coordinates
zf1 - the z coordinate of the first endpoint, in view coordinates
p2 - the second endpoint of the line, in screen coordinates
zf2 - the z coordinate of the second endpoint, in view coordinates
cam - the camera from which to draw the line
color - the line color

renderWireframe

public void renderWireframe(WireframeMesh mesh,
                            Camera cam,
                            java.awt.Color color)
Render a wireframe object.

Specified by:
renderWireframe in interface CanvasDrawer

renderMeshTransparent

public void renderMeshTransparent(RenderingMesh mesh,
                                  VertexShader shader,
                                  Camera cam,
                                  Vec3 viewDir,
                                  boolean[] hideFace)
Render an object with flat shading in subtractive (transparent) mode.

Specified by:
renderMeshTransparent in interface CanvasDrawer

renderMesh

public void renderMesh(RenderingMesh mesh,
                       VertexShader shader,
                       Camera cam,
                       boolean closed,
                       boolean[] hideFace)
Render a mesh to the canvas.

Specified by:
renderMesh in interface CanvasDrawer

drawString

public void drawString(java.lang.String text,
                       int x,
                       int y,
                       java.awt.Color color)
Draw a piece of text onto the canvas.

Specified by:
drawString in interface CanvasDrawer

drawShape

public void drawShape(java.awt.Shape shape,
                      java.awt.Color color)
Draw the outline of a Shape into the canvas.

Specified by:
drawShape in interface CanvasDrawer

fillShape

public void fillShape(java.awt.Shape shape,
                      java.awt.Color color)
Draw a filled Shape onto the canvas.

Specified by:
fillShape in interface CanvasDrawer

drawImage

public void drawImage(java.awt.Image image,
                      int x,
                      int y)
Draw an image onto the canvas.

Specified by:
drawImage in interface CanvasDrawer

renderImage

public void renderImage(java.awt.Image image,
                        Vec3 p1,
                        Vec3 p2,
                        Vec3 p3,
                        Vec3 p4,
                        Camera camera)
Render an image onto the canvas. This method uses a ridiculously inefficient method for rendering the image. So why does it work that way? First, because I was lazy and didn't want to take the trouble to actually write a proper rasterizer. Second, because most people will be using the OpenGL renderer instead. And third, because renderImage() is currently only used for reference images, all of which means that the speed of this method won't be very important for very many people.

Specified by:
renderImage in interface CanvasDrawer
Parameters:
image - the image to render
p1 - the coordinates of the first corner of the image
p2 - the coordinates of the second corner of the image
p3 - the coordinates of the third corner of the image
p4 - the coordinates of the fourth corner of the image
camera - the camera from which to draw the image

imageChanged

public void imageChanged(java.awt.Image image)
Description copied from interface: CanvasDrawer
This should be called to indicate that a previously drawn image has changed, and cached information for it needs to be discarded.

Specified by:
imageChanged in interface CanvasDrawer


Copyright © 1999-2011 by Peter Eastman.