PA_3D.h

Aller à la documentation de ce fichier.
00001 #ifndef _PA_3D
00002 #define _PA_3D
00003 #include <nds.h>
00004 #include <malloc.h>
00005 #include <nds/arm9/image.h>
00006 
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010 
00011 extern const u8 PAlib[];
00012 extern const u32 PAlib_size[];
00013 
00014 #define texPCX 1
00015 #define texBIN 2
00016 
00024 extern int textureID;
00025 extern float angle3dX, angle3dY;
00026 extern float viseeX, viseeY, viseeZ;
00027 
00028 typedef struct{
00029        u32 *callList;
00030        float maxx, maxy, maxz, minx, miny, minz;
00031        float scalex,scaley,scalez;
00032 }PA_3DObject;
00033 
00034 
00048 void PA_Init3D(void);
00049 
00055 void PA_Init3DAndBg(void);
00056 
00062 void PA_LoadSplash3D(void);
00063 
00064 
00065 
00090 void PA_Init3DDrawing(float x1, float y1, float z1, float x2, float y2, float z2);
00091 
00092 
00093 
00094 
00129 void PA_glulookat(float eyex, float eyey, float eyez, float lookAtx, float lookAty, float lookAtz, float upx, float upy, float upz);
00136 extern inline void PA_image8to16(sImage* img)
00137  {
00138         int i;
00139 
00140         u16* temp = (u16*)malloc(img->height*img->width*2);
00141         
00142         for(i = 0; i < img->height * img->width; i++)
00143                temp[i] = img->palette[img->data8[i]] | (1<<15);
00144 
00145         img->data16 = temp;
00146  }
00147 
00148 
00149 void PA_VueKeys(void);
00165 extern inline void PA_LoadTexture(int numtexture, u8* nomtexture, int mode){
00166        if(mode == texBIN){
00167        glBindTexture(0, numtexture);
00168        glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0,TEXGEN_TEXCOORD, (u8*)nomtexture);
00169        }
00170        else if(mode == texPCX){
00171        sImage pcx;
00172        loadPCX((u8*)nomtexture, &pcx);
00173        PA_image8to16(&pcx);
00174        glBindTexture(0, numtexture);
00175        glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.data8);
00176        }
00177 }
00186 extern inline void PA_Texture(int numtexture){
00187 glBindTexture(0, numtexture);
00188 }
00230 void PA_3DBox(float x, float y, float z, float longueur, float largeur, float hauteur,float rotatex, float rotatey, float rotatez, uint8 red, uint8 green, uint8 blue);
00272 void PA_3DBoxTexture(float x, float y, float z, float longueur, float largeur, float hauteur,float rotatex, float rotatey, float rotatez,uint8 red, uint8 green, uint8 blue);
00273 
00274 
00275 
00290 extern inline void PA_Rotate3D(float x,float y,float z){
00291        glRotateX(x);
00292     glRotateY(y);
00293        glRotateZ(z);
00294 }
00309 extern inline void PA_Translate3D(float x, float y, float z){
00310 glTranslate3f32(floattof32(x),floattof32(y),floattof32(z));
00311 }
00326 extern inline void PA_Scale3D(float x, float y, float z){
00327        if(x==0.0)x=1.0;
00328        if(y==0.0)y=1.0;
00329        if(z==0.0)z=1.0;
00330        MATRIX_SCALE = floattof32(x);
00331        MATRIX_SCALE = floattof32(y);
00332        MATRIX_SCALE = floattof32(z);
00333 }
00348 extern inline void PA_Vertex3D(float x, float y, float z){
00349 glVertex3v16(floattov16(x),floattov16(y),floattov16(z));
00350 }
00356 extern inline void PA_3Dto2D(){
00357 MATRIX_IDENTITY = 0;
00358 }
00359 
00360 
00372 extern inline void PA_Vertex2D(int x, int y){
00373        float x1 = (float)((x*0.36)/256)-0.18;
00374        float y1 = (float)((y*0.28)/192)-0.14;
00375        glVertex3v16(floattov16(x1),floattov16(y1),floattov16(-0.2));
00376 }
00388 extern inline void PA_TexCoord(float x, float y){
00389 glTexCoord1i(TEXTURE_PACK(inttot16((int)x),inttot16((int)y)));
00390 }
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 int PA_InitCallList(PA_3DObject *obj);
00399 int PA_VertexCallList(PA_3DObject *obj, float x, float y, float z);
00400 int PA_TexCoordCallList(PA_3DObject *obj, int x, int y);
00401 int PA_EndCallList(PA_3DObject *obj);
00402 int PA_Draw3Dobject(PA_3DObject obj);
00403 int PA_ScaleCallList(PA_3DObject *obj, float x, float y, float z); // end of 3D
00405 
00406 #ifdef __cplusplus
00407 }
00408 #endif
00409 
00410 #endif

Généré le Tue Jan 30 23:10:49 2007 pour PAlib par  doxygen 1.3.9.1