Download presentation
Presentation is loading. Please wait.
Published byMarsha Goodwin Modified over 9 years ago
1
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University
2
3D Graphics Basics: The Scene A three dimensional model of an object A camera that takes a picture of the object A viewport (projection surface) for a picture, which is a projection of the object to a planar surface The 3D rendering engine determines the color for every pixel by calculating the amount of light that is reflected by any light sources All surfaces of objects have a material (brush). The material defines how much light is reflected for a specific angle and the brush defines the color. A brush can either be a simple color or a gradient or even an image called texture
4
3D WPF is a world of triangles A surface of a 3D object is called a mesh A mesh is defined by a number of 3D points called Vertices (Vertex) The vertices are joined together by a winding pattern to define the triangles Every triangle has a front and a back side. Only the front side is rendered WPF uses a counter clockwise winding pattern
6
WPF is a right handed coordinate system
7
WPF Elements of a 3D scene Viewport3D The viewport is the control that builds the gate between the 2D and the 3D world. Camera Every 3D scene has excactly one camera. The camera defines the Position and the LookDirection and the UpDirection of the viewer. WPF supports orthographical and perspective cameras. 3D Models A 3D model defines an object in the scene. It has a Geometry that is the mesh and a Material that can be a diffuse, specular or emmisive material. The material itself has a brush. Lights Without any lights you see nothing. So we need to place at least one light in our scene to illuminate our models
9
A Point in Space In C# code, we create and initialize a Point3D object: In XAML, you represent a Point3D objects as a text string with spaces and/or single commas separating the numbers: or
10
Points in Space In C# code, use the Point3DCollection class In XAML, just by listing them in a string:
11
Vectors A vector encapsulates a magnitude and a direction
12
Points and Vectors Relationship For vector (x v, y v, z v ), the direction of the vector is the direction from the origin (0, 0, 0) to the point (x v, y v, z v ). The magnitude of the vector (M) is The normalized vectors or unit vectors will have magnitude of 1 point ± point vector point ± vector point vector * D vector vector / D vector
13
Define the 3D object
14
Define the simplest light A 3D scene usually requires some light. If you don't have any light in a 3D scene, you'll still be able to see the figures you've created, but they won't have any color Different types of light are available in WPF 3D The simplest light is a class named AmbientLight which has a white color by default. or
15
Define the simplest camera The camera must be located in a specific position in 3D space by setting the Position property You also need to specify a direction in which the camera is pointed by setting the LookDirection property. The simplest camera Sits right on the positive Z axis, which means that the X and Y coordinates are set to zero Points in a direction parallel to the negative Z axis, which is the vector (0, 0, –1)
16
Camera In the scene
17
The Viewport3D and Its Constituents We generally define a whole 3D scene inside a Viewport3D element It can be a part of a larger layout of elements, and it can receive mouse, keyboard, and stylus input Viewport3D defines a ModelVisual3D and Camera properties. ModelVisual3D has a property named Content Each Content might contains GeometryModel3D or Light GeometryModel3D has a Geometry, Material, and BackMaterial properties.
18
Ggeneral structure of a simple Viewport3D
19
Put everything together
20
Model3DGroup Combine the geometry and light into one
21
Light sources AmbientLight Setting a Color property DirectionalLight Setting Color and Direction properties. PointLight SpotLight
22
DirectionalLight PointLight SpotLight
23
Camera Perspective Camera Orthographic Camera
24
PerspectiveCameraOrthographicCamera
25
LookDirection property A vector that points from the Position property to the target point (x, y, z). If the Position property is (–2, 0, 5) and the target is the origin (0, 0, 0), the calculation is ( 0, 0, 0) – (–2, 0, 5) = (2, 0, –5) It's also possible to calculate LookDirection so that the center of the triangle appears in the center of the display (0, 0.5, –1) – (–2, 0, 5) = (2, 0.5, –6)
26
Field Of View (FOV)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.