[Mod] Procedural Furniture [furniture]

Post Reply
User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

[Mod] Procedural Furniture [furniture]

by the_raven_262 » Post

ImageImage
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.

ImageA 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. ImageA *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 LinkImageSorry 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 LinkImageVery 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 LinkImageYes, 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 LinkImageThis 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 LinkImageIt 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
    },
Keep in mind that your model *must* be named the same as the “name”, or if you’re using the same model for multiple pieces then same as the “base”. If your piece uses node swapping (activation) then you need to have
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. Image
Next, switch to the front view and press U, select Project from View (Bounds).Image
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:Image
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!
Last edited by the_raven_262 on Mon Jan 30, 2023 15:17, edited 1 time in total.

Sapphire_Jester
New member
Posts: 2
Joined: Wed Oct 19, 2022 20:59

Re: [Mod] Procedural Furniture [furniture]

by Sapphire_Jester » Post

Hi there, I like the mod. It's easy to use, and I really like how the cabinets and wardrobes have inventory functions (especially the wadrobe's huge amount of spaces).

I'm writing mainly because I wanted to make note of a few things, things that may or may not be issues to be fixed. First, I experienced a conflict when both this mod and the flowerpot mod are installed, where the furniture mod's flowerpot will use the flowerpot mod's flowerpot model instead, leaving an ugly chunk of soil revealed above the pot. Looks like this:
Spoiler
Image
I believe it is caused by both mods naming their flowerpot models as "flowerpot", as when I changed the name of the furniture mod's flowerpot model and added that name to the flowerpot's table as the base, the issue was resolved and both flowerpots would show up in game using their correct models.

Second thing is that the recipes tab in the inventory shows the activated versions of the doors, which are both uncraftable and create unneeded clutter in the tab. Adding groups_active.not_in_craft_guide = 1 after the line that removes the active versions from the creative menu fixes that.

Third, every furniture that is made of wood or stone can be used to craft an object that uses anything in the wood or stone group. For example, with three stone tables and some sticks you can make an axe. Not sure if that was an intentional choice or not, but I thought it was funny enough to mention.

Last, for some reason the sounds used for the furniture in this mod are louder that same sounds used on default stuff, like if you compare the default wooden door to one of your doors. I don't know if this is a problem with my settings, something is making default quieter, or something else, but again I wanted to make note of it.

Anyways, that's all I have. Thanks for making the mod and for reading.
Last edited by Sapphire_Jester on Thu Oct 20, 2022 21:39, edited 1 time in total.

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [Mod] Procedural Furniture [furniture]

by the_raven_262 » Post

Oh, thank you for reviewing my mod!

So for the first issue: the models aren't using a modname prefix like textures do. I'll just make all the models have a "furniture_" prefix and that'll fix the issue. I don't know why this isn't a common practice (it isn't done in default for some reason)

Second: I didn't know that "not_in_craft_guide" group exists ("_active" nodes don't have craft recipes so they wouldn't appear in craftguide anyway), easy fix as you already said.

Third: Ah yes, the furniture inherits all the groups from the base node. I can make a workaround that removes the groups such as "stone" and "wood" from the resulting furniture (since the table already has to be copied, I could just add a filter). Should I though? Maybe we should call this a feature

Fourth: I didn't adjust the gain for sounds and just left it at 100 (forgot, sorry). I'll fix that.

I'll make these changes/fixes later today, thanks again for pointing these out!

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [Mod] Procedural Furniture [furniture]

by the_raven_262 » Post

Alright, I decided to leave the crafting in; it is now officially a feature!
The sounds can now be given specific gain values. And, the models are required to have a "furniture_" prefix.

Sapphire_Jester
New member
Posts: 2
Joined: Wed Oct 19, 2022 20:59

Re: [Mod] Procedural Furniture [furniture]

by Sapphire_Jester » Post

Thanks for responding and updating. I tried it out on my end and everything works as it should. I'm glad I able to help.

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [Mod] Procedural Furniture [furniture]

by the_raven_262 » Post

LOTT support has just been added to the mod. Image I did not play LOTT in quite a while and I hope that the crafting recipes are achievable/not too expensive.
If you encounter any recipes that are actually broken, please do notify me.

In the meantime I did not make any new models, but more model collections are planned. My goal is to recreate most of the homedecor furniture in this blocky and more minetest-like style (as opposed to homedecor's 3d models for example).

Post Reply

Who is online

Users browsing this forum: Nathan.S and 19 guests