3D meshes for players and creatures [Models are now upstream!]

kingtux
New member
 
Posts: 7
Joined: Sat Jul 07, 2012 16:59

by kingtux » Tue Jul 17, 2012 00:22

I have used irrlicht and I know that it can load plenty of mesh types, so it won't be all that hard to use meshes.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Tue Jul 17, 2012 09:51

There are two things I'm unclear about. First of all, can the current nodeboxes be animated? So you can animate the arms and legs of the player as he walks around for example, in those cases where players are made with node boxes. I seen a screenshot of someone adding 3D animals with these, but can't tell if they were animated or like a statue.

As for 3D mesh support, I'm unclear as to when someone will consider implementing it. Many are waiting for this feature but no one's looking into it yet. I'm actually worried a bit, since I can't consider working on my custom games until this is added (as well as LUA biomes and natural blocks).

When can we get started on implementing this? Note that I'm bad at C++ and don't know the MineTest code, so I'll likely be helpful with testing and maybe making some models in Blender. I'll also be away for about 3 weeks. But like I said on IRC, we likely don't have to code support for 3D meshes, because Irrlicht already has that. We just need to code the proper LUA hooks to allow the API to point to a 3D model, an animation to play on it (for skeletal formats) and render that for players and mobs... that's likely it.
 

Nubelite
Member
 
Posts: 161
Joined: Mon Jul 16, 2012 23:10

by Nubelite » Thu Jul 19, 2012 03:16

I made some modifications and added some collar and uvmaps to your mesh MirceaKitsune hope you don't mind :). If this model is to be used i am willing to make some animations and add a skeleton system to it. Total of 86 vertices. The shirt and pants are mapped so they can be customized for armor, jackets, layer shirts all with optical illusion graphics of course. I think just changing the jpg file for some clothing mods would be doable not fully sure.

Download Zip

Image
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Jul 19, 2012 10:20

Nubelite wrote:I made some modifications and added some collar and uvmaps to your mesh MirceaKitsune hope you don't mind :). If this model is to be used i am willing to make some animations and add a skeleton system to it. Total of 86 vertices. The shirt and pants are mapped so they can be customized for armor, jackets, layer shirts all with optical illusion graphics of course. I think just changing the jpg file for some clothing mods would be doable not fully sure.

Download Zip

Image


Not a problem, do whatever you wish with it :) It looks pretty good so far, nice work.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Thu Jul 19, 2012 16:45

Looks interesting. Just adjust the shapes of the hands and head and you have a lego minifig there. :-)
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

Nubelite
Member
 
Posts: 161
Joined: Mon Jul 16, 2012 23:10

by Nubelite » Sat Jul 21, 2012 08:05

Found this today Thread

Does this no longer work? i tired it and got no where
 

wokste
Member
 
Posts: 78
Joined: Sat Feb 11, 2012 09:06

by wokste » Sat Jul 21, 2012 08:53

Nubelite wrote:Found this today Thread

Thanks for adding the reference.
Unfortunately, this patch has a more or less a hardcoded model in it. Therefore it is not directly usable.
Secondly, there have been reports on performance issues. (whether they are true, I don't know)
We must be careful not to clone Notches mistakes.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu Aug 16, 2012 22:32

Animations are not possible yet with node boxes
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Oct 22, 2012 18:20

Ok. Since I got bored of waiting for this to happen, I decided to dive into it and try to implement it myself. I have not coded anything yet, but found some useful information. I tend to finish something first then post about it, but in this case I'd rather post what I discovered then see if I can do it (I am a n00b coder so I can't promise anything).

After quickly digging through the MineTest code, it appears you'd first define a new rendering type then set individual objects to use it (in this case the player). Some of the current types are "cube" or "upright_sprite". To find them easily, do a grep in the minetest/src/ folder. They seem to be handled in two parts of the code, here it is for the cube:

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
content_cao.cpp, line 783: else if(m_prop.visual == "cube"){
content_cao.cpp, line 1025: if(m_prop.visual == "cube")


The first line seems to set the draw properties, while the second line to handle the material configuration for the selected kind of mesh. The player itself is set to use "upright_sprite" in the following line:

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
content_sao.cpp, line 785: m_prop.visual = "upright_sprite";


From my understanding, we need to define a new drawing type where "cube" and "upright_sprite" are, which I will probably call "mesh". Like I said I'm not interested in animated nodeboxes for players and mobs (maybe for some items), I want to see this done with rigged models. Irrlicht natively supports such and works with various formats, and this is what I'm trying to achieve. Apparently it's easy... one of the current draw types should be possible to modify and simply point to a mesh instead. I also looked at how this is done for Irrlicht and am working with the following resources:

http://irrlicht.sourceforge.net/docu/
http://irrlicht.sourceforge.net/docu/example004.html

The first link has a section called "Short example" that shows the following line of code:

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
scene::ISceneNode* node = scenemgr->addAnimatedMeshSceneNode(scenemgr->getMesh("quake2model.md2"));


In MineTest for the "cube" type (those lines of code I mentioned first in the post) we see something 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
scene::IMesh *mesh = createCubeMesh(v3f(BS,BS,BS));
m_meshnode = smgr->addMeshSceneNode(mesh, NULL);
mesh->drop();


scenemgr in one code and smgr in the other represent the same thing. So the switch seems to be fairly easy. I don't know if there's something I'm missing and if other complications may occur, we will see. This should conclude how to set a 3D mesh using the native Irrlicht implementation to a MineTest node, if everything is correct.

Next topic is how to change animations on nodes with models. I spoke with the Irrlicht people on IRC and they pointed out the second resource link I listed. The command in their example would be:

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
anms->setFrameLoop(0, 13);
anms->setAnimationSpeed(15);
anms->setMD2Animation(scene::EMAT_RUN);


Not sure if the last line is of any use, but that's what I got. What the first line does is setting the mesh to loop between frames 0 and 13, while the second line sets animation speed to 15. So whenever changing animation (eg: Because we pressed the forward key to go forward), at least the setFrameLoop function needs to be called to change what animation is played on the model. This is a bit more complicated and I haven't checked where it should be done in the MineTest code yet. Each animation of the model is placed in a specific frame range (eg: frames 0 to 15 could be the standing animation, 16 to 38 the walk animation, 39 to 53 the mine / use animation, and so on).

The last concern was what mesh format to use for MineTest. Quake md2 is an Irrlicht standard, but I want a *rigged* format that uses an animation skeleton and is easy to export from Blender. The users on #irrlicht suggested obj, which is a common format and Blender has a native exporter for it. Seems like the best option for me so far, and it's what I will try to go with.

The trickiest part is where to set the LUA hooks for specifying the model and triggering animations, and I'm pretty bad at this one too. There will probably be a lot of other things that need doing, but I think these are some of the most important basics. I'll try to see where I get with this, but if I don't succeed this should be a very good starting point for anyone else who tries. If I do I'll post the changes on my GIT remote and let everyone know.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Oct 22, 2012 20:53

I began work on coding the feature. The news is better than what I expected for today: I was able to render the player as a static mesh. Here is a screenshot:

Image

The black sphere is a simple obj file I made and exported in Blender. Unfortunately I was wrong in my earlier post... obj is a static format, and I need to find something else for rigged models.

Next step is to work on getting a material to show, and perhaps create a good player model similar to the one in MineCraft. Player appearance is currently hard-coded, I may try to change that as well. After that I shall see if I can add the LUA hooks to allow nodes and items to use 3D models as well. I will put my code on GIT soon and post instructions on how to access my remote.

[EDIT] Created a GIT branch for this on my remote, where I will be updating the code. https://github.com/MirceaKitsune/minetest/tree/models
Last edited by MirceaKitsune on Mon Oct 22, 2012 21:28, edited 1 time in total.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Mon Oct 22, 2012 21:04

This is awesome! I can't wait for the Git repo to be put up.

MirceaKitsune wrote:The black sphere is a simple obj file I made and exported in Blender. Unfortunately I was wrong in my earlier post... obj is a static format, and I need to find something else for rigged models.


Yes, OBJ is a static format. Not very flexible either, but it's text based and basically every 3D application can export it. In fact, you can even write it out by hand. People do animation with OBJ files by making one for each keyframe and interpolating between them, or just making one for every single frame.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Oct 22, 2012 21:31

Temperest wrote:This is awesome! I can't wait for the Git repo to be put up.


Thank you. Just finished that, see https://github.com/MirceaKitsune/minetest/tree/models

Temperest wrote:Yes, OBJ is a static format. Not very flexible either, but it's text based and basically every 3D application can export it. In fact, you can even write it out by hand. People do animation with OBJ files by making one for each keyframe and interpolating between them, or just making one for every single frame.


If it can't be animated it's useless for players however. I need to find a more sane format that supports rigging. The bright side is that the same code should work for any mesh format, as Irrlicht does the reading of those... so that can be done later.
 

irksomeduck
Member
 
Posts: 224
Joined: Tue Aug 28, 2012 21:45

by irksomeduck » Tue Oct 23, 2012 17:08

Well, I think that minetest is in desperate need of 3D characters, and I would support it all the way.
I love exploring minetest worlds :D
If you have a good seed let me know
--------------------------------------------------
My world/house pack- http://minetest.net/forum/viewtopic.php?id=3066
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Tue Oct 23, 2012 17:38

Been a full day of work on the feature today, but I'm very happy with the progress. The code now requires LUA to set player appearance to a mesh, and a simple script can already do so. Error handling was added and texturing should also work (needs testing however). Nodes other than players should also be possible to mesh now, but I haven't tried those yet. Grab the latest code here:

https://github.com/MirceaKitsune/minetest/tree/models

Use the following LUA script to mesh players (inspired by another script):

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
function switch_player_visual()
        prop = {
            mesh="player.obj",
            texture="player.png",
            visual="mesh",
        }
    for _, obj in pairs(minetest.get_connected_players()) do
        obj:set_properties(prop)
    end
    minetest.after(1.0, switch_player_visual)
end
minetest.after(1.0, switch_player_visual)


There's still no player model as I'm looking for a good format, and the code needs to be finished first. Once that's done I'll probably try to make one. Last part will be animations, which should also be fairly easy if all goes well.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Oct 24, 2012 12:17

New improvements since the last update: Properly read the mesh and texture from their mods folder. During testing the model had to be located in /bin next to the minetest binary, now it's read from .../minetest/games/minetest_game/mods/default/models. Fixed material rendering, lighting was not being set and models appeared black. Tested with a texture and UV-mapped mesh, confirmed to work well on local server. Fix texturing for multi-material (segmented) models. Meshes now use the same "textures" field as blocks, and multiple textures are added to an array under LUA. Also added a property which should allow LUA to read the mesh of a player, not tested yet. This should make room for working on animations next. Here is the latest code comparison:

https://github.com/MirceaKitsune/minetest/compare/models

The updated (but still incomplete) script to mesh players is:

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
function switch_player_visual()
    local modpath = minetest.get_modpath("default")
    prop = {
        mesh=modpath.."/models/player.obj",
        textures = {modpath.."/models/player.png", },
        visual="mesh",
    }
    for _, obj in pairs(minetest.get_connected_players()) do
        obj:set_properties(prop)
    end
    minetest.after(1.0, switch_player_visual)
end
minetest.after(1.0, switch_player_visual)


How textured meshes look like (still uses the test mesh, that's the last part to get to):

Image

[EDIT] Created a minetest_game branch which contains the LUA script and current test model and texture. When a player model will be ready this will also contain it. https://github.com/MirceaKitsune/minetest_game/tree/models
Last edited by MirceaKitsune on Wed Oct 24, 2012 12:31, edited 1 time in total.
 

Shadowmang
Member
 
Posts: 10
Joined: Mon Oct 22, 2012 17:05

by Shadowmang » Wed Oct 24, 2012 12:58

that's a lot of progress of ~2days. Well done.

I wish my skills were good enough to aid you
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Wed Oct 24, 2012 16:47

That is simply incredible, do you have a plan for animation and how that's going to be exposed in Lua? I think simply using the frame numbers system should be more than sufficient. Something like LuaEntity:seek_animation(frame) and play_animation(framecount) should be a great start.

I'd love to see support for animated nodes too, but I suppose that's something to consider at another time.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Oct 24, 2012 19:49

Animation support was delayed by a discovery I made, that the mesh and its texture were not being put through the media stream. I fixed it with celeron55 and meshes are now sent from the server to clients like everything else.

I'm currently working on getting an animated test model working, but it's hard to find a skeletal format for Irrlicht. The b3d format works and I'm trying it out. A blender exporter was hard to find but I got one... so far the mesh isn't rendering like obj did, and I'm trying to find out why. It's unlikely I'll get any animation code done until tomorrow, and I'm still thinking how exactly LUA will handle this.

@ Shadowmang: Thanks for the support, it helps to know everyone finds this useful.

@ Temperest: From what I understand animation works in the following way: The mesh has a number of frames in order. Walk animation could be frame 0 to 10, jump animation could be frame 11 to 23, punch / mine 24 to 32, and so on. The way you set a model to animate is by using mesh->setFrameLoop(x, y); where x is the start frame and y the end frame. So LUA will simply parse those two values at the time it wants to animate the player, with the frame range of a specific animation. Yes, that means the start and end frames must be manually coded in LUA by who exports the mesh, but that's normally never a problem.

As for nodes with animated meshes, this should already be possible. Any drawing type the player can be set to anything else can. But I haven't tested with notes yet, just the player.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Oct 24, 2012 20:21

Important update: I was just able to get a skeletal mesh with looping animation to render (not controlled by the code yet). b3d would not work, so I'm going with the x format (DirectX). Blender has a native exporter for it, and Irrlicht supports it natively as well, so it's all good. This means the next part is getting working on the code to specify animation ranges. I might make a video if I find a working way to record my screen under Linux.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Wed Oct 24, 2012 20:41

you're doing such a great job!~ keep it up!
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu Oct 25, 2012 07:04

MirceaKitsune wrote:Important update: I was just able to get a skeletal mesh with looping animation to render (not controlled by the code yet). b3d would not work, so I'm going with the x format (DirectX). Blender has a native exporter for it, and Irrlicht supports it natively as well, so it's all good. This means the next part is getting working on the code to specify animation ranges. I might make a video if I find a working way to record my screen under Linux.

Bandicam works in Wine.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
Calinou
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou

by Calinou » Thu Oct 25, 2012 07:14

Use ffmpeg (commandline -- not that hard to use though) or gtk-RecordMyDesktop (GUI).
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Thu Oct 25, 2012 13:47

Thank you. I have began working on the animation code and LUA API for it. Animations are very easy to set in Irrlicht and it's only a matter of how to implement it best in the code, part of it should be done today. Another very useful resource I'm working with:

http://www.irrlicht3d.org/wiki/index.php?n=Main.HowToUseTheNewAnimationSystem

I'll be implementing animation smoothing / blending, and joint animations too apart from frame animations so the head can be oriented up or down based on where the player is looking. Biggest issue is I don't have enough LUA hooks to determine when the player is walking (and in what direction), when he's mining, etc. I'll need to make do with what I have and maybe implement more LUA hooks later on.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Oct 26, 2012 00:33

4am update, didn't wanna leave until finishing more code. Animations are now possible via the LUA API. You can set a start and end frame, the animation speed, and even enable animation blending for smooth transitions (though it's glitching with my test model). LUA code for bone animations was also added but is not functional yet, getting to it tomorrow. Once animations are finished, the last feature on my list are attachments, so players can hold items in their hands that are visible for others.

https://github.com/MirceaKitsune/minetest/tree/models

https://github.com/MirceaKitsune/minetest_game/tree/models
Last edited by MirceaKitsune on Fri Oct 26, 2012 00:34, edited 1 time in total.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Fri Oct 26, 2012 02:45

Oh wow! Entity parenting is the only thing left that's really needed by a lot of mods. The carts mod can finally smoothly transport players, players can hold items in their hands, mobs can have heads that can look independently of the body, Mesecons pistons can animate pushing blocks, etc.

That is truly very impressive.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
tkerwel
Member
 
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Fri Oct 26, 2012 04:21

can there be pls a compiled version for testing for those ppl how have some probs to do it themselves..
please please please
++++ Kung walang tiyaga, walang nilaga. ++++
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Oct 26, 2012 08:21

The head will already be able to look independently of the body using joint overrides (code positioning of bones). Parenting will however be useful for players holding items. Sadly both things will be tricky to implement, but I'm getting on it right now.

I can only send the compiled binaries for Linux... in my case it's compiled on openSUSE. If that helps I can put them in an archive later and send.
 

User avatar
tkerwel
Member
 
Posts: 213
Joined: Fri Jan 13, 2012 07:35

by tkerwel » Fri Oct 26, 2012 09:51

MirceaKitsune wrote:The head will already be able to look independently of the body using joint overrides (code positioning of bones). Parenting will however be useful for players holding items. Sadly both things will be tricky to implement, but I'm getting on it right now.

I can only send the compiled binaries for Linux... in my case it's compiled on openSUSE. If that helps I can put them in an archive later and send.


maybe somebody else can complie this and provide version for windows/ubuntu etc...

its realy amazing what kind of progress you are doing, i wish some of this features could get into the original code of minetest. for my opinion this would be a big progress for animation
++++ Kung walang tiyaga, walang nilaga. ++++
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Fri Oct 26, 2012 13:37

tkerwel wrote:
MirceaKitsune wrote:The head will already be able to look independently of the body using joint overrides (code positioning of bones). Parenting will however be useful for players holding items. Sadly both things will be tricky to implement, but I'm getting on it right now.

I can only send the compiled binaries for Linux... in my case it's compiled on openSUSE. If that helps I can put them in an archive later and send.


maybe somebody else can complie this and provide version for windows/ubuntu etc...

its realy amazing what kind of progress you are doing, i wish some of this features could get into the original code of minetest. for my opinion this would be a big progress for animation


talk to Sfan5 on irc, he can complie it in no time :)
 

mito551-guest
 

by mito551-guest » Fri Oct 26, 2012 16:40

i compiled it on ubuntu but i still get the textures. default ones. what am i doing wrong?
 

PreviousNext

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 11 guests