1 | <HTML> |
---|
2 | |
---|
3 | <HEAD> |
---|
4 | </HEAD> |
---|
5 | <TITLE> OGRE tutorial. |
---|
6 | </TITLE> |
---|
7 | <BODY> |
---|
8 | |
---|
9 | <H2 ALIGN=CENTER > Tutorial: Exporting meshes from 3dsmax 5</H2> |
---|
10 | |
---|
11 | |
---|
12 | This tutorial shows how to export a skateboard from 3D studio Max 5. You will export a mesh made up of several submeshes and |
---|
13 | its assigned material. |
---|
14 | |
---|
15 | <H4> Introduction </H4> |
---|
16 | First, open the file "skateboard_1.max" that you can find in this <A href=skateboard_1.zip>zip file</A>.<BR> |
---|
17 | <B>Copy the png file to "C:\" directory or change the path in the material editor. You should also copy it to your OGRE Media directory.</B><BR> |
---|
18 | You can see 2 boards which have been cloned. They are made up of a board that have been mapped with <I>UVW unwrap</I>, |
---|
19 | 4 wheels and 2 trucks.<BR> |
---|
20 | |
---|
21 | <img src="images/intro1.jpg" /> <img src="images/intro2.jpg" /> <BR> |
---|
22 | |
---|
23 | |
---|
24 | <H4> Create one object with submeshes</H4> |
---|
25 | |
---|
26 | <UL> |
---|
27 | <LI> Select the board (whose name is "board") which is at (0,0,0) and convert it to an editable mesh. |
---|
28 | Attach the wheels and the trucks.<BR><BR> |
---|
29 | </LI> |
---|
30 | |
---|
31 | <LI> As you can see, texture mapping has changed, we must create a MultiMaterial and assign material ids to submeshes. |
---|
32 | In the material editor (press "M"), assign the multiMaterial to the board, and in the element subobject mode, |
---|
33 | choose material Id 1 for the board, 2 for the wheels and 3 for the trucks.<BR> |
---|
34 | <img src="images/assignIds.jpg" /> |
---|
35 | <BR> |
---|
36 | <BR><BR> |
---|
37 | </LI> |
---|
38 | <LI> That's all, the mesh is ready to be exported. </LI> |
---|
39 | </UL> |
---|
40 | |
---|
41 | <H4> Run the mesh exporter</H4> |
---|
42 | |
---|
43 | The script allows you to run XMLConverter after exporting. This is set in the OgreScript.ini file. |
---|
44 | Here is an example: |
---|
45 | <PRE> |
---|
46 | [Directories] |
---|
47 | XMLConverterPath=e:\C++\ogrenew\Tools\XMLConverter\bin\Debug |
---|
48 | MediaPath=E:\C++\ogrenew\Samples\Media |
---|
49 | |
---|
50 | [Exe] |
---|
51 | XMLConverterExe=OgreXMLconverter.exe |
---|
52 | |
---|
53 | [Settings] |
---|
54 | lastFile=e:\C++\ogrenew\Tools\XMLConverter\bin\Debug\bbb |
---|
55 | lastAnimName=walk |
---|
56 | lastMaterialFile=E:\C++\ogrenew\Samples\Media\3ds.material |
---|
57 | |
---|
58 | [Tools] |
---|
59 | runXMLConverter=no |
---|
60 | </PRE> |
---|
61 | |
---|
62 | As you can see, settings are saved, so you avoid to write again and again the same output files and animation name. |
---|
63 | To be able to run XMLConverter, change the last line as: |
---|
64 | <PRE> |
---|
65 | runXMLConverter=yes |
---|
66 | </PRE> |
---|
67 | and set up your directories. |
---|
68 | <B>Nota:</B>you may have to change XMLConverterExe to another name (to the former XMLConverter), there will not be any warnings if a path or the exe file contains errors. <BR> |
---|
69 | <BR> |
---|
70 | Now choose the board, check the "export mesh" checkbox and press the export button.<BR><BR> |
---|
71 | <B>Nota: Using the log - When there is no submesh: </B> |
---|
72 | Open the Maxscript Listener ("MaxScript/Maxscript Listener" or "F11"), You should see a log. |
---|
73 | You should verify that there is the number of submeshes you expect, <U>especially when you have not |
---|
74 | any submesh</U>. 3dsmax sets 6 material Id when a mesh is created, I think. So if you see lots of submeshes, |
---|
75 | just set the material ID in subobject mode. |
---|
76 | <BR><BR> |
---|
77 | |
---|
78 | |
---|
79 | <B>Nota: material names : </B> |
---|
80 | As you can see if you open the .mesh.xml file which has been written, submesh material names are materialname/* |
---|
81 | where * is a sub material name. If you forget this, you may have an "material not found" error at runtime.<BR> |
---|
82 | |
---|
83 | So our materials are called: skateboard_board/board, skateboard_board/wheels, skateboard_board/trucks. |
---|
84 | |
---|
85 | Here is the material file you have to write (in any .material file in the Media directory) |
---|
86 | <PRE> |
---|
87 | material skateboard_board/board_#132 |
---|
88 | { |
---|
89 | technique |
---|
90 | { |
---|
91 | pass |
---|
92 | { |
---|
93 | ambient 0.588 0.588 0.588 |
---|
94 | diffuse 0.588 0.588 0.588 |
---|
95 | specular 0.9 0.9 0.9 0.0 |
---|
96 | emissive 0.0 0.0 0.0 |
---|
97 | texture_unit |
---|
98 | { |
---|
99 | texture skateboard.png |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | material skateboard_board/wheels |
---|
106 | { |
---|
107 | technique |
---|
108 | { |
---|
109 | pass |
---|
110 | { |
---|
111 | ambient 0.796079 0.780392 0.588235 |
---|
112 | diffuse 0.796079 0.780392 0.588235 |
---|
113 | specular 0.9 0.9 0.9 0.0 |
---|
114 | emissive 0.0 0.0 0.0 |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | material skateboard_board/trucks |
---|
120 | { |
---|
121 | technique |
---|
122 | { |
---|
123 | pass |
---|
124 | { |
---|
125 | ambient 0.737255 0.737255 0.737255 |
---|
126 | diffuse 0.737255 0.737255 0.737255 |
---|
127 | specular 0.9 0.9 0.9 0.0 |
---|
128 | emissive 0.0 0.0 0.0 |
---|
129 | } |
---|
130 | } |
---|
131 | } |
---|
132 | </PRE> |
---|
133 | |
---|
134 | But, read the next section before doing this ;) . |
---|
135 | |
---|
136 | <H4> Run the material exporter</H4> |
---|
137 | |
---|
138 | No run the material exporter in the Ogre Toolbar. (If you don't find the material exporter button, have a look |
---|
139 | <A href="../ToolBar/index.html">here</A>) <BR>It can only (but it's sufficient) export MultiMaterials and Standard Materials. |
---|
140 | |
---|
141 | <UL> |
---|
142 | <LI> It adds /* to material names. </LI> |
---|
143 | <LI> It retrieves the Diffuse map of submaterials, or if it is undefined, it uses ambient, diffuse, etc. colors.</LI> |
---|
144 | </UL> |
---|
145 | |
---|
146 | You should see the following window: <BR> |
---|
147 | <img src="images/materialtools.jpg" /> <BR> |
---|
148 | <BR> |
---|
149 | Click on "Pick material", choose Scene in the right panel, and choose the snowboard_board material.<BR> |
---|
150 | <img src="images/choosemultimaterial.jpg" /> <BR> |
---|
151 | |
---|
152 | Click on 'Ok' button in order to select the material you want to export.<BR> |
---|
153 | |
---|
154 | Select instance in the popup, <BR> |
---|
155 | Choose an output filename (in the OGRE Media directory), <BR> |
---|
156 | Press the Export button. <BR> |
---|
157 | <BR> |
---|
158 | There is an other button which allow you to export all the materials used in the scene.<BR> |
---|
159 | |
---|
160 | <BR><B> That's all ! Have fun with this exporter !</B><BR><BR> |
---|
161 | |
---|
162 | <CENTER> |
---|
163 | <A href="../../index.html">Return to homepage</A> |
---|
164 | </CENTER> |
---|
165 | <BR> |
---|
166 | <BR> |
---|
167 | If you have seen any errors or have any suggestions, mail me at mallard@iie.cnam.fr. |
---|
168 | |
---|
169 | </BODY> |
---|
170 | </HTML> |
---|