Show 40 post(s) from this thread on one page
Page 8 of 340 First 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 58 108 ... Last
• 04-29-2006, 02:00 PM
Kage68
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.
• 04-29-2006, 05:33 PM
SG57
Maybe a small example, you lost me therem but i understand some of it.
• 04-29-2006, 07:01 PM
Kage68
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;```
It's not commented, but most of what's going on is pretty self explanatory. This uses the first method I mentioned (rotate the image, put it on the screen) because I haven't looked into the second to see if it's feasible yet. I also wasn't too concerned about efficiency, considering that rotating the image is the only thing that this program does.

I hope you find it useful.
• 04-29-2006, 08:15 PM
Samstag
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.
• 04-29-2006, 09:30 PM
Kage68
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.
• 04-30-2006, 03:49 AM
SG57
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.
• 04-30-2006, 05:28 AM
Samstag
Quote:

Originally Posted by Kage68
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.

The Luaplayer source seems to be the best way to learn the GU functions. There's alse a lot of good information available at www.ps2dev.org. Here's a very good post that I think will help out.
• 04-30-2006, 02:39 PM
Devun_06
can someone tell me where I can findout all about PRX`s and how to use them. :confused:
• 05-01-2006, 05:39 AM
SodR
Quote:

Originally Posted by Devun_06
can someone tell me where I can findout all about PRX`s and how to use them. :confused:

You can either check the tutorial at forums.ps2dev.org or just use the sample included in the sdk.
• 05-01-2006, 11:23 AM
Devun_06
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?
• 05-01-2006, 11:58 AM
SodR
Quote:

Originally Posted by Devun_06
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?

• 05-01-2006, 02:01 PM
Devun_06
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.
• 05-02-2006, 01:26 AM
lord pip
if you wanna get into prx stuff use irshell
then you can edit and replace the mp3 prx
http://www.ahman.co.nr/

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.
• 05-04-2006, 11:07 PM
Art
Check file size
How do you check the size of a file on ms with normal file io commands?
• 05-05-2006, 02:44 AM
Fanjita
Quote:

Originally Posted by Art
How do you check the size of a file on ms with normal file io commands?

Use sceIoOpen, then sceIoLSeek32 to the end of the file.

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.
• 05-05-2006, 03:41 AM
Art
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.
• 05-05-2006, 10:21 AM
Art
Ok, thnx, I found a working example:
file_size = sceIoLseek32(musac, 0, SEEK_END);
Cheers, Art.
• 05-05-2006, 04:23 PM
SG57
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...
• 05-06-2006, 02:42 AM
SodR
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.

• 05-06-2006, 07:00 AM
Slasher
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```
• 05-06-2006, 02:42 PM
Samstag
Quote:

Originally Posted by Slasher
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```

Code:

```char *string = "Hello Lua user"; printf("%s", string[7]; printf(%.*s", 3, string[7]);```
Make sure you check that the string has at least 7 characters and is null-teminated.
• 05-10-2006, 06:56 AM
Devun_06
I know this is a stupid question, but I've searched go0gle, yahoo and I couldn't findout how to remove the error
const_cast undefined

can someone tell me what the problem is, adding #include <stdio> isn't helping?
• 05-10-2006, 07:03 AM
SodR
Code:

`#include <stdio.h>`
Code:

`#include <stdio>`
• 05-10-2006, 01:28 PM
Devun_06
Quote:

Originally Posted by SodR
Code:

`#include <stdio.h>`
Code:

`#include <stdio>`

That isn't working either...
• 05-12-2006, 08:31 PM
Art
Code:

```#include <pspgu.h> #include <png.h>```
Could I please have a description of what these two includes do,
If you draw all of your own graphics on the screen, would you ever need png.h?
Cheers, Art.
• 05-12-2006, 08:33 PM
soccerPMN
Quote:

Originally Posted by Art
Code:

```#include <pspgu.h> #include <png.h>```
Could I please have a description of what these two includes do,
If you draw all of your own graphics on the screen, would you ever need png.h?
Cheers, Art.

I'm pretty sure that the gu header is connected to hardware somehow, but the I'm pretty sure that if you weren't using PNGs, then you wouldn't need the png header.
• 05-12-2006, 08:43 PM
Art
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.
• 05-12-2006, 08:46 PM
soccerPMN
Quote:

Originally Posted by Art
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.

Did you look in the png header? Perhaps somewhere in the code the size of the array/buffer to hold the image can be changed to be greater than 480x272.
• 05-12-2006, 09:03 PM
Art
I was talking about filesize. Both pics are 480x272.
A png file size increases with the detail in the picture.
• 05-12-2006, 09:05 PM
soccerPMN
Quote:

Originally Posted by Art
I was talking about filesize. Both pics are 480x272.
A png file size increases with the detail in the picture.

I know, so you mean the memory itself cannot hold more than that? I originally thought it was limited by the buffer in the code, but you're suggesting it's limited in hardware?
Show 40 post(s) from this thread on one page
Page 8 of 340 First 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 58 108 ... Last