Using models in a mod is simpler than everyone makes it out to be. :-)
The hardest part is learning a good modeling tool like Blender.
Once you have most of the model drawn, create a Material and give it a meaningful name, then assign some polygons to it, according to the model's needs. Keeping only those polygons selected, do Unwrap -> Reset. Then, in the UV Map Editor screen, load an image, and Blender will assign it to the selected polygons. From there, move, rotate, resize, flip, and otherwise alter, tweak, and tune the UV shapes as needed, using the "textured solid" mode in the 3D View screen to preview the results.
Usually, I just add all the Materials and assign polygons in one go, after I've created the majority of the model geometry. Then I load and map images one at a time.
The UV mapping may be as simple or as complex as you please for each image. There's no real limit to the level of detail or complexity of your UV maps, other than your target audience's computing resources (and your personal preferences) regarding maximum image resolution, file size, polygon count, etc., just as long as you don't try to use more than 6 image files, since that's Minetest's limit.
Once you have the model looking right, export it to OBJ format. In Blender, use these settings during export:
Spoiler
Blender is all I know for this, so it's up to you to figure out your modeling program's equivalents, if you use something else.
Among your mod files, create a folder named
models/ in the top level, i.e. where
textures/ and
init.lua are, and put your model in there.
Then in your code:
Code: Select all
minetest.register_node("my_mod:cool_model_node", {
description = "My cool model node",
drawtype = "mesh",
mesh = "my_mod_cool_model_node_filename.obj",
tiles = {
"my_mod_cool_model_node_first_material_texture.png",
"my_mod_cool_model_node_second_material_texture.png",
-- ...and so on
},
paramtype = "light",
-- .. and then all the rest of the usual node def. stuff, as necessary for your node
})
Minetest does
not use any texture images or texture information embedded in the model file, i.e. the above settings will create an untextured model. You supply the texture files to be applied via your code, as implied above. If it isn't already obvious, the usual +X, -X, +Y, ... convention has no meaning here. :-)
The Material order in the exported model determines the order of the filenames in the
tiles entry in the node definition. Blender can be a little unpredictable in this regard, so use a text editor or
grep or something to search inside the OBJ file, for "
g " (one space).