QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Rotating function in C

This is a discussion on Rotating function in C within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; hi. i need a function/lib which will allow me to rotate an image by the given angle. (in C, not ...

Reply
 
LinkBack Thread Tools
Old 09-06-2006, 08:45 PM   #1

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Question Rotating function in C

hi.

i need a function/lib which will allow me to rotate an image by the given angle. (in C, not C++) ive googled, and found no good results. some people told me that oslib allowed me to rotate images. but i have yet to find that function, and i prefer that i use the "original" lib that came with cygwin and not oslib.


thanks to everyone!
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-06-2006, 09:35 PM   #2

Developer
 
Join Date: Mar 2006
Posts: 1,026
Trader Feedback: 0
Default

You have two options really.

Option 1: Do it using hardware.
You're wanting to rotate images, I assume on the Z plane. Read up on sceGumRotateZ. This is probably harder than the second option, it depends on how you're setting up the graphics.

Option2: Do it in software.
Use maths to calculate your new vertices based on an angle. Namely just using sin/cos to calculate new position for your 'image'.
__________________

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197

Quote:
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
Insert_Witty_Name is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-06-2006, 10:32 PM   #3

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Smerity has tried mathematically rotating an image... Horrible results as it slows your fraemrate considerably. Your best bet would be to use the hardware rotation. The graphics library will allow sceGumRotateZ() if you 'touch-up' the blitting function... I suggest OSlib over anything, as you can do pretty much everything a quality 2D game needs. Best of luck Grimfate
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 05:17 AM   #4

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
Originally Posted by SG57
Smerity has tried mathematically rotating an image... Horrible results as it slows your fraemrate considerably. Your best bet would be to use the hardware rotation. The graphics library will allow sceGumRotateZ() if you 'touch-up' the blitting function... I suggest OSlib over anything, as you can do pretty much everything a quality 2D game needs. Best of luck Grimfate
ive also thought about using oslib, BUT i cant find the documentation of the rotation function. i want to do it the way the maker of CSPSP did it. it seemed very smooth in his game..

@insomniac, il try the first option.
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 05:45 AM   #5

100% Pure Awesome
 
Join Date: Jan 2006
Posts: 508
Trader Feedback: 0
Default

One way it was done on old systems was using frames for each angle. It doesn't take any more power than just showing a regular frame, and it can look just as good if done correctly.
__________________

Ravine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 06:07 AM   #6
 
Join Date: Jul 2006
Posts: 53
Trader Feedback: 0
Default

Quote:
Originally Posted by Grimfate126
ive also thought about using oslib, BUT i cant find the documentation of the rotation function.
There is no function.

Code:
myimage->angle = any_angle;
СУББОТА is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 02:38 PM   #7

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
Originally Posted by СУББОТА
There is no function.

Code:
myimage->angle = any_angle;
awesome! im gonna try tat.
-= Double Post =-
i need help installing OSlib. i read the manual and heres what (part of) it says:

Code:
Finally, the OSLib directory is what it's all about; you should copy this to
a suitable place on your hard disc; probably in the same place as your other
libraries. Don't put it too low down in the directory structure; if you do
the path name will become too long for the system to resolve it. Two or three
levels down should be OK. It is possible to use OSLib within the archive, but
you will find it will significantly slow down the compilation process.

Using OSLib
-----------
At the top level in the OSLib directory you will find an Obey file named
SetVars. When this is run, the OSLib: path is set up. If you want to change
it, that's fine, but the default is really all you need. Make sure SetVars is
executed before you attempt to build anything using the library.

i put the oslib folder in my cygwin folder. BUT, when i try to run "SetVars" in cygwin, it says command not found... how do i install it??
__________________
--------------------------------------------------------------------------------------

Last edited by Grimfate126; 09-07-2006 at 02:38 PM.. Reason: Automerged Doublepost
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 02:47 PM   #8

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Uhhh, install it? SVN and download OSlib using Cygwin. 'cd' into the folder, type make, then make install... See what happens. I for one, have OSlib installed right now, but can't quite remember how I did it, so I just did the usual make, make install...
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 02:51 PM   #9

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
Originally Posted by SG57
Uhhh, install it? SVN and download OSlib using Cygwin. 'cd' into the folder, type make, then make install... See what happens. I for one, have OSlib installed right now, but can't quite remember how I did it, so I just did the usual make, make install...
how do u download from SVN?? i download the library itslef (in folder format)
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 02:56 PM   #10

100% Pure Awesome
 
Join Date: Jan 2006
Posts: 508
Trader Feedback: 0
Default

My way is much more hardcore It also takes hardly any processing power. Can you state exactly what you are doing with the rotation?
__________________

Ravine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 03:02 PM   #11

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

By hardcore you mean 'hardcore game-size-increase'? lol
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 03:10 PM   #12

100% Pure Awesome
 
Join Date: Jan 2006
Posts: 508
Trader Feedback: 0
Default

It increases the image by maybe 10kb...OMFGBBQ!!!...
__________________

Ravine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 03:14 PM   #13

Your Fate is Grim...
 
Grimfate126's Avatar
 
Join Date: Oct 2005
Posts: 2,269
Trader Feedback: 0
Default

Quote:
Originally Posted by Ravine
My way is much more hardcore It also takes hardly any processing power. Can you state exactly what you are doing with the rotation?
ok. here goes. im making a platform view game in C. the main guy is holding a gun, and when a move my analouge, it will rotate the gun accordingly. thats the basic stuf.
__________________
--------------------------------------------------------------------------------------
Grimfate126 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 05:10 PM   #14
 
Join Date: Jul 2006
Posts: 53
Trader Feedback: 0
Default

First thing you need to do is get the most recent version of oslib. You install it with "install.bat". From there the documentation covers everything you need to know to get started programming with it, and the samples will help understand the documentation.

I don't know what you've got, but I suspect it's not a PSP library. Make sure to add "psp" when googling for it.
СУББОТА is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 05:23 PM   #15

100% Pure Awesome
 
Join Date: Jan 2006
Posts: 508
Trader Feedback: 0
Default

Rotate the gun as in up and down??
__________________

Ravine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 06:44 PM   #16

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Rotating an image to pre-defined angles in an image, youll need to load additional images. And if you need 360* rotation, youll be adding 360 images... That is, if your rotated image is small enough to fit 360 of them n on 512x512 image, then youll need 1 image

I just think you should use hardware rotation... OSlib has that I believe (?)
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-07-2006, 09:26 PM   #17

Developer
 
Raphael's Avatar
 
Join Date: Jan 2006
Location: Germany
Posts: 919
Trader Feedback: 0
Default

There's something else too beyond whole degrees, you know... but if you're desperate on wasting space, you could also have images for every 0.5° or even 0.25° or 0.01°... not that anyone would notice the difference... but you have rotation on fractional degree precision!!!!!111eleven

Apart from the fact that a circle is point-symmetrical, it's also axis-symmetrical, and if you put some logics in that, you'll find that you only need to store 1/4 of those angles rotations, because the others can be achieved by simple horizontal/vertical flipping.
Also, what ravine was talking about was seriously NOT having an image for every possible degree, but maybe only for every 30° (ie 4 images in total), or if really more precise rotation is needed, every 10° (10 images). That's nothing that will blow your PSPs memory out of the roof...

PS: Rotating 4 vectors in software and giving them to GU will only cripple your apps speed if you don't know what you're doing.
PPS: Still the fully hardware rotation would be the most favorable, it's little bit slower than ravines implementation but still very fast and also has no memory footprint.
Raphael is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-08-2006, 04:16 AM   #18

100% Pure Awesome
 
Join Date: Jan 2006
Posts: 508
Trader Feedback: 0
Default

My idea works best for action/arcade games, such as Gauntlet. I wasn't exactly sure what you were doing so I threw it out there. You could still use mine and have it look kind of choppy on the rotation of the gun.
__________________

Ravine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
function , rotating

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 06:00 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us