2
\$\begingroup\$

I'm not really sure what I'm asking, so sorry for the bad title. I'm still new to game programming and especially the "game specific parts" like models and graphics.

Let's say I have a model of a space ship. On this model there's are a couple of locations where I want to place thrusters and there's another spot for a large main thruster. I think I have most of the physics figured out. I can place thrusters at positions relative to the center of mass and the ship behaves appropriately when they're fired. Now, back to the model - how do I place my engines (in the simulation), how to get the relative X, Y and Z values from the model?

Obviously, the naive solution would be to open up the model in a modelling program and find the coordinate where I want the engines to be placed and then put those values in my database. That would mean that every time I change the model or create a new ship I'd need to redo this procedure and handle a lot of values. Surely this can't be how it's done? Is there a way to "mark" a point in a model and find that point from code? Am I missing something obvious?

I'm using C# and XNA, by the way.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

I've done this by creating a special object or vertex at the point of interest and naming it something special. Then when the model is being loaded, those points of interest are loaded as well. For example, in Blender you can create an empty object that has its position exported along with all the other model data.

How you create the point of interest and how you read it in will depend on the technology you're using.

This solves the problem of keeping the point updated when the model changes, since you simply move the point at the same time you're updating the model. While not fully automatic, it's a simple approach and keeps the changes you make localized to one task.

\$\endgroup\$
2
\$\begingroup\$

If you're using skeletal animation on your ship, one way to do this is to create joints (bones) representing the attachment points. These joints wouldn't have any geometry attached to them, but would just serve as position (and/or direction) markers. You could give them special names that would allow you to look them up from the game engine.

If you don't already plan to use skeletal animation, it's probably not worth implementing just for this. However, you can still do something similar by creating a specially-named object in your modeling program (it could be just a cube, or you could model a little arrow or something to indicate thrust). At runtime, when you load this object you would throw away its geometry and just use its position as the marker.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .