Sign in to follow this  
AoS

Swapping out meshes at runtime

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ([url="http://www.valvesoftware.com/company/publications.html"]Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2[/url]).

Share this post


Link to post
Share on other sites
[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.
[/quote]

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?

Share this post


Link to post
Share on other sites
[quote name='noizex' timestamp='1349200934' post='4986126']
[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.
[/quote]

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this