Swapping out meshes at runtime

Started by
5 comments, last by slicer4ever 11 years, 6 months ago
I am working on an RTS game in 3D and I am having a slight problem. The current model format for unit models is not as flexible as I would like.

Units in the game can get upgraded weapons and armors and such and I want to have a visual clue about what stuff each unit has. It would be nice if I could use one animated model per weapon type, such as spears and swords, but switch in a new weapon mesh or re-texture an existing weapon or armor to indicate a change in what the unit has.

So a bronze weapon would be one color, bronze I guess, and an iron weapon would be reddish silver while steel would be bluish silver. I suspect that the re-texturing wouldn't be too hard, at least compared to swapping a weapon mesh.

For the weapon thing or possibly for armor I would want to be able to swap in a new weapon without creating and animating a whole new model. This is both because it would cut down on the amount of modeling and because I think it would greatly reduce file sizes.

I know I would need separate animations for spears vs swords, but a longer spear or sword or one with a thicker blade or something wouldn't need its own animations.

What would be the easiest way to do this sort of thing? I am not really too great in the graphics department.
Advertisement
If you are using a skeleton animation system, you could create several attachment points for weapons, which would be attached to the joints, so the animation would in theory also influence the attached weapon if neccisary.

Rather this creates a nice animation between spear users and sword users is really down to how well you animator makes generic attack animations.

Anywho, thats probably how i'd do it, more information about you animation system would allow us to give you potentially better solutions.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Well I am mostly looking for a general example. Skeletons would allow me to attack an arbitrary weapon to a joint and then the weapon would just follow the arm? That is definitely what I want to do.

My goal is just to be able to animate the model once and stick a new mesh in the weapons slot based on the item the unit is currently holding. How would the file store the various weapons to be rendered? Should I make a separate folder with all the weapons, armors, and textures of the interchangeable parts and just notify the model what to use?
Attachments should be in separate files, since they are not directly related to one character (e.g. Monsters that wield weapons).

With skeletal animation, you can indeed attach models to points on the original one and have them follow its animation.

I would still try to make a few animations of the same type. For example, you can swing a sword or a spear the same way, but stabbing with them is done quite differently.
Here're some tips:
1. Separate the weapon models from the character models, This will work for other riggid meshes like shields, helms too. In fact all models are separated and you just can attach one model to an other model.
2. Use a skeletal animation system: use special, none mesh deforming bones as attachment points. In your game you need to apply the animation to the skeleton first, then take the attachment bone and transform it into world space (the bone itself is just a transformation matrix), and eventually use the world-bone matrix as transformation matrix for your weapon mesh.
3. To add diversity to your model texture take a look into gradient maps (Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2).

1. Separate the weapon models from the character models, This will work for other riggid meshes like shields, helms too. In fact all models are separated and you just can attach one model to an other model.
2. Use a skeletal animation system: use special, none mesh deforming bones as attachment points. In your game you need to apply the animation to the skeleton first, then take the attachment bone and transform it into world space (the bone itself is just a transformation matrix), and eventually use the world-bone matrix as transformation matrix for your weapon mesh.


I have one question regarding weapon placement - what decides how weapon is "oriented" after such transformation? And how should the weapon be oriented in modelling program for this to work? I always had a hard time understanding how these pieces fit together - I get the idea of "socket" on one model thats just non-deforming bone parented to character's hand - but how does that bone work together with weapon model so the model points in right direction, as it should, not backwards, upwards or other weird way?

Where are we and when are we and who are we?
How many people in how many places at how many times?

[quote name='Ashaman73' timestamp='1343808312' post='4965132']
1. Separate the weapon models from the character models, This will work for other riggid meshes like shields, helms too. In fact all models are separated and you just can attach one model to an other model.
2. Use a skeletal animation system: use special, none mesh deforming bones as attachment points. In your game you need to apply the animation to the skeleton first, then take the attachment bone and transform it into world space (the bone itself is just a transformation matrix), and eventually use the world-bone matrix as transformation matrix for your weapon mesh.


I have one question regarding weapon placement - what decides how weapon is "oriented" after such transformation? And how should the weapon be oriented in modelling program for this to work? I always had a hard time understanding how these pieces fit together - I get the idea of "socket" on one model thats just non-deforming bone parented to character's hand - but how does that bone work together with weapon model so the model points in right direction, as it should, not backwards, upwards or other weird way?
[/quote]

the model should be transformed by the hand bone's matrix, so when you model the weapon, you should model it in a way that it's attached to the pose position of the character wielding the weapon.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement