PAlib: PA_3D.h Source File

Main Page | Modules | File List | Globals | Search for

# PA_3D.h

Go to the documentation of this file.

    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
    00051 void PA_Init3D(void);
    00057 void PA_LoadSplash3D(void);
    00082 void PA_Init3DDrawing(float x1, float y1, float z1, float x2, float y2, float z2);
    00083
    00084
    00085
    00086
    00121 void PA_glulookat(float eyex, float eyey, float eyez, float lookAtx, float lookAty, float lookAtz, float upx, float upy, float upz);
    00128 extern inline void PA_image8to16(sImage* img)
    00129  {
    00130         int i;
    00131
    00132         u16* temp = (u16*)malloc(img->height*img->width*2);
    00133
    00134         for(i = 0; i < img->height * img->width; i++)
    00135                temp[i] = img->palette[img->data8[i]] | (1<<15);
    00136
    00137         img->data16 = temp;
    00138  }
    00139
    00140
    00141 void PA_VueKeys(void);
    00157 extern inline void PA_LoadTexture(int numtexture, u8* nomtexture, int mode){
    00158 if(mode == texBIN){
    00159 glBindTexture(0, numtexture);
    00160 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0,TEXGEN_TEXCOORD, (u8*)nomtexture);
    00161 }
    00162 else if(mode == texPCX){
    00163 sImage pcx;
    00164 loadPCX((u8*)nomtexture, &pcx);
    00165 PA_image8to16(&pcx);
    00166 glBindTexture(0, numtexture);
    00167 glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.data8);
    00168 }
    00169 }
    00178 extern inline void PA_Texture(int numtexture){
    00179 glBindTexture(0, numtexture);
    00180 }
    00222 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);
    00264 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);
    00265
    00266
    00267
    00282 extern inline void PA_Rotate3D(float x,float y,float z){
    00283        glRotateX(x);
    00284     glRotateY(y);
    00285        glRotateZ(z);
    00286 }
    00301 extern inline void PA_Translate3D(float x, float y, float z){
    00302 glTranslate3f32(floattof32(x),floattof32(y),floattof32(z));
    00303 }
    00318 extern inline void PA_Scale3D(float x, float y, float z){
    00319        if(x==0.0)x=1.0;
    00320        if(y==0.0)y=1.0;
    00321        if(z==0.0)z=1.0;
    00322        MATRIX_SCALE = floattof32(x);
    00323        MATRIX_SCALE = floattof32(y);
    00324        MATRIX_SCALE = floattof32(z);
    00325 }
    00340 extern inline void PA_Vertex3D(float x, float y, float z){
    00341 glVertex3v16(floattov16(x),floattov16(y),floattov16(z));
    00342 }
    00348 extern inline void PA_3Dto2D(){
    00349 MATRIX_IDENTITY = 0;
    00350 }
    00351
    00352
    00364 extern inline void PA_Vertex2D(int x, int y){
    00365        float x1 = (float)((x*0.36)/256)-0.18;
    00366        float y1 = (float)((y*0.28)/192)-0.14;
    00367        glVertex3v16(floattov16(x1),floattov16(y1),floattov16(-0.2));
    00368 }
    00380 extern inline void PA_TexCoord(float x, float y){
    00381 glTexCoord1i(TEXTURE_PACK(inttot16((int)x),inttot16((int)y)));
    00382 }
    00383
    00384
    00385
    00386
    00387
    00388
    00389
    00390 int PA_InitCallList(PA_3DObject *obj);
    00391 int PA_VertexCallList(PA_3DObject *obj, float x, float y, float z);
    00392 int PA_TexCoordCallList(PA_3DObject *obj, int x, int y);
    00393 int PA_EndCallList(PA_3DObject *obj);
    00394 int PA_Draw3Dobject(PA_3DObject obj);
    00395 int PA_ScaleCallList(PA_3DObject *obj, float x, float y, float z); // end of 3D
    00397
    00398 #ifdef __cplusplus
    00399 }
    00400 #endif
    00401
    00402 #endif