00001 #include "vlib.h"
00002
00003 PSP_MODULE_INFO ( "Test vLib", 0, 1, 1 );
00004 PSP_MAIN_THREAD_ATTR ( THREAD_ATTR_USER | THREAD_ATTR_VFPU );
00005
00006 const int TIMES = 500;
00007
00008 int main() {
00009
00010 scePowerSetClockFrequency ( 333, 333, 166 );
00011
00012 start_vLib();
00013 set_linear_filter ( ON );
00014
00015 set_fog ( 10, 20, RGB ( 0, 0, 0 ) );
00016
00017
00018 Image *texture = load_image ( "data/texture.png", IN_VRAM );
00019
00020 Model *model = load_model ( "data/model.obj" );
00021
00022
00023 float xCamPos = 0.0f;
00024 float yCamPos = 0.0f;
00025 float zCamPos = 0.0f;
00026
00027 float xCamRot = 3.4f;
00028 float yCamRot = 0.0f;
00029 float zoomCam = -2.0f;
00030
00031 float tempx, tempz, padDist, rotCurrent;
00032
00033 float camRate;
00034
00035 texture->height = 50.0f;
00036 texture->width = 50.0f;
00037
00038 for ( ;; ) {
00039 update_delta_time();
00040
00042
00044 read_input ( MASK_NONE, 0, 0 );
00045
00046 if ( button->pressed.start )
00047 sceKernelExitGame();
00048
00049
00050 if ( button->analogY <= -40 || button->analogY >= 40 || button->analogX <= -40 || button->analogX >= 40 ) {
00051
00052 rotCurrent = atan2f ( button->analogY, button->analogX );
00053
00054 if ( rotCurrent < -PI / 2 ) rotCurrent += 2 * PI;
00055
00056 tempx = vfpu_cosf ( yCamRot + rotCurrent );
00057 tempz = vfpu_sinf ( yCamRot + rotCurrent );
00058
00059 padDist = sqrtf ( button->analogX * button->analogX + button->analogY * button->analogY );
00060 if ( padDist > 128 ) padDist = 128;
00061
00062 xCamPos += tempx * padDist * 0.05f * deltaTime;
00063 zCamPos += tempz * padDist * 0.05f * deltaTime;
00064 }
00065
00066 camRate = 3.0f * deltaTime;
00067
00068 if ( button->held.up && zoomCam < -2.1f )
00069 zoomCam += camRate;
00070 if ( button->held.down && zoomCam > -4.8f )
00071 zoomCam -= camRate;
00072 if ( button->held.R )
00073 yCamRot += camRate;
00074 if ( button->held.L )
00075 yCamRot -= camRate;
00076
00077 if ( button->held.up )
00078 texture->y -= 300.0f * deltaTime;
00079 if ( button->held.down )
00080 texture->y += 300.0f * deltaTime;
00081 if ( button->held.left )
00082 texture->x -= 300.0f * deltaTime;
00083 if ( button->held.right )
00084 texture->x += 300.0f * deltaTime;
00085
00086 if ( button->held.cross )
00087 texture->height -= 300.0f * deltaTime;
00088 if ( button->held.triangle )
00089 texture->height += 300.0f * deltaTime;
00090 if ( button->held.square )
00091 texture->width -= 300.0f * deltaTime;
00092 if ( button->held.circle )
00093 texture->width += 300.0f * deltaTime;
00094
00095 if ( button->held.R )
00096 texture->angle += 3.0f * deltaTime;
00097 if ( button->held.L )
00098 texture->angle -= 3.0f * deltaTime;
00099
00101
00103
00104
00105 start_drawing();
00106
00107 clear_screen();
00108
00110
00112
00113
00114 set_camera_3rd_person(xCamPos,yCamPos,zCamPos, xCamRot,yCamRot, zoomCam);
00115
00116 draw_model(model, texture);
00117
00118
00119 texture->centerX = -(texture->width/2);
00120 texture->centerY = -(texture->height/2);
00121
00122 draw_image ( texture );
00123
00125
00127
00128
00129 end_drawing();
00130
00131 fps();
00132
00133 flip_screen();
00134 }
00135
00136 stop_vLib();
00137 sceKernelExitGame();
00138 return 0;
00139 }