forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Does sceGeGetMtx even work?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
tacoSunday



Joined: 31 Aug 2007
Posts: 34

PostPosted: Fri Aug 31, 2007 11:11 pm    Post subject: Does sceGeGetMtx even work? Reply with quote

I need to implement billboarding for my particle system. At first I thought this would be trivial with the GU_SPRITES primitive. Alas this does not seem to be the case. GU_SPRITES does not align to the view (ie: you can view the sprites edge on). I then went hunting through the headers for a way to retrieve the current view matrix so I could align the sprites myself. I finally stumbled across sceGeGetMtx(...). Thinking I had this one in the bag I hastily hammered out:

Code:

float viewmat[16];
         ...
sceGeGetMtx(PSP_GE_MATRIX_VIEW, viewmat);


To my utter dismay It didn't work. I fired up gdb and poked around. I discovered that no matter what matrix I requested I received a matrix full of zero's. It definitely seems to be writing to my matrix (I passed it an array initialized to 1's and got back 0's). Needless to say this is mighty frustrating as I just want to align a silly sprite.

Does sceGuGetMtx even work? Other than the meager documentation in pspge.h, I can't find a single reference to it on Google that isn't just a hit on the header file or a syscall index table.

Is this function even referencing the same matrices manipulated by sceGumTranslate and kin? I do find it slightly odd that it is in pspge.h and not pspgu(m).h .

If this is not the correct method to retrieve the transformation matrices could someone kindly point me in the right direction?

many thanks.

P.S. Looking through the source for pspgl's glGetFloatv I noticed that they don't use sceGeGetMtx. They seem to do their own bookkeeping and then switch to a VFPU context based on the requested matrix before directly copying the matrix from the VFPU registers to memory.
Code:

void glGetFloatv (GLenum pname, GLfloat *params)
{
        struct pspgl_matrix_stack *s;

        switch (pname) {
               .
               .
               .
        case GL_MODELVIEW_MATRIX:   s = &pspgl_curctx->modelview_stack; goto get_matrix;
        case GL_TEXTURE_MATRIX:      s = &pspgl_curctx->texture_stack; goto get_matrix;
        case GL_PROJECTION_MATRIX:   s = &pspgl_curctx->projection_stack; goto get_matrix;
        case GL_VIEW_PSP:      s = &pspgl_curctx->view_stack; goto get_matrix;
        case GL_BONE0_PSP ... GL_BONE7_PSP:
                s = &pspgl_curctx->bone_stacks[pname - GL_BONE0_PSP];
                /* FALLTHROUGH */
        get_matrix:
                if (params) {
                        const GLfloat *matrix = s->stack[s->depth].mat;
                        int i;

                        __pspgl_matrix_sync(pspgl_curctx, s);

                        for (i=0; i<16; i++)
                                params[i] = matrix[i];
                }
                break;
        default:
                GLERROR(GL_INVALID_ENUM);
        }
}


Code:

void __pspgl_matrix_sync(struct pspgl_context *c, const struct pspgl_matrix_stack *s)
{
        struct pspgl_matrix *m = &s->stack[s->depth];

        if ((s->flags & MF_VFPU) == 0)
                return;

        pspvfpu_use_matrices(c->vfpu_context, VFPU_STACKTOP, 0);

        asm volatile("sv.q   c700,  0 + %0, wb\n"
                     "sv.q   c710, 16 + %0, wb\n"
                     "sv.q   c720, 32 + %0, wb\n"
                     "sv.q   c730, 48 + %0, wb\n"
                     : "=m" (m->mat[0]) : : "memory");
}

This leads me to believe thet sceGeGetMtx isn't what I want it to be. I really don't want to jump through all those hoops. I haven't gotten around to looking at a disassembly of the sceGeGetMtx syscall yet. Maybe that will yield some answers...
Back to top
View user's profile Send private message
Sdw



Joined: 17 Jul 2007
Posts: 29

PostPosted: Sat Sep 01, 2007 1:23 am    Post subject: Reply with quote

That is strange, I also thought that GU_SPRITES where supposed to act as billboards. So right now a GU_SPRITE is exactly the same as a normal QUAD?
Back to top
View user's profile Send private message
tacoSunday



Joined: 31 Aug 2007
Posts: 34

PostPosted: Sat Sep 01, 2007 6:18 am    Post subject: Reply with quote

Not exactly like a quad. It seems to me that It's only purpose is to save 2 verts per quad. It really just creates a rectangular quad perpendicular to the XY plane from two opposing corners.

You can see the effect in my particle system.

Edit: new url
http://perniciousbeaver.ath.cx/broken/EBOOT.PBP


Last edited by tacoSunday on Sat Sep 01, 2007 7:35 am; edited 1 time in total
Back to top
View user's profile Send private message
Vincent_M



Joined: 03 Apr 2007
Posts: 73

PostPosted: Sat Sep 01, 2007 6:48 am    Post subject: Reply with quote

Use sceGumStoreMatrix right after you're done doing all view matrix operations to store that frame's view matrix in an instance of ScePspFMatrix4.
Back to top
View user's profile Send private message
tacoSunday



Joined: 31 Aug 2007
Posts: 34

PostPosted: Sat Sep 01, 2007 7:34 am    Post subject: Reply with quote

Thank you so much! I can't believe I overlooked that one!

http://perniciousbeaver.ath.cx/fixed/EBOOT.PBP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group