Skip to content

Commit 2a0a16b

Browse files
[Anims] Index rewrite, MMS and naming (#156)
* [Anims] Index rewrite, MMS and naming * Fixes * Add animation decompiler to gothic sourcer * fix: tests to handle some edge cases * Fix typos * Change SPD description --------- Co-authored-by: Kamil Krzyśków <kamilzary@gmail.com>
1 parent 4824b2c commit 2a0a16b

9 files changed

Lines changed: 476 additions & 110 deletions

File tree

docs/zengin/anims/.pages

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
nav:
2+
- naming.md
23
- ...
4+
- events.md
35
- tutorials

docs/zengin/anims/events.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ General Syntax:
6161
| [eventSFX](#eventsfx) | create sound effect |
6262
| [eventSFXGRND](#eventsfxgrnd) | create sound effect on the ground |
6363
| [eventTag](#eventtag) | generic event, does action specified in parameters |
64-
| Defined in engine but never used ? | |
6564
| [eventPFXGRND](#eventpfxgrnd) | create particle effect on the ground |
6665
| [eventSetMesh](#eventsetmesh) | ? |
67-
| [modelTag](#modeltag) | same as eventTag, but applies to morphmesh? |
66+
| [modelTag](#modeltag) | same as eventTag, but applies to all amiations in aniEnum |
6867

6968

7069
### eventCamTremor
@@ -125,7 +124,7 @@ Syntax:
125124

126125
Both `INTENSITY` and `HOLD_TIME` can be specified in the MMS script. All gothic morph meshes specify those values in .MMS, therefore behavior when both specified in eventMMStartAni and .MMS file is unknown/untested
127126

128-
## eventPfx
127+
### eventPfx
129128

130129
Start particle effect at the specified bone.
131130

@@ -155,7 +154,7 @@ Syntax:
155154
`ATTACH` is used to create demons burning hand during the attack, while without this keyword dust particles are made to stay at the position where NPC landed after falling.
156155

157156

158-
## eventPFXStop
157+
### eventPFXStop
159158

160159
Stops particle effect previously started by [eventPfx](#eventpfx)
161160

@@ -177,7 +176,7 @@ Syntax:
177176
`PFX_HANDLE` - an integer value. *Handle* of the particle effect, that should be destroyed. Particle effect must be spawned using the same handle by [eventPfx](#eventpfx) first
178177

179178

180-
## eventSwapMesh
179+
### eventSwapMesh
181180

182181
Move mesh from source `NODE` to target node. Item should be present in the node already. Only mesh of the Items is moved, engine internally still keeps a reference to items in the original slot? Never used in game?
183182

@@ -201,7 +200,7 @@ Syntax:
201200
!!! Note
202201
In some rare occasions duplicates item
203202

204-
## eventSfx
203+
### eventSfx
205204

206205
Play sound effect. It can be either `SFX` instance from scripts, or `.WAV` file.
207206

@@ -230,7 +229,7 @@ Syntax:
230229
A lot of original game animations contain `EMTPY_SLOT` instead of `EMPTY_SLOT` which was probably unintended. Gothic therefore acts as no keyword was provided, which causes a lot of sound interruptions. Therefore be mindful of spelling when copying original MDS scripts
231230

232231

233-
## eventSfxGrnd
232+
### eventSfxGrnd
234233

235234
the same as [eventSfx](#eventsfx) with only one difference, the sound effect name is appended with the current material name.
236235

@@ -263,7 +262,7 @@ Depending on the material of the texture, the character is standing on, the game
263262
NPC running on grass texture, with material set to EARTH in world editor, will play sound `Run_Earth` by using `*eventSFXGrnd (12 "Run")` in run animation. `_Earth` suffix is determined and added by the engine.
264263

265264

266-
## eventTag
265+
### eventTag
267266

268267
This is a generic type of event that does different actions based on the first parameter after the frame parameter. It was probably later in development to extend MDS functionality without the need to expand parser itself.
269268
All parameters except `FRAME` are passed inside quotes Further parameters are specific for every `EVENT_TAG_TYPE`.
@@ -848,27 +847,25 @@ ani ("s_1hAttack" 1 "s_1hAttack" 0.0 0.1 M. "Hum_1hAttackComboT3_M05.asc
848847

849848

850849

850+
### eventPfxGrnd
851851

852-
853-
## eventPfxGrnd
854-
855-
Not used anywhere in the original game. Could possibly spawn particle effect like [eventPfx](#eventpfx) but with an added suffix similar to how [eventSfxGrnd](#eventsfxgrnd) works. Needs to be investigated.
852+
Not used anywhere in the original game. Probably meant to spawn particle effect like [eventPfx](#eventpfx) but with an added suffix similar to how [eventSfxGrnd](#eventsfxgrnd) works. In practice, it does nothing.
856853

857854
Syntax:
858855
```dae
859856
*eventPFXGRND (FRAME)
860857
```
861858

862-
## eventSetMesh
859+
### eventSetMesh
863860

864861
Unknown
865862

866863
Syntax:
867864
```dae
868-
*eventSETMESH (FRAME "NODE_NAME")
865+
*eventSETMESH (FRAME "ASC_NAME")
869866
```
870867

871-
## modelTag
868+
### modelTag
872869

873870
Should work similarly to [eventTag](#eventtag), but can be defined inside aniEnum block and applies to all animations of the Model.
874871

docs/zengin/anims/index.md

Lines changed: 75 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,93 @@
11

22
# Animation
3+
Animations in ZenGin consist of animation files and animation scripts. Working with them requires deep understanding of the architecture and concepts. This section provides information necessary to effectively work with animations within the engine.
34

5+
## Types
6+
There are two main types of animations - `skeletal` and `morphmesh`. Skeletal animations are used for animating characters and objects with a skeleton, while morph mesh animations are used for animating facial expressions and other models that require vertex-based deformations.
47

5-
# Animations in ZenGin
6-
Animations are (apart from maybe advanced programming work using Ikarus or Union) one of the most advanced modding techniques, since you not only must understand the way they work, but also know how to write the animation script and understand the whole scheme selection system, naming convention and of course know how to animate (that is my biggest problem :D). To get a new animation into ZenGin (the Gothic engine) is not difficult per se, I would describe it as tedious.
8+
## Formats
79

8-
Luckily, there are tools to help us to achieve our goal - get a new animation to be used by the engine, and in effect, to be used and seen in the game.
10+
### Raw
911

10-
To describe the whole process, I constructed this small tutorial, to help other people to get animations working and to spare them many hours of searching the excellent forum posts, that describe parts of the process.
11-
__
12+
**Animation files**
1213

13-
Excluding advanced programming work with Ikarus or Union, animations are arguably the most advanced modding discipline of ZenGin engine. Its difficulty stems for the fact that you not only have to understand the general concept, but also learn how to write the animation scripts and understand the whole scheme selection system, including naming conventions and, most important for last - actually know how to animate. Adding new animations into ZenGin is more tedious than actually difficult.
14+
ZenGin uses the `.ASC` file format for raw animation files. Following things could be saved as the `.ASC` file:
1415

15-
There are tool to help with this endeavor - to get a new animation implemented in the engine, and seeing its effects in game. Following tutorial has been constructed to help others to get their animations working without having to scour old forum posts for hours.
16+
- Animation model (skeleton + skin or morph mesh)
17+
- Actual animation data (keyframes)
18+
- Animation targets (like doors, beds etc.)
1619

17-
## Prerequisites - Tools & Materials
18-
1. Gothic Mod Development Kit (MDK)
19-
- Gothic 1 MDK - [link](https://github.com/PhoenixTales/gothic-devkit)
20-
- Gothic 2 MDK - [link](https://www.worldofgothic.de/dl/download_94.htm)
21-
2. [Blender](https://www.blender.org/)
22-
3. [Kerrax's Import Export plugin](https://gitlab.com/Patrix9999/krximpexp) - follow the installation instructions to install the plugin, make sure to set up the texture paths too
23-
4. Tool for decompiling animations [GothicSourcer](https://worldofplayers.ru/threads/41942/), or use [phoenix](https://github.com/lmichaelis/phoenix) or write your own using [ZenLib](https://github.com/Try/ZenLib)
2420

21+
The `.ASC` files can be imported into blender using the [KrxImpExp](#krximpexp) add-on.
2522

23+
**Script files**
2624

27-
## The workflow
28-
This is the basic step-by-step workflow on how to get the animation into the game.
25+
Every animated model in ZenGin has its own animation script file with the `.MDS` extension for skeleton based models and `.MMS` for morph mesh based models. These files are used to define animation data. You can find more about these files in the [MDS](mds.md) and [MMS](mms.md) sections.
2926

30-
1. Load the actor (character or object) into your 3D software
31-
2. Create your animation
32-
3. Export the animation as an `.asc` file
33-
4. Write the MDS file
34-
5. Run the game to compile your animations
35-
6. Test your animations in-game using a Daedalus script or a console command
27+
### Compiled
28+
Raw formats are great for editing, but can be a bit heavy for the engine use (ASCII based formats are slower to parse and work with), because of that ZenGin compiles these animations into various internal formats.
3629

37-
Sounds simple enough, except there is a lot missing. Even though the steps start with loading the actor into blender, understanding the system of animations to get high quality assets into your mod is more important.
30+
| Format | Extension | Content |
31+
|--------|-----------|-------------|
32+
| Model Animation | `.MAN` | Single animation data |
33+
| Model Hierarchy | `.MDH` | Skeletal structure and slots for a model |
34+
| Model Mesh | `.MDM` | Softskin mesh and proto mesh structure for a model |
35+
| Model | `.MDL` | `.MDH` + `.MDM` combined |
36+
| Model Script | `.MSB` | Compiled version of the `.MDS` file |
37+
| Morph Mesh | `.MMB` | Morph mesh with its mesh and animation data |
3838

39-
## Animation "types"
40-
There are two main types of animations - `skeletal` and `morphmesh` animations. Character body animations are skeletal, and we animate the skeleton and the entire model (skin) moves around it. Morph mesh animation is, on the other hand, used for facial animations such as eating, blinking or talking and for animated meshes like wave water ferns or fish in Khorinis' harbor.
4139

42-
This guide focuses on skeletal animations. There are few different ones, all of which will have their own demonstration in the future. Categories are:
4340

44-
1. Standalone animation - waving, bowing, eating
45-
2. MOBSI animations - bed, alchemy table, anvil
46-
3. Item animations - sweeping the floor with a broomstick, using the horn, playing the lute
47-
4. Mandatory animations - running, walking, sneaking
48-
5. Combined/interpolated animations - picking stuff up, aiming with a bow/crossbow
41+
## Engine compilation
42+
By default, animations are compiled by the engine when the model appears in the game or a game is started with `-zconvertall` parameter.
4943

50-
All of these animations are defined in an MDS file which will be talked about in the next sections.
44+
!!! Danger
45+
If you want to recompile animations, make sure that the `.MSB` or `.MMS` files are deleted, including the ones in the VDF volumes, otherwise the engine will not recompile them.
46+
47+
### Graphical overview
48+
49+
A star `*` means that multiple files could be used/generated.
50+
51+
<div class="grid" markdown>
52+
53+
=== "Skeletal Animation"
54+
``` mermaid
55+
flowchart TD
56+
A[Model .ASC] --> D(Compilation)
57+
B[Animation .ASC *] --> D
58+
C[Model Script .MDS] --> D
59+
D --> E[Compiled Model Script .MSB]
60+
D --> F[Model Animation .MAN *]
61+
D --> G[Model Hierarchy .MDH]
62+
D --> H[Model Mesh .MDM]
63+
```
64+
65+
66+
=== "Morph Mesh Animation"
67+
``` mermaid
68+
flowchart TD
69+
A[Model .ASC] --> D(Compilation)
70+
B[Animation .ASC *] --> D
71+
C[Morph Mesh Script .MMS] --> D
72+
D --> E[Morph Mesh .MMB]
73+
```
74+
75+
</div>
76+
77+
78+
## Tools
79+
80+
### KrxImpExp
81+
Blender add-on that implements support for Gothic 3D formats.
82+
83+
[:fontawesome-brands-gitlab: GitLab](https://gitlab.com/Patrix9999/krximpexp)
84+
85+
### Gothic Sourcer
86+
Tool for decompiling animation files.
87+
88+
[:octicons-arrow-right-24: Read more](../tools/gothic_sourcer.md)
89+
90+
### ZenKit
91+
C++ Library for loading and saving various ZenGin files (including some animation formats).
92+
93+
[:octicons-arrow-right-24: Read More](../tools/libraries/zenkit.md)

0 commit comments

Comments
 (0)