Easily. Just supply an animated texture like you would with any other node, if you want most of the model to display an animation, or if you're using very small, simple texture files. That is, you can just tile the texture vertically for however many frames you need, modify the parts that need to be animated (just like with any other node), and reference it as an animated image in your code, like you would for, say, a torch (you can see a good example of this practice in the texture for the steel 3d-ish nodebox-based torch that Home Decor got from the old 3dforniture mod).
For models with complex shapes (and hence, complex UV maps), or with high resolution texture files, you'll probably want to split the animated part off into its own file. This is especially true if you want to reference a generic, animated texture that someone else has already prepared or which is included in the default game. That way, you can use a single, static image for the non-animated parts of the model. For example,
this campfire mod does this, and in fact its files are how I learned how it works so that I could do the same sort of thing in Pipeworks' pouring spigot model, detailed below.
To do this, you need to put two or more materials in your model, one for each part of the model that needs a separate texture file, and make sure "Objects as OBJ Groups" and "Material Groups" are both enabled when you export the model. Then in your mod code, simply assign separate texture files by putting more than one image filename in the tiles={} field of the node def, like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_node("pipeworks:spigot_pouring", {
description = "Spigot outlet",
drawtype = "mesh",
mesh = "pipeworks_spigot_pouring.obj",
tiles = {
{
name = "default_water_flowing_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
{ name = "pipeworks_spigot.png" }
},
-- .... more stuff for the node here
})
Model file to go with this code:
https://github.com/VanessaE/pipeworks/b ... ouring.objHere, I call upon the standard animated, flowing water texture, which in this particular node is assigned to the material that's wrapped around a static, ordinary cylinder that sticks down out of the bottom of the spigot model. The second texture is assigned to the other material, which is wrapped around the rest of the spigot model.
The order of textures matters, but it's not well-defined in Blender just which material will appear first in the model's list, so if the textures are swapped when you load your new node in the game, just swap them in your tiles={} definition.
Depending on the model, it may be a good idea to separate the animated parts from the non-animated parts, putting each into their own separate Blender objects. Each still gets its own material. For some people, this will make the model easier to handle.