Presentation is loading. Please wait.

Presentation is loading. Please wait.

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Behavior and Interaction.

Similar presentations


Presentation on theme: "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Behavior and Interaction."— Presentation transcript:

1 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Behavior and Interaction

2 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 Objectives F To understand dynamic behaviors in graphics F To understand Java 3D Behavior and WakeupCondition classes F To apply Behavior nodes in scene graphs F To use mouse behaviors F To use key navigator behaviors F To use view platform behaviors F To combine picking and behaviors

3 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 Behavior

4 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 Behavior F During the initialization of the Behavior object, it sets a WakeupCondition object. F When the wakeup condition occurs, it will awaken the Behavior by calling its processStimulus. F After executing the custom code in processStimulus, a wakeup condition can be set again by calling the wakeupOn method. F The process will then repeat indefinitely.

5 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 Behavior Classes

6 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Wakeup Condition

7 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 Boolean Operators on Wakeup Criteria WakeupAnd(WakeupCriterion[] criteria) WakeupOr(WakeupCriterion[] criteria) WakeupOrOfAnds(WakeupAnd[] criteriaAnds) WakeupAndOfOrs(WakeupOr[] criteriaOrs)

8 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Implement Custom Behavior F Define a subclass of Behavior class and override the initialize and processStimulus methods. F Set the appropriate wakeup condition in the initialize method. If necessary set the wakeup condition again in processStimulus. F Create an instance of the custom Behavior class and add it to the scene graph as a leaf. F Set the influence bound for the behavior object.

9 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 Example: A Clock SourceRunSource

10 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 Interaction

11 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 Mouse Behaviors F MouseRotate: drag the mouse with the left button down. F MouseTranslate: drag the mouse with the right button down. F MouseZoom: drag the mouse with the middle button down (or with left button down while holding the Alt key). SourceRun

12 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 KeyNavigatorBehavior F, : Rotate left/right F, : Translate forward/backward F Alt-, Alt- : Translate left/right F PgUp, PgDn: Rotate up/down F Alt-PgUp, Alt-PgDn: Translate up/down F -: Reduce back clip distance F +: Reset back clip distance F =: Reset SourceRun

13 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 View Platform Behavior Source Run OrbitBehavior() OrbitBehavior(Canvas3D cv) OrbitBehavior(Canvas3D cv, int flags)

14 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 14 Picking and Mouse Behavior PickRotateBehavior rotator = new PickRotateBehavior(cv, root, bounds); root.addChild(rotator); Source Run

15 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 Data Visualization Example Source Run

16 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 16 Obtaining Pick Intersection PickIntersection inter = results[i].getIntersection(0); Point3d pt = inter.getClosestVertexCoordinates(); int[] ind = inter.getPrimitiveCoordinateIndices();


Download ppt "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 10 Behavior and Interaction."

Similar presentations


Ads by Google