Creating Multiple Skins For A Model: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
Datiswous (talk | contribs)
m →‎Common Errors: better formatting
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Original_Reference|OrbWeaver|3098}}
The skins functionality in D3 allows a single model to have a number of textures ("skins") which can be selected from a dialog in the editor. This provides ease-of-use for mappers and provides a great variability for the models.


The skins functionality in D3 allows a single model to have a number of textures ("skins") which can be selected from a dialog in the editor. This provides ease-of-use for mappers and (possibly) reduced memory usage as the model only needs to be loaded once.
=File Structure=
An entry in the skin file has the following basic structure:
skin [name]
{
model [complete path of the model]
[name of material definition to be replaced]  [name of replacement material definition]
}


== Model your object in the usual way ==
'''TIP: You can view the skins that ship with the game in tdm_models_decls01.pk4\skins\'''
Model your object using your 3D application of choice. Here a simple pillar is being created.


[[Image:Skins1.jpg|300px]]
=Creating a New Skin=
The header has the format
skin [your_skin_name]
Your skin name has to be unique and (like all definitions in TDM) should not contain any hyphens (-).


== Default Skin ==
In the inner part of the brackets, you first define for which model the skin can be applied. If you do not define this, the skin will not show in the model menu in DR. Regardless, it can still be applied via the skin spawnarg. In this place you can define several models at once, if they share textures. Make sure to use the complete path inside the TDM folder and to include the file extension of the model. The easiest way to do this (and to avoid any spelling errors) is by inserting the model into DR and copying the "model" spawnarg to your skin file. Note that the file ending is not recognised if written in caps.
As usual, the model file points to the material paths that should be applied to that model in-game. This is the "default skin". In this example, I have given the model a default skin consisting of test colours only, to illustrate the process.


[[Image:Skins2.jpg|300px]]
In order to replace materials, you first need to know which materials are present in a given model. One easy way to do that is to open the model preview window in DR. On the left side, directly beneath the models list, there is a list of all materials used in the selected model. To replace one or several of these, you insert the whole path of the material you want to replace and, separated with a space (or for better readability a tab), write the path of the material you want as a replacement behind it. If you want to replace more than one material you can simply list the materials in the aforementioned style beneath each other. Each texture that gets not listed here, is not replaced. If you want any part of the model to not appear at all you can use the nodraw material ("textures/common/nodraw").


The material file for this is as follows:
=Common Errors=
sk/templecolumn1_gndsupport
If the model should appear completely black in game, this means that TDM cannot find your definition for the skin. Check for spelling errors! Similarly, if any part of your model appears black, the defined texture cannot be found. Keep in mind, that any custom texture you want to use has to have a material definition!
{
  {
      blend diffusemap
      map _white
      red 0.5
  }
}
sk/templecolumn1_pillar
{
  {
      blend diffusemap
      map _white
      red 0.0
  }
}
sk/templecolumn1_pillarbase
{
  {
      blend diffusemap
      map _white
      green 0.5
  }
}
sk/templecolumn1_topsupport
{
  {
      blend diffusemap
      map _white
      blue 0.5
  }
}


As you can see this model consists of four parts (submeshes), each of which can have its texture changed independently. This allows a greater variety of skins to be produced, just from stock textures.
Another reason could be that you used a number at the start of your skin-name. This does not work in tdm. You can use a number in the skin-name, but not at the start.


== Create the Skin File ==
If the skin does not show up as an option for your model, you have an error in the "model" line. Make sure you have included the file extension of the model and that this is in lower cases, as an upper case file extension might not be registered.
Now the .skin file is created. This is a simple declaration which substitutes new textures for the default ones ("sk/templecolumn_whatever"). It contains an optional model specification which allows the skin to be easily matched to the model.


skin templecolumn1_whitemarble
=Example=
{
Let's say you want to exchange one material of Springheel's module "mansion01_wall04", so the white part is stone instead.
    model models/custom/structural/column_pillar/templecolumn1.ase
    sk/templecolumn1_gndsupport textures/custom/marble/whitemarble
    sk/templecolumn1_pillar textures/custom/marble/whitemarble
    sk/templecolumn1_pillarbase textures/custom/marble/whitemarble
    sk/templecolumn1_topsupport textures/custom/marble/whitemarble
}
skin templecolumn1_whitemarble_vcol
{
    model models/custom/structural/column_pillar/templecolumn1.ase
    sk/templecolumn1_gndsupport textures/custom/marble/whitemarble_vcol
    sk/templecolumn1_pillar textures/custom/marble/whitemarble_vcol
    sk/templecolumn1_pillarbase textures/custom/marble/whitemarble_vcol
    sk/templecolumn1_topsupport textures/custom/marble/whitemarble_vcol
}
skin templecolumn1_speckedmarble
{
    model models/custom/structural/column_pillar/templecolumn1.ase
    sk/templecolumn1_gndsupport textures/custom/marble/whitemarble
    sk/templecolumn1_pillar textures/custom/marble/specked_marble
    sk/templecolumn1_pillarbase textures/custom/marble/specked_marble
    sk/templecolumn1_topsupport textures/custom/marble/whitemarble
}
skin templecolumn1_greystone
{
    model models/custom/structural/column_pillar/templecolumn1.ase
    sk/templecolumn1_gndsupport textures/custom/stone/crackedgreystone
    sk/templecolumn1_pillar textures/custom/stone/crackedgreystone
    sk/templecolumn1_pillarbase textures/custom/stone/crackedgreystone
    sk/templecolumn1_topsupport textures/custom/stone/crackedgreystone
}


Each skin has a name (which must be unique), a link to the model file, and a set of subtitutions in the form "old/texture/path new/texture/path". In this case the test colour textures are being replaced with stock textures that are already in my textures list, however they could just as easily be replaced by specific per-model skins or even nodraw textures if parts of the model should be hidden.
First, create a file named "stone_wall.skin" (or any other name) in the folder [your_FM]/skins and open it.
Then, create a skin entry:
<pre>
skin mansion01_stone
{
}
</pre>
(Make sure that the skin-name does not start with a number, because that won't work. So for example using ''01mansion_stone'' will not show up in tdm. You will see a black texture.)


Notice that the skin "templecolumn1_speckedmarble" is applying different textures to different parts of the model (the top and bottom square supports will get a whitemarble texture, whereas the round pillar will get a specked marble texture).


Save this file in the '''skins/''' folder with a .skin extension.
Personally, I would recommend to write the brackets right away, so you will not forget it later.
In order to show the skin in DR, give the complete path of mansion01_wall04, including its file extension:
<pre>
skin mansion01_stone
{
model models/darkmod/architecture/modules/interior_mansion01/mansion01_wall04.lwo
}
</pre>
As described before, the easiest way to find the material you want to exchange is to choose "Create model..." and search for the model you want to work on. In the "Choose Model" window, you can find all used materials in the model; in this case:


== Choose your Skin in the Entity Inspector ==
"textures/darkmod/wood/boards/white_painted_wood01"
When all is set up correctly, the skins become available in the Skin Browser, which is accessed by clicking the '''Skin...''' button in the Entity Inspector.


[[Image:Skins3.jpg|300px]]
"textures/darkmod/wood/panels/molding_walnut"


Notice how the model's alternative skins are automatically located and listed under Matching Skins, due to the existence of a "model" line in the skin declarations. If no matching skins are found, check that the model path has been entered correctly.
"textures/darkmod/wood/panels/panel_carved_rectangles_01_walnut"


== The finished Product ==
"textures/darkmod/wood/panels/walnut_panel01"


[[Image:Skins4.jpg|300px]]
"textures/darkmod/wood/panels/wood_walnut_panel02"


Note that the use of vertex colours is a stage-specific keyword, therefore this can be selected on a per-skin basis. This model has vertex colours which are applied in only one skin (second from left).
By unticking each "Visible" mark, we can see, which material we need. The white part is "textures/darkmod/wood/boards/white_painted_wood01". As a stone material I have chosen "textures/darkmod/stone/brick/blocks_brown". This will just be put into the next line (for better readability, I recommend to leave one line free in between) and we get:
<pre>
skin mansion01_stone
{
model models/darkmod/architecture/modules/interior_mansion01/mansion01_wall04.lwo


Note: You don't need modelling software unless
textures/darkmod/wood/boards/white_painted_wood01 textures/darkmod/stone/brick/blocks_brown
* You want to add vertex colours to modulate a texture or blend between textures
}
* You want to divide the mesh into submeshes in order to apply a different texture to each
</pre>
* You want to precisely fit a "trim" texture onto a specific part of the model (UV editing required)
When you want to test, if your skin is registered and works, you can update all existing skins in DR via File -> Reload Skins
* You need to determine the UV face layout, and this has not been provided by the modeller
 
= Wildcard skins =
 
If you want to replace every material on a model with the same material, you can use the * character (to mean "every material").
 
 
For example, this skin will turn any entire model to stone, regardless of what materials it used originally:
 
  skin all_dark_rough_stone {
  * textures/darkmod/stone/natural/dark_rough
  }
 
Another swap example, for an invisible skin:
 
  skin invisible {
  * "textures/common/nodraw"
  }
 
Or suppose you want to get rid of all decals on a model, say, for performance reasons:
 
  skin no_decals {
  textures/darkmod/decals/* textures/common/nodraw
  }


{{tutorial-models}}
{{tutorial-models}}

Latest revision as of 09:10, 12 April 2024

The skins functionality in D3 allows a single model to have a number of textures ("skins") which can be selected from a dialog in the editor. This provides ease-of-use for mappers and provides a great variability for the models.

File Structure

An entry in the skin file has the following basic structure: skin [name] { model [complete path of the model] [name of material definition to be replaced] [name of replacement material definition] }

TIP: You can view the skins that ship with the game in tdm_models_decls01.pk4\skins\

Creating a New Skin

The header has the format skin [your_skin_name] Your skin name has to be unique and (like all definitions in TDM) should not contain any hyphens (-).

In the inner part of the brackets, you first define for which model the skin can be applied. If you do not define this, the skin will not show in the model menu in DR. Regardless, it can still be applied via the skin spawnarg. In this place you can define several models at once, if they share textures. Make sure to use the complete path inside the TDM folder and to include the file extension of the model. The easiest way to do this (and to avoid any spelling errors) is by inserting the model into DR and copying the "model" spawnarg to your skin file. Note that the file ending is not recognised if written in caps.

In order to replace materials, you first need to know which materials are present in a given model. One easy way to do that is to open the model preview window in DR. On the left side, directly beneath the models list, there is a list of all materials used in the selected model. To replace one or several of these, you insert the whole path of the material you want to replace and, separated with a space (or for better readability a tab), write the path of the material you want as a replacement behind it. If you want to replace more than one material you can simply list the materials in the aforementioned style beneath each other. Each texture that gets not listed here, is not replaced. If you want any part of the model to not appear at all you can use the nodraw material ("textures/common/nodraw").

Common Errors

If the model should appear completely black in game, this means that TDM cannot find your definition for the skin. Check for spelling errors! Similarly, if any part of your model appears black, the defined texture cannot be found. Keep in mind, that any custom texture you want to use has to have a material definition!

Another reason could be that you used a number at the start of your skin-name. This does not work in tdm. You can use a number in the skin-name, but not at the start.

If the skin does not show up as an option for your model, you have an error in the "model" line. Make sure you have included the file extension of the model and that this is in lower cases, as an upper case file extension might not be registered.

Example

Let's say you want to exchange one material of Springheel's module "mansion01_wall04", so the white part is stone instead.

First, create a file named "stone_wall.skin" (or any other name) in the folder [your_FM]/skins and open it. Then, create a skin entry:

skin mansion01_stone
{
}

(Make sure that the skin-name does not start with a number, because that won't work. So for example using 01mansion_stone will not show up in tdm. You will see a black texture.)


Personally, I would recommend to write the brackets right away, so you will not forget it later. In order to show the skin in DR, give the complete path of mansion01_wall04, including its file extension:

skin mansion01_stone
{
model models/darkmod/architecture/modules/interior_mansion01/mansion01_wall04.lwo
}

As described before, the easiest way to find the material you want to exchange is to choose "Create model..." and search for the model you want to work on. In the "Choose Model" window, you can find all used materials in the model; in this case:

"textures/darkmod/wood/boards/white_painted_wood01"

"textures/darkmod/wood/panels/molding_walnut"

"textures/darkmod/wood/panels/panel_carved_rectangles_01_walnut"

"textures/darkmod/wood/panels/walnut_panel01"

"textures/darkmod/wood/panels/wood_walnut_panel02"

By unticking each "Visible" mark, we can see, which material we need. The white part is "textures/darkmod/wood/boards/white_painted_wood01". As a stone material I have chosen "textures/darkmod/stone/brick/blocks_brown". This will just be put into the next line (for better readability, I recommend to leave one line free in between) and we get:

skin mansion01_stone
{
model	models/darkmod/architecture/modules/interior_mansion01/mansion01_wall04.lwo

textures/darkmod/wood/boards/white_painted_wood01	textures/darkmod/stone/brick/blocks_brown
}

When you want to test, if your skin is registered and works, you can update all existing skins in DR via File -> Reload Skins

Wildcard skins

If you want to replace every material on a model with the same material, you can use the * character (to mean "every material").


For example, this skin will turn any entire model to stone, regardless of what materials it used originally:

 skin all_dark_rough_stone {
 	* textures/darkmod/stone/natural/dark_rough
 }

Another swap example, for an invisible skin:

 skin invisible {
 	* "textures/common/nodraw"
 }

Or suppose you want to get rid of all decals on a model, say, for performance reasons:

 skin no_decals {
  	textures/darkmod/decals/* textures/common/nodraw
 }