|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--render.RenderPanel
Provides a panel interface to the Renderer
.
It also implements control features dealing with mouse and keyboard interaction.
You can add this as a Component to your application /applet
Renderer
,
Serialized FormNested Class Summary | |
protected class |
RenderPanel.KeyHandler
|
protected class |
RenderPanel.MouseHandler
mouse and keyboard handlers |
Field Summary | |
protected double |
currentTime
Holds current system time. |
protected double |
elapsed
Measures time elapsed from initialization. |
boolean |
enableLod
Enables level of detail computation for meshes. |
protected double |
frameRate
Contains current frame rate of the renderer |
protected int |
H
Image height |
protected java.awt.Image |
im
Image framebuffer |
protected boolean |
isDamage
Flag to force a renderer refresh when true. |
protected int |
mx
Current mouse position |
protected int |
my
Current mouse position |
double |
phi
Euler angle for camera positioning (vertical view rotation). |
Renderer |
renderer
Renderer object |
boolean |
showFPS
Flag that determines whether to display current frame rate. |
protected double |
startTime
Holds actual time of initialization. |
double |
theta
Euler angle for camera positioning (horizontal view rotation). |
protected int |
W
Image width |
Geometry |
world
root of the scene Geometry |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
RenderPanel()
|
Method Summary | |
void |
addLight(double x,
double y,
double z,
double r,
double g,
double b)
Adds light source with direction (x, y, z) & color (r, g, b). |
void |
animate(double time)
Override this to animate. |
void |
damage()
Forces a refresh of the renderer. |
Geometry |
getGeometry(int x,
int y)
Returns the Geometry of the frontmost object at the point (x, y) in the image (like a z-buffer value of geometries). |
boolean |
getPoint(int x,
int y,
double[] xyz)
Returns the location in world space of the point (x, y) on the screen. |
void |
identity()
Sets current matrix to the identity matrix. |
void |
init()
Initializes the applet and internal variables. |
void |
initialize()
Override this to initialize the application program. |
Matrix |
m()
Returns the matrix at the top of the stack. |
boolean |
mouseDown(java.awt.Event event,
int x,
int y)
Listener for mouse down. |
boolean |
mouseDrag(java.awt.Event event,
int x,
int y)
Dragging the mouse causes gradual view rotation in the phi and theta directions. |
boolean |
mouseMove(java.awt.Event event,
int x,
int y)
Listener for mouse movement. |
boolean |
mouseUp(java.awt.Event event,
int x,
int y)
Listens for mouse release and controls aspects of the renderer. |
void |
pop()
Pops the top matrix from the stack. |
boolean |
processCommand(int key)
Handles commands received (generally for unicode commands from the KeyListener, but also for commands from any other sources, like buttons from webpages) : various default control keys to modify render style (Use CTRL + key). |
int |
pull(Geometry s,
double x0,
double x1,
double x2,
double y0,
double y1,
double y2,
double z0,
double z1,
double z2)
Deforms a geometric shape according to the beginning, middle, and end parameters in each dimension. |
void |
push()
Pushes a copy of the top matrix onto the stack. |
void |
renderFrame()
|
void |
rotate(double t,
double x,
double y,
double z)
Rotates the top matrix around any axis by angle t (radians). |
void |
rotateX(double t)
Rotates the top matrix around the X axis by angle t (radians). |
void |
rotateY(double t)
Rotates the top matrix around the Y axis by angle t (radians). |
void |
rotateZ(double t)
Rotates the top matrix around the Z axis by angle t (radians). |
void |
run()
Renderer thread. |
void |
scale(double x,
double y,
double z)
Scales the top matrix by x, y, z in their respective dimensions. |
void |
setBgColor(double r,
double g,
double b)
Sets the background color ( RGB values range: 0..1). |
void |
setFL(double value)
Sets the camera's focal length. |
void |
setFOV(double value)
Sets the field of view value. |
void |
setOpaque(boolean opaque)
|
void |
start()
Starts the renderer thread. |
void |
stop()
Stops the renderer thread. |
void |
transform(Geometry s)
Applies the top transformation matrix to Geometry s. |
void |
translate(double[] v)
Translates the top matrix by vector v. |
void |
translate(double x,
double y,
double z)
Translates the top matrix by x, y, z. |
void |
update(java.awt.Graphics g)
Updates the image buffer to output device. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseEnter, mouseExit, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public Renderer renderer
Renderer
object
public Geometry world
Geometry
public boolean showFPS
public boolean enableLod
public double theta
public double phi
protected int mx
protected int my
protected int W
protected int H
protected java.awt.Image im
protected boolean isDamage
protected double startTime
protected double currentTime
protected double elapsed
protected double frameRate
Constructor Detail |
public RenderPanel()
Method Detail |
public void animate(double time)
time
- system timepublic void damage()
public void setFOV(double value)
value
- Renderer.setFOV(double value)
public void setFL(double value)
value
- focal lengthRenderer.setFL(double value)
public void setBgColor(double r, double g, double b)
r
- red component 0..1g
- green component 0..1b
- blue component 0..1public void setOpaque(boolean opaque)
public void addLight(double x, double y, double z, double r, double g, double b)
Arguments x,y,z indicate light direction. Arguments r,g,b indicate light direction.
Renderer.addLight(double x,double y,double z,
double r,double g,double b)
public void identity()
public Matrix m()
public void pop()
public void push()
public void rotateX(double t)
t
- angle in radianspublic void rotateY(double t)
t
- angle in radianspublic void rotateZ(double t)
t
- angle in radianspublic void rotate(double t, double x, double y, double z)
t
- angle in radiansx
- y
- z
- public void scale(double x, double y, double z)
x
- x scale factory
- y scale factorz
- z scale factorpublic void transform(Geometry s)
Geometry
s.
s
- Geometry objectpublic void translate(double[] v)
v
- an array of three doubles representing translations
in the x,y,z directions.public void translate(double x, double y, double z)
x
- - translation in the x direction.y
- - translation in the y direction.z
- - translation in the z direction.public int pull(Geometry s, double x0, double x1, double x2, double y0, double y1, double y2, double z0, double z1, double z2)
0 - beginning, 1 - middle, 2 - end. To indicate infinity (a constant transformation) set two adjacent parameters to the same value. Setting all three parameters to the same value transforms the shape geometry consistently across the entire axis of the parameters.
s
- shape object to be deformedx0
- location of the beginning of deformation along the x axisx1
- location of the middle of deformation along the x axisx2
- location of the end of deformation along the x axisy0
- location of the beginning of deformation along the y axisy1
- location of the middle of deformation along the y axisy2
- location of the end of deformation along the y axisz0
- location of the beginning of deformation along the z axisz1
- location of the middle of deformation along the z axisz2
- location of the end of deformation along the z axis
Geometry.pull(render.Matrix, double, double, double, double, double, double, double, double, double)
public void init()
initialize()
.
initialize()
public void initialize()
public void start()
public void stop()
public void run()
run
in interface java.lang.Runnable
public void renderFrame()
public void update(java.awt.Graphics g)
update
in class java.awt.Container
g
- Specifies the output device.public Geometry getGeometry(int x, int y)
x
- x coordinate in the imagey
- y coordinate in the image
public boolean getPoint(int x, int y, double[] xyz)
x
- x coordinate in the imagey
- y coordinate in the image
public boolean mouseMove(java.awt.Event event, int x, int y)
If mouse is placed in the lower left cornder it displays the framerate.
mouseMove
in class java.awt.Component
public boolean mouseDown(java.awt.Event event, int x, int y)
Mouse down starts a view rotation.
mouseDown
in class java.awt.Component
public boolean mouseDrag(java.awt.Event event, int x, int y)
mouseDrag
in class java.awt.Component
event
- Eventx
- - new x coordinatey
- - new y coordinatepublic boolean mouseUp(java.awt.Event event, int x, int y)
A release in the upper left corner toggles Renderer.tableMode
.
A release in the upper right corner toggle visibility of the Material.table
display. When true, the current material table is displayed in the upper left corner of the window. Position of the mouse determines current material.
A release in the lower right toggles Renderer.showMesh
mouseUp
in class java.awt.Component
event
- Eventx
- current x coordinatey
- current y coordinate
public boolean processCommand(int key)
'e' - toggles Renderer.showMesh
, that just displays
the shapes as mesh wireframes
'l' - toggles Renderer.getOutline()
which produces a
sketch-line drawing rendition of the scene
'm' - toggles Renderer.seeMesh
which determines mesh
visibility
't' - toggles global texture manipulation method (MIP on/off) (@link Texture#useMIP)
key
- value of the key released
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |