Results 1 to 7 of 7

Thread: Rotating a sprite

  1. #1
    ChimpFace9000
    Guest

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

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    API or DX?
    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.

  3. #3
    ChimpFace9000
    Guest
    VGA.

  4. #4
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  5. #5
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  6. #6
    ChimpFace9000
    Guest
    Ok so i have to calculate it...

    What calculations do i have to do?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width