reman3/Rayman_X/cpa/Appli/Max23Dos/src/ModLoad.c

1264 lines
50 KiB
C

/*=========================================================================
*
* ModLoad.c - Loading functions for MOD file
*
* Version 1.0
* Revision date
*
*=======================================================================*/
#include "ModLoad.h"
#include "MTH.h"
#include "conventi.h"
#include "defines.h"
#include "main.h"
#include "print.h"
#include "system.h"
#include "util.h"
#include "vertex.h"
#include "ModLib.h"
#include "SpoLoad.h"
#include "Textures.h"
//--------------------------------------------------------------------
/****************************************************************************
* Description: init for loading a Mod file
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void MLT_vInitMODLoad ()
{
// register all necessary callbacks
SCR_fn_v_RdL0_RegisterCallback (M_Geometric, MLT_xLoadGeometric, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementIndexedTriangles, MLT_xLoadElementIndexedTriangles, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementFaceMapDescriptors, MLT_xLoadElementFaceMapDescriptors, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementSprites, MLT_xLoadElementSprites, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementTMeshes, MLT_xLoadElementTMeshes, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementLines, MLT_xLoadElementLines, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementSpheres, MLT_xLoadElementSpheres, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementAlignedBoxes, MLT_xLoadElementAlignedBoxes, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementPoints, MLT_xLoadElementPoints, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_ElementMegaFace, MLT_xLoadElementMegaFace, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_FaceMapDescriptor, MLT_xLoadFaceMapDescriptor, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_Sprite, MLT_xLoadSprite, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_Material, MLT_xLoadMaterial, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_Texture, MLT_xLoadTextureSection, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_GameMaterial, MLT_xLoadGameMaterial, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback (M_FichierMOD, MLT_xLoadModCallback, SCR_CRC_c_RdL0_ForFile);
}
/****************************************************************************
* Description: load a MOD file
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadModCallback(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstGeometricObject **p_xGeometricInFile;
MLT_tdstGeometricObject *p_xFoundObject;
long xNbGeometric;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_xGeometricInFile = (MLT_tdstGeometricObject**)malloc(sizeof(MLT_tdstGeometricObject*));
SCR_M_RdL0_SetContextLong(0,0,(long)p_xGeometricInFile);
SCR_M_RdL0_SetContextLong(0,1,(long)0);
break;
case SCR_EA_Anl_EndSubSection:
if (strcmp(szParams[0],M_Geometric)==0)
{
MLT_tdstGeometricObject *hGeometric;
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstGeometricObject**,p_xGeometricInFile);
SCR_M_RdL0_GetContextLong(0,1,long,xNbGeometric);
SCR_M_RdL0_GetSectionLong(1,0,MLT_tdstGeometricObject*,hGeometric);
p_xFoundObject = MLT_pFindInGivenLib(hGeometric->sName, p_xGeometricInFile, xNbGeometric);
if (p_xFoundObject)
{
MLT_vOutput( C_ComRes_cErrorLine, "\nError : Object %s is duplicated", hGeometric->sName);
}
else
{
p_xGeometricInFile = (MLT_tdstGeometricObject**)realloc(p_xGeometricInFile,(++xNbGeometric)*sizeof(MLT_tdstGeometricObject*));
p_xGeometricInFile[xNbGeometric-1]=hGeometric;
SCR_M_RdL0_SetContextLong(0,0,(long)p_xGeometricInFile);
SCR_M_RdL0_SetContextLong(0,1,(long)xNbGeometric);
}
}
break;
case SCR_EA_Anl_EndSection:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstGeometricObject**,p_xGeometricInFile);
SCR_M_RdL0_GetContextLong(0,1,long,xNbGeometric);
SCR_M_RdL0_SetSectionLong(0,0,(long)p_xGeometricInFile);
SCR_M_RdL0_SetSectionLong(0,1,(long)xNbGeometric);
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a geometric object
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadGeometric(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstGeometricObject *p_stGeometric;
long xIndex;
static long lNbPoints, lNbEdges, lNbElements;
xString sFile, sAction, sIdent;
char *p_Char1;
char *p_sConstraintAxis;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stGeometric=(MLT_tdstGeometricObject*)malloc(sizeof(MLT_tdstGeometricObject));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stGeometric);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stGeometric);
p_stGeometric->bNotForSave = FALSE;
p_stGeometric->xNbPoints=atoi(szParams[0]);
p_stGeometric->xNbEdges=atoi(szParams[1]);
p_stGeometric->xNbElements=atoi(szParams[2]);
sprintf(p_stGeometric->sName,"%s",SCR_M_RdL0_GetCompleteSectionNameR(0));
p_stGeometric->iFlags =0;
p_stGeometric->bHasElementOf = FALSE;
SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
if ((g_cCategoryType == C_Bank) && (!g_bExistSpo))
{
p_sConstraintAxis = (char *)malloc(7*sizeof(char));
if (p_sConstraintAxis != NULL)
{
MLT_vGeomProp( &p_stGeometric->iFlags, &sIdent, &p_stGeometric->cGeom, &p_stGeometric->fGeom, &p_sConstraintAxis);
strcpy(p_stGeometric->sConstraintAxis, p_sConstraintAxis);
free(p_sConstraintAxis);
}
}
p_Char1=sIdent;
MLT_vRemoveGeomProp(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stGeometric->sName, sFile, sAction, sIdent);
sprintf(p_stGeometric->sPointsOf,"");
sprintf(p_stGeometric->sPhysicalSection, "");
sprintf(p_stGeometric->sComment, "");
MLT_xAllocateGeometric(p_stGeometric);
lNbPoints = 0;
lNbEdges = 0;
lNbElements = 0;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstGeometricObject*,p_stGeometric);
if(strcmp(szAction,M_MODActionComment)==0)
{
sprintf(p_stGeometric->sComment,"%s",szParams[0]);
}
// Loading object vertex
if (strcmp(szAction,M_MODActionAddVertex)==0)
{
lNbPoints ++;
xIndex = (long)atoi(szParams[0]);
MLT_M_SetVertexXYZ((p_stGeometric->d_stListOfPoints+xIndex),
(float)(MLT_M_FloatToValue(atof(szParams[1]) * MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName))),
(float)(MLT_M_FloatToValue(atof(szParams[2]) * MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName))),
(float)(MLT_M_FloatToValue(atof(szParams[3]) * MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName)))
);
MLT_M_SetVertexXYZ((p_stGeometric->d_stListOfPointsNormals+xIndex),
(float)(MLT_M_FloatToValue(atof(szParams[4]))),
(float)(MLT_M_FloatToValue(atof(szParams[5]))),
(float)(MLT_M_FloatToValue(atof(szParams[6])))
);
if (szParams[7] && szParams[8] &&szParams[9])
{
p_stGeometric->d_stListOfPointsReceivedLightIntensity[xIndex].xR=(float)(atof(szParams[7]));
p_stGeometric->d_stListOfPointsReceivedLightIntensity[xIndex].xG=(float)(atof(szParams[8]));
p_stGeometric->d_stListOfPointsReceivedLightIntensity[xIndex].xB=(float)(atof(szParams[9]));
}
}
if (strcmp(szAction,M_MODActionGetVertices)==0)
{
sprintf(p_stGeometric->sPointsOf,"%s",szParams[0]);
}
// Loading object edge
if (strcmp(szAction,M_MODActionAddEdge)==0)
{
lNbEdges ++;
xIndex = (long)atoi(szParams[0]);
p_stGeometric->d_stListOfEdges[xIndex].a2_xIndex[0] = (long)(atoi(szParams[1]));
p_stGeometric->d_stListOfEdges[xIndex].a2_xIndex[1] = (long)(atoi(szParams[2]));
}
// Loading object element
if (strcmp(szAction,M_MODActionAddElement)==0)
{
unsigned short uwTypeElement;
void *p_stElement;
SCR_tdst_Cxt_Values *p_stVal;
lNbElements ++;
xIndex = atoi(szParams[0]);
if(strcmp(szParams[1],M_IndexedTriangles)==0)
uwTypeElement = MLT_C_xElementIndexedTriangles;
else if(strcmp(szParams[1],M_FaceMapDescriptors)==0)
uwTypeElement = MLT_C_xElementFaceMapDescriptors;
else if(strcmp(szParams[1],M_TMeshes)==0)
uwTypeElement = MLT_C_xElementTMeshes;
else if(strcmp(szParams[1],M_Spheres)==0)
uwTypeElement = MLT_C_xElementSpheres;
else if(strcmp(szParams[1],M_AlignedBoxes)==0)
uwTypeElement = MLT_C_xElementAlignedBoxes;
else if(strcmp(szParams[1],M_Points)==0)
uwTypeElement = MLT_C_xElementPoints;
else if(strcmp(szParams[1],M_Sprites)==0)
uwTypeElement = MLT_C_xElementSprites;
else if(strcmp(szParams[1],M_Lines)==0)
uwTypeElement = MLT_C_xElementLines;
else if(strcmp(szParams[1],M_MegaFace)==0)
uwTypeElement = MLT_C_xElementMegaFace;
// load element
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[2], SCR_CDF_uw_Anl_Normal);
p_stElement = (void *)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
p_stGeometric->d_xListOfElementsTypes[xIndex] = uwTypeElement;
p_stGeometric->d_stListOfElements[xIndex] = p_stElement;
}
if (strcmp(szAction,M_MODActionGetElement)==0)
{
p_stGeometric->bHasElementOf = TRUE;
xIndex = atoi(szParams[0]);
sprintf(p_stGeometric->sElementOf[xIndex],"%s",szParams[1]);
p_stGeometric->sIndexOf[xIndex] = atoi(szParams[2]);
p_stGeometric->d_xListOfElementsTypes[xIndex] = -1;
}
break;
case SCR_EA_Anl_EndSection:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstGeometricObject*,p_stGeometric);
if (strlen(p_stGeometric->sPointsOf) == 0)
p_stGeometric->xNbPoints=lNbPoints;
p_stGeometric->xNbEdges=lNbEdges;
if (!p_stGeometric->bHasElementOf)
p_stGeometric->xNbElements=lNbElements;
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load an indexed triangle element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementIndexedTriangles(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementIndexedTriangles *p_stElement;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementIndexedTriangles*)malloc(sizeof(MLT_tdstElementIndexedTriangles));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbFaces=atoi(szParams[0]);
p_stElement->xNbElementUV=atoi(szParams[1]);
p_stElement->d_stListOfFacesTripled = (MLT_tdstTripledIndex*)malloc(p_stElement->xNbFaces*sizeof(MLT_tdstTripledIndex));
p_stElement->d_stListOfFacesNormals = (MTH3D_tdstVector*)malloc(p_stElement->xNbFaces*sizeof(MTH3D_tdstVector));
p_stElement->d_stListOfFacesTripledIndexUV = (MLT_tdstTripledIndex*)malloc(p_stElement->xNbFaces*sizeof(MLT_tdstTripledIndex));
p_stElement->d_stListOfFacesReceivedLightIntensity = (MLT_tdstColor*)malloc(p_stElement->xNbFaces*sizeof(MLT_tdstColor));
p_stElement->d_stListOfElementUV = (ACP_tdst2DUVValues*)malloc(p_stElement->xNbElementUV*sizeof(ACP_tdst2DUVValues));
sprintf(p_stElement->sSectorName, "");
sprintf(p_stElement->sMaterial, "");
p_stElement->hMaterial = NULL;
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
p_stElement->xIndexOfParallelBox = -1;
sprintf(p_stElement->sFacesOf, "");
sprintf(p_stElement->sUVsOf, "");
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementIndexedTriangles*,p_stElement);
// Loading Face
if (strcmp(szAction,M_MODActionAddFaceUV)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[0]=(long)(atoi(szParams[1]));
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[1]=(long)(atoi(szParams[2]));
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[2]=(long)(atoi(szParams[3]));
MLT_M_SetVertexXYZ((p_stElement->d_stListOfFacesNormals+xIndex),
MLT_M_FloatToValue((float)atof(szParams[4])),
MLT_M_FloatToValue((float)atof(szParams[5])),
MLT_M_FloatToValue((float)atof(szParams[6])) );
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[0]=(long)(atoi(szParams[7]));
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[1]=(long)(atoi(szParams[8]));
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[2]=(long)(atoi(szParams[9]));
}
if (strcmp(szAction,M_MODActionGetFaces)==0)
{
sprintf(p_stElement->sFacesOf, "%s", szParams[0]);
}
if (strcmp(szAction,M_MODActionAddFace)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[0]=(long)(atoi(szParams[1]));
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[1]=(long)(atoi(szParams[2]));
p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[2]=(long)(atoi(szParams[3]));
MLT_M_SetVertexXYZ((p_stElement->d_stListOfFacesNormals+xIndex),
MLT_M_FloatToValue((float)atof(szParams[4])),
MLT_M_FloatToValue((float)atof(szParams[5])),
MLT_M_FloatToValue((float)atof(szParams[6]))
);
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[0]=(long)(0);
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[1]=(long)(0);
p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[2]=(long)(0);
}
// Loading Element's UV
if (strcmp(szAction,M_MODActionAddUV)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stElement->d_stListOfElementUV[xIndex].xU=(MLT_tdxUVValue)(atof(szParams[1]));
p_stElement->d_stListOfElementUV[xIndex].xV=(MLT_tdxUVValue)(atof(szParams[2]));
}
if (strcmp(szAction,M_MODActionGetUVs)==0)
{
sprintf(p_stElement->sFacesOf, "%s", szParams[0]);
}
// Loading material
if (strcmp(szAction,M_MODActionMaterial)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
xString sFile, sAction, sIdent;
SCR_fn_v_RdL0_SplitSectionName(szParams[0], sFile, sAction, sIdent);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sMaterial, sFile, sAction, sIdent);
// multitextures
sprintf(sFile, "%s.mod", g_sFileIn);
SCR_fn_v_RdL0_ComputeSectionName(sAction, sFile, M_Material, sIdent);
// if(SCR_fn_c_RdL0_IsSectionExists(sAction))
// {
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(/*szParams[0]/*/sAction, SCR_CDF_uw_Anl_Normal);
p_stElement->hMaterial = (MLT_tdstMaterial*)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
// replace # with _
while ((p_Char1 = strstr(p_stElement->sMaterial, "#")) != NULL)
strncpy(p_Char1, "_", 1);
while ((p_Char1 = strstr(p_stElement->hMaterial->sName, "#")) != NULL)
strncpy(p_Char1, "_", 1);
//if the name of the material contains $..., remove the $... from it and complete the name of the CMT
if ((p_Char1 = strstr(p_stElement->sMaterial, "$")) != NULL)
{
p_stElement->sMaterial[strlen(p_stElement->sMaterial)-strlen(p_Char1)]='\0';
if ((p_Char1 = strstr(p_stElement->hMaterial->sName, "$")) != NULL)
{
p_stElement->hMaterial->sName[strlen(p_stElement->hMaterial->sName)-strlen(p_Char1)]=0;
strcpy(p_stElement->hMaterial->sNameCMT, p_Char1+1);
p_stElement->hMaterial->bMaxMaterial = TRUE;
}
}
else
{
strcpy(p_stElement->hMaterial->sNameCMT, "");
p_stElement->hMaterial->bMaxMaterial = TRUE;
}
// }
}
// sector
if(strcmp (szAction,M_MODActionPointedSector)==0)
{
sprintf(p_stElement->sSectorName, "%s", szParams[0]);
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a face map descriptor element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementFaceMapDescriptors(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementFaceMapDescriptors *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementFaceMapDescriptors*)malloc(sizeof(MLT_tdstElementFaceMapDescriptors));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbFaces=atoi(szParams[0]);
p_stElement->d_stListOfFacesQuadrupled = (MLT_tdstFaceMapTriangle*)malloc(p_stElement->xNbFaces*sizeof(MLT_tdstFaceMapTriangle));
p_stElement->d_stListOfFacesNormals = (MTH3D_tdstVector*)malloc(p_stElement->xNbFaces*sizeof(MTH3D_tdstVector));
p_stElement->d_stListOfFacesReceivedLightIntensity = (MLT_tdstColor*)malloc(p_stElement->xNbFaces*sizeof(MLT_tdstColor));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag_flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementFaceMapDescriptors*,p_stElement);
// Loading Face
if (strcmp(szAction,M_MODActionAddFaceFMD)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
MLT_tdstFaceMapDescriptor **p_hFaceMapDescriptor;
xIndex = (long)atoi(szParams[0]);
// loading element
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[7], SCR_CDF_uw_Anl_Normal);
p_hFaceMapDescriptor = (MLT_tdstFaceMapDescriptor **)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[0]=(long)(atoi(szParams[1]));
p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[1]=(long)(atoi(szParams[2]));
p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[2]=(long)(atoi(szParams[3]));
p_stElement->d_stListOfFacesQuadrupled[xIndex].hFaceMapDescriptor = *p_hFaceMapDescriptor;
MLT_M_SetVertexXYZ((p_stElement->d_stListOfFacesNormals+xIndex),
MLT_M_FloatToValue((float)atof(szParams[4])),
MLT_M_FloatToValue((float)atof(szParams[5])),
MLT_M_FloatToValue((float)atof(szParams[6]))
);
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a sprite element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementSprites(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementSprite *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementSprite*)malloc(sizeof(MLT_tdstElementSprite));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbSprites=atoi(szParams[0]);
p_stElement->d_stListOfSprites = (MLT_tdstIndexedSprite*)malloc(p_stElement->xNbSprites*sizeof(MLT_tdstIndexedSprite));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementSprite*,p_stElement);
// Loading of Face
if (strcmp(szAction,M_MODActionAddSprite)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
MLT_tdstSprite **p_hSprite;
xIndex = (long)atoi(szParams[0]);
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[4], SCR_CDF_uw_Anl_Normal);
p_hSprite = (MLT_tdstSprite **)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
p_stElement->d_stListOfSprites[xIndex].xCenterPoint=(long)(atoi(szParams[1]));
p_stElement->d_stListOfSprites[xIndex].stSize.xX=(MTH_tdxReal)(atof(szParams[2]));
p_stElement->d_stListOfSprites[xIndex].stSize.xY=(MTH_tdxReal)(atof(szParams[3]));
p_stElement->d_stListOfSprites[xIndex].hSprite=*p_hSprite;
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a line element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementLines(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementLines *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementLines*)malloc(sizeof(MLT_tdstElementLines));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbLines=atoi(szParams[0]);
p_stElement->d_stListOfLineIndex = (MLT_tdstDoubledIndex*)malloc(p_stElement->xNbLines*sizeof(MLT_tdstDoubledIndex));
p_stElement->d_stListOfLinesReceivedLightIntensity = (MLT_tdstColor*)malloc(p_stElement->xNbLines*sizeof(MLT_tdstColor));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementLines*,p_stElement);
// Loading Line
if (strcmp(szAction,M_MODActionAddLine)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stElement->d_stListOfLineIndex[xIndex].a2_xIndex[0]=(long)(atoi(szParams[1]));
p_stElement->d_stListOfLineIndex[xIndex].a2_xIndex[1]=(long)(atoi(szParams[2]));
}
if (strcmp(szAction,M_MODActionThickness)==0)
{
p_stElement->xThickness = (MTH_tdxReal)(atof(szParams[0]));
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a sphere element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementSpheres(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementSpheres *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementSpheres*)malloc(sizeof(MLT_tdstElementSpheres));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbSpheres=atoi(szParams[0]);
p_stElement->d_stListOfSpheres = (MLT_tdstIndexedSphere*)calloc(p_stElement->xNbSpheres,sizeof(MLT_tdstIndexedSphere));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementSpheres*,p_stElement);
// Loading Face
if (strcmp(szAction,M_MODActionAddSphere)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
xIndex = (long)atoi(szParams[0]);
sprintf(p_stElement->d_stListOfSpheres[xIndex].sMaterial, "%s", szParams[3]);
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[3], SCR_CDF_uw_Anl_Normal);
p_stElement->d_stListOfSpheres[xIndex].hMaterial = (MLT_tdstMaterial*)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
// replace # with _
while ((p_Char1 = strstr(p_stElement->d_stListOfSpheres[xIndex].sMaterial, "#")) != NULL)
strncpy(p_Char1, "_", 1);
while ((p_Char1 = strstr(p_stElement->d_stListOfSpheres[xIndex].hMaterial->sName, "#")) != NULL)
strncpy(p_Char1, "_", 1);
if ((p_Char1 = strstr(p_stElement->d_stListOfSpheres[xIndex].sMaterial, "$")) != NULL)
{ //change the name of the material and CMT
p_stElement->d_stListOfSpheres[xIndex].sMaterial[strlen(p_stElement->d_stListOfSpheres[xIndex].sMaterial) -strlen(p_Char1)] = 0;
if ((p_Char1 = strstr(p_stElement->d_stListOfSpheres[xIndex].hMaterial->sName, "$")) != NULL)
{
p_stElement->d_stListOfSpheres[xIndex].hMaterial->sName[strlen(p_stElement->d_stListOfSpheres[xIndex].hMaterial->sName)-strlen(p_Char1)]=0;
strcpy(p_stElement->d_stListOfSpheres[xIndex].hMaterial->sNameCMT, p_Char1+1);
p_stElement->d_stListOfSpheres[xIndex].hMaterial->bMaxMaterial = TRUE;
}
}
else
{
strcpy(p_stElement->d_stListOfSpheres[xIndex].hMaterial->sNameCMT, "");
p_stElement->d_stListOfSpheres[xIndex].hMaterial->bMaxMaterial = TRUE;
}
p_stElement->d_stListOfSpheres[xIndex].xCenterPoint=(long)(atoi(szParams[1]));
p_stElement->d_stListOfSpheres[xIndex].xRadius=(MTH_tdxReal)(MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName) * (float)atof(szParams[2]));
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a box element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementAlignedBoxes(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementAlignedBoxes *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementAlignedBoxes*)malloc(sizeof(MLT_tdstElementAlignedBoxes));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbAlignedBoxes=atoi(szParams[0]);
p_stElement->d_stListOfAlignedBoxes = (MLT_tdstIndexedAlignedBox*)calloc(p_stElement->xNbAlignedBoxes,sizeof(MLT_tdstIndexedAlignedBox));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementAlignedBoxes*,p_stElement);
// Loading Line
if (strcmp(szAction,M_MODActionAddAlignedBox)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
xIndex = (long)atoi(szParams[0]);
sprintf(p_stElement->d_stListOfAlignedBoxes[xIndex].sMaterial, "%s", szParams[3]);
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[3], SCR_CDF_uw_Anl_Normal);
p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial = (MLT_tdstMaterial*)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
// replace # with _
while ((p_Char1 = strstr(p_stElement->d_stListOfAlignedBoxes[xIndex].sMaterial, "#")) != NULL)
strncpy(p_Char1, "_", 1);
while ((p_Char1 = strstr(p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sName, "#")) != NULL)
strncpy(p_Char1, "_", 1);
if ((p_Char1 = strstr(p_stElement->d_stListOfAlignedBoxes[xIndex].sMaterial, "$")) != NULL)
{
p_stElement->d_stListOfAlignedBoxes[xIndex].sMaterial[strlen(p_stElement->d_stListOfAlignedBoxes[xIndex].sMaterial) -strlen(p_Char1)] = 0;
if ((p_Char1 = strstr(p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sName, "$")) != NULL)
{
p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sName[strlen(p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sName) - strlen(p_Char1)]=0;
strcpy(p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sNameCMT, p_Char1+1);
p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->bMaxMaterial = TRUE;
}
}
else
{
strcpy(p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->sNameCMT, "");
p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial->bMaxMaterial = TRUE;
}
p_stElement->d_stListOfAlignedBoxes[xIndex].xMinPoint=(long)(atoi(szParams[1]));
p_stElement->d_stListOfAlignedBoxes[xIndex].xMaxPoint=(long)(atoi(szParams[2]));
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a point element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementPoints(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex;
MLT_tdstElementPoints *p_stElement;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementPoints*)malloc(sizeof(MLT_tdstElementPoints));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->xNbPoints=atoi(szParams[0]);
p_stElement->d_xListOfPointIndex = (long*)malloc(p_stElement->xNbPoints*sizeof(long));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent);
p_stElement->xIndexOfParallelBox = -1;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementPoints*,p_stElement);
// Loading Line
if (strcmp(szAction,M_MODActionAddPoint)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stElement->d_xListOfPointIndex[xIndex]=(long)(atoi(szParams[1]));
}
if (strcmp(szAction,M_MODActionFatness)==0)
{
p_stElement->xFatness = (MTH_tdxReal)(atof(szParams[0]));
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a TMesh element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementTMeshes(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a mega face element
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadElementMegaFace (SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long xIndex, iParam, i;
MLT_tdstElementMegaFace *p_stElement;
MLT_tdstMegaFace *p_stMegaFace;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stElement=(MLT_tdstElementMegaFace*)malloc(sizeof(MLT_tdstElementMegaFace));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_stElement);
SCR_M_RdL0_SetContextLong(0,0,(long)p_stElement);
p_stElement->lNbMegaFaces=atoi(szParams[0]);
p_stElement->d_stListOfMegaFaces = (MLT_tdstMegaFace*)malloc(p_stElement->lNbMegaFaces*sizeof(MLT_tdstMegaFace));
sprintf(p_stElement->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstElementMegaFace*,p_stElement);
// Loading MegaFace
if (strcmp(szAction,M_MODActionAddMegaFace)==0)
{
xIndex = (long)atoi(szParams[0]);
p_stMegaFace = &p_stElement->d_stListOfMegaFaces[xIndex];
p_stMegaFace->lIndex = xIndex;
p_stMegaFace->lNbFaces = 0;
iParam = 1;
while (szParams[iParam] != NULL)
iParam++;
p_stMegaFace->lNbFaces = iParam - 1;
p_stMegaFace->d_stListOfFaces = (long*)malloc(p_stMegaFace->lNbFaces*sizeof(long));
for (i=0; i<p_stMegaFace->lNbFaces; i++)
p_stMegaFace->d_stListOfFaces[i] = (long) atoi(szParams[i+1]);
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a face map descriptor
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadFaceMapDescriptor(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstFaceMapDescriptor **p_hFMD;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_hFMD=(MLT_tdstFaceMapDescriptor **)malloc(sizeof(MLT_tdstFaceMapDescriptor *));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_hFMD);
SCR_M_RdL0_SetContextLong(0,0,(long)p_hFMD);
*p_hFMD = (MLT_tdstFaceMapDescriptor *)malloc(sizeof(MLT_tdstFaceMapDescriptor));
sprintf((*p_hFMD)->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName((*p_hFMD)->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName((*p_hFMD)->sName, sFile, sAction, sIdent);
(*p_hFMD)->hMaterial = NULL;
(*p_hFMD)->AlreadySave = FALSE;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstFaceMapDescriptor**,p_hFMD);
// Loading Line
if (strcmp(szAction,M_MODActionTripledUV)==0)
{
(*p_hFMD)->stUVValues[0].xU = (float)atof(szParams[0]);
(*p_hFMD)->stUVValues[0].xV = (float)atof(szParams[1]);
(*p_hFMD)->stUVValues[1].xU = (float)atof(szParams[2]);
(*p_hFMD)->stUVValues[1].xV = (float)atof(szParams[3]);
(*p_hFMD)->stUVValues[2].xU = (float)atof(szParams[4]);
(*p_hFMD)->stUVValues[2].xV = (float)atof(szParams[5]);
}
if (strcmp(szAction,M_MODActionMaterial)==0)
{
SCR_tdst_Cxt_Values *p_stVal;
xString sFile, sAction, sIdent;
SCR_fn_v_RdL0_SplitSectionName(szParams[0], sFile, sAction, sIdent);
sprintf(sFile, "%s.gmt", g_sFileIn);
sprintf(sAction, M_GameMaterial);
SCR_fn_v_RdL0_ComputeSectionName((*p_hFMD)->sMaterial, sFile, sAction, sIdent);
// multitextures
sprintf(sFile, "%s.mod", g_sFileIn);
SCR_fn_v_RdL0_ComputeSectionName(sAction, sFile, M_Material, sIdent);
// if(SCR_fn_c_RdL0_IsSectionExists(sAction))
// {
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(/*szParams[0]/*/sAction, SCR_CDF_uw_Anl_Normal);
(*p_hFMD)->hMaterial = (MLT_tdstMaterial*)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
// replace # with _
while ((p_Char1 = strstr((*p_hFMD)->sMaterial, "#")) != NULL)
strncpy(p_Char1, "_", 1);
while ((p_Char1 = strstr((*p_hFMD)->hMaterial->sName, "#")) != NULL)
strncpy(p_Char1, "_", 1);
if ((p_Char1 = strstr((*p_hFMD)->sMaterial, "$")) != NULL)
{ (*p_hFMD)->sMaterial[strlen((*p_hFMD)->sMaterial) - strlen(p_Char1)] = 0;
if ((p_Char1 = strstr((*p_hFMD)->hMaterial->sName, "$")) != NULL)
{
(*p_hFMD)->hMaterial->sName[strlen((*p_hFMD)->hMaterial->sName)-strlen(p_Char1)]=0;
strcpy((*p_hFMD)->hMaterial->sNameCMT, p_Char1+1);
(*p_hFMD)->hMaterial->bMaxMaterial = TRUE;
}
}
else
{
strcpy((*p_hFMD)->hMaterial->sNameCMT, "");
(*p_hFMD)->hMaterial->bMaxMaterial = TRUE;
}
// }
}
// sector
if(strcmp (szAction,M_MODActionPointedSector)==0)
{
sprintf((*p_hFMD)->sSprObjFile, "%s", szParams[0]);
sprintf((*p_hFMD)->sSprObjName, "%s", szParams[1]);
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load a sprite
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadSprite(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstSprite **p_hSprite;
long xNbSprites;
xString sFile, sAction, sIdent;
char *p_Char1;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_hSprite=(MLT_tdstSprite **)malloc(sizeof(MLT_tdstSprite *));
SCR_M_RdL0_SetSectionLong(0,0,(long)p_hSprite);
SCR_M_RdL0_SetContextLong(0,0,(long)p_hSprite);
(*p_hSprite) = (MLT_tdstSprite*)malloc(sizeof(MLT_tdstSprite));
xNbSprites = atoi(szParams[0]);
MLT_vCreateRotativSprite(p_hSprite, xNbSprites);
sprintf((*p_hSprite)->sName, "%s", SCR_M_RdL0_GetCompleteSectionNameR(0));
SCR_fn_v_RdL0_SplitSectionName((*p_hSprite)->sName, sFile, sAction, sIdent);
//remove the $flag$flag from its name
p_Char1=sIdent;
MLT_vRemoveFlags(&p_Char1);
strcpy(sIdent, p_Char1);
SCR_fn_v_RdL0_ComputeSectionName((*p_hSprite)->sName, sFile, sAction, sIdent);
(*p_hSprite)->AlreadySave = FALSE;
break;
case SCR_EA_Anl_Entry:
// Recuperation du handle a remplir
SCR_M_RdL0_GetContextLong(0,0,MLT_tdstSprite**,p_hSprite);
if (strcmp(szAction,M_MODActionAddMaterial)==0)
{
xString sFile, sAction, sIdent;
long xIndex;
SCR_tdst_Cxt_Values *p_stVal;
xIndex = atoi(szParams[0]);
SCR_fn_v_RdL0_SplitSectionName(szParams[1], sFile, sAction, sIdent);
sprintf(sFile, "%s.gmt", g_sFileIn);
SCR_fn_v_RdL0_ComputeSectionName((*p_hSprite)->d_sMaterial[xIndex], sFile, M_GameMaterial, sIdent);
// multitextures
sprintf(sFile, "%s.mod", g_sFileIn);
SCR_fn_v_RdL0_ComputeSectionName(sAction, sFile, M_Material, sIdent);
// if(SCR_fn_c_RdL0_IsSectionExists(sAction))
// {
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(/*szParams[1]/*/sAction, SCR_CDF_uw_Anl_Normal);
(*p_hSprite)->d_hMaterial[xIndex] = (MLT_tdstMaterial*)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
// replace # with _
while ((p_Char1 = strstr((*p_hSprite)->d_hMaterial[xIndex]->sName, "#")) != NULL)
strncpy(p_Char1, "_", 1);
while ((p_Char1 = strstr((*p_hSprite)->d_sMaterial[xIndex], "#")) != NULL)
strncpy(p_Char1, "_", 1);
if ((p_Char1 = strstr((*p_hSprite)->d_hMaterial[xIndex]->sName, "$")) != NULL)
{
(*p_hSprite)->d_sMaterial[xIndex][strlen((*p_hSprite)->d_sMaterial[xIndex]) - strlen(p_Char1)] = 0;
if ((p_Char1 = strstr((*p_hSprite)->d_hMaterial[xIndex]->sName, "$")) != NULL)
{
(*p_hSprite)->d_hMaterial[xIndex]->sName[strlen((*p_hSprite)->d_hMaterial[xIndex]->sName)-strlen(p_Char1)]=0;
strcpy((*p_hSprite)->d_hMaterial[xIndex]->sNameCMT, p_Char1+1);
(*p_hSprite)->d_hMaterial[xIndex]->bMaxMaterial = TRUE;
}
}
else
{
strcpy((*p_hSprite)->d_hMaterial[xIndex]->sNameCMT, "");
(*p_hSprite)->d_hMaterial[xIndex]->bMaxMaterial = TRUE;
}
// }
}
if( strcmp(szAction,M_MODActionAddInfo)==0)
{
long xIndex;
MTH_tdxReal xParam;
BOOL b2DScaled;
xIndex = atoi(szParams[0]);
if( strcmp(szParams[1],M_2DScaled)==0)
{
(*p_hSprite)->d_xSpriteDrawMode[xIndex] = MLT_C_lSpriteDrawMode2DScaled;
b2DScaled = TRUE;
}
else if( strcmp(szParams[1],M_2DNonScaled)==0)
{
(*p_hSprite)->d_xSpriteDrawMode[xIndex] = 0;
b2DScaled = FALSE;
}
xParam = MTH_M_xDoubleToReal(atof(szParams[2]));
(*p_hSprite)->d_xThresholds[xIndex] = xParam;
if(b2DScaled)
{
(*p_hSprite)->d_xSizeOfSprite[xIndex].xX = MTH_M_xDoubleToReal(atof(szParams[3])*MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName));
(*p_hSprite)->d_xSizeOfSprite[xIndex].xY = MTH_M_xDoubleToReal(atof(szParams[4])*MLT_dGetUnitInMeterInFile(p_fFile->a_szOpenFileName));
}
else
{
(*p_hSprite)->d_xSizeOfSprite[xIndex].xX = MTH_M_xDoubleToReal(atof(szParams[3]));
(*p_hSprite)->d_xSizeOfSprite[xIndex].xY = MTH_M_xDoubleToReal(atof(szParams[4]));
}
(*p_hSprite)->d_xDisplacementOfSprite[xIndex].xX = MTH_M_xDoubleToReal(atof(szParams[5]));
(*p_hSprite)->d_xDisplacementOfSprite[xIndex].xY = MTH_M_xDoubleToReal(atof(szParams[6]));
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: allocate a geometric object
*
* Parameters: p_stGeometric : geometric object
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void MLT_xAllocateGeometric(MLT_tdstGeometricObject *p_stGeometric)
{
long xNbPoints,xNbElements,xNbEdges;
xNbPoints=p_stGeometric->xNbPoints;
xNbElements=p_stGeometric->xNbElements;
xNbEdges=p_stGeometric->xNbEdges;
if (xNbPoints)
{
p_stGeometric->d_stListOfPoints=(MTH3D_tdstVector*)malloc(xNbPoints*sizeof(MTH3D_tdstVector));
p_stGeometric->d_stListOfPointsNormals=(MTH3D_tdstVector*)malloc(xNbPoints*sizeof(MTH3D_tdstVector));
p_stGeometric->d_stListOfPointsReceivedLightIntensity=(MLT_tdstColor*)malloc(xNbPoints*sizeof(MLT_tdstColor));
}
if ((!p_stGeometric->d_stListOfPoints) || (!p_stGeometric->d_stListOfPointsNormals) || (!p_stGeometric->d_stListOfPointsReceivedLightIntensity))
return ;
if (xNbEdges)
p_stGeometric->d_stListOfEdges=(MLT_tdstDoubledIndex*)malloc(xNbEdges*sizeof(MLT_tdstDoubledIndex));
if ((p_stGeometric->d_stListOfEdges==NULL) && (xNbEdges!=0))
return ;
if (xNbElements)
{
p_stGeometric->d_xListOfElementsTypes=(long*)malloc(xNbElements*sizeof(long));
p_stGeometric->d_stListOfElements=(void**)malloc(xNbElements*sizeof(void*));
p_stGeometric->sElementOf=(xString*)malloc(xNbElements*sizeof(xString));
p_stGeometric->sIndexOf=(long*)malloc(xNbElements*sizeof(long));
}
if (p_stGeometric->d_xListOfElementsTypes==NULL)
return ;
}
/****************************************************************************
* Description: create a sprite
*
* Parameters: p_hSprite : sprite to create
* xNbAngles : nb of angles
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void MLT_vCreateRotativSprite ( MLT_tdstSprite **p_hSprite , long xNbAngles)
{
long liCount;
*p_hSprite = (MLT_tdstSprite*)malloc(sizeof(MLT_tdstSprite));
(*p_hSprite)->d_xThresholds = (MTH_tdxReal*)malloc(sizeof(long)*xNbAngles);
(*p_hSprite)->d_xSpriteDrawMode = (short*)malloc(sizeof(short)*xNbAngles);
(*p_hSprite)->d_hMaterial = (MLT_tdstMaterial **)malloc(sizeof(MLT_tdstMaterial*)*xNbAngles);
(*p_hSprite)->d_sMaterial = (xString*)malloc(sizeof(xString)*xNbAngles);
(*p_hSprite)->d_xSizeOfSprite = (MTH2D_tdstVector*)malloc(sizeof(MTH2D_tdstVector)*xNbAngles);
(*p_hSprite)->d_xDisplacementOfSprite = (MTH2D_tdstVector*)malloc(sizeof(MTH2D_tdstVector)*xNbAngles);
for(liCount=0; liCount<xNbAngles; liCount++)
{
(*p_hSprite)->d_hMaterial[liCount] = NULL;
(*p_hSprite)->d_xSpriteDrawMode[liCount] = MLT_C_lSpriteDrawMode2DRotativ;
(*p_hSprite)->d_xSizeOfSprite[liCount].xX = 1.00f;
(*p_hSprite)->d_xSizeOfSprite[liCount].xY = 1.00f;
(*p_hSprite)->d_xDisplacementOfSprite[liCount].xX = 0.0f;
(*p_hSprite)->d_xDisplacementOfSprite[liCount].xY = 0.0f;
}
(*p_hSprite)->xNbSprites = xNbAngles;
}