I am currently working on the equipping technique for the characters in our game. Regarding the paint-on-armor(cloth leather chain) it is rather easy by assigning different materials to the desired SubEntities. For the modelled armor pieces like plate armor I am a little bit stuck now, I have searched around on the boards and in the wiki but cannot find the real clue. Attaching to bone doesnt seem to be a good option.
Is it possible to load a different mesh into a submesh and how does it work? Should I load all the gear in one go from the start and set the SubEntities to invisible untill i need them or what would be the best method to change the equipment on a game-character?
Thanks in advance
A:You’re on the right track.
Attaching to bones is not the way to go for clothing. It works well for equipment (guns, swords, etc) and maybe some accesories (hat, holster, etc) but woul dnot work well for armour.
Building your model with all conceivable geometries (leather vs plate vs robe) in seperate subentities and then enabling/disabling as needed is a good way to go. A lot of games go this way.
You could also building your character out of components (leather torso vs plate torso vs robe torso) and attach/assembled limbs and heads as needed. A lot of game go this way (probably more than above).
Each has pros and cons. The first has some more overhead in terms of animation and vert/poly counts — not sure how “smart" OGRE is in ignoring/optimising invisible subentities (but I would guess pretty smart).
The second way can be harder in terms of managing animation (crashing polys, seams, etc), but has some added benefits in terms of being able to easily detach components (i.e. decapitation and dismemberment), plus customizability options may be easier to do.
If you want something fast/eas(ish), go with 1. If you want something a little more robust/extensible, go with two.
You can’t “swap" them but you can set them visible/invisible using
You could do it this way if you have a low number of combinations, but it’s a bad idea if you have hundreds of pieces of clothing. With a few pieces, it’s a decent idea though.
If you have lots of combinations, I think your best bet is to have a base character mesh, with bones and skeleton, animations, etc. Then have additional pieces that you share the skeleton with.
So for example, if a naked character is ok for your base mesh, use it. Let’s say you want your character wearing armor. You’d model your armor in your 3d program and bind it to the same skeleton structure as your base mesh. All bones have to exist with the same names, positions and orientations.
Then in Ogre you can use:
That means as one animates, it animates both at the same time. I got this working through a bit of trial and error. I can’t remember the problems I had but they were minor.
In the end, for a full system, you probably need a combination of the following:
1. Attaching certain pieces to bones
2. Sharing the skeleton between some pieces
3. Attaching equipment to the same scene node as the base mesh and playing the same animation name. For example, let’s say you have a robe that has special animation for the robe cloth, you can’t use #2 because it’ll have different bones and special skeletal animation.
Anyhow, good luck. Also you should look into the Ogre files yourself – you could have found the answer to the SubEntity->setVisible problem in like 2 seconds.