Jump to content
  • Advertisement
Sign in to follow this  
adam17

fscanf failing

This topic is 4975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ive been working on an ASE file parser for the past few days and i hit a road block and i hit it HARD! everytime i run it and read in a file fscanf cannot read a portion of data from the file. it keeps failing at reading in the value after "MATERIAL_REF". take a look:

#include <iomanip.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <fstream.h>
#include <math.h>

#include <GL/gl.h>
#include <GL/glu.h>

#include <vector>
using namespace std;

typedef struct _point3
{
	float x, y, z;
	int s;			//for smoothing groups
} point3;

typedef struct _point2
{
	float x, y;
} point2;

typedef struct _polygon
{
	point3	v1, v2, v3;
	point3	n1, n2, n3;
	int		smoothgroup;
	int		material;
} polygon;

point3 Cross(point3 vector1, point3 vector2)
{
	point3 temp_vector;

	temp_vector.x = (vector1.z * vector2.y) - (vector1.y * vector2.z);
	temp_vector.y = (vector1.x * vector2.z) - (vector1.z * vector2.x);
	temp_vector.z = (vector1.y * vector2.x) - (vector1.x * vector2.y);

	return temp_vector;
}

float Magnitude(point3 vector)
{	
	return sqrt(vector.x * vector.x +
				vector.y * vector.y +
				vector.z * vector.z);
}

point3 Normalize(point3 vector)
{
	float len = Magnitude(vector);
	vector.x /= len;
	vector.y /= len;
	vector.z /= len;

	return vector;
}

typedef struct _material
{
	char	name[259];

	point3	ambient;
	point3	diffuse;
	point3	specular;
	float	transparency;

	char	diffuseMap[259];
	char	specularMap[259];
	char	bumpMap[259];		//can also be used as normal map
} material;

struct Mesh
{
	int		NumVertex;			//length of array
	int		NumFace;			//length of array	
	int		NumTexCoord;		//length of array
	int		NumFaceTex;			//length of array
	vector<point3> Vert;		//indexed vertex array
	vector<point3> Face;		//indexed face-vertex array
	vector<point3> TexCoord;	//indexed texture coordinate array
	vector<point3> FaceTex;		//indexed face-texcoord array
	
	int		NumFaceNormal;
	int		NumVertexNormal;
	int		NumSmoothGroup;
	vector<point3> FaceNormal;
	vector<point3> VertexNormal;

	int		NumObject;

	vector<polygon> polys;

	int				NumMaterial;
	vector<material>Material;
	vector<int>		MatList;

	int		QueryMaterial(char* Mname);
	bool	LoadObj(char* filename);
	bool	LoadMtl(char* filename);
	bool	LoadASE(char* filename);
	void	BuildModel();

	Mesh();

};
Mesh::Mesh()
{	
	NumVertex = 0;
	NumTexCoord = 0;
	NumFace = 0;
	NumFaceTex = 0;
	NumFaceNormal = 0;
	NumVertexNormal = 0;
	NumObject = 0;
	NumSmoothGroup = -1;
	NumMaterial = 0;
}

void Mesh::BuildModel()
{
	polys.resize(NumFace);
	for(int x=0; x<NumFace; x++)
	{
		polys[x].v1 = Vert[Face[x].x];
		polys[x].v2 = Vert[Face[x].y];
		polys[x].v3 = Vert[Face[x].z];

		polys[x].material = MatList[x];
	}
}

bool Mesh::LoadASE(char* filename)
{
	point3	temp;
	int		itemp;
	FILE	*infile;
	char	cChar;
	char	sChar[255] = {0};
	char	*szChar = " ";
	int		currentMaterial = 0;
	int		numMaterial = -1;
	int		numSubMaterial = -1;
	char	materialName[255] = {0};

	int		tempNumVertex = 0,
			tempNumFace = 0,
			tempNumTexCoord = 0,
			tempNumFaceTex = 0;
	char	mapType[255] = {0};

	int		offset = 0;

	vector<int>	tempMatRef;

	infile = fopen(filename, "r");
	if(!infile)
	{
		MessageBox(NULL,"Could Not Find File.","FILE ERROR",MB_OK | MB_ICONINFORMATION);
		return false;
	}

	while(!feof(infile))
	{
		cChar = fgetc(infile);

		if(cChar == '*')
		{
			fscanf(infile, "%s", sChar);

			if(strcmp(sChar, "GEOMOBJECT") == 0)
				NumObject++;

			if(strcmp(sChar, "MATERIAL_REF") == 0)
			{
				fscanf(infile, "%i", &currentMaterial);
			}

			/**********************************			 Loading Mesh Offset information...
			\**********************************/
			if(strcmp(sChar, "MESH_NUMVERTEX") == 0)
			{
				fscanf(infile, "%i", &tempNumVertex);
				NumVertex += tempNumVertex;
			}
			if(strcmp(sChar, "MESH_NUMFACES") == 0)
			{
				fscanf(infile, "%i", &tempNumFace);
				NumFace += tempNumFace;
			}
			if(strcmp(sChar, "MESH_NUMTVERTEX") == 0)
			{
				fscanf(infile, "%i", &tempNumTexCoord);
				NumTexCoord += tempNumTexCoord;
			}
			if(strcmp(sChar, "NUMTVFACES") == 0)
			{
				fscanf(infile, "%i", &tempNumFaceTex);
				NumFaceTex += tempNumFaceTex;
			}


			/**********************************			 Loading Mesh information...
			\**********************************/
			if(strcmp(sChar, "MESH_VERTEX") == 0)
			{
				fscanf(infile, "%i %f %f %f", &itemp, &temp.x, &temp.y, &temp.z);
				Vert.push_back(temp);
			}
			if(strcmp(sChar, "MESH_FACE") == 0)
			{
				fscanf(infile, "%s %s %f %s %f %s %f", 
					&sChar, &sChar, &temp.x, &sChar, &temp.y, &sChar, &temp.z);

				temp.x += (NumVertex - tempNumVertex);
				temp.y += (NumVertex - tempNumVertex);
				temp.z += (NumVertex - tempNumVertex);

				Face.push_back(temp);
			}
			if(strcmp(sChar, "MESH_MTLID") == 0)
			{
				fscanf(infile, "%i", &itemp);
				MatList.push_back(itemp);
			}
			if(strcmp(sChar, "MESH_TVERT") == 0)
			{
				fscanf(infile, "%i %f %f %f", &itemp, &temp.x, &temp.y, &temp.z);
				TexCoord.push_back(temp);
			}
			if(strcmp(sChar, "MESH_TFACE") == 0)
			{
				fscanf(infile, "%i %f %f %f", &itemp, &temp.x, &temp.y, &temp.z);

				temp.x += (NumTexCoord - tempNumTexCoord);
				temp.y += (NumTexCoord - tempNumTexCoord);
				temp.z += (NumTexCoord - tempNumTexCoord);

				FaceTex.push_back(temp);
			}
			if(strcmp(sChar, "MESH_FACENORMAL") == 0)
			{
				fscanf(infile, "%i %f %f %f", &itemp, &temp.x, &temp.y, &temp.z);
				temp = Normalize(temp);
				FaceNormal.push_back(temp);
				NumFaceNormal++;
			}
			if(strcmp(sChar, "MESH_VERTEXNORMAL") == 0)
			{
				fscanf(infile, "%i %f %f %f", &itemp, &temp.x, &temp.y, &temp.z);
				temp = Normalize(temp);
				VertexNormal.push_back(temp);
				NumVertexNormal++;
			}

			/**********************************			 Loading Material information...
			\**********************************/
			if((strcmp(sChar, "MATERIAL") == 0) ||
				(strcmp(sChar, "GEOMOBJECT") == 0))
			{
				if(numSubMaterial != -1)
					tempMatRef.push_back(numSubMaterial+1);
				numSubMaterial = -1;
				//cout << "material: " << numMaterial << endl;
			}
			if(strcmp(sChar, "SUBMATERIAL") == 0)
			{
				numMaterial++;
				numSubMaterial++;
			}
			if(strcmp(sChar, "MATERIAL_REF") == 0)
			{
				itemp = 0;
				//scan in ref number
                                /***********this area is failing***********/
				if(fscanf(infile, "%i", &itemp))
					cout << "itemp:  " << itemp << endl;
				else
					cout << "fscanf failed" << endl;
                                /***********this area is failing***********/

				//pull offset number from array
				for(int i=0; i<itemp; i++)
					offset += tempMatRef;
				cout << "offset: " << offset << endl;

				//loop through mat_ids adding the offset
			}
			if(strcmp(sChar, "MAP_DIFFUSE") == 0)
			{
				strcpy(mapType, "diffuse");
				//cout << mapType << endl;
			}
			if(strcmp(sChar, "MAP_SHINE") == 0)
			{
				strcpy(mapType, "shine");
				//cout << mapType << endl;
			}
			if(strcmp(sChar, "MAP_BUMP") == 0)
			{
				strcpy(mapType, "bump");
				//cout << mapType << endl;
			}

			if(strcmp(sChar, "BITMAP") == 0)
			{
				vector<char> str;
				cChar = fgetc(infile);
				cChar = fgetc(infile);
				cChar = fgetc(infile);				

				while(cChar != '\"')
				{
					str.push_back(cChar);
					cChar = fgetc(infile);
				}
				str.push_back('\0');
				for(int i=0; i<str.size(); i++)
				{
					sChar = str;
				}
				//cout << sChar << endl;
			}
		}
	}

	for(int i=0; i<tempMatRef.size(); i++)
		cout << tempMatRef << ' ';
	cout << endl;

	NumMaterial = numMaterial + 1;
	BuildModel();

	return true;
}

int main()
{
	char file[256] = {0};
	char choice = 'a';
	Mesh mesh;

	cout << "Enter a file to open..." << endl;
	cin >> file;
	if(mesh.LoadASE(file) == false)
	{
		cout << "File " << file << " Could Not Be Found" << endl;
		return 0;
	}

	cout << "Num objects:        " << mesh.NumObject << endl;
	cout << "Num vertices:       " << mesh.NumVertex << endl;
	cout << "Num faces:          " << mesh.NumFace << endl;
	cout << "Num texture coords  " << mesh.NumTexCoord << endl;
	cout << "Num face normals    " << mesh.NumFaceNormal << endl;
	cout << "Num vertex normals  " << mesh.NumVertexNormal << endl;
	cout << "Num materials       " << mesh.NumMaterial << endl;

	return 1;
}

any ideas? here is an ase file if you need one
*3DSMAX_ASCIIEXPORT	200
*COMMENT "AsciiExport Version  2.00 - Thu Mar 03 22:00:39 2005"
*SCENE {
	*SCENE_FILENAME "scene.max"
	*SCENE_FIRSTFRAME 0
	*SCENE_LASTFRAME 100
	*SCENE_FRAMESPEED 30
	*SCENE_TICKSPERFRAME 160
	*SCENE_BACKGROUND_STATIC 0.0000	0.0000	0.0000
	*SCENE_AMBIENT_STATIC 0.0000	0.0000	0.0000
}
*MATERIAL_LIST {
	*MATERIAL_COUNT 2
	*MATERIAL 0 {
		*MATERIAL_NAME "01 - Default"
		*MATERIAL_CLASS "Multi/Sub-Object"
		*MATERIAL_AMBIENT 0.5880	0.5880	0.5880
		*MATERIAL_DIFFUSE 0.5880	0.5880	0.5880
		*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
		*MATERIAL_SHINE 0.1000
		*MATERIAL_SHINESTRENGTH 0.0000
		*MATERIAL_TRANSPARENCY 0.0000
		*MATERIAL_WIRESIZE 1.0000
		*NUMSUBMTLS 3
		*SUBMATERIAL 0 {
			*MATERIAL_NAME "Material #25"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.5880	0.5880	0.5880
			*MATERIAL_DIFFUSE 0.5880	0.5880	0.5880
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
			*MAP_DIFFUSE {
				*MAP_NAME "Map #1"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 1
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Stone.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_SHINE {
				*MAP_NAME "Map #6"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 3
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Stone.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_BUMP {
				*MAP_NAME "Map #7"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 8
				*MAP_AMOUNT 0.3000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Stone.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
		}
		*SUBMATERIAL 1 {
			*MATERIAL_NAME "Material #26"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.5880	0.5880	0.5880
			*MATERIAL_DIFFUSE 1.0000	0.0000	0.0000
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
			*MAP_DIFFUSE {
				*MAP_NAME "Map #2"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 1
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Crate.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_SHINE {
				*MAP_NAME "Map #8"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 3
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Crate.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_BUMP {
				*MAP_NAME "Map #9"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 8
				*MAP_AMOUNT 0.3000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Crate.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
		}
		*SUBMATERIAL 2 {
			*MATERIAL_NAME "Material #27"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.5880	0.5880	0.5880
			*MATERIAL_DIFFUSE 0.0000	0.0000	1.0000
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
			*MAP_DIFFUSE {
				*MAP_NAME "Map #3"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 1
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Grass.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_SHINE {
				*MAP_NAME "Map #4"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 3
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Grass.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_BUMP {
				*MAP_NAME "Map #5"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 8
				*MAP_AMOUNT 0.3000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Grass.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
		}
	}
	*MATERIAL 1 {
		*MATERIAL_NAME "02 - Default"
		*MATERIAL_CLASS "Multi/Sub-Object"
		*MATERIAL_AMBIENT 0.8980	0.8980	0.8980
		*MATERIAL_DIFFUSE 0.8980	0.8980	0.8980
		*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
		*MATERIAL_SHINE 0.1000
		*MATERIAL_SHINESTRENGTH 0.0000
		*MATERIAL_TRANSPARENCY 0.0000
		*MATERIAL_WIRESIZE 1.0000
		*NUMSUBMTLS 2
		*SUBMATERIAL 0 {
			*MATERIAL_NAME "Material #36"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.8980	0.8980	0.8980
			*MATERIAL_DIFFUSE 0.8980	0.8980	0.8980
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
			*MAP_DIFFUSE {
				*MAP_NAME "Map #39"
				*MAP_CLASS "Bitmap"
				*MAP_SUBNO 1
				*MAP_AMOUNT 1.0000
				*BITMAP "E:\Adam\Software\Visual C++\Box Physics\Crate.bmp"
				*MAP_TYPE Screen
				*UVW_U_OFFSET 0.0000
				*UVW_V_OFFSET 0.0000
				*UVW_U_TILING 1.0000
				*UVW_V_TILING 1.0000
				*UVW_ANGLE 0.0000
				*UVW_BLUR 1.0000
				*UVW_BLUR_OFFSET 0.0000
				*UVW_NOUSE_AMT 1.0000
				*UVW_NOISE_SIZE 1.0000
				*UVW_NOISE_LEVEL 1
				*UVW_NOISE_PHASE 0.0000
				*BITMAP_FILTER Pyramidal
			}
			*MAP_REFLECT {
				*MAP_NAME "Map #38"
				*MAP_CLASS "Flat Mirror"
				*MAP_SUBNO 9
				*MAP_AMOUNT 1.0000
			}
		}
		*SUBMATERIAL 1 {
			*MATERIAL_NAME "Material #37"
			*MATERIAL_CLASS "Standard"
			*MATERIAL_AMBIENT 0.5880	0.5880	0.5880
			*MATERIAL_DIFFUSE 0.5880	0.5880	0.5880
			*MATERIAL_SPECULAR 0.9000	0.9000	0.9000
			*MATERIAL_SHINE 0.1000
			*MATERIAL_SHINESTRENGTH 0.0000
			*MATERIAL_TRANSPARENCY 0.0000
			*MATERIAL_WIRESIZE 1.0000
			*MATERIAL_SHADING Blinn
			*MATERIAL_XP_FALLOFF 0.0000
			*MATERIAL_SELFILLUM 0.0000
			*MATERIAL_FALLOFF In
			*MATERIAL_XP_TYPE Filter
			*MAP_BUMP {
				*MAP_NAME "Map #14"
				*MAP_CLASS "Normal Bump"
				*MAP_SUBNO 8
				*MAP_AMOUNT 1.0000
				*MAP_GENERIC {
					*MAP_NAME "Map #26"
					*MAP_CLASS "Bitmap"
					*MAP_SUBNO 0
					*MAP_AMOUNT 1.0000
					*BITMAP "E:\Adam\Software\Visual C++\Box Physics\normal.jpg"
					*MAP_TYPE Screen
					*UVW_U_OFFSET 0.0000
					*UVW_V_OFFSET 0.0000
					*UVW_U_TILING 1.0000
					*UVW_V_TILING 1.0000
					*UVW_ANGLE 0.0000
					*UVW_BLUR 1.0000
					*UVW_BLUR_OFFSET 0.0000
					*UVW_NOUSE_AMT 1.0000
					*UVW_NOISE_SIZE 1.0000
					*UVW_NOISE_LEVEL 1
					*UVW_NOISE_PHASE 0.0000
					*BITMAP_FILTER Pyramidal
				}
				*MAP_GENERIC {
					*MAP_NAME "Map #27"
					*MAP_CLASS "Bitmap"
					*MAP_SUBNO 1
					*MAP_AMOUNT 1.0000
					*BITMAP "E:\Adam\Software\Visual C++\Box Physics\normal.jpg"
					*MAP_TYPE Screen
					*UVW_U_OFFSET 0.0000
					*UVW_V_OFFSET 0.0000
					*UVW_U_TILING 1.0000
					*UVW_V_TILING 1.0000
					*UVW_ANGLE 0.0000
					*UVW_BLUR 1.0000
					*UVW_BLUR_OFFSET 0.0000
					*UVW_NOUSE_AMT 1.0000
					*UVW_NOISE_SIZE 1.0000
					*UVW_NOISE_LEVEL 1
					*UVW_NOISE_PHASE 0.0000
					*BITMAP_FILTER Pyramidal
				}
			}
		}
	}
}
*GEOMOBJECT {
	*NODE_NAME "Box01"
	*NODE_TM {
		*NODE_NAME "Box01"
		*INHERIT_POS 0 0 0
		*INHERIT_ROT 0 0 0
		*INHERIT_SCL 0 0 0
		*TM_ROW0 1.0000	0.0000	0.0000
		*TM_ROW1 0.0000	1.0000	0.0000
		*TM_ROW2 0.0000	0.0000	1.0000
		*TM_ROW3 0.0000	0.0000	93.8709
		*TM_POS 0.0000	0.0000	93.8709
		*TM_ROTAXIS 0.0000	0.0000	0.0000
		*TM_ROTANGLE 0.0000
		*TM_SCALE 1.0000	1.0000	1.0000
		*TM_SCALEAXIS 0.0000	0.0000	0.0000
		*TM_SCALEAXISANG 0.0000
	}
	*MESH {
		*TIMEVALUE 0
		*MESH_NUMVERTEX 8
		*MESH_NUMFACES 12
		*MESH_VERTEX_LIST {
			*MESH_VERTEX    0	-18.0000	-18.0000	93.8709
			*MESH_VERTEX    1	18.0000	-18.0000	93.8709
			*MESH_VERTEX    2	-18.0000	18.0000	93.8709
			*MESH_VERTEX    3	18.0000	18.0000	93.8709
			*MESH_VERTEX    4	-18.0000	-18.0000	129.8709
			*MESH_VERTEX    5	18.0000	-18.0000	129.8709
			*MESH_VERTEX    6	-18.0000	18.0000	129.8709
			*MESH_VERTEX    7	18.0000	18.0000	129.8709
		}
		*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    1:    A:    3 B:    1 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    2:    A:    4 B:    5 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    3:    A:    7 B:    6 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    4:    A:    0 B:    1 C:    5 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    5:    A:    5 B:    4 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    6:    A:    1 B:    3 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    7:    A:    7 B:    5 C:    1 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    8:    A:    3 B:    2 C:    6 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE    9:    A:    6 B:    7 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE   10:    A:    2 B:    0 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
			*MESH_FACE   11:    A:    4 B:    6 C:    2 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
		}
		*MESH_NUMTVERTEX 12
		*MESH_TVERTLIST {
			*MESH_TVERT 0	0.0000	0.0000	0.0000
			*MESH_TVERT 1	1.0000	0.0000	0.0000
			*MESH_TVERT 2	0.0000	1.0000	0.0000
			*MESH_TVERT 3	1.0000	1.0000	0.0000
			*MESH_TVERT 4	0.0000	0.0000	0.0000
			*MESH_TVERT 5	1.0000	0.0000	0.0000
			*MESH_TVERT 6	0.0000	1.0000	0.0000
			*MESH_TVERT 7	1.0000	1.0000	0.0000
			*MESH_TVERT 8	0.0000	0.0000	0.0000
			*MESH_TVERT 9	1.0000	0.0000	0.0000
			*MESH_TVERT 10	0.0000	1.0000	0.0000
			*MESH_TVERT 11	1.0000	1.0000	0.0000
		}
		*MESH_NUMTVFACES 12
		*MESH_TFACELIST {
			*MESH_TFACE 0	9	11	10
			*MESH_TFACE 1	10	8	9
			*MESH_TFACE 2	8	9	11
			*MESH_TFACE 3	11	10	8
			*MESH_TFACE 4	4	5	7
			*MESH_TFACE 5	7	6	4
			*MESH_TFACE 6	0	1	3
			*MESH_TFACE 7	3	2	0
			*MESH_TFACE 8	4	5	7
			*MESH_TFACE 9	7	6	4
			*MESH_TFACE 10	0	1	3
			*MESH_TFACE 11	3	2	0
		}
		*MESH_NORMALS {
			*MESH_FACENORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 2	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 2	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 5	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 3	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 6	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 1	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 6	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 3	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 5	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 8	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 2	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 9	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 7	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 10	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 0	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
			*MESH_FACENORMAL 11	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 6	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
		}
	}
	*PROP_MOTIONBLUR 0
	*PROP_CASTSHADOW 1
	*PROP_RECVSHADOW 1
	*MATERIAL_REF 0
}
*GEOMOBJECT {
	*NODE_NAME "Box02"
	*NODE_TM {
		*NODE_NAME "Box02"
		*INHERIT_POS 0 0 0
		*INHERIT_ROT 0 0 0
		*INHERIT_SCL 0 0 0
		*TM_ROW0 1.0000	0.0000	0.0000
		*TM_ROW1 0.0000	1.0000	0.0000
		*TM_ROW2 0.0000	0.0000	1.0000
		*TM_ROW3 0.0000	0.0000	0.0000
		*TM_POS 0.0000	0.0000	0.0000
		*TM_ROTAXIS 0.0000	0.0000	0.0000
		*TM_ROTANGLE 0.0000
		*TM_SCALE 1.0000	1.0000	1.0000
		*TM_SCALEAXIS 0.0000	0.0000	0.0000
		*TM_SCALEAXISANG 0.0000
	}
	*MESH {
		*TIMEVALUE 0
		*MESH_NUMVERTEX 8
		*MESH_NUMFACES 12
		*MESH_VERTEX_LIST {
			*MESH_VERTEX    0	-18.0000	-18.0000	0.0000
			*MESH_VERTEX    1	18.0000	-18.0000	0.0000
			*MESH_VERTEX    2	-18.0000	18.0000	0.0000
			*MESH_VERTEX    3	18.0000	18.0000	0.0000
			*MESH_VERTEX    4	-18.0000	-18.0000	36.0000
			*MESH_VERTEX    5	18.0000	-18.0000	36.0000
			*MESH_VERTEX    6	-18.0000	18.0000	36.0000
			*MESH_VERTEX    7	18.0000	18.0000	36.0000
		}
		*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    1:    A:    3 B:    1 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    2:    A:    4 B:    5 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    3:    A:    7 B:    6 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    4:    A:    0 B:    1 C:    5 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    5:    A:    5 B:    4 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    6:    A:    1 B:    3 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    7:    A:    7 B:    5 C:    1 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    8:    A:    3 B:    2 C:    6 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE    9:    A:    6 B:    7 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE   10:    A:    2 B:    0 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
			*MESH_FACE   11:    A:    4 B:    6 C:    2 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
		}
		*MESH_NUMTVERTEX 12
		*MESH_TVERTLIST {
			*MESH_TVERT 0	0.0000	0.0000	0.0000
			*MESH_TVERT 1	1.0000	0.0000	0.0000
			*MESH_TVERT 2	0.0000	1.0000	0.0000
			*MESH_TVERT 3	1.0000	1.0000	0.0000
			*MESH_TVERT 4	0.0000	0.0000	0.0000
			*MESH_TVERT 5	1.0000	0.0000	0.0000
			*MESH_TVERT 6	0.0000	1.0000	0.0000
			*MESH_TVERT 7	1.0000	1.0000	0.0000
			*MESH_TVERT 8	0.0000	0.0000	0.0000
			*MESH_TVERT 9	1.0000	0.0000	0.0000
			*MESH_TVERT 10	0.0000	1.0000	0.0000
			*MESH_TVERT 11	1.0000	1.0000	0.0000
		}
		*MESH_NUMTVFACES 12
		*MESH_TFACELIST {
			*MESH_TFACE 0	9	11	10
			*MESH_TFACE 1	10	8	9
			*MESH_TFACE 2	8	9	11
			*MESH_TFACE 3	11	10	8
			*MESH_TFACE 4	4	5	7
			*MESH_TFACE 5	7	6	4
			*MESH_TFACE 6	0	1	3
			*MESH_TFACE 7	3	2	0
			*MESH_TFACE 8	4	5	7
			*MESH_TFACE 9	7	6	4
			*MESH_TFACE 10	0	1	3
			*MESH_TFACE 11	3	2	0
		}
		*MESH_NORMALS {
			*MESH_FACENORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 2	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 2	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 5	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 3	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 6	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 1	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 6	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 3	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 5	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 8	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 2	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 9	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 7	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 10	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 0	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
			*MESH_FACENORMAL 11	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 6	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
		}
	}
	*PROP_MOTIONBLUR 0
	*PROP_CASTSHADOW 1
	*PROP_RECVSHADOW 1
	*MATERIAL_REF 1
}
*LIGHTOBJECT {
	*NODE_NAME "Omni01"
	*LIGHT_TYPE Omni
	*NODE_TM {
		*NODE_NAME "Omni01"
		*INHERIT_POS 0 0 0
		*INHERIT_ROT 0 0 0
		*INHERIT_SCL 0 0 0
		*TM_ROW0 1.0000	0.0000	0.0000
		*TM_ROW1 0.0000	1.0000	0.0000
		*TM_ROW2 0.0000	0.0000	1.0000
		*TM_ROW3 5.8978	-23.2791	59.5083
		*TM_POS 5.8978	-23.2791	59.5083
		*TM_ROTAXIS 0.0000	0.0000	0.0000
		*TM_ROTANGLE 0.0000
		*TM_SCALE 1.0000	1.0000	1.0000
		*TM_SCALEAXIS 0.0000	0.0000	0.0000
		*TM_SCALEAXISANG 0.0000
	}
	*LIGHT_SHADOWS Off
	*LIGHT_USELIGHT 1
	*LIGHT_SPOTSHAPE Circle
	*LIGHT_USEGLOBAL 0
	*LIGHT_ABSMAPBIAS 0
	*LIGHT_OVERSHOOT 0
	*LIGHT_SETTINGS {
		*TIMEVALUE 0
		*LIGHT_COLOR 1.0000	1.0000	1.0000
		*LIGHT_INTENS 1.0000
		*LIGHT_ASPECT -1.0000
		*LIGHT_TDIST -1.0000
		*LIGHT_MAPBIAS 1.0000
		*LIGHT_MAPRANGE 4.0000
		*LIGHT_MAPSIZE 512
		*LIGHT_RAYBIAS 0.0000
	}
}
*GEOMOBJECT {
	*NODE_NAME "Box03"
	*NODE_TM {
		*NODE_NAME "Box03"
		*INHERIT_POS 0 0 0
		*INHERIT_ROT 0 0 0
		*INHERIT_SCL 0 0 0
		*TM_ROW0 1.0000	0.0000	0.0000
		*TM_ROW1 0.0000	1.0000	0.0000
		*TM_ROW2 0.0000	0.0000	1.0000
		*TM_ROW3 90.6608	0.0000	0.0000
		*TM_POS 90.6608	0.0000	0.0000
		*TM_ROTAXIS 0.0000	0.0000	0.0000
		*TM_ROTANGLE 0.0000
		*TM_SCALE 1.0000	1.0000	1.0000
		*TM_SCALEAXIS 0.0000	0.0000	0.0000
		*TM_SCALEAXISANG 0.0000
	}
	*MESH {
		*TIMEVALUE 0
		*MESH_NUMVERTEX 8
		*MESH_NUMFACES 12
		*MESH_VERTEX_LIST {
			*MESH_VERTEX    0	72.6608	-18.0000	0.0000
			*MESH_VERTEX    1	108.6608	-18.0000	0.0000
			*MESH_VERTEX    2	72.6608	18.0000	0.0000
			*MESH_VERTEX    3	108.6608	18.0000	0.0000
			*MESH_VERTEX    4	72.6608	-18.0000	36.0000
			*MESH_VERTEX    5	108.6608	-18.0000	36.0000
			*MESH_VERTEX    6	72.6608	18.0000	36.0000
			*MESH_VERTEX    7	108.6608	18.0000	36.0000
		}
		*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    1:    A:    3 B:    1 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    2:    A:    4 B:    5 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    3:    A:    7 B:    6 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    4:    A:    0 B:    1 C:    5 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    5:    A:    5 B:    4 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    6:    A:    1 B:    3 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    7:    A:    7 B:    5 C:    1 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    8:    A:    3 B:    2 C:    6 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE    9:    A:    6 B:    7 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE   10:    A:    2 B:    0 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
			*MESH_FACE   11:    A:    4 B:    6 C:    2 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
		}
		*MESH_NUMTVERTEX 12
		*MESH_TVERTLIST {
			*MESH_TVERT 0	0.0000	0.0000	0.0000
			*MESH_TVERT 1	1.0000	0.0000	0.0000
			*MESH_TVERT 2	0.0000	1.0000	0.0000
			*MESH_TVERT 3	1.0000	1.0000	0.0000
			*MESH_TVERT 4	0.0000	0.0000	0.0000
			*MESH_TVERT 5	1.0000	0.0000	0.0000
			*MESH_TVERT 6	0.0000	1.0000	0.0000
			*MESH_TVERT 7	1.0000	1.0000	0.0000
			*MESH_TVERT 8	0.0000	0.0000	0.0000
			*MESH_TVERT 9	1.0000	0.0000	0.0000
			*MESH_TVERT 10	0.0000	1.0000	0.0000
			*MESH_TVERT 11	1.0000	1.0000	0.0000
		}
		*MESH_NUMTVFACES 12
		*MESH_TFACELIST {
			*MESH_TFACE 0	9	11	10
			*MESH_TFACE 1	10	8	9
			*MESH_TFACE 2	8	9	11
			*MESH_TFACE 3	11	10	8
			*MESH_TFACE 4	4	5	7
			*MESH_TFACE 5	7	6	4
			*MESH_TFACE 6	0	1	3
			*MESH_TFACE 7	3	2	0
			*MESH_TFACE 8	4	5	7
			*MESH_TFACE 9	7	6	4
			*MESH_TFACE 10	0	1	3
			*MESH_TFACE 11	3	2	0
		}
		*MESH_NORMALS {
			*MESH_FACENORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 2	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 2	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 5	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 3	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 6	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 1	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 6	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 3	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 5	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 8	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 2	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 9	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 7	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 10	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 0	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
			*MESH_FACENORMAL 11	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 6	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
		}
	}
	*PROP_MOTIONBLUR 0
	*PROP_CASTSHADOW 1
	*PROP_RECVSHADOW 1
	*MATERIAL_REF 1
}
*GEOMOBJECT {
	*NODE_NAME "Box04"
	*NODE_TM {
		*NODE_NAME "Box04"
		*INHERIT_POS 0 0 0
		*INHERIT_ROT 0 0 0
		*INHERIT_SCL 0 0 0
		*TM_ROW0 1.0000	0.0000	0.0000
		*TM_ROW1 0.0000	1.0000	0.0000
		*TM_ROW2 0.0000	0.0000	1.0000
		*TM_ROW3 111.3195	135.2638	0.0000
		*TM_POS 111.3195	135.2638	0.0000
		*TM_ROTAXIS 0.0000	0.0000	0.0000
		*TM_ROTANGLE 0.0000
		*TM_SCALE 1.0000	1.0000	1.0000
		*TM_SCALEAXIS 0.0000	0.0000	0.0000
		*TM_SCALEAXISANG 0.0000
	}
	*MESH {
		*TIMEVALUE 0
		*MESH_NUMVERTEX 8
		*MESH_NUMFACES 12
		*MESH_VERTEX_LIST {
			*MESH_VERTEX    0	93.3195	117.2638	0.0000
			*MESH_VERTEX    1	129.3195	117.2638	0.0000
			*MESH_VERTEX    2	93.3195	153.2638	0.0000
			*MESH_VERTEX    3	129.3195	153.2638	0.0000
			*MESH_VERTEX    4	93.3195	117.2638	36.0000
			*MESH_VERTEX    5	129.3195	117.2638	36.0000
			*MESH_VERTEX    6	93.3195	153.2638	36.0000
			*MESH_VERTEX    7	129.3195	153.2638	36.0000
		}
		*MESH_FACE_LIST {
			*MESH_FACE    0:    A:    0 B:    2 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    1:    A:    3 B:    1 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 2 	*MESH_MTLID 2
			*MESH_FACE    2:    A:    4 B:    5 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    3:    A:    7 B:    6 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 3 	*MESH_MTLID 0
			*MESH_FACE    4:    A:    0 B:    1 C:    5 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    5:    A:    5 B:    4 C:    0 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 4 	*MESH_MTLID 1
			*MESH_FACE    6:    A:    1 B:    3 C:    7 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    7:    A:    7 B:    5 C:    1 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 5 	*MESH_MTLID 1
			*MESH_FACE    8:    A:    3 B:    2 C:    6 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE    9:    A:    6 B:    7 C:    3 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 6 	*MESH_MTLID 1
			*MESH_FACE   10:    A:    2 B:    0 C:    4 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
			*MESH_FACE   11:    A:    4 B:    6 C:    2 AB:    1 BC:    1 CA:    0	 *MESH_SMOOTHING 7 	*MESH_MTLID 1
		}
		*MESH_NUMTVERTEX 12
		*MESH_TVERTLIST {
			*MESH_TVERT 0	0.0000	0.0000	0.0000
			*MESH_TVERT 1	1.0000	0.0000	0.0000
			*MESH_TVERT 2	0.0000	1.0000	0.0000
			*MESH_TVERT 3	1.0000	1.0000	0.0000
			*MESH_TVERT 4	0.0000	0.0000	0.0000
			*MESH_TVERT 5	1.0000	0.0000	0.0000
			*MESH_TVERT 6	0.0000	1.0000	0.0000
			*MESH_TVERT 7	1.0000	1.0000	0.0000
			*MESH_TVERT 8	0.0000	0.0000	0.0000
			*MESH_TVERT 9	1.0000	0.0000	0.0000
			*MESH_TVERT 10	0.0000	1.0000	0.0000
			*MESH_TVERT 11	1.0000	1.0000	0.0000
		}
		*MESH_NUMTVFACES 12
		*MESH_TFACELIST {
			*MESH_TFACE 0	9	11	10
			*MESH_TFACE 1	10	8	9
			*MESH_TFACE 2	8	9	11
			*MESH_TFACE 3	11	10	8
			*MESH_TFACE 4	4	5	7
			*MESH_TFACE 5	7	6	4
			*MESH_TFACE 6	0	1	3
			*MESH_TFACE 7	3	2	0
			*MESH_TFACE 8	4	5	7
			*MESH_TFACE 9	7	6	4
			*MESH_TFACE 10	0	1	3
			*MESH_TFACE 11	3	2	0
		}
		*MESH_NORMALS {
			*MESH_FACENORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 2	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 3	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 1	0.0000	0.0000	-1.0000
				*MESH_VERTEXNORMAL 0	0.0000	0.0000	-1.0000
			*MESH_FACENORMAL 2	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 5	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 3	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 7	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 6	0.0000	0.0000	1.0000
				*MESH_VERTEXNORMAL 4	0.0000	0.0000	1.0000
			*MESH_FACENORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 1	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 5	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 4	0.0000	-1.0000	0.0000
				*MESH_VERTEXNORMAL 0	0.0000	-1.0000	0.0000
			*MESH_FACENORMAL 6	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 3	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 7	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 5	1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 1	1.0000	0.0000	0.0000
			*MESH_FACENORMAL 8	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 2	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 9	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 6	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 7	0.0000	1.0000	0.0000
				*MESH_VERTEXNORMAL 3	0.0000	1.0000	0.0000
			*MESH_FACENORMAL 10	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 0	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
			*MESH_FACENORMAL 11	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 4	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 6	-1.0000	0.0000	0.0000
				*MESH_VERTEXNORMAL 2	-1.0000	0.0000	0.0000
		}
	}
	*PROP_MOTIONBLUR 0
	*PROP_CASTSHADOW 1
	*PROP_RECVSHADOW 1
	*MATERIAL_REF 1
}


Share this post


Link to post
Share on other sites
Advertisement
Well after playing around with it a bit, I figured out why it's not working, but I can't explain the logics of it. If you take a look at the reference page of fscanf it tells you what format specifiers you may use. Of which, %i is not one of them. I gave this code a try:

if(strcmp(sChar, "MATERIAL_REF") == 0)
{
itemp = 0;
float itemp2;
//scan in ref number
/***********this area is failing***********/
cout << " File Position: " << ftell (infile) << endl;
if( fscanf(infile, "%f", &itemp2) )
cout << "itemp: " << itemp << endl;
else
cout << "fscanf failed" << endl;
/***********this area is failing***********/

//pull offset number from array
for(int i=0; i<itemp; i++)
offset += tempMatRef;
cout << "offset: " << offset << endl;

//loop through mat_ids adding the offset
}




And made the first MATERIAL_REF to:

*MATERIAL_REF 0.0


I then ran it and got this:

itemp: 0
offset: 0
fscanf failed
offset: 0
fscanf failed
offset: 0
fscanf failed
offset: 0
3 2
Num objects: 4
Num vertices: 32
Num faces: 48
Num texture coords 48
Num face normals 48
Num vertex normals 144
Num materials 5
Press any key to continue




As you can see, the function no longer fails. I then made all the changes to the file and ran. No more failures but the results were not right. So, obviously that was not the problem. Next, I tried replacing the interger input with a string input:

if(strcmp(sChar, "MATERIAL_REF") == 0)
{
//itemp = 0;
char itemp2[256];
//scan in ref number
/***********this area is failing***********/

if(fscanf(infile, "%s", &itemp2))
cout << "itemp: " << itemp2 << endl;
else
cout << "fscanf failed" << endl;
/***********this area is failing***********/

//pull offset number from array
for(int i=0; i<itemp; i++)
offset += tempMatRef;
cout << "offset: " << offset << endl;

//loop through mat_ids adding the offset
}




When I ran it, this was the output:

itemp: }
offset: 0
itemp: }
offset: 0
itemp: }
offset: 0
itemp: }
offset: 0
3 2
Num objects: 4
Num vertices: 32
Num faces: 48
Num texture coords 48
Num face normals 48
Num vertex normals 144
Num materials 5
Press any key to continue




Well now it looks like we are getting somewhere. I think I figured out the problem, but to make sure, I added one
 fscanf(infile, "%s", &itemp2); 
before the test, and this was the new output:


itemp: *GEOMOBJECT
offset: 0
itemp: *LIGHTOBJECT
offset: 0
itemp: *GEOMOBJECT
offset: 0
itemp: }
offset: 0
3 2
Num objects: 2
Num vertices: 32
Num faces: 48
Num texture coords 48
Num face normals 48
Num vertex normals 144
Num materials 5
Press any key to continue




Ah Ha! As I suspected, you have skipped past the input part while you obtained the "MATERIAL_REF", so all you are left with is a "{". This is why the function was failing. So, I traced back to how you first got the file data:

fscanf(infile, "%s", sChar);

This was right, you will only get a string and process it. However, this is the part where your going to kick yourself, take a look at the second if statement after that:


if(strcmp(sChar, "MATERIAL_REF") == 0)
{
fscanf(infile, "%i", ¤tMaterial);
}



As you can see, you already get the current material in the beginning of the function!! [lol] I am not laughing at you, but with you buddy [smile]. After commenting that out, run the code and you will get this:

itemp: 0
offset: 0
itemp: 1
offset: 0
itemp: 1
offset: 0
itemp: 1
offset: 0
3 2
Num objects: 4
Num vertices: 32
Num faces: 48
Num texture coords 48
Num face normals 48
Num vertex normals 144
Num materials 5
Press any key to continue




All done! The reason I went through this step by step rather than just giving you the solution, is so you, as well as anyone else reading this, can pick up a good way to debug your programs. Hopefully you have learned some new techniques. Good luck with your coding!

- Drew

Share this post


Link to post
Share on other sites
omg i feel like an idiot but in a good way. i havent pulled one of those in a LONG TIME. :rofl: this is great!

Share this post


Link to post
Share on other sites
Quote:
Original post by adam17
omg i feel like an idiot but in a good way. i havent pulled one of those in a LONG TIME. :rofl: this is great!


[grin] We all have our days!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!