Class RenderPanel
raft.kilavuz.util.jpct
java.lang.Object
  java.awt.Component
      java.awt.Container
          javax.swing.JComponent
              javax.swing.JPanel
                  raft.kilavuz.util.jpct.RenderPanel
All Implemented Interfaces:

public class RenderPanel
extends javax.swing.JPanel

swing panel to ease testing and prototyping. RenderPanel allows user to freely move camera around or follow a given avatar. it can display sectors in the Land as boxes.

these are the keys used:


Nested Class Summary
static interface
RenderPanel.Listener
call back interface to report user has clicked on some collidable object
Field Summary
protected boolean
drawWireFrame
if true world is rendered also in wireframe
protected Land
land
Land instance encapsulating current pathfinding information
protected World
world
World instance this RenderPanel is used to render
Constructor Summary
RenderPanel(World world, Land land, RenderPanel.Listener listener, SimpleVector cameraEllipsoid, float moveVelocity)
creates a RenderPanel
Method Summary
void
addListener(RenderPanel.Listener listener)
adds given listener to set of listeners.
void
cameraPositionChanged()
call this method if you change position or direction or camera externally
void
followAvatar(Object3D avatar, float height, float distance, float angle)
switchs between modes free camera and following avatar.
getFrameBuffer()
returns the current FrameBuffer.
protected void
paintComponent(java.awt.Graphics g)
paints this component
void
placeCamera(float seconds)
places camera according to current settings.
void
removeListener(RenderPanel.Listener listener)
remoevs given listener from set of listeners.
void
render()
renders (paints) world.
void
setCameraEllipsoid(SimpleVector cameraEllipsoid)
sets camera ellipsoid.
void
setMoveVelocity(float moveVelocity)
sets move velocity used to move camera.
void
showMessage(String message, int milliseconds)
display given message on center of screen for a certain time
Field Detail
world
protected final World world
World instance this RenderPanel is used to render

land
protected final Land land
Land instance encapsulating current pathfinding information

drawWireFrame
protected boolean drawWireFrame
if true world is rendered also in wireframe
Constructor Detail
RenderPanel
public RenderPanel(World world,
                   Land land,
                   RenderPanel.Listener listener,
                   SimpleVector cameraEllipsoid,
                   float moveVelocity)
creates a RenderPanel
Parameters:
world - the world instance to render
land - land information used to visualize sectors, may be null
listener - listener to notify user clicked on a collidable object, may be null
cameraEllipsoid - used to move camera around
moveVelocity - speed of camera in world units to move camera around
Method Detail
setCameraEllipsoid
public void setCameraEllipsoid(SimpleVector cameraEllipsoid)
sets camera ellipsoid. all three coordinates must be positive

setMoveVelocity
public void setMoveVelocity(float moveVelocity)
sets move velocity used to move camera. must be positive
Parameters:
moveVelocity - camera move velocity in world units

followAvatar
public void followAvatar(Object3D avatar,
                         float height,
                         float distance,
                         float angle)
switchs between modes free camera and following avatar. in follow mode, a takeback position over avatar is calculated and camera is tried to taken back from this point given distance amount with given angle. then for smoothness camera position is interpolated to calculated position. camera always looks at takeback point in follow mode
Parameters:
avatar - avatar to follow, if null switches to free camera mode
height - distance between avatar's transformed center and takeback point
distance - camera is tried to take back this much amount
angle - horizontal angle camera is taken back. a positive value means camera looks down to takeback point, and vice versa

addListener
public void addListener(RenderPanel.Listener listener)
adds given listener to set of listeners. does nothing if listener is already in set or listener is null

removeListener
public void removeListener(RenderPanel.Listener listener)
remoevs given listener from set of listeners. does nothing if listener is not in set

cameraPositionChanged
public void cameraPositionChanged()
call this method if you change position or direction or camera externally

getFrameBuffer
public FrameBuffer getFrameBuffer()
returns the current FrameBuffer. each time this RenderPanel is resized a new FrameBuffer is created

render
public void render()
renders (paints) world. call this method each frame. should not called outside of awt thread.

paintComponent
protected void paintComponent(java.awt.Graphics g)
paints this component
Overrides:

placeCamera
public void placeCamera(float seconds)
places camera according to current settings. call this method each frame before calling render

showMessage
public void showMessage(String message,
                        int milliseconds)
display given message on center of screen for a certain time
Java API documentation generated with DocFlex/Doclet v1.5.2
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc. If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com