3D Theory & PracticeThe area of 3D graphics covers a massive area and can only be done justice to by reading books and browsing the net, this section only serves as a basis from which to work in MilkShape 3D and understand what is going on, which is not strictly necessary but it fills a few gaps where knowledge may be desired. The Basics of 3D
3D Space is represented by 3 planes or dimensions (hence 3-Dimensional). These are the X, Y and Z planes. Y Ranges in the up and down directions, X in the left and right and Z in the depth. Y is the height, X is the width and Z is the depth. In 3D space every point has 3 coordinates, these are (you guessed it) X, Y and Z. These represent the position of a point in the respective plane. This is the MilkShape 3D axis viewed from the 3D perspective window. The Constructs of 3D
There are many different building blocks available in the area of 3D. High-end 3D applications allow the use of Splines, Curves, NURBS (Non-Uniform Rational B-Splines), etc... MilkShape 3D deals with the basics that are widely supported on numerous Graphics Cards and Graphics Application Programming Interfaces (APIs) such as DirectX and OpenGL. The basic building blocks MilkShape 3D deals with are Polygons, Vertices and Normals. Vertices
A Vertex is the simplest construct, it is a point in 3D space, which has an X, Y and Z coordinate value. In MilkShape 3D vertices can be placed and used to define a polygon (triangle) and are represented by a dot. Polygons
The word 'polygon' can mean a lot of things to many people. In generic terms a Polygon is a flat surface with either three sides (triangle) or four sides (quad). MilkShape 3D uses only triangles. However in 3D Theory a polygon can have an infinite number of sides. As computers cannot handle 'infinity', in practice the number of sides a polygon can have is usually limited to three or four. In MilkShape 3D a polygon (triangle) is represented by lines joining three vertices. An outward (forward) facing polygon is defined counter-clockwise, an inward (backward) facing polygon is defined clockwise. By definition a Polygon is a convex shape, there are no concave areas around its edge. The following image shows a variety of valid and non-valid polygons. As a rule of thumb, a shape with any side which would intersect any other side, if an infinite line was projected from it, is a non-valid polygon. All of these shapes can be made in MilkShape 3D using triangles, the Non-Valid shapes would be valid as they would be composed of triangles which are themselves Valid polygons. However, as single polygons (i.e. not composed of other Valid polygons) the Non-Valid polygons are still Non-Valid, that is; not a polygon.
A normal is basically a vector, that is; a straight line. It is defined by a start point and an end point, both of which are points in 3D space (meaning they have an X, Y and Z coordinate value). In a 3D object only one vertex is needed per normal as the vertex the normal is attached to defines the start position for the normal. Normals are used to determine how a polygon is lit by the light sources around it. A normal (in Flat Shading) can be imagined to project from the middle of the polygon at a 90 degree angle to the surface of the polygon. The normal always faces from the side of the polygon looking outward. Graphics Hardware will calculate the intensity of the light on the surface of the polygon by using the normal. The intensity depends on how close the angle of the normal is to the angle of the light, e.g. if the normal is perpendicular (on the same angle) with the angle of the light, this is the point at which the intensity of the light on the polygon is brightest. If the normal is facing away from the light direction then this will be the point at which the intensity of the light is at its darkest. This image shows the different light intensities on the surface of the model. Each side is composed of four triangles, so strictly speaking there should be a black line (representing a normal) originating from the centre of each triangle upwards in a 90 degree angle to the surface of the polygon. In this demonstration though, we can deduce that because the light intensity is the same for each side (the four triangles) the normals are also the same i.e. they are equal. In MilkShape 3D the light in the scene comes from the viewing perspective of the camera in the scene, like a camera with a flashlight on it. The normal with an angle closest to that of the light (the same position as the camera) is number one; therefore the surface it is attached to is the brightest. The surface that normal two is attached to is less bright as this normal is facing away from the light more. Normal three is facing away from the camera the most and therefore its surface is even darker. MilkShape 3D possesses another method of surface shading called Smooth Shading. If you have switched between Smooth and Flat Shading you will have noticed that polygons in Flat Shaded mode are more defined, this is due to the difference in lighting methods. With Smooth Shading a normal is projected from each vertex at a 90 degree angle from the face it is attached to. Where a vertex is attached to more than one face an average of the angles between the faces and the vertex is used. This image shows the normals that are attached to the vertices. Vertex Lighting (as it is termed) results in a Smooth finish to the surfaces. This is due to an averaging of light intensity between surfaces that results in a gradient, rather than a solid fill as would be achieved by Flat Shading. This concept can be further explained by taking a better example. In the image immediately below is a box. The right side of the image is a flat shaded box therefore all normals attatched to vertices are pointing in exactly the same direction as the face is pointed. By Unwelding vertices (Vertex->Unweld) you create more vertices, four for each face and none are shared, so in the image instead of having eight vertices (as the Smooth Shaded box on the right of the image does) there are 36 i.e. 12 triangle faces times 3 vertices for each face = 36. The white lines show where the normals would be if a line was drawn from the vertex to the normal. One more thing to note is that Normals are of a unit length, i.e. they are a length that is a whole number; 1, 2, etc... To Normalise something means to introduce an equation that will make a number equal to one, that equation is commonly the number divided by itself. With everything that has been said before you are probably in the state if mind that Normals are lines. Well metaphorically speaking, they are lines, they have a start point (the vertex it is attatched to) and an end point (the normal position). But in actual fact a normal is a point in space, a vector, much as a vertex is a vector. A vector, if you have not heard of one before, generally speaking is a numerical quantity. In 3D graphics it can be literrally described as a direction. A direction is a straight line and the direction can be obtained by knowing the current position and the destination position. A normal therefore is a point in 3D space, a vector, 3 values x, y and z. The renderer in 3D engines takes the position of the normal in relation to the position of the vertex it is attatched to, in order to figure out the lighting intensity the surface will have. Texture Mapping
Texture Mapping literally means mapping a texture onto a surface. In order for a texture to appear correctly on a surface UV coordinates are used at each of the vertices that compose the surface. The U coordinate is the Texture X coordinate and the V is the Texture Y coordinate, we deal with only two dimensions as images are only two dimensions (there are also 3D textures but that goes out with the scope of this document). As the following image shows, imagine taking the texture and pasting it on top of the surface (in this case a triangle). The coordinates that the image is transposed onto the surface are stored at each vertex that make up the surface. The bit that is not mapped to the triangle (i.e. the lower right triangle of the bitmap) is cut off. UV Coordinates allow the surface to have mapped any area of the applied texture the user wishes. In the texture coordinate editor the vertices represent the UV coordinates on the texture, on the model the texture is applied to the surface using the UV coordinates.
|