![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; For image rotation you're going to need to use some matrix math. Build a rotation matrix for theta (amount of ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#211 |
|
For image rotation you're going to need to use some matrix math. Build a rotation matrix for theta (amount of rotation; remember it's in radians, not degrees), then apply the matrix to your image. The resulting image should be put into the back buffer; storing it as an Image is just an unneeded hassle, unless you plan on saving it.
Granted, this method won't compensate for the origin of your image being in the upper left corner. To do that, you'll need to build an affine transformation using the rotation matrix that you should already have. Translate the image so that the origin lies in the center rather than the corner, apply the rotation matrix, then translate the image back to where it was before. It can be tricky to keep all of your variables straight, so consider building a struct as a representation of vectors and matrices, and define functions for dot products/linear transformations. This will help to keep your code clean, and a good vector struct with helper functions can be reused in the future. Have fun, and good luck. Edit: After I posted this I realized that starting with screen coordinates and moving back to the image via the inverse of the rotation matrix might be more effective. With the method that I posted first you might get "holes" in the image due to rounding; this second method takes care of that problem. By starting with the rotated image and looking up the color on the original image you'll get a filled image. From what I've seen, this is probably what most games use. Last edited by Kage68; 04-29-2006 at 02:33 PM.. Reason: Thought of a (possibly) better way |
|
|
|
|
|
|
#212 |
![]() ![]() ...in a dream...
|
Maybe a small example, you lost me therem but i understand some of it.
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#213 |
|
I wrote a quick little program to rotate an image earlier today. It uses my Vector2 struct with some helper functions, so you'll have to replace them with your own data type. Here's main():
Code:
SceCtrlData pad;
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
Image* img = loadImage("image.png");
if(!img)
{
printf("Image failed to load.\n");
sceKernelSleepThread();
return 0;
}
Color* vram;
Vector2 rotation[] = {{0,0},{0,0}};
int theta=0;
printf("Entering main loop.\n");
while((pad.Buttons&PSP_CTRL_CIRCLE)==0)
{
fillScreenRect(RGB(theta,64,224),0,0,480,272);
vram = getVramDrawBuffer();
sceCtrlReadBufferPositive(&pad,1);
if(pad.Buttons&(PSP_CTRL_UP|PSP_CTRL_RIGHT))
++theta;
if(pad.Buttons&(PSP_CTRL_DOWN|PSP_CTRL_LEFT))
--theta;
float sinTh = sin((float)theta*pi/180),cosTh = cos((float)theta*pi/180);
rotation[0].x = cosTh;
rotation[0].y = sinTh;
rotation[1].x = -sinTh;
rotation[1].y = cosTh;
int y;
for(y=0;y<img->imageHeight;++y)
{
int x;
for(x=0;x<img->imageWidth;++x)
{
Vector2 image = V2Create(x-img->imageWidth/2,y-img->imageHeight/2);
image = V2LinearTransform(rotation,image);
vram[PSP_LINE_SIZE * ((int)image.y+136) + (int)image.x+240] = img->data[img->imageWidth*y+x];
}
}
flipScreen();
}
freeImage(img);
sceKernelSleepThread();
return 0;
I hope you find it useful. |
|
|
|
|
|
|
#214 |
![]() ![]() Developer
|
It's actually going to be much quicker and cleaner to transform a pair of triangles in a triangle strip (giving you 4 corners) and render the image as a texture on the triangles. Then let the graphics processor do all the work while your original image is intact.
|
|
|
|
|
|
#215 |
|
I just found the GU documentation and samples in the pspsdk... I feel like an idiot for doing all of this the hard way. Much of what I've done is already built into the GU, so go ahead and disregard the code I posted earlier.
Thanks for pointing that out, Samstag. Now I just have to start figuring out how to use the sceGu_() functions. Is there another reference for them somewhere? The documentation that came with pspsdk is good, but doesn't give too much information. |
|
|
|
|
|
|
#216 |
![]() ![]() ...in a dream...
|
I agree, the SDK isn't 100% infomationalably understandable. But who has the time to comment every part. Especially after looking at the SDK, its huge.
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#217 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#219 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#220 |
![]() |
Sorry I wasn't clear about what I was looking for, but I've already looked into the ps2|)ev.org's pinned topic and it helped, but didn't exactly go over all that I was looking for.
It looks like PRX's load up automatically when a program closes or is able to atleast boot when another application closes. Also, the sample lacked comments from my standpoint. Maybe there is a simple tutorial, or should I just find a better way for the sceKernelLoadExec() then coming back to the oginal application. Since I've heard the 2.7 has a camera prx for new functions, could it be that prx's act as dll's? |
|
|
|
|
|
#221 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#222 |
![]() |
There is a link of a quite small way of obtaining ram data, but even with it, I need to findout how I would go about using a prx. I know prx's are a must to do returns, correct?
http://forums.ps2dev.org/viewtopic.p...6aa1457eef9b5b Although, I don't exactly see why ram would matter, but who cares... * I opened FileAssistant before and... I think they're way above my level. Last edited by Devun_06; 05-01-2006 at 02:06 PM.. |
|
|
|
|
|
#223 |
![]() |
if you wanna get into prx stuff use irshell
then you can edit and replace the mp3 prx http://www.ahman.co.nr/ in the downloads page at the bottom The source code for it is closed, but you can use the prx to display those memory things you use and compair what he did to the memory. Or just go on from there. So far there isn't any real help besides me, and I think you know more than I do. He made the prx plugin as a way to shut people up. So if you get anywhere pm me some betas.
__________________
[CENTER]You can hyperlink quotes and the whole box will be a link: [URL=http://forums.qj.net/showthread.php?t=35215][COLOR=DarkRed][QUOTE=ANTONIO_424][CENTER][COLOR=DarkRed]Go for it, and remember, video tape every moment...........I gotta see this :D[/COLOR][/CENTER][/QUOTE][/COLOR][/URL][SIZE=1][B][U][URL=http://forums.qj.net/showthread.php?t=65979]A Ultimate QJ FAQ[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/search.php?do=finduser&u=13500]Topics I'm in[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/f-psp-development-forum-11/t-pps-game-66613.html]My qj game topic[/URL][/U][/B]-[B][U][URL=http://www.psp-programming.com/dev-forum/viewtopic.php?t=962]My psp-prog topic[/URL][/U][/B]-[B][U][URL=http://files.pspupdates.qj.net/cgi-bin/cfiles.cgi]Old QJ Download site[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/showthread.php?t=46926]Only ISO topic[/URL][/U][/B][/SIZE] "You stayed up all night trying to make your psp crash? LOLOL!!" - my brother My PSN name is "icantthinkofone".[/CENTER] |
|
|
|
|
|
#225 | |
![]() ![]() Muppet Magnet
|
Quote:
The LSeek call returns the current file position - which by definition equals the size of the file. Or, use sceIoGetstat, which has the file size in the stats structure. Or, read it directly from an sceIoDirent structure, if you've been using sceIoDread to browse around the directories.
__________________
Using firmware v2.00-v3.50? Open up a whole world of homebrew here
The PSP Homebrew Database needs YOU! Your ISP may be illegally wiretapping all your web activity. Stop Phorm Now! Visiting the Edinburgh Festivals? Get practical advice from experts. |
|
|
|
|
|
|
#226 |
![]() ![]() Bush Programmer
|
Any chance of an example of the first method?
If I read a file after it's finished, I just keep reading zeros. This would be one way to tell most files have ended, unless the file actually ends with a lot of zeros. |
|
|
|
|
|
#228 |
![]() ![]() ...in a dream...
|
Can anyone tell me how to get the damned OSLib to install properly? I just need the rotation in it, but its being a pain, keep getting errors and what not while installing and setting up a mkaefile to include it, along with undefined errors after installation of the OSLib...
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#229 |
![]() ![]() Developer
|
How does SceKernelSysClock work? Can you somehow use it to display the same time as the clock in the os in your program with printf?? I have tryed to get it to work but no go so far... If someone has an example how how to use it please tell me.
Thanks in Advance! |
|
|
|
|
|
#230 |
![]() ![]() OMFG
|
Here's a quick one...
What's the equivalent to string.sub in LUA; but in C? An example of what string.sub does in LUA: Code:
string.sub(s, i [, j])
Return a substring of the string passed. The substring starts at i. If the third argument j is not given, the substring will end at the end of the string. If the third argument is given, the substring ends at and includes j.
> = string.sub("Hello Lua user", 7) -- from character 7 until the end
Lua user
> = string.sub("Hello Lua user", 7, 9) -- from character 7 until and including 9
Lua
Last edited by Slasher; 05-06-2006 at 07:36 AM.. |
|
|
|
|
|
#231 | |
![]() ![]() Developer
|
Quote:
Code:
char *string = "Hello Lua user";
printf("%s", string[7];
printf(%.*s", 3, string[7]);
|
|
|
|
|
|
|
#236 | |
![]() |
Quote:
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] |
|
|
|
|
|
|
#237 |
![]() ![]() Bush Programmer
|
Do you know if pspgu has anything to do with graphics?
I know I'm slack, I should look it up on ps2dev. BTW, the file size of pngs that can be loaded is limited even if resolution is 480x272. I tried to use a complicated 73.9 KB (75,684 bytes) png file and it broke my program, but a smaller file of the same resolution did work. |
|
|
|
|
|
#238 | |
![]() |
Quote:
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] |
|
|
|
|
|
|
#240 | |
![]() |
Quote:
__________________
[URL="http://www.newlilwayne.com"]www.NewLilWayne.com[/URL] |
|
|
|
|
![]() |
| Tags |
| c or c , c++ , c/c++ , code , coding , c_language , programming , psp , psp programming , thread |
| Thread Tools | |
|
|