In Windows Phone, xNa provides a game framework for developers, which greatly improves the efficiency of game development. While enjoying the convenience of using xNa for 2D development, 3D development can also be easily implemented. I would like to introduce this in a series of articles, for your reference when you want to use xNa for 3D development in Windows Phone.
3D development requires more knowledge, including linear algebra and computer graphics. These theories are beyond the scope of this article. If you need them, you can find many reference books.
Next, let's take a look at the basic situation of the 3D world.
First, let's look at the coordinate system. In the 2D plane, the coordinate system is no longer familiar. It uses the Cartesian coordinate system and uniquely identifies a plane from the vertical X and Y coordinate axes, all vertices in a plane can be expressed as (x, y.
In 3D space, due to the introduction of depth, the plane coordinates obviously cannot meet the requirements. three-dimensional coordinates are required to represent points in space. The 3D coordinate system is also called the world coordinate system. The X, Y, and Z coordinate axes are used to introduce a Z axis perpendicular to the plane on the X and Y axes of the plane coordinate system. In Windows Phone, the right-hand coordinate system is used. When the mobile phone screen faces us, the positive side of the Z axis points to the face from the mobile phone screen. All vertices in the space are expressed in the form of (x, y, z). The origin is (0, 0, 0 ). Shows the coordinate system. (Note: The image is from Microsoft's lab manual)
Since all vertices in the space need to be expressed in the form of (x, y, z), in order to facilitate programming, xNa provides the vector3 class. The vector3 class facilitates the expression of points and vectors in the space. Common User methods are as follows:
Vector3 Pos = new vector3 (0, 0, 20 );
For zero vectors or common vectors, The vector3 class also provides static methods for our use. For example, to create a zero vector, you can write it:
Vector3 Pos = vector3.zero;
Vector3 also provides addition, subtraction, multiplication, division, and other operations, as well as intersection and distance operations, which can be conveniently used in program development.
In this way, we know how to use the 3D Coordinate System and Its Expression in the code, but this is not enough for 3D development. Imagine an object in a space, although its coordinates remain unchanged, can be viewed from any angle, but the results are different from each angle. Therefore, only the coordinate system is not enough. We need to add new content to determine the real expression of objects in a space. I want to know what is going on later, and it will be broken down later.
-- Welcome to reprint, please indicate the source of http://blog.csdn.net/caowenbin --