コード例 #1
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMaterialSubMaterial(zASE_Material &mat, int subMaterial)
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MATERIAL_NAME ") )			{ CopyString( temp, mat.name );			continue; }
	//	else if( EqualString( temp, "*MATERIAL_CLASS ") )		{ CopyString( temp, mat.classname );	continue; }
		else if( EqualString( temp, "*MATERIAL_AMBIENT ") )		{ CopyVector4( temp, mat.ambient );		continue; }
		else if( EqualString( temp, "*MATERIAL_DIFFUSE ") )		{ CopyVector4( temp, mat.diffuse );		continue; }
		else if( EqualString( temp, "*MATERIAL_SPECULAR ") )		{ CopyVector4( temp, mat.specular );		continue; }
		else if( EqualString( temp, "*MATERIAL_SHINE ") )		{ CopyFloat ( temp, mat.shine );		continue; }
		else if( EqualString( temp, "*MATERIAL_SHINESTRENGTH ") ){ CopyFloat ( temp, mat.shineStrength );continue; }
		else if( EqualString( temp, "*MATERIAL_TRANSPARENCY ") )	{ CopyFloat ( temp, mat.transparency );	continue; }
		else if( EqualString( temp, "*MATERIAL_WIRESIZE ") )		{ CopyFloat ( temp, mat.wiresize );		continue; }
	//	else if( EqualString( temp, "*MATERIAL_SHADING ") )		{ strcpy( mat.shading, temp);			continue; }
	//	else if( EqualString( temp, "*MATERIAL_XP_FALLOFF ") )	{ CopyFloat ( temp, mat.xp_falloff );	continue; }
		else if( EqualString( temp, "*MATERIAL_SELFILLUM ") )	{ CopyFloat ( temp, mat.selfIllum );	continue; }
	//	else if( EqualString( temp, "*MATERIAL_FALLOFF ") )		{ strcpy( mat.falloff, temp);			continue; }
	//	else if( EqualString( temp, "*MATERIAL_XP_TYPE ") )		{ strcpy( mat.xp_type, temp);			continue; }
		else if( EqualString( temp, "*MAP_DIFFUSE ") )		{ if(!ReadMaterialMap( mat, subMaterial))return 0;	continue; }
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #2
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_TFaceList_(zASE_Object &obj)
{
	char temp[255];
	int index=0,i;
	if( obj.numOfFaces!=0)obj.pFaceCoord_ = new zASE_Face[obj.numOfFaces];
	else return ReadUnknown( temp);
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MESH_TFACE ") )
		{
		//	*MESH_TFACE 0	9	11	10
		//	sscanf( temp, "%d", &index)
			if(index>=obj.numOfFaces)
			{
				if( FindBracketClose( temp) )return 1;
				else continue;
			}
			sscanf( temp, "%d %hu %hu %hu", &i, &obj.pFaceCoord_[index].index[0], &obj.pFaceCoord_[index].index[1], &obj.pFaceCoord_[index].index[2] );
			index++;
		}
	//	else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #3
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_Vertex_List(zASE_Object &obj)
{
	char temp[255];
	int index=0,i;
	if( obj.numOfVerts!=0)obj.pVerts = new vec[obj.numOfVerts];
	else return ReadUnknown( temp);
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MESH_VERTEX ") )
		{
		//	*MESH_VERTEX    0	-9.00000	-3.00000	3.00000
		//	sscanf( temp, "%d", &index)
			if(index>=obj.numOfVerts)
			{
				if( FindBracketClose( temp) )return 1;
				else continue;
			}
			sscanf( temp, "%d\t%f\t%f\t%f", &i, &obj.pVerts[index].x, &obj.pVerts[index].y, &obj.pVerts[index].z );
			index++;
		}
	//	else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #4
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_Face_List(zASE_Object &obj)
{
	char temp[255];
	int index=0,i;
	if( obj.numOfFaces!=0)obj.pFaces = new zASE_Face[obj.numOfFaces];
	else return ReadUnknown( temp);
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MESH_FACE ") )
		{
		//	*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 1
		//	sscanf( temp, "%d", &index)
			if(index>=obj.numOfFaces)
			{
				if( FindBracketClose( temp) )return 1;
				else continue;
			}
			sscanf( temp, "%d: A: %hu B: %hu C: %hu", &i, &obj.pFaces[index].index[0], &obj.pFaces[index].index[1], &obj.pFaces[index].index[2] );
			index++;
		}
	//	else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #5
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_TVertList_(zASE_Object &obj)
{
	char temp[255];
	int index=0,i;
	if( obj.numOfTexVerts_!=0)obj.pTexVerts_ = new vec2[obj.numOfTexVerts_];
	else return ReadUnknown( temp);
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MESH_TVERT ") )
		{
		//	*MESH_TVERT 0	0.00000	0.00000	0.00000 
		//	sscanf( temp, "%d", &index)
			if(index>=obj.numOfTexVerts_)
			{
				if( FindBracketClose( temp) )return 1;
				else continue;
			}
			sscanf( temp, "%d %f %f", &i, &obj.pTexVerts_[index].x, &obj.pTexVerts_[index].y );
			index++;
		}
	//	else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #6
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadGeomObject()
{
	char temp[255];
	zASE_Object	obj;
	memset( &obj, 0, sizeof( zASE_Object));
	obj.rotmatrix[0].set(1,0,0);
	obj.rotmatrix[1].set(0,1,0);
	obj.rotmatrix[2].set(0,0,1);
	do
	{
		if( !fgets(temp, 255, file) )return 0;
	
		if( EqualString( temp, "*NODE_NAME ") )			{ CopyString( temp, obj.name );	continue; }
		else if( EqualString( temp, "*NODE_TM ") )		{ if(!ReadNode_TM( obj ))return 0;continue; }
		else if( EqualString( temp, "*MESH ") )				
		{ if( !ReadMesh(obj) )return 0; else continue; }
	//	else if( EqualString( temp, "*PROP_MOTIONBLUR ") )			{ continue; }		// 0,1
	//	else if( EqualString( temp, "*PROP_CASTSHADOW ") )			{ continue; }		// 0,1
	//	else if( EqualString( temp, "*PROP_RECVSHADOW ") )			{ continue; }		// 0,1
	//	else if( EqualString( temp, "*WIREFRAME_COLOR ") )			{ continue; }		// 3 x float
		else if( EqualString( temp, "*MATERIAL_REF ") )			{ obj.materialID = atoi(temp); continue; }
		else ReadUnknown( temp);

	}while(!FindBracketClose( temp));		// while temp not contain '}'
	objects.push_back( obj);
	return 1;
}
コード例 #7
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMaterial(int num)
{
	char temp[255];
	zASE_Material mat;
	memset( &mat, 0, sizeof( zASE_Material));
	mat.textureId=-1;
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MATERIAL_NAME ") )			{ CopyString( temp, mat.name );			continue; }
	//	else if( EqualString( temp, "*MATERIAL_CLASS ") )		{ CopyString( temp, mat.classname );	continue; }
		else if( EqualString( temp, "*MATERIAL_AMBIENT ") )		{ CopyVector4( temp, mat.ambient );		continue; }
		else if( EqualString( temp, "*MATERIAL_DIFFUSE ") )		{ CopyVector4( temp, mat.diffuse );		continue; }
		else if( EqualString( temp, "*MATERIAL_SPECULAR ") )		{ CopyVector4( temp, mat.specular );		continue; }
		else if( EqualString( temp, "*MATERIAL_SHINE ") )		{ CopyFloat ( temp, mat.shine );		continue; }
		else if( EqualString( temp, "*MATERIAL_SHINESTRENGTH ") ){ CopyFloat ( temp, mat.shineStrength );continue; }
		else if( EqualString( temp, "*MATERIAL_TRANSPARENCY ") )	{ CopyFloat ( temp, mat.transparency );	continue; }
		else if( EqualString( temp, "*MATERIAL_WIRESIZE ") )		{ CopyFloat ( temp, mat.wiresize );		continue; }
	//	else if( EqualString( temp, "*MATERIAL_SHADING ") )		{ strcpy( mat.shading, temp);			continue; }
	//	else if( EqualString( temp, "*MATERIAL_XP_FALLOFF ") )	{ CopyFloat ( temp, mat.xp_falloff );	continue; }
		else if( EqualString( temp, "*MATERIAL_SELFILLUM ") )	{ CopyFloat ( temp, mat.selfIllum );	continue; }
	//	else if( EqualString( temp, "*MATERIAL_FALLOFF ") )		{ strcpy( mat.falloff, temp);			continue; }
	//	else if( EqualString( temp, "*MATERIAL_XP_TYPE ") )		{ strcpy( mat.xp_type, temp);			continue; }
		else if( EqualString( temp, "*MAP_DIFFUSE ") )		{ if(!ReadMaterialMap( mat ))return 0;		continue; }
		else if( EqualString( temp, "*NUMSUBMTLS ") )			
		{
			mat.numOfSubMaterials = atoi(temp);
			if(mat.numOfSubMaterials<=0)continue;
			mat.pSubMaterials = new zASE_Material[mat.numOfSubMaterials];
			memset( &mat.pSubMaterials[0], 0, mat.numOfSubMaterials*sizeof( zASE_Material));
			for(int i=0; i<mat.numOfSubMaterials; i++)
				mat.pSubMaterials[i].textureId=-1;
			continue; 
		}
		else if( EqualString( temp, "*SUBMATERIAL ") )		
		{ 
			int num = atoi( temp);
			if( num<0 || num>=mat.numOfSubMaterials){	ReadUnknown( temp);	continue; }
			if(!ReadMaterialSubMaterial( mat.pSubMaterials[num], num ))return 0;
			continue; 
		}
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	materials.push_back(mat);
	return 1;
}
コード例 #8
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMaterial_List()
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*MATERIAL ") )	{	if( !ReadMaterial(atoi(temp)) )return 0; }
	//	else if( EqualString( temp, "*MATERIAL_COUNT ") ) numOfMat=atoi(temp);
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #9
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadLightObjectNodeTM(z_Light &light)
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*TM_POS ") )	{ CopyVector( temp, light.lpos); continue; }
		else ReadUnknown( temp);

	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #10
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadGroup()
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*GEOMOBJECT ") )		{ if(!ReadGeomObject())return 0;	continue; }
		else if( EqualString( temp, "*LIGHTOBJECT") )	{	if(!ReadLightObject())return 0;}
	//	else if( EqualString( temp, "*HELPEROBJECT ") )	{ if(!ReadGroupHelperObject())return 0;	continue; }
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #11
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadLightObjectLightSettings(z_Light &light)
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		if( EqualString( temp, "*LIGHT_COLOR ") )	{ CopyVector( temp, light.color); continue; }
		if( EqualString( temp, "*LIGHT_ATTNEND ") )	{ light.light_range = atof( temp); continue; }
		else ReadUnknown( temp);

	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #12
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadUnknown(char *text)
{
	if( FindBracketOpen(text) )
	{
		char temp[255];
		do
		{
			if( !fgets(temp, 255, file) )return 0;
			if(!ReadUnknown(temp))return 0;
		
		}while(!FindBracketClose( temp));		// while temp not contain '}'
	}
	return 1;
}
コード例 #13
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMaterialMap(zASE_Material &mat, int subMaterial)
{
	char temp[255],name[255]={0};
	do
	{
		if( !fgets(temp, 255, file) )return 0;
		//	*BITMAP "D:\programy\VC++\MyProjects\027_ASE_loader\data\model\earth.bmp"
		if( EqualString( temp, "*BITMAP ") )	{ CopyString( temp, name );			continue; }
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	if( name[0]==NULL)return 0;
	FILE* test;
	test = fopen(name,"rb");
	char texture_name[255];
	if(test==NULL)
	{
		strcpy( texture_name, directory);

		char *pdest = strrchr( name, '\\' );
		if( pdest!=NULL && pdest[1]!=NULL)
			strcat(texture_name, pdest+1);
		else
			strcat(texture_name, name);
	}
	else
	{
		fclose(test);
		for(int i=0; i<strlen(name); i++)
			if(name[i]=='\\')name[i]='/';
		strcpy( texture_name, name);
	}
	
	for(int i=0; i<textureNames.size(); i++)
	{
		if(!strcmp(texture_name, textureNames[i]))
		{
			mat.textureId = i;
			i = textureNames.size()+1;
		}
	}
	if(i==textureNames.size())
	{
		char* newName = new char[strlen(texture_name)+1];
		strcpy(newName,texture_name);
		textureNames.push_back(newName);
		mat.textureId = textureNames.size()-1;
	}
	return 1;
}
コード例 #14
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_MappingChannel(zASE_Object &obj)
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
	
		else if( EqualString( temp, "*MESH_NUMTVERTEX ") )	{ obj.numOfTexVerts_ = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_TVERTLIST ") )	{ if( !ReadMesh_TVertList_(obj) )return 0; else continue; }
	//	else if( EqualString( temp, "*MESH_NUMTVFACES ") )	{ obj.numOfFaces = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_TFACELIST ") )	{ if( !ReadMesh_TFaceList_(obj) )return 0; else continue; }
		else 
			ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #15
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadAseFile()
{
	char temp[255];
	if(!file)return 0;

	while( fgets(temp, 255, file) )
	{
		if( EqualString( temp, "*MATERIAL_LIST") )		{	if(!ReadMaterial_List())return 0;}
		else if( EqualString( temp, "*GEOMOBJECT") )	{	if(!ReadGeomObject())return 0;}
		else if( EqualString( temp, "*GROUP") )			{	if(!ReadGroup())return 0;}
		else if( EqualString( temp, "*LIGHTOBJECT") )	{	if(!ReadLightObject())return 0;}
	//	else if( EqualString( temp, "*CAMERAOBJECT") )	{	if(!ReadCameraObject())return 0;}
		else ReadUnknown( temp);
	}
	return 1;
}
コード例 #16
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadMesh_Normals(zASE_Object &obj)
{
	char temp[255];
	int index=0,i;
	if( obj.numOfVerts!=0)obj.pNormals = new vec[obj.numOfVerts];
	else return ReadUnknown( temp);
	if( obj.numOfFaces!=0)obj.pFaceNormals = new vec[obj.numOfFaces];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
	//	*MESH_FACENORMAL 0	0.00000	0.00000	-1.00000
	//		*MESH_VERTEXNORMAL 0	0.00000	0.00000	-1.00000
	//		*MESH_VERTEXNORMAL 2	0.00000	0.00000	-1.00000
	//		*MESH_VERTEXNORMAL 3	0.00000	0.00000	-1.00000

		if( EqualString( temp, "*MESH_FACENORMAL ") )
		{
			sscanf( temp, "%d", &index);
			if(index>=obj.numOfFaces || index<0)continue;
		//	sscanf( temp, "%d %f %f %f", &i, &obj.pFaceNormals[index].x, &obj.pFaceNormals[index].y, &obj.pFaceNormals[index].z );
			vec in;	sscanf( temp, "%d %f %f %f", &i, &in.x, &in.y, &in.z );
			obj.pFaceNormals[index].x = DOT3( obj.rotmatrix[0], in );
			obj.pFaceNormals[index].y = DOT3( obj.rotmatrix[1], in );
			obj.pFaceNormals[index].z = DOT3( obj.rotmatrix[2], in );
			obj.pFaceNormals[index].Normalize();

		}
		else if (EqualString( temp, "*MESH_VERTEXNORMAL "))
		{
			sscanf( temp, "%d", &index);
			if(index>=obj.numOfVerts || index<0)continue;
		//	sscanf( temp, "%d %f %f %f", &i, &obj.pNormals[index].x, &obj.pNormals[index].y, &obj.pNormals[index].z );
			vec in;	sscanf( temp, "%d %f %f %f", &i, &in.x, &in.y, &in.z );
			obj.pNormals[index].x = DOT3( obj.rotmatrix[0], in );
			obj.pNormals[index].y = DOT3( obj.rotmatrix[1], in );
			obj.pNormals[index].z = DOT3( obj.rotmatrix[2], in );
		//	obj.pNormals[index].Normalize();
		}
	//	ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #17
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadNode_TM(zASE_Object &obj)
{
	char temp[255];
	vec row[3];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
	
		if( EqualString( temp, "*TM_ROW0 ") )		{ CopyVector( temp, row[0]); continue; }
		else if( EqualString( temp, "*TM_ROW1 ") )	{ CopyVector( temp, row[1]); continue; }
		else if( EqualString( temp, "*TM_ROW2 ") )	{ CopyVector( temp, row[2]); continue; }
	//	else if( EqualString( temp, "*TM_POS ") )	{ CopyVector( temp, obj.pos); continue; }
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	obj.rotmatrix[0].set( row[0].x, row[1].x, row[2].x);
	obj.rotmatrix[1].set( row[0].y, row[1].y, row[2].y);
	obj.rotmatrix[2].set( row[0].z, row[1].z, row[2].z);
	obj.rotmatrix[0].Normalize();
	obj.rotmatrix[1].Normalize();
	obj.rotmatrix[2].Normalize();
	return 1;
}
コード例 #18
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
/*	*MESH {
		*TIMEVALUE 0
		*MESH_NUMVERTEX 8
		*MESH_NUMFACES 12
		*MESH_VERTEX_LIST {
			*MESH_VERTEX    0	-9.00000	-3.00000	3.00000
		}
		*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 1
		}
		*MESH_NUMTVERTEX 0
		*MESH_NUMCVERTEX 0
		*MESH_NORMALS {
			*MESH_FACENORMAL 0	0.00000	0.00000	-1.00000
				*MESH_VERTEXNORMAL 0	0.00000	0.00000	-1.00000
				*MESH_VERTEXNORMAL 2	0.00000	0.00000	-1.00000
				*MESH_VERTEXNORMAL 3	0.00000	0.00000	-1.00000
		}
	}
*/
int AseFile::ReadMesh(zASE_Object &obj)
{
	char temp[255];
	do
	{
		if( !fgets(temp, 255, file) )return 0;
	
	//	if( EqualString( temp, "*TIMEVALUE ") )			{ CopyFloat ( temp, time );	continue; }
		if( EqualString( temp, "*MESH_NUMVERTEX ") )		{ obj.numOfVerts = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_NUMFACES ") )	{ obj.numOfFaces = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_VERTEX_LIST ") )	{ if( !ReadMesh_Vertex_List(obj) )return 0; else continue; }
		else if( EqualString( temp, "*MESH_FACE_LIST ") )	{ if( !ReadMesh_Face_List(obj) )return 0; else continue; }
		else if( EqualString( temp, "*MESH_NUMTVERTEX ") )	{ obj.numOfTexVerts = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_TVERTLIST ") )	{ if( !ReadMesh_TVertList(obj) )return 0; else continue; }
	//	else if( EqualString( temp, "*MESH_NUMTVFACES ") )	{ obj.numOfFaces = atoi(temp); continue; }
		else if( EqualString( temp, "*MESH_TFACELIST ") )	{ if( !ReadMesh_TFaceList(obj) )return 0; else continue; }
	//	else if( EqualString( temp, "*MESH_NUMCVERTEX ") )	{ continue; }
		else if( EqualString( temp, "*MESH_NORMALS ") )		{ if( !ReadMesh_Normals(obj) )return 0; else continue; }
		else if( EqualString( temp, "*MESH_MAPPINGCHANNEL 3 ") ){ if( !ReadMesh_MappingChannel(obj) )return 0; else continue; }
		else ReadUnknown( temp);
	}while(!FindBracketClose( temp));		// while temp not contain '}'
	return 1;
}
コード例 #19
0
ファイル: AseFile.cpp プロジェクト: Mantora/GA
int AseFile::ReadLightObject()
{
	z_Light light;
	light.lpos.set(0,0,0);
	light.color.set(1,1,1);
	light.light_range = 100.f;
	light.modification = 1;
	char temp[255];
	int ok=0;

	do
	{
		if( !fgets(temp, 255, file) )return 0;

		if( EqualString( temp, "*LIGHT_TYPE ") )		 { if(!strncmp(temp,"Omni",4))ok=1; continue;}
		else if( EqualString( temp, "*NODE_TM ") )		 { if(!ReadLightObjectNodeTM(light))return 0;}
		else if( EqualString( temp, "*LIGHT_SETTINGS ") ){ if(!ReadLightObjectLightSettings(light))return 0;}
		else ReadUnknown( temp);

	}while(!FindBracketClose( temp));		// while temp not contain '}'
	if(ok)static_lights.push_back(light);
	return 1;
}
コード例 #20
0
			void ReadChunks()
			{
				Context context;

				while (!stream.Eof())
				{
					dword id = stream.Read32();
					const dword length = stream.Read32();
					NST_VERIFY( length <= SIZE_1K * 4096UL );

					switch (id)
					{
						case AsciiId<'N','A','M','E'>::V: id = (context( 0, id ) ? ReadName       (         ) : 0); break;
						case AsciiId<'R','E','A','D'>::V: id = (context( 1, id ) ? ReadComment    (         ) : 0); break;
						case AsciiId<'D','I','N','F'>::V: id = (context( 2, id ) ? ReadDumper     (         ) : 0); break;
						case AsciiId<'T','V','C','I'>::V: id = (context( 3, id ) ? ReadSystem     ( context ) : 0); break;
						case AsciiId<'B','A','T','R'>::V: id = (context( 4, id ) ? ReadBattery    (         ) : 0); break;
						case AsciiId<'M','A','P','R'>::V: id = (context( 5, id ) ? ReadBoard      (         ) : 0); break;
						case AsciiId<'M','I','R','R'>::V: id = (context( 6, id ) ? ReadMirroring  (         ) : 0); break;
						case AsciiId<'C','T','R','L'>::V: id = (context( 7, id ) ? ReadController (         ) : 0); break;
						case AsciiId<'V','R','O','R'>::V: id = (context( 8, id ) ? ReadChrRam     (         ) : 0); break;

						default: switch (id & 0x00FFFFFF)
						{
							case AsciiId<'P','C','K'>::V:
							case AsciiId<'C','C','K'>::V:
							case AsciiId<'P','R','G'>::V:
							case AsciiId<'C','H','R'>::V:
							{
								uint index = id >> 24 & 0xFF;

								if (index >= Ascii<'0'>::V && index <= Ascii<'9'>::V)
								{
									index -= Ascii<'0'>::V;
								}
								else if (index >= Ascii<'A'>::V && index <= Ascii<'F'>::V)
								{
									index = index - Ascii<'A'>::V + 10;
								}
								else
								{
									index = ~0U;
								}

								if (index < 16)
								{
									switch (dword part = (id & 0x00FFFFFF))
									{
										case AsciiId<'P','C','K'>::V:
										case AsciiId<'C','C','K'>::V:

											part = (part == AsciiId<'C','C','K'>::V);
											id = (context( 9 + (part << 4) + index, id) ? ReadChecksum( part, index, context.roms[part][index] ) : 0);
											break;

										case AsciiId<'P','R','G'>::V:
										case AsciiId<'C','H','R'>::V:

											part = (part == AsciiId<'C','H','R'>::V);
											id = (context( 9 + 32 + (part << 4) + index, id ) ? ReadRom( part, index, length, context.roms[part] ) : 0);
											break;
									}

									break;
								}
							}

							default:

								id = ReadUnknown( id );
								break;
						}
					}

					if (id < length)
					{
						for (id = length - id; id > 0x7FFFFFFF; id -= 0x7FFFFFFF)
							stream.Seek( 0x7FFFFFFF );

						if (id)
							stream.Seek( id );
					}
					else if (id > length)
					{
						throw RESULT_ERR_CORRUPT_FILE;
					}
				}

				for (uint i=0; i < 2; ++i)
				{
					uint count = 0;
					dword size = 0;

					for (uint j=0; j < 16; ++j)
					{
						if (const dword n=context.roms[i][j].data.Size())
						{
							count++;
							size += n;
						}
					}

					if (count)
					{
						Profile::Board::Roms& rom = (i ? profile.board.chr : profile.board.prg);
						rom.resize( count );

						Ram& dst = (i ? chr : prg);
						dst.Set( size );

						if (!rom.empty())
						{
							for (Profile::Board::Pins::const_iterator it(rom.front().pins.begin()), end(rom.front().pins.end()); it != end; ++it)
								dst.Pin(it->number) = it->function.c_str();
						}

						size = 0;

						for (uint j=0, k=0; j < 16; ++j)
						{
							const Context::Rom& src = context.roms[i][j];

							if (src.data.Size())
							{
								rom[k].id = k;
								rom[k].size = src.data.Size();
								rom[k].hash.Assign( NULL, src.crc );
								k++;

								std::memcpy( dst.Mem(size), src.data.Mem(), src.data.Size() );
								size += src.data.Size();
							}
						}
					}
				}

				if (profileEx.nmt == ProfileEx::NMT_HORIZONTAL)
				{
					profile.board.solderPads = Profile::Board::SOLDERPAD_V;
				}
				else if (profileEx.nmt == ProfileEx::NMT_HORIZONTAL)
				{
					profile.board.solderPads = Profile::Board::SOLDERPAD_H;
				}

				switch (context.system)
				{
					case Context::SYSTEM_NTSC:

						if (favoredSystem == FAVORED_FAMICOM)
						{
							profile.system.type = Profile::System::FAMICOM;
						}
						if (favoredSystem == FAVORED_DENDY)
						{
							profile.system.type = Profile::System::DENDY;
							profile.system.cpu = Profile::System::CPU_DENDY;
							profile.system.ppu = Profile::System::PPU_DENDY;
						}
						else
						{
							profile.system.type = Profile::System::NES_NTSC;
						}
						break;

					default:

						profile.multiRegion = true;

						if (favoredSystem == FAVORED_FAMICOM)
						{
							profile.system.type = Profile::System::FAMICOM;
							break;
						}
						else if (favoredSystem != FAVORED_NES_PAL && favoredSystem != FAVORED_DENDY)
						{
							profile.system.type = Profile::System::NES_NTSC;
							break;
						}

					case Context::SYSTEM_PAL:

						if (favoredSystem == FAVORED_DENDY)
						{
							profile.system.type = Profile::System::DENDY;
							profile.system.cpu = Profile::System::CPU_DENDY;
							profile.system.ppu = Profile::System::PPU_DENDY;
						}
						else
						{
							profile.system.type = Profile::System::NES_PAL;
							profile.system.cpu = Profile::System::CPU_RP2A07;
							profile.system.ppu = Profile::System::PPU_RP2C07;
						}
						break;
				}
			}