24
3D Objects Subject : T0934 / Multimedia Programming Foundation Session : 12 Tahun : 2009 Versi : 1/0

3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Embed Size (px)

Citation preview

Page 1: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

3D Objects

Subject : T0934 / Multimedia Programming FoundationSession : 12Tahun : 2009Versi : 1/0

Page 2: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Bina Nusantara

Learning Outcomes

In the end of this session, students must be able to: – Understand the basic principal

of 3D objects

Page 3: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Outline

• 3D Coordinates systems• 3D Models• 3D Transformation• 3D Rendering• Java 3D API

Bina Nusantara

Page 4: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Coordinate Systems

• Use x,y,z coordinates to represent a 3D object width, height, and length

• Left-handed coordinate system x positive to the right

• Right-handed coordinate system (default for Java) x positive to the left or z positive toward the viewer

Bina Nusantara

YY

XX

ZZYY

XX

ZZYY

XX

ZZ

Page 5: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Object Coordinates

• Geometric center the point in object where x,y, and z are all zero in values, usually located inside the object.

• Object coordinates start from its geometric center

Bina Nusantara

YY

XX

ZZ

Page 6: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

World Coordinates

• Coordinates that shows how the objects are located in relation to the 3D world they are in

Bina NusantaraXX

ZZ

YY

Page 7: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

3D Model

• Vertices (Vertex for singular) corner points of an object

• Edges lines which connect the vertices

Bina Nusantara

Vertex

Edge

Hidden line

Surface/face

Hidden surface

Page 8: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

3D Polygon

• A closed figure created by three or more vertices connected with edges

• Simplest polygon triangle• Complex 3D shapes can be decomposed

into a collection of triangles, commonly called a mesh

Bina Nusantara

Page 9: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Displaying 3D Model

Bina Nusantara

commonly called "eye space" or "camera space”. Objects are converted to view space to know what is visible on the screen.

project the view coordinates into 2D coordinates that map directly to viewport (window or rectangle which limits the visibility of 3D world).

Page 10: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

3D Transformation

• Position (translation)• Size (scaling)• Orientation (rotation)• Shapes (shear)

Bina Nusantara

x’

y’

z’

1

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

x

y

z

1

= *

XX

ZZ

tt

Page 11: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Rendering

• Process of converting the 3D model into an on-screen 2D image

Bina Nusantara

Page 12: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

3D Rendering Techniques

• Flat shading• Lambert shading• Gouraud shading• Phong shading• Texture mapping• Bump mapping• Cel shading• Raytracing• Radiosity• And so on …

Bina Nusantara

Page 13: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Scene Graph

• Maintains information about all entities in the 3D world in structures called nodes

• Group nodes contain information about themselves and point to other nodes (descendants)

• Leaf nodes contain only information about themselves and have no children

Bina Nusantara

Page 14: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Scene Graph

Bina Nusantara

SceneScene

TerrainTerrain

Player1Player1 Player2Player2

Page 15: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Java 3D API

• Enables the creation of three-dimensional graphics applications and Internet-based 3D applets.

• Provides high-level constructs for creating and manipulation 3D geometry and building the structures used in rendering that geometry.

Bina Nusantara

Page 16: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Create 3D canvas

Create The 3D World

Page 17: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Create Background The 3D World

Page 18: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Prepare color for the ball

Prepare The Texture for the ball

Page 19: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Prepare appearance for the ball by including The color and Texture

Create The ball

Page 20: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Prepare PointLight for lightning effect

Page 21: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Adding component to The Universe

Page 22: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Setting action for application

Page 23: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

Sample Code

Bina Nusantara

Rotate The Ball

Result

Page 24: 3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0

References

• Java 3D API Tutorial. 2009. http://java.sun.com/developer/onlineTraining/java3d/

• 3D Game Programming All in One. Finney, Kenneth C. 2004. Ch 3.

• 3D Basic. 1999. http://www.gamedev.net/reference/articles/article673.asp

• Graphics Pipeline. 2000. http://www.arch.ttu.edu/visualization/5347-Digital_VIZ/VideoLectures/PptLecturePdfs/GraphicsPipelineAlgorithmic_12sep08.pdf

• Java 3D Tutorial. 2001. http://www.java3d.org/tutorial.htm• Combining Rotation and Translation in Java 3d. 2009.

http://www.developer.com/java/other/article.php/3712226• Creating a 3D Universe with Java3D. 1998.

http://www.acm.org/crossroads/xrds5-2/ovp52.html

Bina Nusantara