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 8 Views F Views in 3D rendering process.

Similar presentations


Presentation on theme: "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 8 Views F Views in 3D rendering process."— Presentation transcript:

1 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 8 Views F Views in 3D rendering process F Parallel and perspective projections F Specifying the viewing matrix F Specifying the projection matrix F Java 3D standard view model F Java 3D compatibility mode view model F Picking in a 3D scene F To use the avatar in SimpleUniverse

2 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 2 What is a View? F A scene graph has two main branches –Content branch –View branch F The view branch defines the geometric configuration that controls the process of mapping a 3D world to a 2D image F Think of the view as the digital analog of a camera

3 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 3 Views in Java3D F Low-level APIs support a camera-based view model –Dynamic changes of view are difficult F Java3D has a versatile view system –Supports dynamic view changes

4 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 4 View Properties F Projection type F Field of view F Limits to view distance F Size of view plate

5 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 5 Projections F A projection maps a point in the virtual world onto a view plane –view plate is a finite window in the view plane –also limit the depth that is rendered F Two types of projection –parallel –perspective

6 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 6 Parallel Projection F Project along parallel lines from objects in scene to the view plane F For the view plate in the x-y plane –x and y unchanged –z goes to 0

7 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 7 Orthographic Projection F Special case of parallel projection where the projection lines are parallel to the view plane F Used in engineering drawings –front, top and side elevations

8 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 8 Perspective Projection F Projection lines converge at the view point –more distant objects are smaller F If the viewpoint moves to infinite, projection becomes parallel

9 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 9 Computing Projected Coordinates F Using similar triangles y'/d = y/(d + (-z)) y' = y / (1 - z / d) –and similarly for x'

10 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 10 View Specification F View Volume –represented by a projection matrix F View positioning –represented by a view matrix F

11 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 11 View Volume Parameters F Projection – parallel or perspective projection. F View Plate – the window for the rendered image. It is usually a rectangular region. In a real camera the view plate corresponds to the film frame. F Field of view (fov) – the horizontal angle between the left and right plane of the frustum. The vertical field of view and diagonal field of view can be defined similarly. F Focal length – the distance between the view plate and the view point. F Aspect ratio – the ratio of width over length of the view planes. F Front clip plane – the front or near plane of the frustum. F Back clip plane – the back or far plane of the frustum.

12 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 12 Projection Matrix F Defined in the eye-coordinate system –eye at origin facing negative z direction F Maps the given view-volume to a standard volume F For front plane at -c and back plane at -d and -a<x<a and -b<y<b

13 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 13 Viewing Position F Viewpoint, view-reference point (vrp, eye) – the camera or eye position, the 3D point where the camera is located. F View center (look) – the center of view plate or the point that the eye is looking at. F View up direction (up) – the upward direction from a viewer’s perspective. F View plane – the plane of the projected image. F View plane normal (vpn) – the normal vector of the view plane.

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

15 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 15 Classes used for View Specification F ViewPlatform - encapsulates the view matrix F View - encapsulates the projection matrix F PhysicalBody - specification of user's head F PhysicalEnvironment - input devices, audio F Canvas3D - canvas of rendering F Screen3D - properties of display device (e.g. console)

16 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 16 ViewPlatform F Defines observer –Position, Orientation, Scale F Is a Leaf node –Attach to a Locale through one or more TransformGroup nodes –Need one Transform to establish the viewing matrix

17 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 17 View F Attached to the ViewPlatform F Can render to multiple Canvas3D objects F Properties –projection and clip parameters (fov, front and back clip distances) –depth buffer –compatibility mode –rendering policies, etc

18 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 18 Configure a 3D View F Transform3D method to construct the viewing matrix void lookAt(Point3d eye, Point3d look, Vector3d up) F View class has methods to set up the projection matrix void setFieldOfView(double fov) void setFrontClipDistance(double d) void setBackClipDistance(double d) void setProjectionPolicy(int projection)

19 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 19 The Compatibility Mode F A simple mode compatible with OpenGL camera-based model –Static camera –Restricted view mode F Most view parameters are set in the View object F To enable compatibility mode public void setCompatibilityModeEnable( boolean enabled)

20 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 20 Construct the projection matrix F Methods from the Transform3D class public void perspective( double fov, double aspect, double near, double far) public void frustrum( double left, double right, double bottom, double top, double near, double far) public void ortho( double left, double right, double bottom, double top, double near, double far) Coordinates are relative to eye position

21 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 21 Set the projection matrix F Methods from the View class public void setVpcToEc( Transform3D viewingMatrix) public void setLeftProjection( Transform3D viewingMatrix) public void setRightProjection( Transform3D viewingMatrix)

22 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 22 CompatibilityMode.java F Creates all scene graph components directly –Canvas3D, VirtualUniverse, Locale in constructor –BranchGroup, ViewPlatform, View, PhysicalBody, PhysicalEnvironment in createView –Content in createContent

23 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 23 SimpleUniverse F Default implementation for viewing system –Viewer = View, ViewAvatar, PhysicalBody, PhysicalEnvironment, Canvas3D –ViewingPlatform = ViewPlatform, MultiTransformGroup F Default view parameters –Compatibility mode: false –Left projection, Right projection, vpc to ec transform: identity –Field of view: π/4 –Front clip distance: 0.1 –Back clip distance: 10

24 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 24 RotateView.java F Uses SimpleUniverse F Similar to Dodecahedron program from chapter 5 except –Rotator is applied to the ViewPlatform instead of the Dodecahedron

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

26 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 26 Using VirtualUniverse F SimpleUniverse is easy to use but not always adequate F Set up a VirtualUniverse manually for more control

27 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 27 Create Your Own Views View view = new View(); view.setProjectionPolicy(View.PARALLEL_PROJECTION); ViewPlatform vp = new ViewPlatform(); view.addCanvas3D(cv); view.attachViewPlatform(vp); view.setPhysicalBody(new PhysicalBody()); view.setPhysicalEnvironment(new PhysicalEnvironment()); Transform3D trans = new Transform3D(); trans.lookAt(eye, center, vup); trans.invert(); TransformGroup tg = new TransformGroup(trans); tg.addChild(vp); BranchGroup bgView = new BranchGroup(); bgView.addChild(tg);

28 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 28 Multiple Views F A scene graph can contain multiple views –MultipleViews.java has the standard perspective view from SimpleUniverse plus 3 orthographic projections

29 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 29 Picking F The process of selecting a world-space object through the projected (2D) image –The inverse of viewing –Identifies objects that project to a particular point F A point in the 2D plane corresponds to a line in 3d –If the point has a size, it corresponds to a cylinder or cone in 3D

30 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 30 Picking F Pick cone for point (x', y') in the view plate –r is radius of pick point

31 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 31 Core Functionality F PickShape hierarchy F SceneGraphPath specifies path from Locale to a terminal node in the scene graph F Locale and BranchGroup have methods for picking

32 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 32 Picking Methods F Several choices of of behavior SceneGraphPath[] pickAll(PickShape pickShape) SceneGraphPath[] pickAllSorted(PickShape pickShape) SceneGraphPath pickAny(PickShape pickShape) SceneGraphPath pickClosest(PickShape pickShape)

33 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 33 More Pick Classes F com.sun.j3d.utils.picking package provides higher level support F PickTool F PickResult –picked object, SceneGraphPath, Intersection F PickIntersection –detailed information about intersection

34 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 34 Picking.java F Start with 6 wire-frame objects –set capability bits for picking and appearance changes F Use a PickCanvas to perform pick operation F Selecting with mouse click enables lighting –pc.setShapeLocation( MouseEvent)

35 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 35 Head Tracking F Adjustment of view parameters following dynamic head position changes –Based on input from a 6-degree-of-freedom device F Java 3D head tracking support –View –Sensor –PhysicalBody –PhysicalEnvironment

36 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 36 Six Degrees of Freedom F Three for translation –forward/back –up/down –left/right F Three for rotation –roll –pitch –yaw

37 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 37 InputDevice F InputDevice interface –provides methods for interacting with devices F An InputDevice needs to be registered with the PhysicalEnvironment –Three predefined 6DoF tracking devices u 0: UserHead u 1: DominantHand u 2: NondominatnHand

38 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 38 Avatar F Avatar is physical representation of viewer in the scene

39 Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 39 HeadTracking.java F Uses a VirtualInputDevice to simulate a 6DoF input device F ViewerAvatar is a set of coordinate axes (LineAxes)


Download ppt "Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 8 Views F Views in 3D rendering process."

Similar presentations


Ads by Google