]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blobdiff - Exporting-a-weapon-for-Xonotic.md
Add details about Model scale animations problem
[xonotic/xonotic.wiki.git] / Exporting-a-weapon-for-Xonotic.md
index 02fce8f2003d95d187bebdb95ff9881c570a42d0..118164739c527808e49ed52e3e94e75e8d94b282 100644 (file)
@@ -1,9 +1,24 @@
-_This article looks complete, [old methodology](#old-methodology) isn't a very complete section due to  the obsolescence_
+_This article looks complete, [old methodology](#old-methodology) isn't a very complete section due to  the obsolescence._
+
+# _Table of Contents_
+> ### 1. [Modeling requirements](#modeling-requirements)
+> ### 2. [Introduction to export a weapon](#introduction-to-export-a-weapon)
+> ### 3. [Textures and UV map](#textures-and-uv-map)
+> ### 4. [Starting to export](#starting-to-export)
+> > 4.1. [Modifiers](#modifiers)<br/>
+> > 4.2. [Bones and animations](#bones-and-animations)<br/>
+> > 4.3. [Textures and materials](#textures-and-materials)
+> ### 5. [New methodology](#new-methodology)
+> > 5.1. [SMD (includes IQM converter and dpmodel guide)](#smd-includes-iqm-converter-and-dpmodel-guide)
+> ### 6. [Export troubleshooting](#export-troubleshooting)
+> ### 7. [Old methodology](#old-methodology)
+> > 7.1. [MD3](#md3)<br/>
+> > 7.2. [IQM](#iqm)
 
 # Modeling requirements
 ### To follow this, you need knowledge about modeling using Blender
 
-Blender version recommended: 2.79b or later
+Blender version recommended: [**2.79b**](https://download.blender.org/release/Blender2.79/) or [**later**](https://www.blender.org/)
 
 You need [dpmodel](https://icculus.org/twilight/darkplaces/files/) to convert SMD files:
 - [dpmodel tool](https://icculus.org/twilight/darkplaces/files/dpmodel20091008beta1.zip)
@@ -15,15 +30,15 @@ Requires these following tools (addons) for Blender:
 Optional:
 - [MD3 importer/exporter](https://github.com/neumond/blender-md3) to import/export MD3 files.
 
-***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/>
-*If the version of a file is later than 2.79b, we may to make some tweaks and become tedious.*
+***IMPORTANT NOTE**: if you want to contribute, it's strongly recommended using 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/>
+*If the version of a file is later than 2.79b, maybe some tweaks would need to take and would become tedious.*
 
 # Introduction to export a weapon
 **Keep in mind about weapon systems:**
 
 - `g_*.md3`: model mesh for item pickup spawn and third person.
 - `h_*.iqm`: for first person animations (if this step used [old methodology](#old-methodology) is a glue of `v_*`); 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)
-- `v_*.md3`: model mesh for third person; if `h_*.iqm` doesn't match with the animations needed of `v_*.md3`, it will generate spamming errors and bad pivot position.
+- `v_*.md3`: model mesh for third person; if `h_*.iqm` doesn't match with the animations needed of `v_*.md3`, it will generate spamming errors and bad pivot position (usually happens in the [old methodology](#old-methodology)).
 
 More info: [Weapon modeling system](Weaponsystem)
 
@@ -58,10 +73,14 @@ If you didn't this, the model will be invisible and it won't be able to interact
 
 # Starting to export
 
+## Modifiers
+
 Keep in mind, you need to set these modifiers for the mesh/model object: 
 
 <img src="uploads/447f6abe0f73c6d6cadce97e4ed66e8b/blendermodifiersiqmandmd3.jpg" alt="blendermodifiersiqmandmd3" />
 
+## Bones and animations
+
 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.
 
 `tag_Somename` is another one, you can add if you need some optional animation in this bone. (Not useful for [old methodology](#old-methodology))
@@ -70,28 +89,28 @@ Moreover, watch out about position and rotation. `h_*.iqm` alterates the positio
 
 `g_*` and `v_*` MUST contain one bone. The animations can't be included. It isn't like `h_*`.
 
-Required animations: 
+Required animations and in the correct order
 - `fire`
 - `fire2`
 - `idle`
 - `reload`
 
+## Textures and materials
+
 Please note that before exporting, about textures and materials, you have to assign the same as the script like this example shader file (`crylink.shader` file):
 ```
-crylink_new // your material/texture name
+crylink_new // your material name
 {
        dpreflectcube cubemaps/default/sky
        {
-               map textures/crylink_new.tga // your attached texture from Blender
+               map textures/crylink_new.tga // the texture you wanna display in-game, make sure to test in Blender!
                rgbgen lightingDiffuse
        }
 }
 ```
-Note: `crylink_new` must appear in the material and texture.
+Note: `crylink_new` must appear in the material.
 <br/><br/>Material:<br/>
-<img src="uploads/abef98eaddd7c61bec7eb467efe4c3fe/crylinkblendermaterialsample.jpg" alt="crylinkblendermaterialsample" width=500 />
-<br/><br/>Texture:<br/>
-<img src="uploads/ca88b1a8cbab9b9c5b81ef43bb9809f3/crylinkblendertexturesample.jpg" alt="crylinkblendertexturesample" width=500 />
+<img src="uploads/abef98eaddd7c61bec7eb467efe4c3fe/crylinkblendermaterialsample.jpg" alt="crylinkblendermaterialsample" width=920 />
 <br/>
 
 # New methodology
@@ -128,12 +147,32 @@ Save those compiled model files into `models/weapons/` folder where they belong.
 
 **Conclusion**: Sometimes, renaming formats can be useful to save effort. Note: it's a kind of weird way to do stuff, file formats are hardcoded in the gamecode rather than dynamically obtained. The issue of model resources was found here: https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/2629#note_686988936
 
+# Export troubleshooting
+
+- _**Spamming CSQC errors:**_<br/>
 If you received spamming errors like that:<br/>
 <img src="uploads/1f769ede89975be78d88eaad1b062a3d/spammingerrorstagweapon.jpg" alt="spammingerrorstagweapon" width=450 /><br/>
 It's because you didn't do correctly the steps after exporting the models. Remember, `g_*` and `v_*` MUST contain one bone. 
 
+- _**Broken shadow artifacts (enabled with `r_shadows 2` and disabled `r_shadow_shadowmapping 0`):**_<br/>
+To solve this, the possible way is exporting to IQM from Blender, selecting bone and mesh (both highlighted). Usually, this issue happens in `g_*` and `v_*` ones.
+<br/>Reference: https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/2667
+
+- _**When exporting to IQM, get duplicated names in the texture:**_<br/> 
+<img src="uploads/cdb90908aab4a52580019c871a936156/duplicatedtexturenameloadingerror.jpg" alt="duplicatedtexturenameloadingerror" width=700 /><br/>
+Take a closer look what is telling here:<br/>
+_The "Materials" option controls how material names are generated. "material+image-ext" combines the name of the material and the name of the UV-map image (without its extension or directory) to generate the material name, "material" uses only the name of the material, and "image" just uses the name of the UV-map image (without its directory)._ <br/><br/>
+When you export to IQM, you need to watch out that detail after selected File > Export > Inter-Quake Model (.iqm, .iqe).<br/>
+Pay attention to this [section](##textures-and-materials) when you need to export correctly, the material/texture(image) should be one thing, so do the following: Export IQM > Materials: > select `material` or `image` instead `material+image-ext`.<br/>
+<img src="uploads/4fa75dca8ebb724b89d5fd5513fd2787/exportiqmiqeblenderdetails.jpg" alt="exportiqmiqeblenderdetails" width=200 /><br/>
+
+- _**Model scale animations aren't working:**_<br/> 
+SMD format doesn't support bone scaling animations, although you try to compile them into dpmodel tool, it won't change nothing. More info here: https://steamcommunity.com/groups/BlenderSourceTools/discussions/1/152392786900223348/
+
 # Old methodology
 
+*Note: this section is obsolete.*
+
 **IMPORTANT**: In this methodology, you can't make cool animations with separated objects, because `h_*.iqm` here is a plane mesh with bones.
 
 Note: the model should be rotated as YXZ, instead being XYZ. Because the tip of the weapon is Y, horizontally is X.
@@ -146,6 +185,8 @@ Before to export, you need to select all objects in the scene. (Pressing A, seei
 
 <img src="uploads/f3f39c9a06a408bffd5e48bc5e07eac6/exporttutorialMD3.jpg" alt="exporttutorialMD3" />
 
+And export the model to MD3. _Attention: You can't export a model over than 8192 triangles/polys._
+
 ## IQM
 
 Before to export, you need to select all objects and bones in the scene. (Pressing A, seeing all objects highlighting orange or red)
@@ -154,9 +195,9 @@ Before to export, you need to select all objects and bones in the scene. (Pressi
 
 <br/>
 <br/>
-There's a post from InsideQC Forums explaining about IQM:
+For `h_*.iqm`, you will need to make a simple plane with a scale reduced to 0.01 and the following bones attached: `tag_weapon`, `tag_shell` and `tag_shot`.
 
-For `h_*.iqm`, you will need to do this:
+There's a post from InsideQC Forums explaining about IQM:
 
 There is a simple way:
 
@@ -200,7 +241,7 @@ The third number is the frame rate at which the sequence plays. This is independ
 
 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.
 
-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)
+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)
 
 Reference: [IQM animation framegroups (InsideQC Forums)](https://forums.insideqc.com/viewtopic.php?p=55949&sid=952cd347938ae5f2bb8bde276b5a35cd#p55949)