Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am looking for a possibility to map different positions on a 2D Image which has different frames. Let's say I have an image, consisting of three frames, which shows a spaceship. The first frame shows the spaceship how it is tilted a little bit (say 20 to 30 degree) to the left side. The second frame shows the spaceship just from the top. The last frame shows the spaceship tilted a little bit to the right (the same amount as in frame 1). Now I want to know, where for example the part which is in the middle of the second frame, is in the first and third frame. The following painting should show what I mean (sorry, I am a bad artist): 3 Frames of the spaceship

The red arrows show example positions which I want to match.

The background is the following: I want to have the possibility to take away parts of the image while playing. The problem is: I want that the parts which were taken away, are taken away on every frame at the right position.

I fail to imagine how to approach this problem as I cannot think of a possible solution. Is there a possibility to achieve this goal or is it just impossible?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

It is possible and is no rocket science really. However this migh not be the approach you should be looking for.

For this to work you can either process the image to actually tilt it in 3d by 20 degrees or so, or just make sure your artist has some sick skills of matching reality.

To rotate the object in 3d you multiply each vertex by a transformation matrix. In your case it's only a rotation matrix - good for you. Then you will need to project the 3d space onto a 2d plane. Just get rid of the Z axis. It's that simple :) (granted it's all top down).

Next just multiply any point you wish by the matrix. It will provide new coordinates in 3d. Again, get rid of the Z axis.

It all assumes that the camera remains in the same place and space ship rotates exactly around its main axis which is in the middle.

If you should wish to move the camera aswell then there is something called Matrix multiplication. Shouldn't be too hard either, as basic Algebra is plain easy.

share|improve this answer
1  
I am not sure, but I thought it was not possible to tilt a 2D image. Because it is 2D, you cannot know, how it looks from the side or from another view in general. –  M0rgenstern Apr 25 '13 at 4:50
    
Tilting 2D image would just leave you with X axis shrinked and some minor trapezoid distortion. –  Krom Stern Apr 25 '13 at 5:16
    
Well, if is just can shrink the image with a little distortion, I do not need to map the positions, as the image will be the same and the parts I take away are taken away from the image itself –  M0rgenstern Apr 25 '13 at 9:11
add comment

There's no easy way of doing this for 2D images. You might need to ask your graphics artist to draw the parts of the hull below the missing parts and the parts separately for each viewing angle. Having the base hull you can render it and other parts (e.g. wings) on top or below it.

EDIT: Make a thought experiment, if you remove one part of the model, what will be there below it? Where will it be painted? Try making a series of sketches and then see how can you split that in parts.

share|improve this answer
    
The problem is: I cannot have any base or something, because everything can be taken away. Parts of the ship are taken away, when the ship is hit by an enemy or something else. So everything could just be taken away and there would be no rest. –  M0rgenstern Apr 25 '13 at 4:49
    
I would assume you deal with a flying spaceship or a plane, where some parts can be lost, but there's no way to loose the main hull and keep on flying with the rest of the parts still intact ;) –  Krom Stern Apr 25 '13 at 5:18
    
Yes, the ship will be broken if too many parts are taken away. But that are not real parts, but pixels. So after a while, there are some holes but if there is not much left from the ship, it is defect and explodes. –  M0rgenstern Apr 25 '13 at 9:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.