# Boe6's vehicles: Rigging; Making meshes move

{% hint style="info" %}
The `.rig` file ("armature" or "skeleton") is what makes your mesh move in the game. You can find more information about that on the [meshes-and-armatures-rigging](https://wiki.redmodding.org/cyberpunk-2077-modding/for-mod-creators-theory/3d-modelling/meshes-and-armatures-rigging "mention") page.
{% endhint %}

Parts that require a `.rig` file will not import the same as other meshes. For example, the bumper’s 3D models are not positioned in-line with the `body_01` object in **blender**. Bumpers are centered around the **origin** of the 3D space. The part is then lined up correctly with the `.rig` file, which is linked in the `.ent` file.

To model the front bumper, we’ll first export the base game bumper as `.glb`, and import into our **blender** project. As you can see, the game model is positioned around the origin, unlike the custom bumper.

{% hint style="info" %}
If you already import the entire vehicle with the Blender script, you can skip some of this guide. Make sure to be extra careful about the object's origin, as that is what controls the rotation center. Read more below.
{% endhint %}

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-9b72f29058adecd228afe2652c47c1e1362f4515%2Fimage12.png?alt=media" alt=""><figcaption><p>Note the origin marker at the cross between the red and green axis lines.</p></figcaption></figure>

Move it with the move tool, so the corner of the bumper is at the origin and **apply all transforms**.

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-4c8eb3c1e75ba2f173a16da621bcb2c8b688b97f%2Fimage41.png?alt=media" alt=""><figcaption></figcaption></figure>

If you do not have the rig file already, you can now add it to the project. Open your vehicle’s `.ent` file and open this path: `RDTDataViewModel > components > deformation_rig > rig`

Add the file to the project, and rename/move it.\
Example: “`boe6\mini_cooper\boe6_mini_cooper.rig`”

Update the `.ent` rig path with the new file:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-af4892140c3b8d62d226b0b327f00eef4c5acd19%2Fimage210.png?alt=media" alt=""><figcaption></figcaption></figure>

You can also update the .rig path in your vehicle’s .anims file, as well as the rig references here:

* `.ent file > RDTDataViewModel > resolvedDependencies > 0 > .anims file path`
* `.ent file > RDTDataViewModel > components > vehicle_rig > animations > gameplay > 0 > animSet`
* `.ent file > RDTDataViewModel > components > deformation_rig > animations > gameplay > 0 > animSet`

Add it to your project, rename and move it as usual. Then in the `.anims` file, set the rig path to the new one we just created:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-e50105ca6e31a2d427b0126d8a4049c21f18979f%2Fimage156.png?alt=media" alt=""><figcaption><p><code>.anims file > RDTDataViewModel > rig</code></p></figcaption></figure>

Additionally update these paths to your `.anims` file.

Open the .rig file and notice these 3 arrays:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-383b8eda840ed69a864ccacf7ce48ca84c652896%2Fimage169.png?alt=media" alt=""><figcaption></figcaption></figure>

These map all the position data of each `.mesh` file.\
`boneNames` tells you which index value is each item, `boneParentIndex` tells you what each bone’s parent is (example; `wheel_back_left` is a child of `suspension_back_left`. If you change suspension position, wheel will move with it.), and `boneTransforms` is the positional and rotational values for each bone.

For a reference of where the bones are in a model, you can export the vehicle’s `.anims` file to `.glb` and import it into **blender**. You can select each bone to see their name and properties.\
Example:

<div><figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-24ffba4e80158acdad5bd764f22e82abedb2c930%2Fimage122.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-1bfd5ab1da887629e271227e0a5a21a5427fd112%2Fimage158.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Your `0,0,0` position should be in the center of the vehicle. Here is the translation data for each of the suspension wheels of a vanilla car (porsche):

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-be536a7bd7bdd08a898ae8e3038711fa1c5a21d0%2Fimage125.png?alt=media" alt=""><figcaption></figcaption></figure>

These are `frontLeft`, `frontRight`, `backLeft`, and `backRight` respectively. The Translation values are `XYZ` values:

* `(-) x` = left of car, driver side
* `(+) x` = right of car, passenger side
* `(-) y` = back of car
* `(+) y` = front of car
* `(-) z` = bottom of car
* `(+) z` = top of car.

It may help to visualize the car as if from a top-down ariel view, left is `-x`, right is `+x`, up is `+y`, down is `-y`.

You’ll need to update the `.mlmask` and `.mlsetup` files in these `.mesh` files as well, however they may show up at a different location. If they are not listed under “`localMaterialBuffer`”, check under the “`preloadLocalMaterialInstances`” array. The masks set should be in there instead.

Modify the existing `X Y Z` values for the bumper, changing one value at a time to see the amount changed. I suggest starting with a value of +/- 0.1.

For moving parts, such as hoods and doors, we start by replacing the 3D model. Notice the rotation point in-game is a pivot along the origin in 3d space:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-f06c30b5ce4d24a8114d5a7037c80c8117c2ed32%2Fimage10.png?alt=media" alt=""><figcaption></figcaption></figure>

In my case, I have my hood aligned forward, as the axis should be further behind in the real vehicle.

Your part will not align at first. If it is a large distance, try to adjust the 3D model first. Keep in mind the pivot will be the origin, so only adjust in the axis you can edit without messing with how the part will move(left/right for hood/trunk, up/down for doors). Once it’s close, you can adjust the `.rig` file as well to get it positioned correctly:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-4879be859632f970b875c2943faeb6d074febf2d%2Fimage134.png?alt=media" alt="" width="375"><figcaption><p>Before</p></figcaption></figure>

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-dc4de385b77bb4220f50c2b9adaccf20c7fa1ae8%2Fimage105.png?alt=media" alt="" width="375"><figcaption><p>After</p></figcaption></figure>

Swap the `.mesh`’s `.mlmask` and `.mlsetup` to the same as your `body_01` has set. (or to whatever other file you need)

You can also change how components are connected in the vehicle rig.

* For components that don’t have their own movement or bones, they are attached to another component that does. This can be changed to attach a model to another model’s movement.
* `.app` file “`RDTDataViewModel > appearances > 0 > components > entPhysicalMeshComponent > parentTransform > bindName`”\
  Example:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-dc314b335f6acdada0039498fc9c7ab0af6ba211%2Fimage149.png?alt=media" alt=""><figcaption></figcaption></figure>

* Components that do have their own bones are set to the bindName “`vehicle_slots`”, and their `slotName` is set to a `boneName` value in the `.rig` file.\
  Example of `body_01` in `.app`:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-22d5f207b95a2bc9043ca9433a6e4bca3d2f735f%2Fimage62.png?alt=media" alt=""><figcaption></figcaption></figure>

If a component is linked to another component, we cannot use the `.rig` file to move it. Instead, in the `.app` file is each component’s `localTransform`. This can be used to change the position and orientation relative to the parent component.\
Example:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-143da7597b2efd41818a8ad77d6acd716eb5a2fb%2Fimage214.png?alt=media" alt=""><figcaption></figcaption></figure>

Notice that the x,y,z position is saved as `Bits`, instead of as a `float`. To edit the positon data here, we need to convert from a float value to a fixed bit value.

{% hint style="info" %}
The latest release of Wolvenkit nightly seems to do the conversion automatically for you now.
{% endhint %}

The code for this conversion was written by *Loomy(Loomy#3375)* on the modding discord, [here.](https://discord.com/channels/717692382849663036/803201431657250857/817474706973392906)

This can be run in a python console:

* `int( ( n * pow(2,32) ) ) >> 15`

Where “n” is a float value.

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-c8b8de33a5d4948e61d0a2feb33324f7ac5d888a%2Fimage205.png?alt=media" alt=""><figcaption></figcaption></figure>

If you do not have **python** installed, you can try an online console, such as [here.](https://www.programiz.com/python-programming/online-compiler/) (paste the command into the “shell” side on the right, and hit enter)

Rigging wheels requires a 2nd `.rig` file that is used for vehicle handling. It is referenced here:

* `.ent file > RDTDataViewModel > components > vehicle_rig > rig (path to wheelbase rig)`

You can add this new rig to your project and rename/move it.

Notice that the new rig file only has wheel related bones:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-8fb96834ae89321265738df9ab6797d7ad1fc70e%2Fimage52.png?alt=media" alt=""><figcaption></figcaption></figure>

This is the rig file that is referenced for vehicle wheel handling. It controls where the wheels/suspension are located. This file overwrites the values in the `deformation_rig` created earlier.

To update the wheels, generally you want to modify the suspension bones. Since the `wheel_front_left`, `wingarm_front_left`, and `break_front_left` are all parented to `suspension_front_left`, updating the location for suspension also keeps the brakes and swingarms in the correct position relative to the wheel.

If the suspension values are updated/changed in the `vehicle_rig`, the `deformation_rig` may cause issues in some cases. To avoid this, rename the `boneNames` in the `deformation_rig` that are the same as the `vehicle_rig`. This ensures that the vehicle only uses the `vehicle_rig` values. Do not rename front wheel suspension in the `deformation_rig`, as it will break wheel turning.

{% hint style="info" %}
Some users report success with renaming and edits when only editing the Y value of suspension. X and Z changes will likely break vehicle turning. Try at your own risk.
{% endhint %}

For the **Mini Cooper**, I edited all 4 suspension positions in the `vehicle_rig` to update wheel positions, so I renamed the 2 front in the `deformation_rig` (excluding the front, as described above):

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-25d66ff68b6929440ca2d559b2ed8afedd0783f2%2Fimage64.png?alt=media" alt=""><figcaption></figcaption></figure>

You can update the wheels by first replacing all the wheel and tire meshes with ones to match your vehicle. This is similar to how the doors, windows, and hood function.

For the wheel to rotate properly, make sure to have the center of the wheel as the mesh’s origin.\
Example:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-fd8da7ffc3bdcd90c7508b10a5d799cf27eefa22%2Fimage44.png?alt=media" alt=""><figcaption></figcaption></figure>

Once the wheel model is updated, you need to update size data of the wheels.

This is set in your vehicle's tweaks. `vehWheelDimentionsSetup` contains both front and back settings. Update rimRadius, tireRadius, tireWidth, & wheelOffset to match your model's size.

{% hint style="info" %}
These values should match 1:1 with meters. \*not confirmed.
{% endhint %}

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-83d882b5842f484300629cd0a7d910cdd3d758e9%2FwheelDimensions.PNG?alt=media" alt=""><figcaption><p>Example base game vehWheelDimensions tweaks</p></figcaption></figure>

{% hint style="info" %}
Thanks to MAX\_SA5 for finding these controls!
{% endhint %}

Save and test!

{% hint style="warning" %}
Below is an older method which is no longer recommended. In all vanilla vehicles, the scale factor is set to 1.0 and is not used to control wheel size. CDPR (and myself) recommend using tweaks.

It has been kept documented here as a reference and for niche use cases.
{% endhint %}

As an additional method of controlling the wheel size, you can update the `.rig` files.

In both the `deformation_rig` and `vehicle_rig`, find the wheel bones (`wheel_back_left`, `wheel_front_right`, etc.) and update the `Scale` values.\
Example:

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-6e3ffff1f3622d55fdd0de66c80c2aebf48ef22e%2Fimage55.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-584b88d9417fce837c2662e1a78d5847ce66ef52%2Fimage13.png?alt=media" alt=""><figcaption></figcaption></figure>

The wheels should now be making proper contact with the ground!
