How do you make lasers come from turrets in 3D

Started by
2 comments, last by DarkSlayer 19 years, 8 months ago
This problem eludes me. In a 3D space game how do you make shots appear to come from specific points from a model (say a gun port on a space fighter or a turret on a capital ship)? This is done in like every 3D space sim and combat flight sim. From a 3D modeling and programming perspective how is this done? After rotating, scaling and transforming an object to world coordinates if you have a hierarchical 3D model structure is there a way to extract the gun port or turrets coordinates as point to start the shot from? I'm using DirectX but any general ideas would be welcome. Also if there are any books that clearly illustrate this that would be great. Thanks.
Advertisement
If you have the position the shot should start from in untransformed coordinates (i.e. object coordinates) you could just apply the same transformation to this as to the gun (or turret, or whatever.)
I've used bones to indicate locations of weapon emitters, you could also store an offset position based on the origin of the ship, and transform that offset by the same way the ship is transformed, but it might become a bit more difficult if the turret is independantly movable. I'd prefer bones, since typically bones are used to attach objects anyways, the code to get their position is usually there already.
Most models (model parts) should have a "pivot point" or a reference point, 1 point that the rest of the vertices in the model is defined from.

for example, you have a tank .. it has a chassi and a turret, how are they connected? in 3ds or others, you can link objects, and then it is the pivot point that is linked to the other object. once you animate turret, you would turn turret around it's pivot point.

you can then link either visible or invisible objects that would be the source, and direction for the laser...

could recommend do some modding for a game (creating models, maybe script a bit too), this would give you lots of insight

This topic is closed to new replies.

Advertisement