Graphics Reference
In-Depth Information
4.
When initializing the vertices for a mesh, it may also be desirable to reverse the
vertex winding direction or to set the IsFrontCounterClockwise property to
true in the rasterizer state description. For example, to render the quad from the
Rendering a cube and sphere recipe in a right-handed coordinate system, we can
change the order of the indices as follows:
new ushort[] {
0, 2, 1, // instead of 0, 1, 2
2, 0, 3 // instead of 2, 3, 0
}
How it works…
By creating our view and projection matrices in a right-handed coordinate system, with the
x axis still pointing to the right, the positive z axis now extends towards the viewer. Although
we refer to the z axis, any setup where a positive axis points towards the viewer is considered
a right-handed Cartesian coordinate system. It is also common for 3D modeling software to
use a coordinate system where the y axis points towards/away from the viewer and the z axis
points up. Depending on the vertex data, simply reordering the vertices may not be sufficient.
UV coordinates may need adjusting, or normal vectors updated. The PerMaterial buffer has
a UV transform matrix that can be used to adjust UV coordinates; this is covered further in the
next recipe: Loading a static mesh from a file .
See also
F The following information on 3D coordinate systems for DirectX on MSDN
provides more information on how to work with different coordinate systems:
http://msdn.microsoft.com/en-us/library/windows/desktop/
bb324490%28v=vs.85%29.aspx
Loading a static mesh from a file
In this recipe, we will create a mesh renderer that renders meshes loaded from a compiled
mesh object ( .CMO ) file. We will use the Visual Studio graphics content pipeline to compile
an Autodesk FBX model that has been exported from the open source 3D modeling and
animation software, Blender ( blender.org ).
The class Common.Mesh within the provided sample framework will be used to load the .CMO
file format and to store the loaded mesh. The loaded mesh will contain the vertex and index
buffers along with material and lighting parameters and can also include the name of textures
and pixel shaders to use.
 
Search WWH ::




Custom Search