|
-
Dec 13th, 2001, 08:46 PM
#1
Rotating a sprite
This isnt a c or c++ question, more of a graphics question. I have a sprite of a space ship, and the ship is pointing to the right. How do i rotate it so i can display it in any 360 degree angle? So i can move it around in space.
-
Dec 14th, 2001, 07:57 AM
#2
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 14th, 2001, 10:58 AM
#3
-
Dec 14th, 2001, 11:22 AM
#4
Frenzied Member
For each pixel in the destination sprite (the rotated one), calculate where that pixel would have come from in the source sprite. Use the colour value at that point in the source for the current pixel in the destination.
You can do this as roughly as you like, depending on the quality you want. If you want a nice smooth image, use high-res sprites and do floating-point arithmetic to find the weighted average of the colour values around the source point, weighted according to how close it is to each of the 4 source pixels around it.
Rotation is very slow. Last time I was using DirectX was DX6, and they hadn't implemented a HEL version of the DirectDraw surface rotation functions because they just hadn't been able to make a fast enough software rotation algorithm.
Harry.
"From one thing, know ten thousand things."
-
Dec 14th, 2001, 11:23 AM
#5
Frenzied Member
Oh yes - a faster solution, if you can spare the memory, is to precalculate the rotations and stick them in a lookup table.
Harry.
"From one thing, know ten thousand things."
-
Dec 14th, 2001, 01:40 PM
#6
Ok so i have to calculate it...
What calculations do i have to do?
-
Dec 14th, 2001, 02:03 PM
#7
Neither is it implemented in DX7 HEL. And I don't think it is in DX8 either.
Chimp: ask the Math or the Graphics forum.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|