User-customizable characters (meshes): best approach?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

User-customizable characters (meshes): best approach?

Post by Josh1billion »

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?
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
DarkDepths
Posts: 126
Joined: Sun Apr 02, 2006 1:21 am
Location: Canada

Post by DarkDepths »

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!
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

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.
Josiah Hartzell
Image
TBleader
Posts: 6
Joined: Mon Oct 04, 2010 12:43 am

Post by TBleader »

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.
DarkDepths
Posts: 126
Joined: Sun Apr 02, 2006 1:21 am
Location: Canada

Post by DarkDepths »

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.
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?
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

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.?
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.
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.
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Luben
Posts: 568
Joined: Sun Oct 09, 2005 10:12 am
Location: #irrlicht @freenode

Post by Luben »

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.?
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.
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!
	}
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.
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.

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;
And this is how it looks in-game. You might also notice the player holding a shotgun, attached to a hand-joint as described above.
Image
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 ;]
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

Ahh, I didn't know you could do that with skeletal joints. And that's a very convenient way to change skin color. I'll definitely be messing around with these features in the very near future.. maybe tonight. Thanks a bunch, Luben. :)
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Post Reply