Darkage, Caverealms and Default examples
Creates furniture collections
- Simplifies the process of registering model-based nodes over many materials at the same time
- Introduces the furniture type definition, which defines a single furniture piece in a manner that is scalable over materials
- Allows for creation of furniture sets, which control registration over materials
- Implements interactivity trough node swapping
- Handles inventory registration and interaction, only the number of inventory rows need to be specified
- Can generate Locked variants of interact-able pieces automatically
- Requires only a single block/tile-format texture to produce a shaded model — This is due to the UV mapping of the model, I’ll show you how to replicate that later on
- Supports texturing a piece using multiple textures
- Easily creates furniture for other mods
Links:
Download
Browse Code
ContentDB
Introduction
This mod stems from the development of [edgy-dark-ominous-game] (placeholder name, misleading). I have noticed the possibility to tweak the mod a bit in order to make it capable of handling cases which are probably going to be absent from our game, such as node swapping and inventory capability at the same time (like in the case of default chests).
I did not use most of the options present for furniture registration, but you’ll be able to figure out how to make furniture from the present examples. I’ll go trough some of the concepts and examples below as well.
Apart from that, I’ll also explain the methods by which I made the models. Some of you will have more time, patience and experience on your hands to make better models than I did so I want to provide you with some suggestions, or a start.
A library, the windows come with caverealms lite
But before we dive into the technical part (and for those that are only interested in the present content), here is a brief overview of what is included in the mod: Let me introduce you to the three families of furniture models: woodlike, stonelike and glasslike. I’ve made these up using some common sense, and some lack of it at the same time. And that is because of simplification, we agree that materials such as stone and desertstone will have more similar models than wood and desertstone, or especially glass.
The families stonelike and woodlike mirror each other, each piece in one has a counterpart in the other. Glasslike on the other hand only has a small subset of these. Some models are nevertheless shared between stonelike and woodlike. This resulting population of the families is such due to my prioritization, some models I just deemed not important enough to create.
Glasslike is the smallest family and consists of chair, square table, round table, door, flipped door (has the handle on the other side). It is made exclusively out of planes, its a stylistic choice that also happens to be good for the framerate.
Woodlike and stonelike have the same models as glasslike, plus additionally: shelves (small and wide), window, cabinet, half cabinet, wardrobe, mirror (shared), flowerpot (shared), door (shared), flipped door (shared).
As of writing this there also exists a bookshelf (and the wide variant) in the woodlike collection, stone variant is pending. The filled shelves are really easy to register and I’ve provided blueprints that you can use to doodle your own shelf fillings. Which I recommend because it is relaxing to do. A *very* quick build for demonstration
Yes, you can just run this mod over any material and it’ll generate a set of furniture, provided that you’ve got a proper texture for it. Should you have a bunch of furniture nodes for every wood/stone type like this? Debatable.
I’ve made sure to register as many nodes that make sense in minetest_game, though there is nothing stopping you from making cactus furniture for your game. Caverealms LinkSorry if the colorscheme strains your eyes
This is where I did the testing for glasslike models, those crystal textures look really good on window frames. We got a similar situation over in our game (though different crystal textures). Apart from the crystals I’ve registered the furniture for glowing obsidian and obsidian glass, they inherit the glow as well. Darkage LinkVery dark indeed
Darkage has basalt and marble furniture. Both came out pretty well, but the highlights are most likely the different types of medieval glass windows. Dwarf Fortress Caverns LinkYes, a full furniture collection for each of those chairs
Slate furniture, also crystals. But that is, again, not the highlight. Because I’ve come up with an approach for making wood textures that fit the required form for furniture, out of any wood texture (they look passable). So I’ve made furniture for all the wood types in this mod, that’s 10 sets of wooden furniture. .xcf files included with the mod.Ethereal LinkThis image is actually flipped, and yes, a furniture collection exists for each chair color
Ethereal also has a lot of wood types which I’ve made furniture textures for. Though, the uniqueness of original textures (in both resolution and appearance) has not been fully transferred to the furniture versions. I did set the resolution of all the textures to 16px. Apart from wood I’ve registered furniture for the blue marble (which seems to be 32px and my eyes don’t like that). Moreblocks LinkIt is indeed an ugly dungeon
The stone tile texture from moreblocks is a very well fitting texture for my furniture models. Another one that I’ve registered is coal stone bricks, showing off the little texture splicer which I’ve coded for this occasion. It turns brick-format texture into a tile-format. I’m not a fan of the high-contrast result on this material though.
The (super)glowing glass windows are also present. Technical Info A piece of furniture (type, in the code) is defined as a key-value table. If you have registered any nodes in minetest before, some of these will be familiar to you:
Code: Select all
{
— name - code name
— base - base model, no file extension (leave empty if same as name)
— description - description prefix
— active [true/false] - does this node swap with a different version when right clicked
— special_materials - materials other than base, used for crafting (optional, order important)
— special_textures - textures other than base (optional, order important)
— special_textures_activated - textures other than base for the activated model (optional, order important)
— storage - number of rows of inventory, 8 slots each (optional)
— generate_locked [true/false] - do the locked versions of the node generate (optional, only works if there is storage or node is active)
— box - both the selection and the collision box
— box_activated - both the selection and the collision box for the activated counterpart
— activate_sound - table containing the default and mod-material-specific sounds that play upon activation
— deactivate_sound - table containing the default and mod-material-specific sounds that play upon activation of the active counterpart
— groups - groups which are added to the groups table of the resulting node, can override base node’s groups (optional)
— groups_active - groups which are added to the groups table of the active node, can override base node’s groups (optional)
— crafting - an array where each position corresponds to a cell in the crafting grid, values represent materials; 0 is empty, 1 is base and
— above are the other materials in the order from special_materials
— The following overrides can be applied to the base node, and/or to the active node by appending the _active suffix (all optional):
— light_source, visual_scale, post_effect_color, walkable, pointable, diggable, climbable, move_resistance, buildable_to, floodable, drowning, damage per second
},
another model named name + “_activated” to which your piece will swap upon activation.
A set is a collection of pieces, a table containing the names of pieces. When registering furniture for a material, you give the function a set to tell it which pieces to generate for that material.
So when you’ve made the models, you just need to make a table which will contain their definitions. I’ve done this a couple of times for the mod support (check out register.lua), you’ll need to:
- Make the table of pieces
- Append the table to the furniture.types, using furniture.table_append()
- Make a set containing your new pieces (and/or some of the already present ones)
- You can append your set to one of the existing sets
- If you’re using new sounds with already defined pieces (for example making a door but using some new material that you’ve got sounds for), then you’ll have to append the sounds to the sounds table for that piece, using
furniture.dictionary_append()
Though, if you’re making your own piece you can make your own sound table.
- Call the register function (once per material) below the default register calls, to make sure that all the mods have appended their new pieces to the types table.
And that’s it, you’ve got your new furniture collection. The .blend that is included in the mod contains a scene set up for modelling minetest meshes. That is, models which align with minetest’s pixel grid where a node is subdivided into 16 pixels.
You should be able to get a hang of using blender for this specific purpose quite quickly, if you’re not familiar with it. (Tab to switch modes, g to move stuff)
Optionally, you’ll want to assign materials to certain faces on your model. Keep in mind that the material slot number in blender will correspond to the material order in the piece definition.
Materials themselves will not be saved with the model, so make some placeholder ones. After you’re done with modelling (and assigning materials), you’ll have to unwrap your model.
First pick one of the UV bounds from the collection (click next to the collection name to show it and then click on the eye next to models other than your choice to hide them), the 1x1 one if your model is confined to a single node. Then select both the bound and the mesh.
Switch to the UV editing tab, select a front face of your mesh (you didn’t make any diagonal faces, hopefully), Shift+G and then select Normal.
Next, switch to the front view and press U, select Project from View (Bounds).
Repeat for top/down and left/right. Project the top/bottom from top and left/right from left. This makes the shading bearable (but of course not perfect, can’t really do that). Minetest’s shading makes the result a bit different anyway.
Now, you’ll have your model textured like a nodebox is (with a few faces flipped). To actually shade it like I shaded my models, you’ll have to move UV islands to different positions on the texture. This becomes intuitive quite quickly. Don’t forget to subdivide (ctrl+r in edit mode) faces when you need more islands. Though if your subdivision cut ends up cutting across a pixel you’ll have to unwrap the affected faces again.
To move UV islands, select the desired faces in the 3d view and then move the islands which have appeared in the 2d view. To move use G and type the amounts in 1/16’s, since the kind of grid snapping that we need is kinda not an option (at least I haven’t managed to figure it out). Load an example texture as a UV background if you need visualization.
After you’ve spent some time aligning those UVs perfectly, comes the export part. You’ll want to select your model, export as .obj and you’ll want to check Selection Only, Material Groups (if you’ve got more materials), Uncheck Write Materials and Check Triangulate Faces. Also set the Forward to “Z Forward”. Like so:
Now you have a model ready to use. But, there are a few more cases that I need to mention
First, if your model is larger than a node bound you’ll not be able to unwrap it all at once, use other UV bounding boxes that I’ve provided (or make your own if you’re missing a specific case) and unwrap each segment separately.
Second, the filled shelf-type faces (the ones that contain the shelf contents) will be unwrapped with an uneven ratio since their texture is not square. Just unwrap and then scale the resulting UV island. And, that’s it! Do tell me if I missed anything.
I might add support for some subgames such as LOTT or MCL, but currently that’s not my priority. LOTT is supported now! I am excited to see what you guys are gonna build with these.
Also, let me drop one interesting bit of trivia here at the end: you can rotate all the furniture using a screwdriver, and certain pieces can clip trough each other (that’s intentional). Have fun!