Page 1 of 1

2d Sprite Rotation code

Posted: Wed Jul 28, 2004 5:47 pm
by Krylar
Hiya,

I've been messing with Sprite rotation from 3D back to 2D and I tossed together a bit of code that does the following:

1) Load a 2D sprite with 3D capability
2) Rotate the Sprite a user-defined amount
3) Display it in 3D
4) Grab it from the the buffer and stick it into an array for use with 2D

The idea is that you can have 1 2D image be automagically converted into a bunch of them, rotated at certain angle-intervals, and then placed in an array. But have them be accessible as 2D objects for speed.

If you're interested in the code, Get it Here

If someone knows of a faster way to do this using PB's code, please let me know! :D

EDIT...
I know there are many pieces of plugin code out there, but since I'm incorporating stuff into the book I'm somewhat tied by what I can use.
...EDIT

All the best!

-Krylar
Thanks!

-Krylar

Posted: Wed Jul 28, 2004 11:01 pm
by blueznl
you could do it without 3d hardware using the plgblt_ api

Posted: Thu Jul 29, 2004 1:24 am
by Krylar
Heya,

Not familiar with that. I looked through the PB documentation and such but didn't find it.

If it's a library I suppose I can just have people look for it on their own from text in the book, but I'm supposed to be keeping to only actual PB commands and licensed libraries otherwise. :/

Thanks!

-Krylar

Posted: Thu Jul 29, 2004 1:36 am
by Codemonger
You are right it's not an internal PB command. But any Win32 API function can be called from PB without any extra help by appending a underscore as a suffix... so :

win32function_(param1,param2,param3)

would call whatever win32 function. This makes PB very powerful because the easy access to Win32 API

@blueznl
plgblt does not do rotation, heres a quote from the ms docs:
Scaling, translation, and reflection transformations are allowed in the source device context; however, rotation and shear transformations are not.
anyway maybe i'm missing something as i quickly looked this up.

Posted: Thu Jul 29, 2004 1:56 pm
by Krylar
Excellent information, Codemonger. :D

I just did a look up on MSDN as well:

http://msdn.microsoft.com/library/defau ... s_2dis.asp

Also seems that there's compatability problems with this command. From the Requirements section:

"Windows 95/98/Me: Unsupported."

I know most people are moving to XP or NT, but still may be some out there on the older ones.

Anyway, thanks to both you and blueznl for helping to guide me here. As you may imagine I'm in a bit of a crunch for getting up to speed on these things and so in a lot of cases I'm jumping forward and making assumptions on things. ;)

-Krylar

Posted: Fri Jul 30, 2004 1:58 pm
by MadMax
Krylar: For me while sprite3D rotation(1) is fast and OK for some things, it's quality is not so good for others. ATM I'm writing a small aplication, thet will rotate your sprite to the specified angles, and save them all in a single file (either contiguous or with a 1 pixel frame) Then with a small clipping procedure one will be able to use easily in games. (Code is working, just need to get the GUI stuff, I should have a working version soon)

Saddly I'm doing this with Blitz+, I'd love to do it with PB, but I don't have a good rotation routine (Anti-Alias) HINT HINT ! maybe someone would like to send me a good routine to use with PB 8)

(1) If you not too worried about the quality, why not use sprite3D directly? Contrary to popular belief sprite3D can be used for pixel perfect collisions, and can be animated too. If people are interested, tell me and I'll write a couple of small examples.



Well, I have a very primitive version that works, as soon as I write how to use it, I'll post a link, but right now a shower and of to drink a few beers :D

Posted: Mon Aug 02, 2004 10:04 pm
by blueznl
euh, codemonger, you're right about version / compatibility, it doesn't work on pre-win2k... but i think plgblt _ does do rotations (don't have a machine at hand to test it right now, installing new licenses etc.)

Posted: Tue Aug 03, 2004 8:07 am
by Rings
i think rotations are already done, see link here :
purearea.net site, a great lib from Mischa