第八章:加载Maya2011模型

原文链接:

Tutorial 8: Loading Maya 2011 Models

第八章:加载Maya2011模型

This tutorial will cover how to import static 3D models from Maya 2011. Note that this tutorial will be focused on Maya but it also applies to pretty much any other 3D modeling software package with some slight changes.

本章将介绍如何导入Maya2011的静态模型。通过稍微修改本章的方法也可以适用于其他3D建模软件。

In the previous tutorials we have already created our own model format and rendered 3D models using that format. The goal now is to convert Maya 2011 models into our format and render them. I won’t go into how to model 3D objects in Maya as there are hundreds of tutorials on the net already dedicated to that, we will instead start at the point where you have a textured and triangulated 3D model ready for export.

在前面的教程里,我们已经创建了自己的模型格式用作渲染。现在的目标时将Maya2011的模型转换为自己的模型格式再渲染。本章不会介绍如何使用Maya进行3D建模,这方面已经有太多的教程。我们将从导出已经包含贴图的3D模型开始。

For the Maya export format we will use the .OBJ format as it is easily readable and good for beginners to start with.

我们将使用Maya导出.OBJ格式文件,,此格式结构非常简单也很适合初学者。

To export your model in the .obj format you must first enable the .OBJ exporter in Maya. Click "Window", then "Settings/Preferences", then "Plug-in Manager". Scroll down to objExport.mll and select both "Loaded" and "Auto load". Now to export your model in this format click on "File", then "Export All". Now at the bottom select "Files of type:" and scroll down and select "OBJexport". Give it a file name and hit "Export All" and it will export it to a text file with a .obj extension. To look at the file you can right click and select Open With and choose WordPad to read the file. You will then see something that looks like the following:

要在Maya中导出.obj格式必须先要激活.OBJ导出工具。点击“Window”,然后“Settings/Preferences”,然后“Plug-in Manager”。找到objExport.mll选择“Loaded”和“Auto load”。下面开始导出,点击“File”,然后“Export All”。在底部的“Files of type:”选择“OBJexport”。填写一个导出的文件名,点击“Export All”。将导出一个.obj扩展名的文本文件。可以用记事本等文本编辑器打开文件来查看文件的内容。你讲看到类似下面的内容:

Cube.obj

# This file uses centimeters as units for non-parametric coordinates.

mtllib cube.mtl

g default

v -0.500000 -0.500000 0.500000

v 0.500000 -0.500000 0.500000

v -0.500000 0.500000 0.500000

v 0.500000 0.500000 0.500000

v -0.500000 0.500000 -0.500000

v 0.500000 0.500000 -0.500000

v -0.500000 -0.500000 -0.500000

v 0.500000 -0.500000 -0.500000

vt 0.001992 0.001992

vt 0.998008 0.001992

vt 0.001992 0.998008

vt 0.998008 0.998008

vt 0.001992 0.001992

vt 0.998008 0.001992

vt 0.001992 0.998008

vt 0.998008 0.998008

vt 0.001992 0.001992

vt 0.998008 0.001992

vt 0.001992 0.998008

vt 0.998008 0.998008

vt 0.001992 0.001992

vt 0.998008 0.001992

vt 0.001992 0.998008

vt 0.998008 0.998008

vt 0.001992 0.001992

vt 0.998008 0.001992

vt 0.001992 0.998008

vt 0.998008 0.998008

vt 0.998008 0.998008

vt 0.001992 0.998008

vt 0.998008 0.001992

vt 0.001992 0.001992

vn 0.000000 0.000000 1.000000

vn 0.000000 0.000000 1.000000

vn 0.000000 0.000000 1.000000

vn 0.000000 0.000000 1.000000

vn 0.000000 1.000000 0.000000

vn 0.000000 1.000000 0.000000

vn 0.000000 1.000000 0.000000

vn 0.000000 1.000000 0.000000

vn 0.000000 0.000000 -1.000000

vn 0.000000 0.000000 -1.000000

vn 0.000000 0.000000 -1.000000

vn 0.000000 0.000000 -1.000000

vn 0.000000 -1.000000 0.000000

vn 0.000000 -1.000000 0.000000

vn 0.000000 -1.000000 0.000000

vn 0.000000 -1.000000 0.000000

vn 1.000000 0.000000 0.000000

vn 1.000000 0.000000 0.000000

vn 1.000000 0.000000 0.000000

vn 1.000000 0.000000 0.000000

vn -1.000000 0.000000 0.000000

vn -1.000000 0.000000 0.000000

vn -1.000000 0.000000 0.000000

vn -1.000000 0.000000 0.000000

s 1

g pCube1

usemtl file1SG

f 1/1/1 2/2/2 3/3/3

f 3/3/3 2/2/2 4/4/4

s 2

f 3/13/5 4/14/6 5/15/7

f 5/15/7 4/14/6 6/16/8

s 3

f 5/21/9 6/22/10 7/23/11

f 7/23/11 6/22/10 8/24/12

s 4

f 7/17/13 8/18/14 1/19/15

f 1/19/15 8/18/14 2/20/16

s 5

f 2/5/17 8/6/18 4/7/19

f 4/7/19 8/6/18 6/8/20

s 6

f 7/9/21 1/10/22 5/11/23

f 5/11/23 1/10/22 3/12/24

This particular .OBJ model file represents a 3D cube. It has 8 vertices, 24 texture coordinates and normal vectors, and 6 sides made up of 12 faces in total. When examining the file you can ignore every line unless it starts with a "V", "VT", "VN", or "F". The extra information in the file will not be needed for converting .obj to our file format. Lets look at what each of the important lines means:

这个.OBJ文件描述了一个3D盒子。包含8个顶点,24个纹理坐标和法向量,由12个三角形面组成6个矩形面。

1. The "V" lines are for the vertices. The cube is made up of 8 vertices for the eight corners of the cube. Each is listed in X, Y, Z float format.

1. “V”开头的行表示顶点。盒子由8个顶点组成,每个顶点都包含3个浮点数表示x, y, z。

平平淡淡才是真

第八章:加载Maya2011模型

相关文章:

你感兴趣的文章:

标签云: