DirectX9 3D Quick Start 4

Source: Internet
Author: User
Next we will use Mesh to read. X file, about. there are actually a lot of X Files. We can use external tools such as 3DS MAX to create them. 3ds file, and then convert. X File. If you use 3DS at the same time, you may ask, what should we do with the material? You don't have to worry, the. X file can automatically contain materials, and animations, so we can use Mesh to make it easy for us to use 3DS MAX in the game.
. The X file allows custom extensions. Of course, we will talk about this in the future. Let's take a look at how to use it first. By the way, there is also a file format that is used more often. md3 format file, that is, the file used by Quake3. If you have the opportunity, I will also talk about it.
For 3DS files and. X conversions, see the article http://www.gameres.com/Articles/Program/Visual/3D/3DinApp.htm at the GameRes website.
 
The following process is simple and you cannot believe it. Please refer:
Private Mesh mesh = null; // create a Mesh object
Private Material [] meshMaterials; // used to save materials
Private Texture [] meshTextures; // used to save the Texture
Private void LoadMesh (string file)
     {
ExtendedMaterial [] mtrl; // Saves the Mesh subset information and Material information
// Load our mesh
Mesh = Mesh. FromFile (file, MeshFlags. Managed, device, out mtrl );
// If we have any materials, store them
If (mtrl! = Null) & (mtrl. Length> 0 ))
         {
MeshMaterials = new Material [mtrl. Length];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.