Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coderskins
- Coderskins manages setting skins in Bucket_Game. However, it is also an asynchronous framework for overlaying multiple textures onto a player's
- character model. Coderskins is compatible with both rectangular and square (2-layer) skins and automatically detects the ratio. (Presumably in September
- 2021 releases or later:) It also allows applying a mask, badge, or other "decal" onto the second character layer or even over the armor layer.
- Compatibility with 3d_armor:
- - A modified version of 3d_armor (presumably available in September 2021 or later releases of Bucket_Game) utilizes coderskins, so that version of
- 3d_armor should be used to ensure that mods don't fight over what textures to apply, and to ensure compatibility with both rectangular and square
- (2-layer) skins.
- - You can choose whether the decal is over or under the armor by way of the texture's resolution (See "Designing accessories")
- ## Designing accessories
- - Place items that are close to the body in any of the 2nd-layer area(s) of a square (64x64) image (search for 1.8 skin guide online).
- - Leave other areas (first-layer areas) transparent otherwise there will be visual glitches due to "z-fighting": glittering or flashing glitches.
- - Place items that should appear on top of the armor in a rectangular (64x32) texture. See
- [modern_armor/3d_armor_character.md](https://github.com/poikilos/modern_armor/blob/main/modern_armor/3d_armor_character.md) in Poikilos' modern_armor
- repo (Use the [64x32 template](https://github.com/poikilos/modern_armor/blob/main/modern_armor/projects/3d_armor_template-rect-64.png) but you can refer
- to the [oversized guide image](https://github.com/poikilos/modern_armor/blob/main/modern_armor/projects/3d_armor_template-rect-512.png) that is enlarged
- only to fit descriptive labels).
- - Put the word "badge" in the filename to guarantee that the texture will appear over the armor.
- - The armor covers the right appendages and several faces are mirrored on that side and forward on the left.
- - See the music badge code for an example of code that uses coderskins to make an accessory that isn't a 3d_armor accessory.
- - For 3d_armor accessories, use the 3d_armor documentation.
- - The texture string must be either a plain texture filename; or a filter where the second `^`-separated substring is a plain texture filename and the
- first substring contains "transparent" or "trans.png". This filename must start with the name of the mod where its textures directory resides (for
- example: "3d_armor_helmet_gold.png" residing in "3d_armor/textures/"), unless the texture is in "coderskins/textures" since that is the fallback
- directory. This is necessary since Minetest must know the full path of an image file to obtain its dimensions.
- ## Development
- This section explains how to add or maintain character meshes or coderskins code.
- #### What are material IDs?
- An object can have multiple materials so that different parts of it can have different textures that do not intersect. This is useful for variety, for
- making square textures that apply to oddly-shaped objects, or for adding parts to a model when the texture is already filled (such as when backward
- compatibility or resolution prevents reworking its UVs to make space). The material stores UVs. The UV map describes which parts of the texture go on
- which parts of the object. Even if there is only one material, the texture or modified texture is in an ordered table in the entity. An entity's
- "textures" property stores entries that correspond to the material IDs in the model. Each entry is either a texture filename or modified texture string
- (See [Texture modifiers](https://git.minetest.org/minetest/minetest/src/branch/master/doc/lua_api.txt#L407) in lua_api.txt).
- #### Apply a texture to a model
- Lua code using the Minetest API specifies which texture(s) to apply to the model (Minetest uses the material but not the texture filename if any in a 3D
- model file). The 3D model file specifies which material ID applies to which subset of faces on the model.
- #### What material IDs does a character model need?
- The character model in Bucket_Game is moving toward the following standard order of material IDs: `{skin_ratio_2, armor, wielditem, skin_ratio_1}`. In
- other words, armor will be included in the default character model file. No matter what you do, the character model would always be that in Bucket_Game
- (presumably September 2021 or later releases) (or `{skin_ratio_2, armor, wielditem}` in the stujones11 version of the model). In previous releases, the
- order is `{skin_ratio_2, skin_ratio_1}` (armor applied manually on top of the skin), so `skin_ratio_1` is being moved to the 4th ID to make room for
- compatibility with the three 3d_armor IDs (The 2nd and 3rd are 3d_armor specific).
- However, the modified 3d_armor in Bucket_Game (as planned as of September 2021) uses coderskins, so as long as coderskins is consistent with whatever
- model is being used, the mod calling 3d_armor or coderskins will work (The API is backward compatible). To maintain backward compatibility with mods
- that do not utilize the 3d_armor API, keeping at least the first 3 elements the same is advisable. To be compatible with square skins and current plans
- for coderskins, the model must have 4 material IDs and be in the order above (A Minetest character model editing tutorial for Blender is at [Minetest
- with Minecraft 1.8 Square Textures - Player Character Model Editing](https://www.youtube.com/watch?v=eiG_IvsFQq4) on YouTube,
- [Odysee](https://odysee.com/@Poikilos:a/2021-09-02-Minetest-with-Minecraft-1.8-Square-Textures---Player-Character-Model-Editing:6) or
- [LBRY](https://open.lbry.com/2021-09-02-Minetest-with-Minecraft-1.8-Square-Textures---Player-Character-Model-Editing:68687ab1b4d5c4d68305eeee1785f09fa7eb93c2)).
- There is "armor" in the model itself. Not conceptually, physically: Each of the 4 IDs is a physically different part of the model. No matter what you
- call it, it will always be `{skin_ratio_2, armor, wielditem, skin_ratio_1}`. If you say `textures = {foo, bar, bologna, cheese}`, the resulting behavior
- is:
- ```
- skin_ratio_2 = foo
- armor = bar
- wielditem = bologna
- skin_ratio_1 = cheese
- ```
- The model itself has 4 IDs which are called "material IDs" in 3D graphics, and correspond respectively to the 4 indices of the textures table. In
- Blender, the material IDs are assigned to:
- - [1] classic-style body mesh & hat layer with right appendages being mirrored from the left (rectangular texture)
- - [2] armor (floats outside of body by about .03 Minetest meters (.3 Irrlicht units); and shield square in the player's left hand)
- - [3] wielditem (It is a square in the player's right hand.)
- - [4] The mesh (new Sep 2021) matches the specs of square skins: a copy of [1] that only uses the top half of the texture, and a new mesh that is only
- slightly raised from the surface in every direction, like the armor but less--about .02 meters (.3 Irrlicht units)
- #### Automatic Square Skin Detection
- ID 4 is for a rectangular texture, but isn't used for overlays. When a square skin is used, it is used for ID 4.
- - When the texture ratio is 1:1 (64x64 square):
- - A transparent texture is placed on ID 1.
- - A 1:1 texture is placed on ID 4.
- - A 1:1 decal is placed on ID 2 (over the skin)
- - Only use the areas marked 2nd layer on a skin guide for the decal if the decal is square (See "ID 1 is not compatible with the ID 4." below).
- - When the texture ratio is 2:1 (64x32 rectangular):
- - A transparent texture is placed on ID 4
- - A 2:1 skin is placed on ID 1.
- - A 2:1 decal is placed on ID 2 (over the armor).
- #### ID 1 is not compatible with the ID 4
- The reason that the first ID isn't used for overlays is that the layer isn't used when a player is using a square skin. It can't be since it is
- co-planar with the first layer portion of the square skin mesh. Co-planar visible parts generally would cause visible "z-fighting". The first is usable
- only for a skin and is: See "Automatic Square Skin Detection" below). The problem with using the armor layer for a mask is that is that it is raised too
- much. For that reason, a rectangular overlay would be good for things like a badge but not a mask.
- Ways to allow decals on the first layer:
- - Convert all rectangular skins to square skins in real-time using a long series of transforms (See <https://imgur.com/a/hfaqL> for human-readable
- steps) and never use the first material ID (cut it down to a single plane or something to reduce the file size but don't delete it since the material ID
- order must be preserved).
- - Slightly inflate the ID 4 model's first layer so that it is just slightly higher than the material ID 1's, such as by 0.01 Blender units (0.001
- Minetest meters) to make ID 4 compatible with ID 1 (prevent z-fighting).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement