Skip to content

Meshgroup Configuration

samyyc edited this page Nov 9, 2024 · 2 revisions

In CS2, a model may have multiple meshgroups. This feature allows your players to customize their model's meshgroup or force a meshgroup on a model.

Basic structure

"Models": {
    "model1": {
        "path": "xxx.vmdl",
        "xxx": "xxx", // other configuration
        "fixedmeshgroups": {"0": 1, "1": 1, "2": 0} // dict, int -> int
        "meshgroups": {
            "class": {
                "item": 0 // meshgroup index
            }
        }
    }
}

Meshgroup Index

Before you start to configure meshgroups for model, you need to know that what's the index of each meshgroup. I recommend using Source2Viewer to check it.

When you open a .vmdl_c file, it will display an interface like this. The red circle represents the meshgroup, and the meshgroup index refers to the sequence number of these meshgroups starting from 0 from top to bottom. For example, In this image, the index of ears_@0 is 0, the index of ears_@1 is 1, and so on. This picture will be used as an example in following docs.

Important

The last meshgroup should be autodefault, if this is turned off usually large parts of the model will be invisible. For this reason the plugin will automatically set it to on (which means you don't have to fix it in fixedmeshgroups config), but only if you don't allow users to customize it.

Important

If your model only have one meshgroup (likely named as autodefault), it's meaningless to customize to meshgroup because disabling it will only cause the model to be invisible.

Fixed Meshgroups

The configuration fixedmeshgroups is a dictionary, mapping int to int.

  • Key: meshgroup index ( due to the json syntax, it has to be wrapped with a double quote )
  • Value: 1 or 0 ( 1 = enable, 0 = disable )

Example

"fixedmeshgroups: {
    "0": 0,
    "2": 1
}

means force enable the meshgroup 0 (ears_@0 in the picture) to and force disable the meshgroup 2 (horn_@0 in the picture).

Warning

Make sure you don't set these fixed meshgroups in the meshgroups configuration as well

Meshgroups

This configuration allows the player to customize their models. It can be a bit complicated because it involves configuring the menu structure. Let's start with an example.

"meshgroups": {
"Headwear": {
  "Headwear1": 4,
  "Headwear2": 5,
  "Headwear3": 6
},
"Ear@radio": {
  "Show": 0,
  "Hide": 1
},
"Jacket@opradio": {
  "Jacket1": 8,
  "Jacket2": 9,
  "Jacket3": 10
},
"Presets@combination@radio": {
  "Suit1": [0,2,4,5,9,12,16,20,21,22,24],
  "Suit2": [0,2,6,10,13,16,24]
}
}

Let's start with the Headwear configuration. It represents a class of meshgroups, which will be categorized into a sub menu, and "Headwear" is the title. You can see that each sub-option of the Headwear submenu represents a meshgroup index, which means that the player can select any number of these headwear meshgroups or none. It's usually designed for those meshgroups that do not conflict with each other.

Then we move on to the Ears configuration, which is basically the same as the Headwear configuration, but it has a @radio label. This means that the player can only select one meshgroup in this subcategory, and cannot select none. It's usually designed for those 'on/off' meshgroups.

The Jacket configuration replaces @radio with @opradio which means "optional radio", the only difference is that you can select none. It's usually designed for those meshgroups that conflict with each other (like clothes).

The Presets configuration's sub-option is a list of meshgroup indexes because it has a @combination label. This means player can enable or disable multiple meshgroups at the same time. Generally it is a multiple choice. When player select it, all of the meshgroups in the list will be set to enabled, when player unselect it, all of these will be set to disabled.

But if you add a @radio label to it, Then you can only select one of these combinations of meshgroup. When player select it, all of the meshgroups in the list will be set to enabled, and all of the rest will be set to disabled. And player can't unselect it.

A simple version

If this is too difficult for you, you can also put all the options in a submenu, like in the example below. But please note that there are categories between meshgroups. If all meshgroups in a category are unchecked, it may cause part of the model to be invisible.

"meshgroups": {
"All": {
  "Ear": 0,
  "Jacket1": 8,
  "Jacket2": 9,
  "Jacket3": 10,
  "Headwear1": 4,
  "Headwear2": 5,
  "Headwear3": 6
}
}

Clone this wiki locally