🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3D Modeling Rigging and Animating for Monogame(Xna) pipeline?

Started by
2 comments, last by BBeck 7 years, 4 months ago

hello everyone here is the dilemma im facing, I'm a C# developer and lately i decided to work on a Game idea i had for so long, but it's gonna be a pet project(will be working solo) luckily I'm good at making 2D art because i like to paint but i have no experience regarding 3D Modeling and only so little experience with 2D game using Monogame aka Xna, the reason i use or willing to use monogame is because i find it easier to work with than other Game Engines (weird i know). anyway since im going to be working solo on the project i need to create some models to test my idea and see how my conceptual Game model would work and look. so i started searching for how to create models and how to animate them but i understood that whichever Game Engine you decide to use will determine certain choices such as what 3D software works best with the Game Engine or framework you choose(correct me if im wrong in my conclusion/ understanding) also i found that tutorials are labeled by both the Game Engine and the 3D Software but found nothing related to MonoGame regarding 3D game other than very basic things, i basically just want to create one character model with basic animation so i can experiment with it.

so i want to know if there's anything specific i need to do while creating, rigging and animating a model before importing it to MonoGame?

also if anyone made some modeling for Monogame what 3D software is recommended? cause i need to jump in and learn how to model the character i already sketched :) .

Advertisement

this is a monogame related question.

the first thing to do is determine what file formats monogame supports.

any modeling software that can export to some format which monogame supports will work.

also any modeling software that exports to any format that you can then convert to some format monogame supports will work.

so the first question is "what formats does monogame support?"

to get that answer, you read the docs.

then the next question is: "what modeling software or file converters support <any of the fomats supported by monogame> ?

if you find a modeling package you like that supports any of the formats monogames supports, you're done.

if not, you expand the search to include any format that can be converted to <any of the formats monogame supports>.

worst comes to worst, you use the assimp library to read some format form the modeler of your choice, then stuff it into mongame data structures yourself.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

this is a monogame related question.

the first thing to do is determine what file formats monogame supports.

any modeling software that can export to some format which monogame supports will work.

also any modeling software that exports to any format that you can then convert to some format monogame supports will work.

so the first question is "what formats does monogame support?"

to get that answer, you read the docs.

then the next question is: "what modeling software or file converters support <any of the fomats supported by monogame> ?

if you find a modeling package you like that supports any of the formats monogames supports, you're done.

if not, you expand the search to include any format that can be converted to <any of the formats monogame supports>.

worst comes to worst, you use the assimp library to read some format form the modeler of your choice, then stuff it into mongame data structures yourself.

thanks alot for your reply Norman Barrows;

mongame supports .FBX .X files by default , however i read on many website that it doesn't work well with FBX files exported from blender and extra steps are needed to convert blender FBX and OBJ files using a tool called Autodesk FBX converter. i'll need to dig more on this topic an probably just use any free models online from various 3D software to see which works best, thanks again for clear answer now i know what to do,

I used XNA for years. I still have my old website posted off my main website. I only converted a few of my programs to MonoGame and MonoGame is slightly different, so take what I'm about to say with a grain of salt.

Use Blender and .FBX with MonoGame. It about half supports .X, but my experience is that you pretty much have to use .FBX. It does seem like there were a couple of settings on the export you had to tweak just a little. But I used .FBX for everything in XNA for years and never used a "converter" or had serious problems with it. The biggest problem, I believe was that Blender uses completely different axes and the model imports sideways, but that's fixable.

I think MonoGame has the capability to import all the model data and at least one animation. XNA did not however have the built in ability to do skinned animation. XNA is not really a game engine. It's a frame work that you could use to build a game engine like OpenGL or maybe DirectX. Only people who have actually used XNA for years understand that. I think the common perception is that it's similar to Game Maker, Unity, or Unreal. With a few libraries in OGL it's pretty much the exact same thing as OGL. It's no more an engine than OpenGL 4.5 is.

I've used 3D Studio Max and Blender. Never heard of any modeling program having an affinity for any framework or Engine. I've used Blender for XNA, OpenGL 4.5, and DX11.

Skinned animation is not the place to start learning XNA/MonoGame. It's an advanced topic and very difficult if you've never done it before. XNA did not support it out of the box although Microsoft had a sample program that demonstrated how you could extend the content pipeline and the model class to support skinned animation. I went through it for about a weekend and pretty much understood none of it. Extending the content pipeline is a pretty advanced task in and of itself.

Of course that was years ago. I've learned a whole lot since then. Most of it would probably make sense to me at this point, but I stopped doing XNA a few years back and went to DX11 and then now OGL. XNA is an excellent platform for training you up for DX and OGL by the way. By the time I got to DX11 I was basically able to teach it to myself and guess how it worked based on years of experience in XNA. The basic concepts of loading vertex buffers and drawing them is the same, there's just a whole lot more non-game stuff you have to deal with in DX and that doesn't even get into DX12 or Vulkan. I think of XNA as being a small step easier than OGL 4.5 and DX11 with training wheels. It has some built in classes that used to be in DirectX back in DX9 that have been removed in DX11 that really help a beginner get started like a sprite class and a model class, but it also lets you dig into the advanced topics like HLSL and skinned animation and even more advanced than that.

One thing you need to know is that there are two types of animation, skinned animation and rigid animation. Forget about skinned animation until you've mastered rigid animation. You're never going to understand skinned animation until rigid animation is second nature to you. Rigid animation is relatively simple as it's mostly just matrix algebra. Skinned animation is tough but uses the same matrix algebra plus a whole lot more stuff.

For rigid animation you can look at the sample project I did in XNA on my website. You'll have to convert it over to MonoGame, which mostly should just be a matter of recompiling it in MonoGame. In a nutshell, the whole concept is that you model a model in Blender (or whatever) with different pieces as separate meshes. They will be separate objects in Blender. Then you parent them to one another. With a car for example, you create models for the body, doors, and wheels. Everything parents to the body. Even in Blender you will see this allows you to move the body and have the doors and wheels stay attached. But the doors can be rotated to open them independently and the wheels can rotate independently. THAT is rigid animation. In code, each sub-mesh will have it's own world matrix that you can manipulate. That's why you keep seeing those drawing loops in XNA where it loops through all the parts of the model.

The key is that for the child you don't use its world matrix directly you multiply the parent times the child and use the result each from for the world matrix of the child. This is what makes the parent-child relationship work the way it does. Just some simple matrix algebra.

I have another example program that I actually did rebuild for MonoGame 3.4 on my website that illustrates the matrix algebra of moving things around. I think it has some very simple .FBX models in it that I through together in Blender. You really need to get comfortable with matrices before attempting any sort of animation, and possibly quaternions as well for skinned animation. But learn matrices first because quaternions are used in pretty much the exact same way.

Check out RB Whitaker's stuff. He has MonoGame tutorials and what not and used to at least have an XNA rigid animation tutorial.

When you're truly ready for skinned animation, you're in for an uphill battle. I think I've pretty much got it figured out at this point, but have been working on so many other things for the past few years I haven't had a chance to finish implementing it.

Under my XNA examples page I have full XNA project code for playing back Blender animation files entitled "Playing Back Blender Animations". This was my prototype for trying to implement skinned animation in DirecX. It's working XNA code and a Python script. The Python script is a file exporter for Blender to export the animation data into a text file for one or more Blender animations using the built in armature. You should be able to use the Python script to export any humanoid animation that uses the standard armature. Then the XNA code reads in the text file and plays back all the animations in the file as a stick figure.

This is the first step to implementing skinned animation. Until you understand how you do this, you're never going to understand the whole process.

I've been doing modeling this past year. I'm in a 2 year course to become a professional 3D modeler and we use Blender for the class. I'm starting to get reasonably good at it believe it or not. But that aside, you need to learn to skin and the basics of rigging a model in Blender (or some other 3D modeling program) before trying to figure out the code to play it back. Once you understand the basics from the art side, you can understand them from the code side much easier.

Really, all skinned animation is after animating the stick figure is to attach those bones in the armature (their matrices) to vertices. But a given vertex can be attached to more than one matrix(bone) which is what skinning is. The weighted average of each matrix that controls that vertex is what actually animates the vertex. But the whole armature has that same parent-child relationship of multiplying matrices together that you had in rigid animation, which is why you need to learn rigid animation first.

A much easier choice than all of this is to use a game engine like Unity that pretty much does all of this and then some for you. But it's good to learn to do this stuff yourself, if you can find tutorials to teach it.

Also, BasicEffect is basically just a Blinn-Phong shader with 3 lights and fog. You may want to check out my HLSL tutorial (written in XNA) and my matrix videos on my YouTube Channel. You probalby want to watch the vector video before the matrix video if you're not strong in vector algebra because the matrix video kind of builds on it and HLSL uses vectors quite a bit.

Incidentally, if you want to go really hard core, ditch XNA's model class and build your own. That's exactly what I did for my DX engine (DX11 doesn't have a model class so I had no choice unless I used a library). All the code is posted on my website. The Python script included in that project will work fine for anything including XNA/MonoGame as far as exporting your model from Blender. So, you can completely avoid .FBX, .OBJ, .X and everything else by building your own custom file format. This is a really good learning experience. Note however that this file format in my example code supports rigid animation but would have to be extended to support skinned animation. One of the things you would have to do is combine that file info with the animation file info from the other file exporter. Plus, if you can half read C++ code, you can probably see how I used this data to build a model class, which is mostly just a vertex buffer and index buffer. You'll also learn that these model files contain a ton of garbage and you need to ditch them ASAP and create your own binary model file to store the data for your model class efficiently. XNA/MonoGame actually does this without you being aware of it in many cases with their XBA files.

This topic is closed to new replies.

Advertisement