3D Objects Subject : T0934 / Multimedia Programming Foundation

advertisement
3D Objects
Subject
Session
Tahun
Versi
:
:
:
:
T0934 / Multimedia Programming Foundation
12
2009
1/0
Learning Outcomes
In the end of this session, students must be
able to:
– Understand the basic principal of 3D
objects
Bina Nusantara
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
Z
Y
Y
X
X
Bina Nusantara
Y
Z
Z
X
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 Y
Z
X
Bina Nusantara
World Coordinates
• Coordinates that shows how the objects
are located in relation to the 3D world they
are in
Y
Z
Bina Nusantara
X
3D Model
• Vertices (Vertex for singular)  corner points of
an object
• Edges  lines which connect the vertices
Surface/face
Vertex
Edge
Hidden line
Hidden surface
Bina Nusantara
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
Modeling
Create 3D
model in
object space
Transformation
Convert to
world space
coordinates
3D Rendering
Convert to
view
coordinates
2D Rendering
Convert to
screen
coordinates
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)
x’
1 0
0 tx
x
y’
0 1
0 ty
y
z’
1
=
0 0
1 tz
0 0 0 1
*
z
1
Z
t
Bina Nusantara
X
Rendering
• Process of converting the 3D model into
an on-screen 2D image
Calculate the appearance
of object’s different faces
Convert faces into a 2D
form
Send the result to the
video card
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
Scene
Sky
Terrain
Player1
Player2
Lighting
Transform
Land
Lighting
Geometry
Transform
Bina Nusantara
Sea
Man
Man
Lighting
Lighting
Geometry
Geometry
Transform
Transform
Audio
Audio
Lighting
Transform
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
Create 3D canvas
Create The 3D World
Bina Nusantara
Sample Code
Create Background The 3D World
Bina Nusantara
Sample Code
Prepare color for the ball
Prepare The Texture for the ball
Bina Nusantara
Sample Code
Prepare appearance for the ball by including The color and Texture
Create The ball
Bina Nusantara
Sample Code
Prepare PointLight for lightning effect
Bina Nusantara
Sample Code
Adding component to The Universe
Bina Nusantara
Sample Code
Setting action for application
Bina Nusantara
Sample Code
Rotate The Ball
Result
Bina Nusantara
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/5347Digital_VIZ/VideoLectures/PptLecturePdfs/GraphicsPipelineAlgorith
mic_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
Download