Drawing a turned image

Blitz3D Forums/Blitz3D Beginners Area/Drawing a turned image

AJ00200(Posted 2009) [#1]
Is there a way to draw a turned image so that you don't need 360 images?


GIB3D(Posted 2009) [#2]
RotateImage image,angle

Don't try to do that in a loop though. I don't know why, but it makes the image go all weird.


GfK(Posted 2009) [#3]
RotateImage is too slow.

When you say "all weird", you need to rotate all images from the unrotated original. Reason being, when you rotate an image, say, 45 degrees. The [longer] diagonal dimensions of the original image become the width and height of the new image.

If you repeat this process over and over, then your images will become exponentially larger.

Anyway; to answer the original question: No.


GIB3D(Posted 2009) [#4]
Well you could just load them as a texture, put them on a cube and rotate the cube instead.


Ross C(Posted 2009) [#5]
Use a 2d in 3d lib like nSprite 2 or spritecandy :)


GfK(Posted 2009) [#6]
Well you could just load them as a texture, put them on a cube and rotate the cube instead.
Why would you do that?

Yes, the 3D route is an option but its senseless to use a cube (12 tris) when a quad (2 tris) will do.


AJ00200(Posted 2009) [#7]
What do you think the speed would be like if I did:
img=loadImage(...)
turnedImg=copyImage(img) ;<-- EDIT
RotateImage(turnedImage, ANGLE)

PS-The game is a WinBolo (GNU) remake called BlitzBolo.


GfK(Posted 2009) [#8]
What do you think rhe speed would be like if I did:
img=loadImage(...)
turnedImg=copyentity(img)
RotateImage(turnedImage, ANGLE)
You can't use CopyEntity on an image.

I think you need some clarification on the difference between Images, Textures and Entities?


AJ00200(Posted 2009) [#9]
Oh yeah.
Im checking for a copyImage loke command.

EDIT: OK, how about copyImage() instead./


GIB3D(Posted 2009) [#10]
Why would you do that?

Yes, the 3D route is an option but its senseless to use a cube (12 tris) when a quad (2 tris) will do.
It just seemed like the right thing to say at the time ;)


GfK(Posted 2009) [#11]
CopyImage would work fine, provided you make a copy of the original, unrotated image, then rotate the copy.

Instead of making 360 copies - one for every degree, you should consider every five degrees, or even every ten degrees. That way you only have 72 or 36 images instead of 360.


AJ00200(Posted 2009) [#12]
What about in the loop like
While playing
   if keydown(RIGHT KEY) then
      free the image
      copy the normal one
      rodate the copy
      draw it
   end if
   LEFT KEY ...
wend

Or is the image freed if you write over it with a new one?


GfK(Posted 2009) [#13]
No, you'll cause a memory leak that way. You need to manually free the image before copying a new one. Otherwise you'll clog up your RAM with hundreds and hundreds of out of scope images.

You really need to precalculate the rotated images as rotateimage is nowhere near fast enough to work on the fly.


AJ00200(Posted 2009) [#14]
OK.
Thanks Everyone!!!


Jerome Squalor(Posted 2009) [#15]
i think you do it like this.


Graphics 800,600,0,2
SetBuffer BackBuffer()


sourceImg = LoadImage("anyPicture.bmp")

numberOfFrames = 10;

Dim imgs[numberOfFrames]

For x = 0 To numberOfFrames-1
     imgs[x] = CopyImage(sourceImg)
     RotateImage imgs[x],(360/numberOfFrames)*x
Next

x = 0;
While Not KeyHit(1)

Cls

x = x + 1
if(x<numberOfFrames-1)
     x = x + 1
else
     x = 0;
EndIf

DrawImage imgs[i],0,0

Flip

Wend

End



that should do it. :)


AJ00200(Posted 2009) [#16]
Thanks alot Jerome!


Nate the Great(Posted 2009) [#17]
well I may be a bit late but check out my image system. You can rotate/scale/recolor to any degree in real time, no weird fx, and it is 2d in 3d.

http://files.filefront.com/NTG+image+fixedzip/;12250961;/fileinfo.html

wow, I dont even have my password to that filefront account anymore :p