|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--javax.media.j3d.SceneGraphObject
|
+--javax.media.j3d.Node
|
+--javax.media.j3d.Leaf
|
+--javax.media.j3d.Behavior
|
+--Renderer.SandboxController
Supports all the interactive features on a single Sandbox. It handles the keyboard and mouse events that are generated when the view is changed or a Toy is selected and feeds them back to the Sandbox for processing. It also maintains the head-up display.
Sandbox,
Attitude,
Position| Field Summary | |
private float |
ATTITUDE_DAMPER_PITCH
|
private float |
ATTITUDE_DAMPER_YAW
|
private float |
ATTITUDE_ORBIT_YAW
|
private float |
ATTITUDE_OUTSIDE
|
private float |
ATTITUDE_PITCH_NOMINAL
|
private float |
ATTITUDE_ROLL_NOMINAL
|
private float |
ATTITUDE_STEP_PITCH
|
private float |
ATTITUDE_STEP_ROLL
|
private float |
ATTITUDE_STEP_YAW
|
private float |
ATTITUDE_YAW_NOMINAL
|
private int |
AUTOYAW_FRAME_OFFSET
|
private int |
AUTOYAW_INCREMENT
|
private float |
CENTER_AXIS_TWEAK
|
private float |
FIELD_OF_VIEW_HORIZONTAL
|
private float |
FIELD_OF_VIEW_HORIZONTAL_MIDPOINT
|
private float |
FIELD_OF_VIEW_VERTICAL
|
private float |
FIELD_OF_VIEW_VERTICAL_MIDPOINT
|
private int |
HUD_HEIGHT
|
private int |
HUD_SHIFT
|
private int |
HUD_UPDATE_THRESHOLD
|
private int |
HUD_WIDTH
|
private float |
HUD_Z
|
private int |
KEY_ARROW_DOWN
|
private int |
KEY_ARROW_LEFT
|
private int |
KEY_ARROW_RIGHT
|
private int |
KEY_ARROW_UP
|
private int |
KEY_END
|
private int |
KEY_ESCAPE
|
private int |
KEY_F1
|
private int |
KEY_F10
|
private int |
KEY_F11
|
private int |
KEY_F12
|
private int |
KEY_F2
|
private int |
KEY_F3
|
private int |
KEY_F4
|
private int |
KEY_F5
|
private int |
KEY_F6
|
private int |
KEY_F7
|
private int |
KEY_F8
|
private int |
KEY_F9
|
private int |
KEY_HOME
|
private int |
KEY_KEYPAD_DOWN
|
private int |
KEY_KEYPAD_LEFT
|
private int |
KEY_KEYPAD_RIGHT
|
private int |
KEY_KEYPAD_UP
|
private int |
KEY_MODIFIER_ALT
|
private int |
KEY_MODIFIER_CONTROL
|
private int |
KEY_MODIFIER_SHIFT
|
private int |
KEY_PAGE_DOWN
|
private int |
KEY_PAGE_UP
|
private int |
KEY_SHOW_HIDE_HUD
|
private Attitude |
m_attitude
|
private Attitude |
m_attitude_damper_max
|
private Attitude |
m_attitude_damper_min
|
private Attitude |
m_attitude_fov
|
private Attitude |
m_attitude_head
|
private SnapCanvas3D |
m_canvas
|
private float |
m_field_of_view_scale_x
|
private float |
m_field_of_view_scale_y
|
private javax.media.j3d.Shape3D |
m_hud
|
private javax.media.j3d.Appearance |
m_hud_appearance
|
(package private) java.awt.image.BufferedImage |
m_hud_bitmap
|
private javax.media.j3d.BranchGroup |
m_hud_branch_group
|
(package private) javax.media.j3d.ImageComponent2D |
m_hud_image
|
private javax.media.j3d.RenderingAttributes |
m_hud_rendering_attributes
|
(package private) javax.media.j3d.Texture2D |
m_hud_texture
|
private javax.media.j3d.Transform3D |
m_hud_transform_3d
|
private javax.media.j3d.TransformGroup |
m_hud_transform_group
|
private int |
m_hud_update_countdown
|
private javax.media.j3d.BranchGroup |
m_master_branch_group
|
private javax.media.j3d.Transform3D |
m_master_transform_3d
|
private javax.media.j3d.TransformGroup |
m_master_transform_group
|
private Position |
m_mouse_position
|
private Position |
m_position
|
private Position |
m_position_gradient
|
private Sandbox |
m_sandbox
|
private Dimensions |
m_screen_dimensions
|
private Position |
m_screen_frame_max
|
private Position |
m_screen_frame_min
|
private boolean |
m_show_hud
|
private com.sun.j3d.utils.universe.SimpleUniverse |
m_universe
|
private javax.media.j3d.WakeupCondition |
m_wakeup_condition
|
private javax.media.j3d.WakeupCriterion[] |
m_wakeup_criterion
|
private boolean |
MODEL_EDIT_MODE
|
private float |
POSITION_X_MAX
|
private float |
POSITION_X_MIN
|
private float |
POSITION_X_NOMINAL
|
private float |
POSITION_X_SPREAD
|
private float |
POSITION_X_STEP
|
private float |
POSITION_XZ_CORNER_FACTOR
|
private float |
POSITION_Y_MAX
|
private float |
POSITION_Y_MIN
|
private float |
POSITION_Y_NOMINAL
|
private float |
POSITION_Y_OUTSIDE
|
private float |
POSITION_Y_SPREAD
|
private float |
POSITION_Y_STEP
|
private float |
POSITION_Z_MAX
|
private float |
POSITION_Z_MIN
|
private float |
POSITION_Z_NOMINAL
|
private float |
POSITION_Z_SPREAD
|
private float |
POSITION_Z_STEP
|
private java.lang.String |
SCREEN_CAPTURE_FILENAME_PREFIX
|
| Fields inherited from class javax.media.j3d.Node |
ALLOW_AUTO_COMPUTE_BOUNDS_READ, ALLOW_AUTO_COMPUTE_BOUNDS_WRITE, ALLOW_BOUNDS_READ, ALLOW_BOUNDS_WRITE, ALLOW_COLLIDABLE_READ, ALLOW_COLLIDABLE_WRITE, ALLOW_LOCAL_TO_VWORLD_READ, ALLOW_PICKABLE_READ, ALLOW_PICKABLE_WRITE, ENABLE_COLLISION_REPORTING, ENABLE_PICK_REPORTING |
| Fields inherited from class javax.media.j3d.SceneGraphObject |
|
| Constructor Summary | |
SandboxController(SnapCanvas3D canvas,
javax.media.j3d.BranchGroup branch_group,
com.sun.j3d.utils.universe.SimpleUniverse universe,
Sandbox sandbox)
Creates a new controller for a sandbox. |
|
| Method Summary | |
private void |
assumeNominalView()
Resets the position and attitudes to sandbox-center looking toward the back. |
private void |
buildHeadUpDisplay(boolean is_initial_build)
Builds and places the head-up display. |
private void |
determinePickSelection(java.awt.event.MouseEvent event)
Determines which toy, if any, has been clicked on and hands processing off to the appropriate handler in the controlled sandbox. |
private float |
getScaledX(int x)
Returns a horizontal coordinate in Java3D units based on the current canvas width in pixels. |
private float |
getScaledY(int y)
Returns a vertical coordinate in Java3D units based on the current canvas height in pixels. |
Attitude |
getViewerAttitude()
Returns the combined attitude of the field of view and the head of the viewer in the controlled sandbox. |
Attitude |
getViewerFieldOfViewAttitude()
Returns the attitude of the field of view of the viewer in the controlled sandbox. |
Attitude |
getViewerHeadAttitude()
Returns the attitude of the head of the viewer in the controlled sandbox. |
Position |
getViewerPosition()
Returns the position of the viewer in the controlled sandbox. |
void |
initialize()
Configures the event handlers. |
private void |
orbit(float step)
Causes the sandbox to revolve around its center in the given direction and speed. |
private void |
processKeyEvent(java.awt.event.KeyEvent event)
Handles a key event. |
private void |
processMouseEvent(java.awt.event.MouseEvent event)
Handles a mouse event. |
void |
processStimulus(java.util.Enumeration criteria)
Manages the events that occur and redirects them to the appropriate handler. |
java.lang.String |
toString()
Returns a string representation of this object. |
void |
update(boolean force_hud_update)
Updates the contents of the controlled sandbox. |
void |
updateFrame()
Updates the scaling and other parameters that depend on the size of the frame on which the controlled sandbox resides. |
private void |
updateHeadUpDisplay()
Updates the contents of the head-up display. |
| Methods inherited from class javax.media.j3d.Behavior |
getEnable, getNumSchedulingIntervals, getSchedulingBoundingLeaf, getSchedulingBounds, getSchedulingInterval, getView, getWakeupCondition, postId, setEnable, setSchedulingBoundingLeaf, setSchedulingBounds, setSchedulingInterval, updateNodeReferences, wakeupOn |
| Methods inherited from class javax.media.j3d.Node |
cloneNode, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, cloneTree, duplicateNode, getBounds, getBoundsAutoCompute, getCollidable, getLocalToVworld, getLocalToVworld, getParent, getPickable, setBounds, setBoundsAutoCompute, setCollidable, setPickable |
| Methods inherited from class javax.media.j3d.SceneGraphObject |
clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setUserData |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private final boolean MODEL_EDIT_MODE
private Sandbox m_sandbox
private SnapCanvas3D m_canvas
private com.sun.j3d.utils.universe.SimpleUniverse m_universe
private javax.media.j3d.BranchGroup m_master_branch_group
private javax.media.j3d.TransformGroup m_master_transform_group
private javax.media.j3d.Transform3D m_master_transform_3d
private javax.media.j3d.BranchGroup m_hud_branch_group
private javax.media.j3d.TransformGroup m_hud_transform_group
private javax.media.j3d.Transform3D m_hud_transform_3d
private javax.media.j3d.Appearance m_hud_appearance
private javax.media.j3d.RenderingAttributes m_hud_rendering_attributes
private javax.media.j3d.Shape3D m_hud
private final float HUD_Z
private final int HUD_HEIGHT
private final int HUD_WIDTH
private final int HUD_SHIFT
private final int HUD_UPDATE_THRESHOLD
private int m_hud_update_countdown
private boolean m_show_hud
java.awt.image.BufferedImage m_hud_bitmap
javax.media.j3d.ImageComponent2D m_hud_image
javax.media.j3d.Texture2D m_hud_texture
private javax.media.j3d.WakeupCriterion[] m_wakeup_criterion
private javax.media.j3d.WakeupCondition m_wakeup_condition
private final int KEY_ARROW_UP
private final int KEY_ARROW_DOWN
private final int KEY_ARROW_LEFT
private final int KEY_ARROW_RIGHT
private final int KEY_PAGE_UP
private final int KEY_PAGE_DOWN
private final int KEY_F1
private final int KEY_F2
private final int KEY_F3
private final int KEY_F4
private final int KEY_F5
private final int KEY_F6
private final int KEY_F7
private final int KEY_F8
private final int KEY_F9
private final int KEY_F10
private final int KEY_F11
private final int KEY_F12
private final int KEY_ESCAPE
private final int KEY_HOME
private final int KEY_END
private final int KEY_SHOW_HIDE_HUD
private final int KEY_KEYPAD_LEFT
private final int KEY_KEYPAD_RIGHT
private final int KEY_KEYPAD_UP
private final int KEY_KEYPAD_DOWN
private final int KEY_MODIFIER_SHIFT
private final int KEY_MODIFIER_CONTROL
private final int KEY_MODIFIER_ALT
private final float POSITION_X_MIN
private final float POSITION_X_MAX
private final float POSITION_X_NOMINAL
private final float POSITION_X_STEP
private final float POSITION_X_SPREAD
private final float POSITION_Y_MIN
private final float POSITION_Y_MAX
private final float POSITION_Y_NOMINAL
private final float POSITION_Y_STEP
private final float POSITION_Y_OUTSIDE
private final float POSITION_Y_SPREAD
private final float POSITION_Z_MIN
private final float POSITION_Z_MAX
private final float POSITION_Z_NOMINAL
private final float POSITION_Z_STEP
private final float POSITION_Z_SPREAD
private final float POSITION_XZ_CORNER_FACTOR
private final float ATTITUDE_PITCH_NOMINAL
private final float ATTITUDE_ROLL_NOMINAL
private final float ATTITUDE_YAW_NOMINAL
private final float ATTITUDE_STEP_PITCH
private final float ATTITUDE_STEP_ROLL
private final float ATTITUDE_STEP_YAW
private final float ATTITUDE_ORBIT_YAW
private final float ATTITUDE_OUTSIDE
private final float ATTITUDE_DAMPER_PITCH
private final float ATTITUDE_DAMPER_YAW
private final float FIELD_OF_VIEW_HORIZONTAL
private final float FIELD_OF_VIEW_VERTICAL
private final float FIELD_OF_VIEW_HORIZONTAL_MIDPOINT
private final float FIELD_OF_VIEW_VERTICAL_MIDPOINT
private final float CENTER_AXIS_TWEAK
private final int AUTOYAW_FRAME_OFFSET
private final int AUTOYAW_INCREMENT
private Dimensions m_screen_dimensions
private Position m_screen_frame_min
private Position m_screen_frame_max
private float m_field_of_view_scale_x
private float m_field_of_view_scale_y
private Position m_mouse_position
private Position m_position
private Position m_position_gradient
private Attitude m_attitude
private Attitude m_attitude_fov
private Attitude m_attitude_head
private Attitude m_attitude_damper_min
private Attitude m_attitude_damper_max
private final java.lang.String SCREEN_CAPTURE_FILENAME_PREFIX
| Constructor Detail |
public SandboxController(SnapCanvas3D canvas,
javax.media.j3d.BranchGroup branch_group,
com.sun.j3d.utils.universe.SimpleUniverse universe,
Sandbox sandbox)
canvas - - the Java3D canvas of the sandboxbranch_group - - the root branch group of the tree displayed on the canvasuniverse - - the universe where the branch group residessandbox - - the sandbox to control| Method Detail |
private void assumeNominalView()
private void buildHeadUpDisplay(boolean is_initial_build)
is_initial_build - - whether this is the first call, which performs required setup work
private void determinePickSelection(java.awt.event.MouseEvent event)
throws java.lang.Exception
event - - the mouse event
java.lang.Exception - - if the sandbox has not been committedSandbox.processSelectionCallback(java.lang.String, java.awt.event.MouseEvent),
Sandbox.commit()private float getScaledX(int x)
x - - the x coordinate in pixels
private float getScaledY(int y)
y - - the y coordinate in pixels
public Position getViewerPosition()
public Attitude getViewerAttitude()
This is a read-only composite of two attitudes, which are combined in SandboxController.
public Attitude getViewerFieldOfViewAttitude()
The return value may be modified to change the attitude. Call update() afterwards to reflect the changes.
update(boolean)public Attitude getViewerHeadAttitude()
The return value may be modified to change the attitude. Call update() afterwards to reflect the changes.
update(boolean)public void initialize()
initialize in class javax.media.j3d.Behaviorprivate void orbit(float step)
step - - the number of degrees to move. Positive is clockwise; negative is counterclockwiseprivate void processKeyEvent(java.awt.event.KeyEvent event)
event - - the event
private void processMouseEvent(java.awt.event.MouseEvent event)
throws java.lang.Exception
event - - the event
java.lang.Exception - - if a pick selection fails on a mouse clickpublic void processStimulus(java.util.Enumeration criteria)
Side Effect: writes a warning to stderr if the event cannot be processed.
processStimulus in class javax.media.j3d.Behaviorcriteria - - the event criteriaSupport.writeWarning(java.lang.String, java.lang.String)public java.lang.String toString()
toString in class java.lang.ObjectSupport.toPrettyString(java.lang.String)public void update(boolean force_hud_update)
force_hud_update - - whether the head-up dispay should be forced to update; normally it updates after a certain
threshold is reach to reduce unnecessary processingpublic void updateFrame()
private void updateHeadUpDisplay()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||