void CEnemy01::Render() { drawTexture(getObjInfo(), RefPos_Center, 0, getObjkey(), getObjName(), getTexturekey(), getStatekey()); }
int initObj (char *objFullFilename, objObj * obj, FILE ** obj_fp, FILE ** mtl_fp, nameIndex ** mtlIndex, nameIndex ** texIndex) { char errString[255]; /* Path to obj and mtl data */ char pathName[255]; char *p; /* material lib filename */ char mtlFilename[255]; /* with path */ char mtlFullFilename[255]; /* number of vertices, normals, texture coordinates, * faces and materials */ int nbV, nbVN, nbVT, nbF, nbM; int i; mtlFilename[0] = '\0'; //printf ("Obj file : %s\n", objFullFilename); strcpy (pathName, objFullFilename); p = strrchr (pathName, '/'); if (p == NULL) pathName[0] = '\0'; else p[1] = '\0'; if (getObjInfo (objFullFilename, mtlFilename, &nbV, &nbVN, &nbVT, &nbF)) return 1; //printf ("Obj has %d vertices, %d normals, %d texcoords, %d faces\n", // nbV, nbVN, nbVT, nbF); if (mtlFilename[0] == 0) { fprintf (stderr, "Error: No material library\n"); return 1; } strcpy (mtlFullFilename, pathName); strcat (mtlFullFilename, mtlFilename); //printf ("Material library file is %s\n", mtlFullFilename); if (getMtlInfo (mtlFullFilename, &nbM)) return 1; //printf ("Material library has %d materials\n", nbM); *obj_fp = fopen (objFullFilename, "r"); if (*obj_fp == NULL) { sprintf (errString, "Can't open file (%s)", objFullFilename); perror (errString); return 1; } *mtl_fp = fopen (mtlFullFilename, "r"); if (*mtl_fp == NULL) { sprintf (errString, "Can't open file (%s)", mtlFullFilename); perror (errString); return 1; } obj->nbVertex = nbV; obj->nbNormal = nbVN; obj->nbTexcoord = nbVT; obj->nbFace = nbF; obj->nbMaterial = nbM; if (nbV > 0) { obj->vertexList = (objVertex *) malloc (nbV * sizeof (objVertex)); if (obj->vertexList == NULL) { perror ("Unable to allocate memory for vertices array"); return 1; } } if (nbVN > 0) { obj->normalList = (objNormal *) malloc (nbVN * sizeof (objNormal)); if (obj->normalList == NULL) { perror ("Unable to allocate memory for normals array"); return 1; } } if (nbVT > 0) { obj->texcoordList = (objTexcoord *) malloc (nbVT * sizeof (objTexcoord)); if (obj->texcoordList == NULL) { perror ("Unable to allocate memory for texcoords array"); return 1; } } if (nbF > 0) { obj->faceList = (objFace *) malloc (nbF * sizeof (objFace)); if (obj->faceList == NULL) { perror ("Unable to allocate memory for faces array"); return 1; } for (i = 0; i < nbF; i++) { obj->faceList[i].vertexIndexList = NULL; obj->faceList[i].normalIndexList = NULL; obj->faceList[i].texcoordIndexList = NULL; } } if (nbM > 0) { obj->materialList = (objMaterial *) malloc (nbM * sizeof (objMaterial)); if (obj->materialList == NULL) { perror ("Unable to allocate memory for materials array"); return 1; } /* A temporary array to store material names */ *mtlIndex = (nameIndex *) malloc (nbM * sizeof (nameIndex)); if (*mtlIndex == NULL) { perror ("Unable to allocate memory for material temporary index"); return 1; } /* A temporary array to store texture filenames. * Max 3 textures per material (ambient,diffuse,specular) * assuming all nbM materials have got 3 textures each * we can have at most 3*nbM textures */ *texIndex = (nameIndex *) malloc (3 * nbM * sizeof (nameIndex)); if (*texIndex == NULL) { perror ("Unable to allocate memory for texture temporary index"); return 1; } } return 0; }
void CEnemy01::Progress() { calculateMatworld(getObjInfo(), getObjInfo()->getPos(), D3DXVECTOR3(0.2f, -0.2f, 0.f)); }