SlideShare a Scribd company logo
Beginning Direct3D Game Programming:
4. 3D Fundamentals
jintaeks@gmail.com
Division of Digital Contents, DongSeo University.
April 2016
Presentation outline
 Work with vertices and orientation
 Work with faces and polygons
 Use Gouraud shading
 Put into practice the basics of texture mapping
2
3D Fundamentals
 The Direct3D engine uses a left-handed coordinate system
by default.
 The OpenGL coordinate system uses a positive z-axis that
points out of the screen. This is called a right-handed
coordinate system.
3
vertex
 The square uses four vertices, v1 through v4.
 A vertex defines the point of intersection of one or more
lines;
 Direct3D needs a way to place these primitives in a scene.
4
 To define a vertex in 3D space, you must specify three
coordinate values: x, y, and z.
v1 (0, 0, 0)
v2 (0, 2, 0)
v3 (0, 2, 2)
v4 (0, 0, 2)
 You can define the location of a vertex by specifying a
vector from the origin to another point in 3D space.
5
vector
 They are mathematical entities that describe a direction and a
magnitude (which can be used for velocity, for example).
 Vectors are usually denoted by a bold-faced letter, such as a.
 Thus you could say the vector v = (1, 0, 1).
 Vectors are not only used to define the position of the
vertices, they are also used to define a direction.
6
D3DXVECTOR
typedef struct D3DXVECTOR3 {
FLOAT x;
FLOAT y;
FLOAT z;
} D3DXVECTOR3, *LPD3DXVECTOR3;
#ifdef __cplusplus
typedef struct D3DXVECTOR3 : public D3DVECTOR
{
public:
D3DXVECTOR3() {};
D3DXVECTOR3( CONST D3DVECTOR& );
D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z );
// assignment operators
D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& );
D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& );
D3DXVECTOR3& operator *= ( FLOAT );
7
Understanding Vertices
 Vector is often used to describe the position of a vertex.
Nevertheless, a vertex consists of much more data than the
position.
struct Vertex
{
D3DVECTOR3 vPosition;
DWORD dwDiffuse; // diffuse vertex color
D3DVECTOR3 vNormal; // vertex normal
FLOAT u, v; // texture coordinates of vertex
}
 All vertices are stored in a vertex buffer.
8
Working with Orientation
 You might describe the orientation of an object by using at
least four vectors—LOOK, UP, RIGHT, and POSITION.
9
Understanding Faces
 Any 3D object consists of faces, as shown in Figure 4.6.
10
 Every model and 3D world is broken down into points, lines,
and triangles, the only primitives Direct3D is able to render.
 If you design your shapes using polygons with four or more
vertices to reduce the number of faces, Direct3D will divide
every face into triangles.
11
Backface Culling
 Direct3D can cull back faces.
 Backface Culling uses the cross-product of two sides of a
triangle to calculate a vector that is perpendicular to the plane
that is formed by the two sides.
12
D3DCULL
typedef enum D3DCULL {
D3DCULL_NONE = 1,
D3DCULL_CW = 2,
D3DCULL_CCW = 3,
D3DCULL_FORCE_DWORD = 0x7fffffff
} D3DCULL, *LPD3DCULL;
13
Understanding Polygons
 A polygon can be defined in either 2D or 3D space.
 We will refer to polygons as n-sided closed figures defined by
at least three vertices.
 The simplest polygon is a triangle.
 Direct3D uses triangles to compose most polygons because
all three vertices in a triangle are guaranteed to be co-planar.
14
Understanding Normals
 Normals are perpendicular vectors that can be used to define
the direction a face is pointing or the visible side of a face.
 A vertex normal is often perpendicular to a face, and it
usually sits upon the vertex as one unit long.
 The other type of normal is a face normal. It is usually
perpendicular to a face and sits in the middle of the face.
15
Understanding Normals and Gouraud
Shading
 Shading is the process of performing lighting computations
and determining pixel colors from them.
16
Gouraud Shading
 The vertex normal vector is used in Gouraud shading mode
(the default shading mode since the advent of Direct3D 6.0)
to control lighting and to make some texturing effects.
17
Comparison of Shading Models
18
Texture-Mapping Basics
 Texture refers to a special kind of image that you can map
onto a face or multiple faces.
19
Texture Coordinates in Direct3D
 It uses a generic addressing scheme in which all texel
addresses are in the range of 0.0 to 1.0, inclusive.
20
• Illustration of pixel (a square of color) that is mapped into
object space
21
 You can assign parts of a texture to a primitive by using
texture coordinates.
 If you want to texture a triangle, it could work something like
Figure 4.13.
cvVertices [0] = {0.0f, 0.0f, 0.5f, 1.0f, 0.0f, 0.0f}; // x, y, z, rhw, tu, tv
cvVertices [1] = {1.0f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f};
cvVertices [2] = {1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f};
cvVertices [3] = {0.0f, 1.0f, 0.5f, 1.0f, 0.0f, 1.0f};
22
References
23
Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks

More Related Content

PPTX
visual realism in geometric modeling
PPTX
Polygon mesh
PPTX
Visual realism -HIDDEN REMOVAL METHODS
PPTX
Hit and-miss transform
PPTX
Image feature extraction
PPTX
Dilation and erosion
PPT
morphological image processing
PPTX
Visual realism
visual realism in geometric modeling
Polygon mesh
Visual realism -HIDDEN REMOVAL METHODS
Hit and-miss transform
Image feature extraction
Dilation and erosion
morphological image processing
Visual realism

What's hot (20)

PPTX
Polygon mesh
PPT
Boundary Extraction
PDF
PPTX
visual realism Unit iii
PPTX
Hidden line removal algorithm
PPTX
GRPHICS01 - Introduction to 3D Graphics
PPTX
Chapter 9 morphological image processing
PPTX
Chapter 9 morphological image processing
PPT
CS 354 Bezier Curves
DOCX
Bt9301, computer graphics
DOCX
Bt9301, computer graphics
PPTX
Dilation and erosion
PPTX
GRPHICS02 - Creating 3D Graphics
PPTX
Morphological image processing
PPTX
COM2304: Morphological Image Processing
PPT
Morphological Image Processing
PPTX
Morphological image processing
PPTX
Image feature extraction
PPTX
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
PPT
Shape Features
Polygon mesh
Boundary Extraction
visual realism Unit iii
Hidden line removal algorithm
GRPHICS01 - Introduction to 3D Graphics
Chapter 9 morphological image processing
Chapter 9 morphological image processing
CS 354 Bezier Curves
Bt9301, computer graphics
Bt9301, computer graphics
Dilation and erosion
GRPHICS02 - Creating 3D Graphics
Morphological image processing
COM2304: Morphological Image Processing
Morphological Image Processing
Morphological image processing
Image feature extraction
Beginning direct3d gameprogramming01_thehistoryofdirect3dgraphics_20160407_ji...
Shape Features
Ad

Viewers also liked (15)

PPTX
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
PPTX
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
PPTX
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
PPTX
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
PPTX
Beginning direct3d gameprogramming01_20161102_jintaeks
PPTX
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
PPTX
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
PPTX
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
PPTX
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
PPTX
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
PPTX
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
PPTX
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
PPTX
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
PPTX
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
PPTX
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming05_thebasics_20160421_jintaeks
Beginning direct3d gameprogrammingmath04_calculus_20160324_jintaeks
Beginning direct3d gameprogramming01_20161102_jintaeks
Beginning direct3d gameprogramming02_overviewofhalandcom_20160408_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogramming03_programmingconventions_20160414_jintaeks
Beginning direct3d gameprogramming08_usingtextures_20160428_jintaeks
Beginning direct3d gameprogramming07_lightsandmaterials_20161117_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogrammingmath05_matrices_20160515_jintaeks
Ad

Similar to Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks (20)

PPT
1422798749.2779lecture 5
PPTX
3 d graphics with opengl part 2
PDF
Computer Graphics involves technology to access. The Process transforms and p...
PDF
ShaderX³: Geometry Manipulation - Morphing between two different objects
PPTX
From Polygons to Quadratics.pptx
PDF
CGR-Unit-1 Basics of Computer Graphics.pdf
PPT
Rendering: Vertices, Indices, UVs and Shaders
PDF
Cad me2155-lab-manual
PDF
reflective bump environment mappings.pdf
PPTX
3D Display
PPTX
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstCGR_Unit-1.pptx
PPTX
3 d graphics basics
PPT
Java Graphics
PPT
3 d modeling part 1
DOCX
Computer graphics
PPTX
AutoCAD ppt presentation new.pptx
DOCX
L3 u66 modelling 3 d the basics task 1 research
PDF
[Paper] GIRAFFE: Representing Scenes as Compositional Generative Neural Featu...
PDF
3D Reconstruction from Multiple uncalibrated 2D Images of an Object
PPT
Windows and viewport
1422798749.2779lecture 5
3 d graphics with opengl part 2
Computer Graphics involves technology to access. The Process transforms and p...
ShaderX³: Geometry Manipulation - Morphing between two different objects
From Polygons to Quadratics.pptx
CGR-Unit-1 Basics of Computer Graphics.pdf
Rendering: Vertices, Indices, UVs and Shaders
Cad me2155-lab-manual
reflective bump environment mappings.pdf
3D Display
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstCGR_Unit-1.pptx
3 d graphics basics
Java Graphics
3 d modeling part 1
Computer graphics
AutoCAD ppt presentation new.pptx
L3 u66 modelling 3 d the basics task 1 research
[Paper] GIRAFFE: Representing Scenes as Compositional Generative Neural Featu...
3D Reconstruction from Multiple uncalibrated 2D Images of an Object
Windows and viewport

More from JinTaek Seo (14)

PPTX
Neural network 20161210_jintaekseo
PPTX
05 heap 20161110_jintaeks
PPT
02 linked list_20160217_jintaekseo
PPTX
Hermite spline english_20161201_jintaeks
PPT
01 stack 20160908_jintaek_seo
PPTX
03 fsm how_toimplementai_state_20161006_jintaeks
PPTX
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
PPT
Boost pp 20091102_서진택
PPT
아직도가야할길 훈련 20090722_서진택
PPT
3ds maxscript 튜토리얼_20151206_서진택
PPT
Multithread programming 20151206_서진택
PPT
03동물 로봇그리고사람 public_20151125_서진택
PPT
20150605 홀트입양예비부모모임 서진택
PPT
Boost라이브러리의내부구조 20151111 서진택
Neural network 20161210_jintaekseo
05 heap 20161110_jintaeks
02 linked list_20160217_jintaekseo
Hermite spline english_20161201_jintaeks
01 stack 20160908_jintaek_seo
03 fsm how_toimplementai_state_20161006_jintaeks
Beginning direct3d gameprogrammingmath01_primer_20160324_jintaeks
Boost pp 20091102_서진택
아직도가야할길 훈련 20090722_서진택
3ds maxscript 튜토리얼_20151206_서진택
Multithread programming 20151206_서진택
03동물 로봇그리고사람 public_20151125_서진택
20150605 홀트입양예비부모모임 서진택
Boost라이브러리의내부구조 20151111 서진택

Recently uploaded (20)

PPTX
Lecture Notes Electrical Wiring System Components
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Well-logging-methods_new................
PPTX
Sustainable Sites - Green Building Construction
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Geodesy 1.pptx...............................................
PPTX
web development for engineering and engineering
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
additive manufacturing of ss316l using mig welding
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Lecture Notes Electrical Wiring System Components
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Well-logging-methods_new................
Sustainable Sites - Green Building Construction
Arduino robotics embedded978-1-4302-3184-4.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Geodesy 1.pptx...............................................
web development for engineering and engineering
Model Code of Practice - Construction Work - 21102022 .pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
bas. eng. economics group 4 presentation 1.pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Internet of Things (IOT) - A guide to understanding
additive manufacturing of ss316l using mig welding
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf

Beginning direct3d gameprogramming04_3dfundamentals_20160414_jintaeks

  • 1. Beginning Direct3D Game Programming: 4. 3D Fundamentals jintaeks@gmail.com Division of Digital Contents, DongSeo University. April 2016
  • 2. Presentation outline  Work with vertices and orientation  Work with faces and polygons  Use Gouraud shading  Put into practice the basics of texture mapping 2
  • 3. 3D Fundamentals  The Direct3D engine uses a left-handed coordinate system by default.  The OpenGL coordinate system uses a positive z-axis that points out of the screen. This is called a right-handed coordinate system. 3
  • 4. vertex  The square uses four vertices, v1 through v4.  A vertex defines the point of intersection of one or more lines;  Direct3D needs a way to place these primitives in a scene. 4
  • 5.  To define a vertex in 3D space, you must specify three coordinate values: x, y, and z. v1 (0, 0, 0) v2 (0, 2, 0) v3 (0, 2, 2) v4 (0, 0, 2)  You can define the location of a vertex by specifying a vector from the origin to another point in 3D space. 5
  • 6. vector  They are mathematical entities that describe a direction and a magnitude (which can be used for velocity, for example).  Vectors are usually denoted by a bold-faced letter, such as a.  Thus you could say the vector v = (1, 0, 1).  Vectors are not only used to define the position of the vertices, they are also used to define a direction. 6
  • 7. D3DXVECTOR typedef struct D3DXVECTOR3 { FLOAT x; FLOAT y; FLOAT z; } D3DXVECTOR3, *LPD3DXVECTOR3; #ifdef __cplusplus typedef struct D3DXVECTOR3 : public D3DVECTOR { public: D3DXVECTOR3() {}; D3DXVECTOR3( CONST D3DVECTOR& ); D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); // assignment operators D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); D3DXVECTOR3& operator *= ( FLOAT ); 7
  • 8. Understanding Vertices  Vector is often used to describe the position of a vertex. Nevertheless, a vertex consists of much more data than the position. struct Vertex { D3DVECTOR3 vPosition; DWORD dwDiffuse; // diffuse vertex color D3DVECTOR3 vNormal; // vertex normal FLOAT u, v; // texture coordinates of vertex }  All vertices are stored in a vertex buffer. 8
  • 9. Working with Orientation  You might describe the orientation of an object by using at least four vectors—LOOK, UP, RIGHT, and POSITION. 9
  • 10. Understanding Faces  Any 3D object consists of faces, as shown in Figure 4.6. 10
  • 11.  Every model and 3D world is broken down into points, lines, and triangles, the only primitives Direct3D is able to render.  If you design your shapes using polygons with four or more vertices to reduce the number of faces, Direct3D will divide every face into triangles. 11
  • 12. Backface Culling  Direct3D can cull back faces.  Backface Culling uses the cross-product of two sides of a triangle to calculate a vector that is perpendicular to the plane that is formed by the two sides. 12
  • 13. D3DCULL typedef enum D3DCULL { D3DCULL_NONE = 1, D3DCULL_CW = 2, D3DCULL_CCW = 3, D3DCULL_FORCE_DWORD = 0x7fffffff } D3DCULL, *LPD3DCULL; 13
  • 14. Understanding Polygons  A polygon can be defined in either 2D or 3D space.  We will refer to polygons as n-sided closed figures defined by at least three vertices.  The simplest polygon is a triangle.  Direct3D uses triangles to compose most polygons because all three vertices in a triangle are guaranteed to be co-planar. 14
  • 15. Understanding Normals  Normals are perpendicular vectors that can be used to define the direction a face is pointing or the visible side of a face.  A vertex normal is often perpendicular to a face, and it usually sits upon the vertex as one unit long.  The other type of normal is a face normal. It is usually perpendicular to a face and sits in the middle of the face. 15
  • 16. Understanding Normals and Gouraud Shading  Shading is the process of performing lighting computations and determining pixel colors from them. 16
  • 17. Gouraud Shading  The vertex normal vector is used in Gouraud shading mode (the default shading mode since the advent of Direct3D 6.0) to control lighting and to make some texturing effects. 17
  • 19. Texture-Mapping Basics  Texture refers to a special kind of image that you can map onto a face or multiple faces. 19
  • 20. Texture Coordinates in Direct3D  It uses a generic addressing scheme in which all texel addresses are in the range of 0.0 to 1.0, inclusive. 20
  • 21. • Illustration of pixel (a square of color) that is mapped into object space 21
  • 22.  You can assign parts of a texture to a primitive by using texture coordinates.  If you want to texture a triangle, it could work something like Figure 4.13. cvVertices [0] = {0.0f, 0.0f, 0.5f, 1.0f, 0.0f, 0.0f}; // x, y, z, rhw, tu, tv cvVertices [1] = {1.0f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f}; cvVertices [2] = {1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f}; cvVertices [3] = {0.0f, 1.0f, 0.5f, 1.0f, 0.0f, 1.0f}; 22

Editor's Notes

  • #6: The origin of your coordinate system is 0, 0, 0. The position of the vertices of the square could be described as v1 (0, 0, 0) v2 (0, 2, 0) v3 (0, 2, 2) v4 (0, 0, 2)
  • #11: To create a smooth-looking object, you need hundreds or even thousands of faces or surfaces, as shown in Figure 4.7.