Upload
maurice-joseph
View
219
Download
0
Embed Size (px)
Citation preview
3D Objects
Subject : T0934 / Multimedia Programming FoundationSession : 12Tahun : 2009Versi : 1/0
Bina Nusantara
Learning Outcomes
In the end of this session, students must be able to: – Understand the basic principal
of 3D objects
Outline
• 3D Coordinates systems• 3D Models• 3D Transformation• 3D Rendering• Java 3D API
Bina Nusantara
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
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
World Coordinates
• Coordinates that shows how the objects are located in relation to the 3D world they are in
Bina NusantaraXX
ZZ
YY
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
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
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).
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
Rendering
• Process of converting the 3D model into an on-screen 2D image
Bina Nusantara
3D Rendering Techniques
• Flat shading• Lambert shading• Gouraud shading• Phong shading• Texture mapping• Bump mapping• Cel shading• Raytracing• Radiosity• And so on …
Bina Nusantara
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
Scene Graph
Bina Nusantara
SceneScene
TerrainTerrain
Player1Player1 Player2Player2
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
Sample Code
Bina Nusantara
Create 3D canvas
Create The 3D World
Sample Code
Bina Nusantara
Create Background The 3D World
Sample Code
Bina Nusantara
Prepare color for the ball
Prepare The Texture for the ball
Sample Code
Bina Nusantara
Prepare appearance for the ball by including The color and Texture
Create The ball
Sample Code
Bina Nusantara
Prepare PointLight for lightning effect
Sample Code
Bina Nusantara
Adding component to The Universe
Sample Code
Bina Nusantara
Setting action for application
Sample Code
Bina Nusantara
Rotate The Ball
Result
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