Jump to content

  • Log In with Google      Sign In   
  • Create Account


Swapping out meshes at runtime


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 AltarofScience   Members   -  Reputation: 926

Like
0Likes
Like

Posted 31 July 2012 - 01:16 PM

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.

Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3221

Like
0Likes
Like

Posted 31 July 2012 - 01:59 PM

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.

#3 AltarofScience   Members   -  Reputation: 926

Like
0Likes
Like

Posted 31 July 2012 - 02:55 PM

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?

#4 wolfscaptain   Members   -  Reputation: 200

Like
0Likes
Like

Posted 31 July 2012 - 11:10 PM

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.

#5 Ashaman73   Crossbones+   -  Reputation: 6744

Like
1Likes
Like

Posted 01 August 2012 - 02:05 AM

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).

#6 noizex   Members   -  Reputation: 846

Like
0Likes
Like

Posted 02 October 2012 - 12:02 PM

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?

#7 slicer4ever   Crossbones+   -  Reputation: 3221

Like
0Likes
Like

Posted 02 October 2012 - 09:50 PM


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?


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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS