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 

Projection problems...

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



Joined: 15 Apr 2009
Posts: 7

PostPosted: Wed Apr 29, 2009 2:44 pm    Post subject: Projection problems... Reply with quote

I'm trying to project world space coordinates to screen space with the following code.
Code:

        vfpu_identity_matrix(&temp_matrix);
        gumFastInverse(&temp_matrix,cam->view_matrix);

        vfpu_transform_vector(&temp_matrix,sun->position,&temp_vector4d);
        vfpu_transform_vector(cam->proj_matrix,&temp_vector4d,sun->screen);

        if (sun->screen->w!=0.0f) {
           w=1.0f/sun->screen->w;
           sun->screen->x=sun->screen->x*w;
           sun->screen->y=sun->screen->y*w;
           }
        sun->screen->x*=240.0f;
        sun->screen->y*=-136.0f;
        sun->screen->x+=240.0f;
        sun->screen->y+=136.0f;

        // All vectors are 4d. View and projection matrices are ok.
        // sun->position is a world-space position
        // sun->screen is a resulting screen-space position

Results are slightly incorrect. Can someone give a hint please where i made a mistake in this code ?
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Apr 29, 2009 9:43 pm    Post subject: Reply with quote

Well it's going to get quite cranky when screen->w is very near or equal to zero, or negative.

The best idea is to clip these polygons before you get anywhere near this stage in the pipeline.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
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