In a third-person game of some sort, for example an RPG, what would be the best approach to allowing the player to customize their character's appearance in terms of skin color, hair style/color, clothes/armor worn, etc.?
Would the best option be to create several meshes (one for the body, one for the hair, one for the armor, one for the weapon, etc.) and then position them all relative to the body mesh via a child/parent relationship?
Or are there functions available that can be used to generate meshes on-the-fly, and, if so, would these be performance-sensitive?
User-customizable characters (meshes): best approach?
-
- Posts: 125
- Joined: Thu Dec 11, 2008 9:50 pm
- Location: Wisconsin
- Contact:
-
- Posts: 126
- Joined: Sun Apr 02, 2006 1:21 am
- Location: Canada
I think your first intuition is correct for most of the customizable parts.
I've never actually tried it, but after loading a mesh into irrlicht, there should be a way to change the position of the various vertices so that you could, for example, make the nose longer, make the arms thicker, etc.
I'm not really sure how you would do this, I looked in the API and the IMeshBuffer can give you the collection of vertices, but there doesn't seem to be a way to set them, so I think you may have to get the vertices, make any changes you wish and then use those vertices to create a new IMesh. Don't quote me on that though!
For hair styles, and different kinds of jackets, etc. then yes, I think using different meshes is definitely the way to go. For different coloured jackets, or skin colour, you can of course just use different textures!
I've never actually tried it, but after loading a mesh into irrlicht, there should be a way to change the position of the various vertices so that you could, for example, make the nose longer, make the arms thicker, etc.
I'm not really sure how you would do this, I looked in the API and the IMeshBuffer can give you the collection of vertices, but there doesn't seem to be a way to set them, so I think you may have to get the vertices, make any changes you wish and then use those vertices to create a new IMesh. Don't quote me on that though!
For hair styles, and different kinds of jackets, etc. then yes, I think using different meshes is definitely the way to go. For different coloured jackets, or skin colour, you can of course just use different textures!
-
- Posts: 126
- Joined: Sun Apr 02, 2006 1:21 am
- Location: Canada
Yea, I think you are right. I looked again and the function returns an array of pointers. Since you are actually changing the values at the memory location, I guess that would actually be reflected on IMesh, correct?cobra wrote:DarkDepths:
I do believe once you change the position of each vertex, they are kept and will be reflected in the rendering next time it renders.
If not, you might have to update it by setting the position of the node to its current position.
-
- Posts: 125
- Joined: Thu Dec 11, 2008 9:50 pm
- Location: Wisconsin
- Contact:
Thanks for all the input, guys. This information will be helpful when I start my next large Irrlicht project.
Now if I use separate meshes for the character's body, armor, hair, etc.. I assume my 3D artists would have to animate each mesh very carefully to ensure they all line up properly? For example, they'd have to create an animation for the armor that makes it look like an invisible man is wearing it and walking? Same with carrying a sword, etc.?
Now if I use separate meshes for the character's body, armor, hair, etc.. I assume my 3D artists would have to animate each mesh very carefully to ensure they all line up properly? For example, they'd have to create an animation for the armor that makes it look like an invisible man is wearing it and walking? Same with carrying a sword, etc.?
Aha, that's a great idea that didn't even cross my mind. I'll be making use of it. I wonder, however, if I set a model's texture to be one solid color.. would it be shaded at all? I guess this is where shaders come into play.. never having worked with shaders before, it looks like I may have some research to do.TBleader wrote:For skin color, have the default color be white, then change the texture's color according to the user's input. That way it can be truly dynamic. I'm not sure if that works in irrlicht but I'm sure it does.
No. You can make static pieces of armor/weaponry/etc, and make them follow the animated body-part in question. You achieve this by using models with skeletal animation systems.Josh1billion wrote:Now if I use separate meshes for the character's body, armor, hair, etc.. I assume my 3D artists would have to animate each mesh very carefully to ensure they all line up properly? For example, they'd have to create an animation for the armor that makes it look like an invisible man is wearing it and walking? Same with carrying a sword, etc.?
For example, if you've loaded the dwarf-mesh that comes in the media folder as an animated scene node, and you've prepared a mesh-node with a weapon, you can 'attach' it to one of the 'joints' in the dwarf with this piece of code
Code: Select all
ISceneNode *pWristNode = m_pModelNode->getJointNode("lwrist");
if(pHandNode){
//Dont forget to reset the weapons position&rotation
m_equippedWeapon->setParent(pHandNode); //Will now be transformed by this!
}
You don't need to make it a solid color, you can use a normal texture and still make it look different. This is how we give our zombies diverse skin-colors.Josh1billion wrote:I wonder, however, if I set a model's texture to be one solid color.. would it be shaded at all? I guess this is where shaders come into play.. never having worked with shaders before, it looks like I may have some research to do.
Code: Select all
m_zombieColor = SColor(255, irand(128, 255), irand(128,255), irand(128, 255));
m_pModelNode->getMaterial(0).AmbientColor = m_pModelNode->getMaterial(0).DiffuseColor = m_zombieColor;
Notice how even zombie's pants become affected by this though. Our zombies are made with only one material, but one could use one material for skin, hair, etc which colors could be changed individually. That might however lead to lot of render-state-changes, which i've understood is bad, and using shaders might fix that. Dont know yet though ;]
-
- Posts: 125
- Joined: Thu Dec 11, 2008 9:50 pm
- Location: Wisconsin
- Contact: