]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - Exporting-a-weapon-for-Xonotic.md
Add SMD part still WIP
[xonotic/xonotic.wiki.git] / Exporting-a-weapon-for-Xonotic.md
1 ## :rotating_light: :warning: WARNING: This tutorial is under construction! :warning: :rotating_light: 
2
3 # Modeling requirements
4 ### To follow this, you need knowledge about modeling using Blender
5
6 Blender version recommended: 2.79b or later
7
8 Requires these following tools (addons) for Blender:
9 - [IQM exporter](https://gitlab.com/xonotic/iqm) to export IQM files.
10 - [Source Tools (SMD importer/exporter)](http://steamreview.org/BlenderSourceTools/archives/) to import/export SMD files.
11
12 Optional:
13 - [MD3 importer/exporter](https://github.com/neumond/blender-md3) to import/export MD3 files.
14
15 ***IMPORTANT NOTE**: if you want to contribute, it's strongly important use 2.79b version for compatibility cases, they need to open from this version. Share the .blend file using 2.79b or earlier , make sure to work properly from this version!*<br/>
16 *If the version of a file is later than 2.79b, we may to make some tweaks and become tedious.*
17
18 # Introduction to export a weapon
19 **Keep in mind about weapon systems:**
20
21 - `g_*.md3`: model mesh for item pickup spawn and third person.
22 - `h_*.iqm`: for first person animations; the skeleton and the bones (the rigging and animation part). Keep in mind, you would need `*.iqm.framegroups` (more info: [Framegroups](framegroups), you can look `*.iqm.framegroups` opening a notepad to see what animations contain and the keyframes where these are set)
23 - `v_*.md3`: model mesh for first person and a glue of `h_*`; if `h_*.iqm` doesn't match with the animations needed of `v_*.md3`, it will generate spamming errors and bad pivot position.
24
25 More info: [Weapon modeling system](Weaponsystem)
26
27
28 # Textures and UV map
29
30 ### For MD3 exportation:
31
32 You have to add single material with single texture for every mesh object. Name of texture node will be written as is into MD3 data (suffixes like .001, .002 are ignored, feel free to use one texture for many meshes).
33 <br />
34 Keep in mind, when you've done your UV map in your model, you need to set this:
35 <br />
36 <br />
37 <img src="uploads/efee46a2a80a232ebe5fa63e30f4e2d9/Md3exp.png" alt="Md3exp" width="300" />
38 <br />
39 Texture must:
40
41 - be of **Image** type
42 - mapping type **UV**
43 - have UV map assigned
44
45 otherwise resulting data block will be filled with zeroes.
46 <br />
47 <br />
48 <img src="uploads/c48fb7565453eab24faca2d6ffec4347/Md3_textures.png" alt="Md3_textures" width="360" />
49 <br />
50 <br />
51 If you didn't this, the model will be invisible and it won't be able to interact shaders.
52 <br />
53 <br />
54 [Blender reference about UV in MD3](https://archive.blender.org/wiki/index.php/Extensions:2.6/Py/Scripts/Import-Export/MD3/)
55
56 # Starting to export
57
58 Keep in mind, you need to set these modifiers for the mesh/model object: 
59
60 <img src="uploads/447f6abe0f73c6d6cadce97e4ed66e8b/blendermodifiersiqmandmd3.jpg" alt="blendermodifiersiqmandmd3" />
61
62 MUST contain `tag_handle`, `tag_shell` and `tag_shot` bone names attached. These tag_names MUST be attached, if not the model will cause errors.
63
64 `tag_Somename` is another one, you can add if you need some optional animation in this bone.
65
66 Moreover, watch out about position and rotation. `h_*.iqm` alterates the position and rotation of `v_.md3`. The positions may not be equal.
67
68 ## SMD (includes IQM converter and dpmodel guide)
69
70 Use Source Tools to export the model. Selecting the mesh and 1 animation, ............ (Guide WIP)
71
72 ## MD3
73
74 Before to export, you need to select all objects in the scene. (Pressing A, seeing all objects highlighting orange or red)
75
76 <img src="uploads/f3f39c9a06a408bffd5e48bc5e07eac6/exporttutorialMD3.jpg" alt="exporttutorialMD3" />
77
78 ## IQM
79
80 Before to export, you need to select all objects and bones in the scene. (Pressing A, seeing all objects highlighting orange or red)
81
82 <img src="uploads/7df860d73a6fae27408c8f0c024122c7/exporttutorialIQM.jpg" alt="exporttutorialIQM" />
83
84 <br/>
85 <br/>
86 For `h_*.iqm`, you will need to do this:
87
88 There is a simple way:
89
90 You just can use an iqm model like a regular mdl file, you only need to use each frame as a framegroup.
91
92 For example, if you have an iqm called "rocketlauncher.iqm" with 20 frames you need to create a framegroup file with notepad like this:
93
94 ```
95 1 1 1 0  
96 2 1 1 0  
97 3 1 1 0  
98 4 1 1 0  
99 5 1 1 0  
100 6 1 1 0  
101 7 1 1 0  
102 8 1 1 0  
103 9 1 1 0  
104 10 1 1 0  
105 11 1 1 0  
106 12 1 1 0  
107 13 1 1 0  
108 14 1 1 0  
109 15 1 1 0  
110 16 1 1 0  
111 17 1 1 0  
112 18 1 1 0  
113 19 1 1 0  
114 20 1 1 0  
115 ```
116 So you will save it with the name.
117
118 "rocketlauncher.iqm.framegroups" and place it in the same directory where "rocketlauncher.iqm" is located.
119
120 About the framegroups file (explained on [Framegroups](framegroups)):
121
122 The first number represents the start frame of the animation (.framegroups files always start at frame 0, some modeling software starts at 1, so you might have to subtract 1 for the start frame).
123
124 The second number represents how many frames is in that specific frame group.
125
126 The third number is the frame rate at which the sequence plays. This is independent from what the monsters "think" rate is, which I have set at 10 frames-per-second.
127
128 The fourth number is whether the frame sequence loops. 1 for true, 0 for false. The only frame groups that should loop are the standing, walking and running animations.
129
130 It becomes very tedious to make framegroups for models with really many frames, you can use this sample generated for the darkplaces model compiler. It will work in every iqm model (if you wan you only need to cut the specific number of frames in the framegroups file, but it will work anyway)
131
132 Reference: [IQM animation framegroups (InsideQC Forums)](https://forums.insideqc.com/viewtopic.php?p=55949&sid=952cd347938ae5f2bb8bde276b5a35cd#p55949)
133
134
135 Sometimes, renaming formats can be useful to save effort. Note: it's a kind of weird way to do stuff, the issue of model resources was found here: https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/2629#note_686988936
136