# Code-based and Animation-based pipelines

Source: https://wiki.cscdvmp.com/gde/code-based-and-animation-based-pipelines

## 1. Introduction

- **Code-based (CB)** and **Animation-based (AB)** are the two pipelines used to handle the visual side (model/animation) of the hand and gun objects in the main game.
- GDE is the supporting tool that lets anyone who wants to bring their own weapon into the game work with both pipelines quickly and correctly.

---

## 2. Characteristics

- The CB pipeline plays the core role in getting a weapon into the main game, covering the *minimum parameters needed for it to function*.
- CB gives a fast workflow, at the cost of "poorer" animation compared to the AB pipeline.
- The AB pipeline is the more complete approach, and depends partly on CB to work.
- AB gun/hand needs a detailed animation set (reload, chamber a round, draw the weapon, etc.), handled by the model/animation creator.
- CB can work without AB. Specifically: once a weapon meets CB's requirements, it can already function normally in the game (fire, reload, use attachments), but without AB it's missing the polished animations that give gunplay its real soul.
- During rapid testing, CB guarantees the weapon is functional, while AB is an important piece "added on later" that has a strong impact on the experience.
- For anyone who just needs to get their gun into the game, making sure the CB pipeline is complete is enough to cover that need.

---

## 3. Code-based Hand (CBH) and Code-based Gun (CBG)

- CBH is the *default* hand model, built directly into the game's package.
- CBG serves 2 roles: used in FPS view, and used as the weapon's "world model" (once it's dropped in the environment).
- CBH and CBG *share a single pivot*, both in-game and in the 3D software when exporting, forming one unified set.
- CBH is essentially the parent of CBG; the animations CBH plays are simply poses *matched onto* the CBG mesh.
- All CBH and CBG behavior is driven "procedurally" by the game's hardcoded logic.

### 3.1 CBH Animation

- CBH animation is a 1-frame animation type, existing as 3 poses:
    
    
    - Pose `normal`
        
        
        - Right hand grips the hand grip, index finger resting on the trigger.
        - Left hand grips the CBG's hand guard.
    - Pose `mount`
        
        
        - Right hand same as pose `normal`, while the left hand grips the CBG's magazine (if any).
    - Pose `shield`: the pose used while holding a ballistic shield.
- The game's hardcoded logic interpolates between these poses depending on the situation.

### 3.2 CBG Animation

- CBG has 3 animations, 2 of which are poses (1-frame) and 1 a regular animation:
    
    
    - Pose `original`: the default position when the CBG's bolt (if any) isn't cycling.
    - Pose `dry`: the position when the bolt is locked back, typically used for pistols or weapons with a bolt-lockback mechanism. If pose `dry` isn't provided, CBG falls back to pose `original`.
    - Anim `shoot`: the bolt runs through a full cycle, from its starting position, kicking back to the case-eject position, then returning to its starting position.

---

## 4. Animation-based Hand (ABH) and Animation-based Gun (ABG)

- In the 3D software (Blender), the hand and gun model/pose are created and worked on as *a single unified piece*, covering every combined animation required in [Modding Tools/GDE/Manual/Danh sách animation luồng AB](Modding%20Tools/GDE/Manual/Danh%20sách%20animation%20luồng%20AB). The game, however, treats them as 2 separate objects, ABH and ABG. This is because the attachment system needs a standalone ABG to mount onto.
- In practice, ABH and ABG play the same animation at the same time, creating the feel of them fitting together into one.

---

## 5. Relationship between the 4 components CBH, CBG, ABH, ABG

- For CB and AB to work correctly, the model/animation of both pipelines need to follow certain standards. See [Tiêu chuẩn animation cho CB và AB](Tiêu%20chuẩn%20animation%20cho%20CB%20và%20AB)
- Check the diagram below to get a clearer picture of the parent/child relationship as well as how these components operate in the codebase.  
    Character, Cam, Hand, Gun, Attachment Chain.canvas
