879 lines
32 KiB
C++
879 lines
32 KiB
C++
#include "SCENE.H"
|
||
#include <process.h>
|
||
#include "MAD\MAD_Struct_V0.h"
|
||
#include "MAD\MAD_mem.h"
|
||
|
||
#define MEDIA_BASE ".\\Media\\"
|
||
#define TEXTURES_DIRECTORY ""//"Textures\\"
|
||
#define MESHES_DIRECTORY ""//"Meshs\\"
|
||
#define MATERIALS_DIRECTORY ""//"Mats\\"
|
||
#define OBJECTS_DIRECTORY ""//"Objects\\"
|
||
void COPYMATRIX(MATRIX *DST, MAD_Matrix *SRC);
|
||
extern u8 Upper(u8 P);
|
||
|
||
void AddName(char *Directory,UnicID *Dst,UNIC_Dico *Dico,char *ObjectName = NULL,char *ObjectExtend = NULL)
|
||
{
|
||
if (ObjectName)
|
||
{
|
||
char NewName[2048];
|
||
if (ObjectExtend)
|
||
sprintf(NewName,"%s%s%s",Directory,ObjectName,ObjectExtend);
|
||
else
|
||
sprintf(NewName,"%s%s",Directory,ObjectName);
|
||
Dico->GetUnic(Dst , NewName);
|
||
}
|
||
else
|
||
Dico->GetUnic(Dst , "NULL");
|
||
}
|
||
|
||
|
||
|
||
u32 IsTargetMorph(char *Name)
|
||
{
|
||
u32 Last;
|
||
Last = 0;
|
||
while (*Name)
|
||
{
|
||
if (Last == 'TARG')
|
||
{
|
||
if ((Upper(Name[0]) == 'E') &&
|
||
(Upper(Name[1]) == 'T') &&
|
||
((Upper(Name[2]) >= '0') && (Upper(Name[2]) <= '9')) &&
|
||
((Upper(Name[3]) >= '0') && (Upper(Name[3]) <= '9')) &&
|
||
((Upper(Name[4]) == 0) || (Upper(Name[5]) == 0)))
|
||
{
|
||
return ((Upper(Name[2]) - '0') * 10) + (Upper(Name[3]) - '0');
|
||
}
|
||
}
|
||
Last <<= 8;
|
||
Last |= Upper(*Name);
|
||
Name++;
|
||
}
|
||
return -1;
|
||
}
|
||
u32 IsAdditionalUV(char *Name)
|
||
{
|
||
while (*Name)
|
||
{
|
||
if ((Upper(Name[0]) == '_') &&
|
||
(Upper(Name[1]) == 'U') &&
|
||
(Upper(Name[2]) == 'V') &&
|
||
((Upper(Name[3]) == 0)))
|
||
{
|
||
return 0;
|
||
}
|
||
Name++;
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/* Textures import */
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/*SmallScene *BigSmSC;
|
||
UNIC_Dico *BigDico;*/
|
||
void CorrectTextureName(char *Src,char *Dst)
|
||
{
|
||
char *RealBase;
|
||
RealBase = Dst;
|
||
while (*Src)
|
||
{
|
||
*RealBase = *Src;
|
||
if ((*Src == '\\') || (*Src == ':') || (*Src == '/'))
|
||
RealBase = Dst;
|
||
else
|
||
RealBase++;
|
||
Src++;
|
||
}
|
||
*RealBase = 0;
|
||
}
|
||
|
||
void LoadTextureCallback (FILE * f, int size, char *SrcName, int USERPARRAM)
|
||
{
|
||
char Name[2048];
|
||
char TxtName[2048];
|
||
FILE *F2;
|
||
CorrectTextureName(SrcName,TxtName);
|
||
|
||
CreateDirectory((char*)USERPARRAM,NULL);
|
||
sprintf(Name,"%s%s",(char*)USERPARRAM,TxtName);
|
||
//BigDico->GetUnic(&BigSmSC->TexturesIDs[BigSmSC->ulNumberOfTexturesRef++],Name);
|
||
char BUF[256];
|
||
F2 = fopen(Name,"rb");
|
||
if (F2 && (fread(BUF,1,256,F2) > 8))
|
||
{
|
||
CC_fclose(F2);
|
||
return;
|
||
}//*/
|
||
if (F2) CC_fclose(F2);
|
||
F2 = fopen(Name,"wb");
|
||
if (F2)
|
||
{
|
||
while (size)
|
||
{
|
||
u32 LocalSize;
|
||
LocalSize = size > 2048 ? 2048 : size;
|
||
fread(Name,1,LocalSize,f);
|
||
fwrite(Name,1,LocalSize,F2);
|
||
size -= LocalSize;
|
||
}
|
||
CC_fclose(F2);
|
||
}
|
||
}
|
||
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/* MESH import */
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
Mesh *CONVERTMADMESH(MAD_World *MW,MAD_GeometricObject *pGeo,UNIC_Dico *Dico,UNIC_Dico *DicoTarget,char *Directory,SmallScene *SmSC)
|
||
{
|
||
Mesh *CCMeshRet;
|
||
CCMeshRet = new Mesh();
|
||
for (int i = 0 ; i < pGeo->NumberOfPoints ; i++)
|
||
{
|
||
CCMeshRet->Vertex(pGeo->OBJ_PointList[i].Point.x,pGeo->OBJ_PointList[i].Point.y,pGeo->OBJ_PointList[i].Point.z);
|
||
CCMeshRet->VertexN(pGeo->OBJ_PointList[i].Normale.x,pGeo->OBJ_PointList[i].Normale.y,pGeo->OBJ_PointList[i].Normale.z);
|
||
}
|
||
if (pGeo->Colors)
|
||
{
|
||
CCMeshRet->NumberOfPointsVertexColors = pGeo->NumberOfPoints;
|
||
CCMeshRet->VertexColors = (u32*)CC_malloc(4 * CCMeshRet->NumberOfPointsVertexColors);
|
||
u32 BigColorOr = 0;
|
||
for (int i = 0 ; i < pGeo->NumberOfPoints ; i++)
|
||
{
|
||
CCMeshRet->VertexColors[i] = pGeo->Colors[i];
|
||
BigColorOr |= pGeo->Colors[i];
|
||
}
|
||
if ((BigColorOr & 0xff000000) == 0) BigColorOr |= 0xff000000; else BigColorOr &= ~0xff000000;
|
||
if ((BigColorOr & 0xffffff) == 0) BigColorOr |= 0xffffff; else BigColorOr &= ~0xffffff;
|
||
if (BigColorOr)
|
||
{
|
||
for (int i = 0 ; i < pGeo->NumberOfPoints ; i++)
|
||
CCMeshRet->VertexColors[i] |= BigColorOr;
|
||
}
|
||
}
|
||
for (int i = 0 ; i < pGeo->NumberOfUV ; i++)
|
||
{
|
||
CCMeshRet->VertexUV(pGeo->OBJ_UVtextureList[i].x,pGeo->OBJ_UVtextureList[i].y,1.0f);
|
||
}
|
||
for (int i = 0 ; i < pGeo->NumberOfElements ; i++)
|
||
{
|
||
for (int j = 0 ; j < pGeo->Elements[i]->NumberOfTriangles ; j++)
|
||
{
|
||
CCMeshRet->FaceUV(pGeo->Elements[i]->Faces[j].Index[0]+1,pGeo->Elements[i]->Faces[j].Index[1]+1,pGeo->Elements[i]->Faces[j].Index[2]+1,
|
||
pGeo->Elements[i]->Faces[j].UVIndex[0]+1,pGeo->Elements[i]->Faces[j].UVIndex[1]+1,pGeo->Elements[i]->Faces[j].UVIndex[2]+1,
|
||
pGeo->Elements[i]->MaterialID);
|
||
}
|
||
}
|
||
/* Compress SuboBjectIndexes */
|
||
if (CCMeshRet->NumberOfFaces)
|
||
{
|
||
u16 *pCompressed;
|
||
u32 CompressedNumber;
|
||
u32 CompressedSubIndex;
|
||
pCompressed = (u16*)CCMeshRet->FaceSubObjectIndexes;
|
||
CompressedSubIndex = CCMeshRet->FaceSubObjectIndexes[0];
|
||
CompressedNumber = 0;
|
||
for (int i = 0 ; i < CCMeshRet->NumberOfFaces; i++)
|
||
{
|
||
if (CompressedSubIndex == CCMeshRet->FaceSubObjectIndexes[i])
|
||
{
|
||
CompressedNumber ++;
|
||
CompressedSubIndex = CCMeshRet->FaceSubObjectIndexes[i];
|
||
} else
|
||
{
|
||
pCompressed[0] = (u16)CompressedNumber;
|
||
pCompressed[1] = (u16)CompressedSubIndex;
|
||
pCompressed+=2;
|
||
CompressedNumber = 1;
|
||
CompressedSubIndex = CCMeshRet->FaceSubObjectIndexes[i];
|
||
}
|
||
}
|
||
pCompressed[0] = (u16)CompressedNumber;
|
||
pCompressed[1] = (u16)CompressedSubIndex;
|
||
pCompressed+=2;
|
||
CCMeshRet->ulNumberOfSubObjects = (pCompressed - (u16*)CCMeshRet->FaceSubObjectIndexes) >>1;
|
||
}
|
||
|
||
/* Detect additional UVs *************************************************************************************************/
|
||
{
|
||
char Name[2048];
|
||
u32 IsExist,MeshIndex;
|
||
sprintf(Name,"%s_UV",pGeo->ID.Name);
|
||
IsExist = DicoTarget->IsExist(Name);
|
||
if (IsExist == -1)
|
||
{
|
||
sprintf(Name,"%s_UV1",pGeo->ID.Name);
|
||
IsExist = DicoTarget->IsExist(Name);
|
||
}
|
||
if (IsExist != -1)
|
||
{
|
||
MeshIndex = DicoTarget->mpst_Dico[IsExist].AssociatedValue;
|
||
MAD_GeometricObject *pGeoUV;
|
||
pGeoUV = NULL;
|
||
if (MW->AllObjects[MeshIndex]->IDType == ID_MAD_GeometricObject_V0)
|
||
pGeoUV = (MAD_GeometricObject *)MW->AllObjects[MeshIndex];
|
||
if (MW->AllObjects[MeshIndex]->IDType == ID_MAD_SkinnedGeometricObject)
|
||
pGeoUV = ((MAD_SkinnedGeometricObject *)MW->AllObjects[MeshIndex])->pst_GeoObj;
|
||
if ((pGeoUV->NumberOfPoints == CCMeshRet->NumberOfPoints) && (MAD_GetNumberOfFace(pGeoUV) == CCMeshRet->NumberOfFaces))
|
||
{
|
||
CCMeshRet->SwapUV();
|
||
for (int i = 0 ; i < pGeoUV->NumberOfUV ; i++)
|
||
{
|
||
CCMeshRet->VertexUV(pGeoUV->OBJ_UVtextureList[i].x,pGeoUV->OBJ_UVtextureList[i].y,1.0f);
|
||
};
|
||
CCMeshRet->SwapUV();
|
||
|
||
CCMeshRet->Indexes_UV2 = (FaceIndex *)CC_malloc(sizeof(FaceIndex) * (CCMeshRet->NumberOfFaces));
|
||
u32 MADFaceIndex = 0;
|
||
u32 *FaceRedirect;
|
||
FaceRedirect = (u32 *)CC_malloc(sizeof(u32) * (CCMeshRet->NumberOfFaces));
|
||
memset(FaceRedirect,0,sizeof(u32)*CCMeshRet->NumberOfFaces);
|
||
/* Yes, it's square, but faster to code !!*/
|
||
for (int i = 0 ; i < pGeoUV->NumberOfElements ; i++)
|
||
{
|
||
for (int j = 0 ; j < pGeoUV->Elements[i]->NumberOfTriangles ; j++)
|
||
{
|
||
#if 1
|
||
FaceRedirect[MADFaceIndex + j] = MADFaceIndex + j;
|
||
#else
|
||
for (int s = 0 ; s < CCMeshRet->NumberOfFaces ; s++)
|
||
{
|
||
if ((CCMeshRet->Indexes[s].I[0] == pGeoUV->Elements[i]->Faces[j].Index[0]) &&
|
||
(CCMeshRet->Indexes[s].I[1] == pGeoUV->Elements[i]->Faces[j].Index[1]) &&
|
||
(CCMeshRet->Indexes[s].I[2] == pGeoUV->Elements[i]->Faces[j].Index[2]))
|
||
{
|
||
FaceRedirect[MADFaceIndex + j] = s;
|
||
}
|
||
}
|
||
#endif
|
||
}
|
||
MADFaceIndex += pGeoUV->Elements[i]->NumberOfTriangles;
|
||
};
|
||
u32 FaceIndex = 0;
|
||
MADFaceIndex = 0;
|
||
for (int i = 0 ; i < pGeoUV->NumberOfElements ; i++)
|
||
{
|
||
for (int j = 0 ; j < pGeoUV->Elements[i]->NumberOfTriangles ; j++)
|
||
{
|
||
CCMeshRet->Indexes_UV2[FaceRedirect[FaceIndex]].I[0] = pGeoUV->Elements[i]->Faces[j].UVIndex[0];
|
||
CCMeshRet->Indexes_UV2[FaceRedirect[FaceIndex]].I[1] = pGeoUV->Elements[i]->Faces[j].UVIndex[1];
|
||
CCMeshRet->Indexes_UV2[FaceRedirect[FaceIndex++]].I[2] = pGeoUV->Elements[i]->Faces[j].UVIndex[2];
|
||
}
|
||
MADFaceIndex += pGeoUV->Elements[i]->NumberOfTriangles;
|
||
};
|
||
CC_free(FaceRedirect);
|
||
}
|
||
}
|
||
}
|
||
/* Detect TARGETS *************************************************************************************************/
|
||
{
|
||
char Name[2048],*Convert;
|
||
u32 TargetIndexes[256];
|
||
u32 NumberOfTarget;
|
||
u32 IsExist;
|
||
NumberOfTarget = 0;
|
||
for (int h = 0 ; h < 64 ; h ++)
|
||
{
|
||
TargetIndexes[h] = -1;
|
||
sprintf(Name,"%s_target0%d",pGeo->ID.Name,h);
|
||
IsExist = DicoTarget->IsExist(Name);
|
||
if (IsExist == -1)
|
||
{
|
||
sprintf(Name,"%s_target%d",pGeo->ID.Name,h);
|
||
IsExist = DicoTarget->IsExist(Name);
|
||
}
|
||
if (IsExist == -1)
|
||
{
|
||
sprintf(Name,"%s_target00%d",pGeo->ID.Name,h);
|
||
IsExist = DicoTarget->IsExist(Name);
|
||
}
|
||
if (IsExist != -1)
|
||
{
|
||
TargetIndexes[h] = DicoTarget->mpst_Dico[IsExist].AssociatedValue;
|
||
NumberOfTarget = h+1;
|
||
}
|
||
}
|
||
if (NumberOfTarget)
|
||
{
|
||
CCMeshRet->MorphTargets = (Target*)CC_malloc(sizeof(Target) * NumberOfTarget);
|
||
memset(CCMeshRet->MorphTargets,0,sizeof(Target) * NumberOfTarget);
|
||
CCMeshRet->ulNumberOfTarget = NumberOfTarget;
|
||
for (int h = 0;h < NumberOfTarget;h++)
|
||
{
|
||
MAD_GeometricObject *pGeoMorph;
|
||
pGeoMorph = NULL;
|
||
if (TargetIndexes[h]!=-1)
|
||
{
|
||
if (MW->AllObjects[TargetIndexes[h]]->IDType == ID_MAD_GeometricObject_V0)
|
||
pGeoMorph = (MAD_GeometricObject *)MW->AllObjects[TargetIndexes[h]];
|
||
if (MW->AllObjects[TargetIndexes[h]]->IDType == ID_MAD_SkinnedGeometricObject)
|
||
pGeoMorph = ((MAD_SkinnedGeometricObject *)MW->AllObjects[TargetIndexes[h]])->pst_GeoObj;
|
||
}
|
||
CCMeshRet->MorphTargets[h].MorphNumber = 0;
|
||
CCMeshRet->MorphTargets[h].MorphList = (Morphing*)CC_malloc(sizeof(Morphing) * CCMeshRet->NumberOfPoints);
|
||
memset(CCMeshRet->MorphTargets[h].MorphList,0,sizeof(Morphing) * CCMeshRet->NumberOfPoints);
|
||
CCMeshRet->MorphTargets[h].MorphNumber_UV = 0;
|
||
CCMeshRet->MorphTargets[h].MorphList_UV = (Morphing*)CC_malloc(sizeof(Morphing) * CCMeshRet->NumberOfPointsUV);
|
||
memset(CCMeshRet->MorphTargets[h].MorphList_UV,0,sizeof(Morphing) * CCMeshRet->NumberOfPointsUV);
|
||
if (pGeoMorph && (pGeo->NumberOfPoints == pGeoMorph->NumberOfPoints))
|
||
{
|
||
/* Add Different Vertexes */
|
||
MAD_Simple3DVertex *OBJ_PointList1,*OBJ_PointListT;
|
||
OBJ_PointList1 = pGeo->OBJ_PointList;
|
||
OBJ_PointListT = pGeoMorph->OBJ_PointList;
|
||
for (int index = 0;index < pGeo->NumberOfPoints;index++)
|
||
{
|
||
if ((OBJ_PointList1->Point.x != OBJ_PointListT->Point.x) ||
|
||
(OBJ_PointList1->Point.y != OBJ_PointListT->Point.y) ||
|
||
(OBJ_PointList1->Point.z != OBJ_PointListT->Point.z))
|
||
{
|
||
CCMeshRet->MorphTargets[h].MorphList[CCMeshRet->MorphTargets[h].MorphNumber].VIndex = index;
|
||
CCMeshRet->MorphTargets[h].MorphList[CCMeshRet->MorphTargets[h].MorphNumber].Move.x = OBJ_PointListT->Point.x - OBJ_PointList1->Point.x;
|
||
CCMeshRet->MorphTargets[h].MorphList[CCMeshRet->MorphTargets[h].MorphNumber].Move.y = OBJ_PointListT->Point.y - OBJ_PointList1->Point.y;
|
||
CCMeshRet->MorphTargets[h].MorphList[CCMeshRet->MorphTargets[h].MorphNumber].Move.z = OBJ_PointListT->Point.z - OBJ_PointList1->Point.z;
|
||
CCMeshRet->MorphTargets[h].MorphNumber++;
|
||
}
|
||
OBJ_PointList1++;
|
||
OBJ_PointListT++;
|
||
}
|
||
};
|
||
if (pGeoMorph && (pGeo->NumberOfUV == pGeoMorph->NumberOfUV))
|
||
{
|
||
/* Add Different Vertexes */
|
||
MAD_Vertex *OBJ_PointList1,*OBJ_PointListT;
|
||
OBJ_PointList1 = pGeo->OBJ_UVtextureList;
|
||
OBJ_PointListT = pGeoMorph->OBJ_UVtextureList;
|
||
for (int index = 0;index < pGeo->NumberOfUV;index++)
|
||
{
|
||
if ((OBJ_PointList1->x != OBJ_PointListT->x) ||
|
||
(OBJ_PointList1->y != OBJ_PointListT->y) ||
|
||
(OBJ_PointList1->z != OBJ_PointListT->z))
|
||
{
|
||
CCMeshRet->MorphTargets[h].MorphList_UV[CCMeshRet->MorphTargets[h].MorphNumber_UV].VIndex = index;
|
||
CCMeshRet->MorphTargets[h].MorphList_UV[CCMeshRet->MorphTargets[h].MorphNumber_UV].Move.x = OBJ_PointListT->x - OBJ_PointList1->x;
|
||
CCMeshRet->MorphTargets[h].MorphList_UV[CCMeshRet->MorphTargets[h].MorphNumber_UV].Move.y = OBJ_PointListT->y - OBJ_PointList1->y;
|
||
CCMeshRet->MorphTargets[h].MorphList_UV[CCMeshRet->MorphTargets[h].MorphNumber_UV].Move.z = OBJ_PointListT->z - OBJ_PointList1->z;
|
||
CCMeshRet->MorphTargets[h].MorphNumber_UV++;
|
||
}
|
||
OBJ_PointList1++;
|
||
OBJ_PointListT++;
|
||
}
|
||
};
|
||
}
|
||
}
|
||
}
|
||
CCMeshRet->Connect();
|
||
return CCMeshRet;
|
||
}
|
||
|
||
Mesh *CCMesh;// DBUG
|
||
|
||
u32 SAVEMADMESH(MAD_World *MW,MAD_GeometricObject *pGeo,UNIC_Dico *Dico,UNIC_Dico *DicoTargets,char *Directory,SmallScene *SmSC)
|
||
{
|
||
char Name[2048];
|
||
CCMesh = CONVERTMADMESH(MW,pGeo,Dico,DicoTargets,Directory,SmSC);
|
||
FILE *F;
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.MSH",Directory,pGeo->ID.Name);
|
||
Dico->GetUnic(&SmSC->MeshesIDs[SmSC->ulNumberOfMeshes++],Name);
|
||
SaveMesh(CCMesh,Name);
|
||
FreeMesh(CCMesh);
|
||
CC_free(CCMesh);
|
||
|
||
return 0;
|
||
}
|
||
|
||
u32 SAVELIGHT(MAD_World *MW,MAD_Light *pLight,UNIC_Dico *Dico,UNIC_Dico *DicoTargets,char *Directory,SmallScene *SmSC)
|
||
{
|
||
char Name[2048];
|
||
FILE *F;
|
||
|
||
if (SmSC->ulNumberOfLights == 0)
|
||
{
|
||
SmSC->LightsIDs = (UnicID*)CC_malloc(sizeof(UnicID*));
|
||
SmSC->LightsPtrs = (_3D_Light**)CC_malloc(sizeof(_3D_Light*));
|
||
} else
|
||
{
|
||
SmSC->LightsIDs = (UnicID*)CC_realloc(SmSC->LightsIDs,sizeof(UnicID*)*(SmSC->ulNumberOfLights+1));
|
||
SmSC->LightsPtrs = (_3D_Light**)CC_realloc(SmSC->LightsPtrs,sizeof(_3D_Light*)*(SmSC->ulNumberOfLights+1));
|
||
}
|
||
SmSC->LightsIDs[SmSC->ulNumberOfLights] = -1;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights] = (_3D_Light*)CC_malloc(sizeof(_3D_Light));
|
||
memset(SmSC->LightsPtrs[SmSC->ulNumberOfLights],0,sizeof(_3D_Light));
|
||
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightColor.x = (float)((pLight->LightColor & 0xff))/255.0f;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightColor.y = (float)((pLight->LightColor>>8) & 0xff)/255.0f;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightColor.z = (float)((pLight->LightColor>>16) & 0xff)/255.0f;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->IsOn = pLight->IsOn;
|
||
AddName(Directory,&SmSC->LightsPtrs[SmSC->ulNumberOfLights]->ObjectID,Dico, pLight->ID.Name , ".OBJ");
|
||
if (pLight->LightType == 0) // Omni
|
||
{
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightType = 0;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->Near = pLight->Omni.Near;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->Far = pLight->Omni.Far;
|
||
}
|
||
if (pLight->LightType == 1) // Spot
|
||
{
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightType = 1;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->Near = pLight->Omni.Near;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->Far = pLight->Omni.Far;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->SmallAlpha = pLight->Spot.LittleAlpha;
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->BigAlpha = pLight->Spot.BigAlpha;
|
||
}
|
||
if (pLight->LightType == 2) // Direct
|
||
{
|
||
SmSC->LightsPtrs[SmSC->ulNumberOfLights]->LightType = 2;
|
||
}
|
||
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.LGH",Directory,pLight->ID.Name);
|
||
Dico->GetUnic(&SmSC->LightsIDs[SmSC->ulNumberOfLights++],Name);
|
||
Save_3D_Light(SmSC->LightsPtrs[SmSC->ulNumberOfLights-1],Name,Dico);
|
||
Free_3D_Light(SmSC->LightsPtrs[SmSC->ulNumberOfLights-1], Dico);
|
||
CC_free(SmSC->LightsPtrs[SmSC->ulNumberOfLights-1]);
|
||
return 0;
|
||
}
|
||
|
||
|
||
u32 SAVEMADMESH_SKIN(MAD_World *MW,MAD_SkinnedGeometricObject *pGeo,UNIC_Dico *Dico,UNIC_Dico *DicoTargets,char *Directory,SmallScene *SmSC)
|
||
{
|
||
char Name[2048];
|
||
CCMesh = CONVERTMADMESH(MW,pGeo->pst_GeoObj,Dico,DicoTargets,Directory,SmSC);
|
||
/* Add skinning to Mesh */
|
||
CCMesh->ulNumberOfSkins = pGeo->us_NumberOfPonderationLists;
|
||
if (CCMesh->ulNumberOfSkins)
|
||
{
|
||
CCMesh->MeshSkin = (Skin*)CC_malloc(sizeof(Skin) * CCMesh->ulNumberOfSkins);
|
||
for (int i = 0 ; i < CCMesh->ulNumberOfSkins ; i ++ )
|
||
{
|
||
COPYMATRIX(&CCMesh->MeshSkin[i].Flash, &pGeo->pst_PonderationList[i].st_FlashedMatrix);
|
||
if (pGeo->pst_PonderationList[i].us_MatrixIdx < MW->NumberOfHierarchieNodes)
|
||
AddName(Directory,&CCMesh->MeshSkin[i].ObjectID ,Dico, MW->Hierarchie[pGeo->pst_PonderationList[i].us_MatrixIdx].ID.Name , ".OBJ");
|
||
else
|
||
AddName(Directory,&CCMesh->MeshSkin[i].ObjectID ,Dico);
|
||
CCMesh->MeshSkin[i].ObjectIndex = pGeo->pst_PonderationList[i].us_MatrixIdx;
|
||
CCMesh->MeshSkin[i].WeightNumber = pGeo->pst_PonderationList[i].us_NumberOfPonderatedVertices;
|
||
if (CCMesh->MeshSkin[i].WeightNumber)
|
||
{
|
||
CCMesh->MeshSkin[i].WeightList = (Ponderation*)CC_malloc(sizeof(Ponderation) * CCMesh->MeshSkin[i].WeightNumber);
|
||
for (int j = 0 ; j < CCMesh->MeshSkin[i].WeightNumber ; j ++ )
|
||
{
|
||
CCMesh->MeshSkin[i].WeightList[j].VIndex = pGeo->pst_PonderationList[i].p_CmpPdrtVrt[j].Index;
|
||
*((u32 *)&CCMesh->MeshSkin[i].WeightList[j].Weight) = 0;
|
||
((u16 *)&CCMesh->MeshSkin[i].WeightList[j].Weight)[1] = pGeo->pst_PonderationList[i].p_CmpPdrtVrt[j].Ponderation;
|
||
}
|
||
}
|
||
}//*/
|
||
}
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.MSH",Directory,pGeo->ID.Name);
|
||
Dico->GetUnic(&SmSC->MeshesIDs[SmSC->ulNumberOfMeshes++],Name);
|
||
SaveMesh(CCMesh,Name,Dico);
|
||
FreeMesh(CCMesh);
|
||
CC_free(CCMesh);
|
||
return 0;
|
||
}
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/* MATERIAL import */
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
|
||
u32 SAVEMATERIAL(MAD_World *MW,MAD_MAT_MatID *pMat,UNIC_Dico *Dico,char *Directory,SmallScene *SmSC)
|
||
{
|
||
char Name[2048];
|
||
_3D_Material *Mat;
|
||
|
||
if (pMat->MaterialType == ID_MAT_NullMat)
|
||
{
|
||
Mat = (_3D_Material*)CC_malloc(sizeof(_3D_Material));
|
||
memset(Mat,0,sizeof(_3D_Material));
|
||
GLOB_SetDefaultRS(&Mat->Layers[0].RenderState);
|
||
Mat->Layers[0].RenderState.LIGHTED = 1;
|
||
AddName(Directory,&Mat->Layers[0].TextureID,Dico);
|
||
Mat->NumberOfLayers = 1;
|
||
Mat->Layers[0].RenderState.TEXTURED = 0;
|
||
} else
|
||
if (pMat->MaterialType == ID_MAT_Standard)
|
||
{
|
||
Mat = (_3D_Material*)CC_malloc(sizeof(_3D_Material));
|
||
memset(Mat,0,sizeof(_3D_Material));
|
||
MAD_StandarMaterial *MTT;
|
||
MTT = (MAD_StandarMaterial *)pMat;
|
||
Mat->NumberOfLayers = 1;
|
||
GLOB_SetDefaultRS(&Mat->Layers[0].RenderState);
|
||
Mat->Layers[0].RenderState.LIGHTED = 1;
|
||
|
||
/*** impl<70>mentation de la transparence du material ***/
|
||
/* int blendingMode = ((MAD_StandarMaterial*)pMat)->MaterialFlag & MAD_MTF_TransparencyModeMask;
|
||
if(blendingMode<0 || blendingMode>=NB_OF_BLENDING_MODES) blendingMode = 0;
|
||
int blendingModeTranslation[] = {0, 2, 4, 1, 3, 6, 5, 7};
|
||
Mat->Layers[0].RenderState.BlendingMode = blendingModeTranslation[blendingMode];
|
||
/*****************************************************/
|
||
|
||
if (MTT->MadTexture == MAD_NULL_INDEX)
|
||
{
|
||
Mat->Layers[0].RenderState.TEXTURED = 0;
|
||
AddName(Directory,&Mat->Layers[0].TextureID,Dico);
|
||
}
|
||
else
|
||
{
|
||
Mat->Layers[0].RenderState.TEXTURED = 1;
|
||
AddName(Directory,&Mat->Layers[0].TextureID,Dico,MW->AllTextures[MTT->MadTexture]->Texturefile);
|
||
}
|
||
} else
|
||
if (pMat->MaterialType == ID_MAT_MultiMaterial)
|
||
{
|
||
_3D_MultiMaterial *MultiMat;
|
||
MultiMat = (_3D_MultiMaterial*)CC_malloc(sizeof(_3D_MultiMaterial));
|
||
memset(MultiMat,0,sizeof(_3D_MultiMaterial));
|
||
MAD_MultiMaterial *MTT;
|
||
MTT = (MAD_MultiMaterial *)pMat;
|
||
MultiMat->ulNumberOfMaterials = MTT->NumberOfSubMaterials;
|
||
if (MultiMat->ulNumberOfMaterials)
|
||
{
|
||
MultiMat->pMaterialsIDS = (UnicID *)CC_malloc(sizeof(UnicID)*MultiMat->ulNumberOfMaterials);
|
||
for (int i = 0 ; i < MTT->NumberOfSubMaterials; i++)
|
||
{
|
||
if (MTT->SubMats[i] != MAD_NULL_INDEX)
|
||
AddName(Directory,&MultiMat->pMaterialsIDS[i],Dico,MW->AllMaterial[MTT->SubMats[i]]->Name,".MAT");
|
||
else
|
||
AddName(Directory,&MultiMat->pMaterialsIDS[i],Dico);
|
||
}
|
||
}
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.MMT",Directory,pMat->Name);
|
||
Dico->GetUnic(&SmSC->MultiMaterialsIDs[SmSC->ulNumberOfMultiMats++],Name);
|
||
Save_3D_MultiMaterial(MultiMat,Name,Dico);
|
||
Free_3D_MultiMaterial(MultiMat, Dico);
|
||
CC_free(MultiMat);
|
||
return 0;
|
||
} else
|
||
if (pMat->MaterialType == ID_MAT_MultiTexMaterial)
|
||
{
|
||
Mat = (_3D_Material*)CC_malloc(sizeof(_3D_Material));
|
||
memset(Mat,0,sizeof(_3D_Material));
|
||
MAD_MultiTexMaterial *MTT;
|
||
MTT = (MAD_MultiTexMaterial *)pMat;
|
||
Mat->NumberOfLayers = MTT->NumberOfLevels;
|
||
for (int i = 0 ; i < MTT->NumberOfLevels ; i++)
|
||
{
|
||
GLOB_SetDefaultRS(&Mat->Layers[i].RenderState);
|
||
Mat->Layers[i].RenderState.LIGHTED = 1;
|
||
|
||
Mat->Layers[i].ColorMultiplier = 0xffffffff;
|
||
sprintf((s8*)Mat->Layers[i].LayerName,"Layer %d" , i);
|
||
if (MTT->AllLevels[i].s_TextureId == MAD_NULL_INDEX)
|
||
{
|
||
Mat->Layers[i].RenderState.TEXTURED = 0;
|
||
AddName(Directory,&Mat->Layers[i].TextureID,Dico);
|
||
}
|
||
else
|
||
{
|
||
Mat->Layers[i].RenderState.TEXTURED = 1;
|
||
AddName(Directory,&Mat->Layers[i].TextureID,Dico, MW->AllTextures[MTT->AllLevels[i].s_TextureId]->Texturefile);
|
||
}
|
||
}
|
||
} else return 0;
|
||
|
||
Mat->Layers[0].ColorMultiplier = 0xffffffff;
|
||
sprintf((s8*)Mat->Layers[0].LayerName,"Layer %d" , 0);
|
||
|
||
/*** impl<70>mentation de la transparence du material ***/
|
||
float opacity = ((MAD_StandarMaterial*)pMat)->Opacity;
|
||
if(opacity>1.0) opacity = 1.0; if(opacity<0.0) opacity = 0.0;
|
||
Mat->Layers[0].ColorMultiplier = ((unsigned int)(255.0*opacity))<<24 | 0x00ffffff;
|
||
/*****************************************************/
|
||
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.MAT",Directory,pMat->Name);
|
||
Dico->GetUnic(&SmSC->MaterialsIDs[SmSC->ulNumberOfMaterials++],Name);
|
||
Save_3D_Material(Mat,Name,Dico);
|
||
Free_3D_Material(Mat,Dico);
|
||
CC_free(Mat);
|
||
return 0;
|
||
}
|
||
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/* SCENE import */
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
|
||
|
||
void COPYMATRIX(MATRIX *DST, MAD_Matrix *SRC)
|
||
{
|
||
DST->I = *(Vector *)&SRC->I;
|
||
DST->J = *(Vector *)&SRC->J;
|
||
DST->K = *(Vector *)&SRC->K;
|
||
DST->T = *(Vector *)&SRC->Translation;
|
||
//DST->I.Clean();
|
||
//DST->J.Clean();
|
||
//DST->K.Clean();
|
||
//DST->T.Clean();
|
||
|
||
}//*/
|
||
|
||
u32 SAVEMADOBJECT(MAD_World *MW,MAD_WorldNode *pObject,UNIC_Dico *Dico,char *Directory,SmallScene *SmSC)
|
||
{
|
||
char Name[2048];
|
||
_3D_Object *pCCObject;
|
||
pCCObject = (_3D_Object *)CC_malloc(sizeof(_3D_Object));
|
||
memset(pCCObject,0,sizeof(_3D_Object));
|
||
|
||
COPYMATRIX(&pCCObject->GlobalMatrix, &pObject->Matrix);
|
||
/* Compute Relative */
|
||
if (pObject->Parent != MAD_NULL_INDEX)
|
||
{
|
||
MATRIX faMatrix,faMatrix1;
|
||
MAD_WorldNode *pParent;
|
||
pParent = &MW->Hierarchie[pObject->Parent];
|
||
COPYMATRIX(&pCCObject->LocalMatrix, &pObject->Matrix);
|
||
COPYMATRIX(&faMatrix, &pParent->Matrix);
|
||
faMatrix.Inverse(faMatrix1);
|
||
pCCObject->LocalMatrix *= faMatrix1;
|
||
} else
|
||
pCCObject->LocalMatrix = pCCObject->GlobalMatrix;
|
||
pCCObject->Pivot.x = pObject->Pivot.x;
|
||
pCCObject->Pivot.y = pObject->Pivot.y;
|
||
pCCObject->Pivot.z = pObject->Pivot.z;
|
||
|
||
if (pObject->Parent != MAD_NULL_INDEX)
|
||
AddName(Directory,&pCCObject->FatherID,Dico, MW->Hierarchie[pObject->Parent].ID.Name , ".OBJ");
|
||
else
|
||
AddName(Directory,&pCCObject->FatherID,Dico);
|
||
|
||
if ((pObject->Object != MAD_NULL_INDEX) && (
|
||
(MW->AllObjects[pObject->Object]->IDType == ID_MAD_GeometricObject_V0)||
|
||
(MW->AllObjects[pObject->Object]->IDType == ID_MAD_SkinnedGeometricObject)))
|
||
AddName(Directory,&pCCObject->MeshID,Dico, MW->AllObjects[pObject->Object]->Name , ".MSH");
|
||
else
|
||
{
|
||
AddName(Directory,&pCCObject->MeshID,Dico);
|
||
if ((pObject->Object != MAD_NULL_INDEX) && (MW->AllObjects[pObject->Object]->IDType == ID_MAD_Camera))
|
||
{
|
||
if ((Upper(pObject->ID.Name[0]) == 'C') &&
|
||
(Upper(pObject->ID.Name[1]) == 'P') &&
|
||
(Upper(pObject->ID.Name[2]) == 0))
|
||
{
|
||
COPYMATRIX(&SmSC->CameraPosition, &pObject->Matrix);
|
||
}
|
||
else
|
||
{
|
||
if (SmSC->CameraPosition.I.x == 1.0f &&
|
||
SmSC->CameraPosition.J.y == 1.0f &&
|
||
SmSC->CameraPosition.K.z == 1.0f)
|
||
COPYMATRIX(&SmSC->CameraPosition, &pObject->Matrix);
|
||
}
|
||
}
|
||
}
|
||
|
||
pCCObject->pObjectName = (u8 *)CC_malloc(strlen(pObject->ID.Name)+1);
|
||
strcpy((char*)pCCObject->pObjectName, pObject->ID.Name);
|
||
|
||
AddName(Directory,&pCCObject->MaterialID,Dico);
|
||
AddName(Directory,&pCCObject->MultiMaterialID,Dico);
|
||
|
||
if (pObject->Material != MAD_NULL_INDEX)
|
||
{
|
||
if (MW->AllMaterial[pObject->Material]->MaterialType == ID_MAT_MultiMaterial)
|
||
AddName(Directory,&pCCObject->MultiMaterialID,Dico, MW->AllMaterial[pObject->Material]->Name, ".MMT");
|
||
else
|
||
AddName(Directory,&pCCObject->MaterialID,Dico, MW->AllMaterial[pObject->Material]->Name, ".MAT");
|
||
}
|
||
|
||
CreateDirectory(Directory,NULL);
|
||
sprintf(Name,"%s%s.OBJ",Directory,pObject->ID.Name);
|
||
Dico->GetUnic(&SmSC->ObjectsIDs[SmSC->ulNumberOfObjects++],Name);
|
||
Save_3D_Object(pCCObject,Name,Dico);
|
||
Free_3D_Object(pCCObject,Dico);
|
||
CC_free(pCCObject);
|
||
return 0;
|
||
}
|
||
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
/* SCENE import */
|
||
/****************************************************************************************************************/
|
||
/****************************************************************************************************************/
|
||
u32 MAD_2_CAMCAM(char *FullName)
|
||
{
|
||
char FileName[2048];
|
||
char NewName[2048];
|
||
char Name[2048];
|
||
char SceneDir[2048];
|
||
char MEDIA_DIRECTORY[2048];
|
||
SmallScene *BigSmSC;
|
||
MAD_World *MW;
|
||
if (GetFileNameExtend((char *)FullName) == '.MAD')
|
||
{
|
||
char *P;
|
||
P = NewName;
|
||
while (*FullName)
|
||
{
|
||
*P++ = *FullName++;
|
||
}
|
||
*(P-4) = 0;
|
||
FullName = NewName;
|
||
}
|
||
sprintf(Name,"%s.MAD",FullName);
|
||
/* Compute filename */
|
||
{
|
||
u32 FNi;
|
||
FNi = 0;
|
||
while (*FullName)
|
||
{
|
||
FileName[FNi++] = *FullName;
|
||
if ((*FullName == '\\') ||
|
||
(*FullName == '/') ||
|
||
(*FullName == ':'))
|
||
{
|
||
FNi = 0;
|
||
}
|
||
FullName++;
|
||
}
|
||
FileName[FNi] = 0;
|
||
}
|
||
|
||
FILE *TEST;
|
||
TEST = fopen(Name,"rb");
|
||
if (!TEST) return 0;
|
||
CC_fclose(TEST);
|
||
|
||
sprintf(SceneDir,"%s\\",FileName);
|
||
|
||
sprintf(MEDIA_DIRECTORY,"%s",MEDIA_BASE);
|
||
CreateDirectory(MEDIA_DIRECTORY,NULL);
|
||
sprintf(MEDIA_DIRECTORY,"%s%s",MEDIA_BASE,SceneDir);
|
||
CreateDirectory(MEDIA_DIRECTORY,NULL);
|
||
sprintf(MEDIA_DIRECTORY,"%s%s",MEDIA_BASE,FileName);
|
||
#ifdef USE_SVG
|
||
extern void CleanDirectory(TCHAR * directoryPath, bool deleteFilesButNotDirectories = false);
|
||
CleanDirectory(MEDIA_DIRECTORY, true);
|
||
#endif
|
||
sprintf(MEDIA_DIRECTORY,"%s%s\\Modified",MEDIA_BASE,SceneDir);
|
||
CreateDirectory(MEDIA_DIRECTORY,NULL);
|
||
|
||
/* BACKUP */
|
||
sprintf(MEDIA_DIRECTORY,"XCOPY /Y /S %s%s*.* .\\Backup0\\%s*.*",MEDIA_BASE,SceneDir,SceneDir);
|
||
// system(MEDIA_DIRECTORY);
|
||
WinExec(MEDIA_DIRECTORY,SW_HIDE);
|
||
|
||
|
||
sprintf(MEDIA_DIRECTORY,"%s%s",MEDIA_BASE,SceneDir);
|
||
CreateDirectory(MEDIA_DIRECTORY,NULL);
|
||
|
||
UNIC_Dico Dico;
|
||
UNIC_Dico DicoTargets;
|
||
UnicID ID;
|
||
Dico.Init();
|
||
DicoTargets.Init();
|
||
DicoTargets.IsCaseSensitive = 0;
|
||
Dico.GetUnic(&ID,"NULL");
|
||
BigSmSC = (SmallScene*)CC_malloc(sizeof(SmallScene));
|
||
memset(BigSmSC,0,sizeof(SmallScene));
|
||
BigSmSC->CameraPosition.Identity();
|
||
|
||
sprintf(MEDIA_DIRECTORY,"%s%s%s",MEDIA_BASE,SceneDir,TEXTURES_DIRECTORY);
|
||
|
||
MW = MAD_Load(Name,&LoadTextureCallback,(u32)MEDIA_DIRECTORY);
|
||
MAD_ComputeAllNormales(MW);
|
||
if (MW)
|
||
{
|
||
/* Modify texture names *******************************************************************/
|
||
for (int i = 0 ; i < MW->NumberOftexture; i++)
|
||
{
|
||
char Correct[2048];
|
||
CorrectTextureName(MW->AllTextures[i]->Texturefile,Correct);
|
||
strcpy(MW->AllTextures[i]->Texturefile,Correct);
|
||
}
|
||
|
||
/* Save materials ************************************************************************/
|
||
sprintf(MEDIA_DIRECTORY,"%s%s%s",MEDIA_BASE,SceneDir,MATERIALS_DIRECTORY);
|
||
BigSmSC->MaterialsIDs = (UnicID*)CC_malloc(MW->NumberOfMaterials * sizeof(UnicID));
|
||
BigSmSC->MultiMaterialsIDs = (UnicID*)CC_malloc(MW->NumberOfMaterials * sizeof(UnicID));
|
||
for (int i = 0 ; i < MW->NumberOfMaterials; i++)
|
||
{
|
||
SAVEMATERIAL(MW,MW->AllMaterial[i],&Dico,(char*)MEDIA_DIRECTORY,BigSmSC);
|
||
sprintf(Name,"%s%s%s",MEDIA_BASE,SceneDir,TEXTURES_DIRECTORY);
|
||
}
|
||
|
||
/* Save objects ************************************************************************/
|
||
/* CREATE TRACKING OBJECT */
|
||
sprintf(MEDIA_DIRECTORY,"%s%s%s",MEDIA_BASE,SceneDir,OBJECTS_DIRECTORY);
|
||
BigSmSC->ObjectsIDs = (UnicID*)CC_malloc(MW->NumberOfHierarchieNodes * sizeof(UnicID));
|
||
for (int i = 0 ; i < MW->NumberOfHierarchieNodes; i++)
|
||
{
|
||
if ((IsTargetMorph(MW->Hierarchie[i].ID.Name) == -1) && (IsAdditionalUV(MW->Hierarchie[i].ID.Name) == -1))
|
||
SAVEMADOBJECT(MW,&MW->Hierarchie[i],&Dico,(char*)MEDIA_DIRECTORY,BigSmSC);
|
||
}
|
||
|
||
/* Save meshes ************************************************************************/
|
||
sprintf(MEDIA_DIRECTORY,"%s%s%s",MEDIA_BASE,SceneDir,MESHES_DIRECTORY);
|
||
BigSmSC->MeshesIDs = (UnicID*)CC_malloc(MW->NumberOfObjects * sizeof(UnicID));
|
||
for (int i = 0 ; i < MW->NumberOfObjects ; i++)
|
||
{
|
||
UnicID IDLocaaca;
|
||
if ((MW->AllObjects[i]->IDType == ID_MAD_GeometricObject_V0) ||
|
||
(MW->AllObjects[i]->IDType == ID_MAD_SkinnedGeometricObject))
|
||
{
|
||
DicoTargets.GetUnic(&IDLocaaca,MW->AllObjects[i]->Name);
|
||
DicoTargets.mpst_Dico[IDLocaaca].AssociatedValue = i;
|
||
}
|
||
}
|
||
for (int i = 0 ; i < MW->NumberOfObjects ; i++)
|
||
{
|
||
if ((IsTargetMorph(MW->AllObjects[i]->Name) == -1) && (IsAdditionalUV(MW->AllObjects[i]->Name) == -1))
|
||
{
|
||
if (MW->AllObjects[i]->IDType == ID_MAD_GeometricObject_V0)
|
||
SAVEMADMESH(MW,(MAD_GeometricObject *)MW->AllObjects[i],&Dico,&DicoTargets,(char*)MEDIA_DIRECTORY,BigSmSC);
|
||
if (MW->AllObjects[i]->IDType == ID_MAD_SkinnedGeometricObject)
|
||
SAVEMADMESH_SKIN(MW,(MAD_SkinnedGeometricObject *)MW->AllObjects[i],&Dico,&DicoTargets,(char*)MEDIA_DIRECTORY,BigSmSC);
|
||
}
|
||
}
|
||
|
||
/* Save Lights ************************************************************************/
|
||
for (int i = 0 ; i < MW->NumberOfObjects ; i++)
|
||
{
|
||
if (MW->AllObjects[i]->IDType == ID_MAD_Light)
|
||
{
|
||
SAVELIGHT(MW,(MAD_Light *)MW->AllObjects[i],&Dico,&DicoTargets,(char*)MEDIA_DIRECTORY,BigSmSC);
|
||
}
|
||
}
|
||
|
||
CreateDirectory(MEDIA_DIRECTORY,NULL);
|
||
sprintf(Name,"%s%s",MEDIA_DIRECTORY,"SmSc.Ssc");
|
||
BigSmSC->MustComputeInverseSkinning = 1;
|
||
SaveSmallScene(BigSmSC,Name,&Dico);
|
||
FreeSmallScene(BigSmSC,&Dico);
|
||
CC_free(BigSmSC);
|
||
|
||
/*****************************************************************************************************************/
|
||
/* Save a template Sample of IK */
|
||
SmallScene_IK *IK;
|
||
IK = (SmallScene_IK *)CC_malloc(sizeof(SmallScene_IK));
|
||
memset(IK,0,sizeof(SmallScene_IK));
|
||
IK->ulNumberOfPatchs = 1;
|
||
IK->pObjPatchs = (IK_ObjectPatch *)CC_malloc(sizeof(IK_ObjectPatch));
|
||
memset(IK->pObjPatchs,0,sizeof(IK_ObjectPatch) * IK->ulNumberOfPatchs);
|
||
IK->ulNumberOfCollider = 1;
|
||
IK->pColliders = (IK_Collider *)CC_malloc(sizeof(IK_Collider));
|
||
memset(IK->pColliders,0,sizeof(IK_Collider) * IK->ulNumberOfCollider);
|
||
sprintf(Name,"%s%s",MEDIA_DIRECTORY,"SmSc.IKM");
|
||
SaveSmallScene_IK(IK,Name,&Dico);
|
||
FreeSmallScene_IK(IK,&Dico);
|
||
CC_free(IK);
|
||
/*****************************************************************************************************************/
|
||
|
||
|
||
Dico.Destroy();
|
||
DicoTargets.Destroy();
|
||
Mad_free();
|
||
}
|
||
return 0;
|
||
}
|
||
|