Creating Multiple Skins For A Model: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
RSoul (talk | contribs)
Destined (talk | contribs)
No edit summary
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 ==
=Creating a New Skin=
Model your object using your 3D application of choice. Here a simple pillar is being created.
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 (-).


[[Image:Skins1.jpg|300px]]
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.


== Default Skin ==
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").
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]]
=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!
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.


The material file for this is as follows:
=Example=
sk/templecolumn1_gndsupport
Let's say you want to exchange one material of Springheel's module "mansion01_wall04", so the white part is stone instead.
{
  {
      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.
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>
Personally, I would recommend to write the bracketts 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:


== Create the Skin File ==
"textures/darkmod/wood/boards/white_painted_wood01"
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
"textures/darkmod/wood/panels/molding_walnut"
{
    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.
"textures/darkmod/wood/panels/panel_carved_rectangles_01_walnut"


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).
"textures/darkmod/wood/panels/walnut_panel01"


Also be aware that you should not use hyphens (-) in the filenames of models or materials. Skins will show up in DarkRadiant but not in game.
"textures/darkmod/wood/panels/wood_walnut_panel02"


Save this file in the '''skins/''' folder with a .skin extension.
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


== Choose your Skin in the Entity Inspector ==
textures/darkmod/wood/boards/white_painted_wood01 textures/darkmod/stone/brick/blocks_brown
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.
}
 
</pre>
[[Image:Skins3.jpg|300px]]
When you want to test, if your skin is registered and works, you can update all existing skins in DR via File -> Reload Skins
 
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.
 
== The finished Product ==
 
[[Image:Skins4.jpg|300px]]
 
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).
 
Note: You don't need modelling software unless
* 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
* You want to precisely fit a "trim" texture onto a specific part of the model (UV editing required)
* You need to determine the UV face layout, and this has not been provided by the modeller
 
 
== Wildcard skins ==
 
(Note added by VanishedOne)
 
If you want to replace every material on a model with the same material, you can use the * character like this:
 
  skin all_dark_rough_stone {
  * textures/darkmod/stone/natural/dark_rough
  }
 
This skin will turn any entire model to stone, regardless of what materials it used originally.
 
{{tutorial-models}}

Revision as of 09:04, 28 October 2018

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] }

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! 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
{
}

Personally, I would recommend to write the bracketts 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