bool CCourse::LoadTerrainTypes () {
	CSPList list(MAX_TERR_TYPES +10);

	if (!list.Load (param.terr_dir, "terrains.lst")) {
		Message ("could not load terrain types");
		return false;
	}

	TerrList.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		TerrList[i].textureFile = SPStrN (line, "texture", "");
		TerrList[i].sound = SPStrN (line, "sound", "");
		TerrList[i].starttex = SPIntN (line, "starttex", -1);
		TerrList[i].tracktex = SPIntN (line, "tracktex", -1);
		TerrList[i].stoptex = SPIntN (line, "stoptex", -1);
		TerrList[i].col = SPColor3N (line, "col", TColor3(1, 1, 1));
		TerrList[i].friction = SPFloatN (line, "friction", 0.5);
		TerrList[i].depth = SPFloatN (line, "depth", 0.01);
		TerrList[i].particles = SPBoolN (line, "part", false);
		TerrList[i].trackmarks = SPBoolN (line, "trackmarks", false);
		TerrList[i].texture = NULL;
		TerrList[i].shiny = SPBoolN(line, "shiny", false);
		TerrList[i].vol_type = SPIntN (line, "vol_type", 1);
	}
	return true;
}
Example #2
0
void CEnvironment::LoadLight () {
	static const string idxstr = "[fog]-1[0]0[1]1[2]2[3]3[4]4[5]5[6]6";

	CSPList list(24);
	if (!list.Load (EnvDir, "light.lst")) {
		Message ("could not load light file", "");
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		string item = SPStrN (line, "light", "none");
		int idx = SPIntN (idxstr, item, -1);
		if (idx < 0) {
			fog.is_on = SPBoolN (line, "fog", true);
			fog.start = SPFloatN (line, "fogstart", 20);
			fog.end = SPFloatN (line, "fogend", param.forward_clip_distance);
			fog.height = SPFloatN (line, "fogheight", 0);
			SPArrN (line, "fogcol", fog.color, 4, 1);
			fog.part_color = SPColorN (line, "partcol", def_partcol);
		} else if (idx < 4) {
			lights[idx].is_on = true;
			SPArrN (line, "amb", lights[idx].ambient, 4, 1);
			SPArrN (line, "diff", lights[idx].diffuse, 4, 1);
			SPArrN (line, "spec", lights[idx].specular, 4, 1);
			SPArrN (line, "pos", lights[idx].position, 4, 1);
		}
	}
}
Example #3
0
void LoadCreditList () {
	CSPList list(MAX_CREDITS);

	string creditfile;
	int i;
	double offset;
	string item;
	string line;

	if (!list.Load (param.data_dir, "credits.lst")) {
		Message ("could not load credits list");
		return;
	}

	for (i=0; i<list.Count(); i++) {
		line = list.Line(i);
		CreditList[i].text = SPStrN (line, "text", "");

		offset = SPFloatN (line, "offs", 0) * OFFS_SCALE_FACTOR * param.scale;
		if (i>0) CreditList[i].offs = CreditList[i-1].offs + (int)offset;
		else CreditList[i].offs = offset;

		CreditList[i].col = SPIntN (line, "col", 0);
		CreditList[i].size = SPFloatN (line, "size", 1.0);
		numCredits = i + 1;
	}
}
void CCourse::LoadItemList () {
	CSPList list (16000);

	if (!list.Load (CourseDir, "items.lst")) {
		Message ("could not load items list");
		return;
	}

	CollArr.clear();
	NocollArr.clear();
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int x = SPIntN (line, "x", 0);
		int z = SPIntN (line, "z", 0);
		double height = SPFloatN (line, "height", 1);
		double diam = SPFloatN (line, "diam", 1);
		double xx = (nx - x) / (double)(nx - 1.0) * curr_course->size.x;
		double zz = -(ny - z) / (double)(ny - 1.0) * curr_course->size.y;

		string name = SPStrN (line, "name", "");
		size_t type = ObjectIndex[name];
		if (ObjTypes[type].texture == NULL && ObjTypes[type].drawable) {
			string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile;
			ObjTypes[type].texture = new TTexture();
			ObjTypes[type].texture->LoadMipmap(terrpath, 0);
		}
		bool coll = ObjTypes[type].collidable;
		if (coll == 1) {
			CollArr.push_back(TCollidable());
		    CollArr.back().pt.x = xx;
		    CollArr.back().pt.z = zz;
		    CollArr.back().pt.y = FindYCoord (xx, zz);
		    CollArr.back().height = height;
		    CollArr.back().diam = diam;
		    CollArr.back().tree_type = type;
		} else if (coll == 0) {
			NocollArr.push_back(TItem());
		    NocollArr.back().pt.x = xx;
		    NocollArr.back().pt.z = zz;
		    NocollArr.back().pt.y = FindYCoord (xx, zz);
			NocollArr.back().height = height;
		    NocollArr.back().diam = diam;
		    NocollArr.back().item_type = type;
			NocollArr.back().collectable = ObjTypes[type].collectable;
			NocollArr.back().drawable = ObjTypes[type].drawable;
			ObjTypes[type].num_items++;
		}
	}
}
Example #5
0
bool CScore::LoadHighScore () {
	CSPList list (520);

	Scorelist.resize(Course.CourseList.size());

	if (!list.Load (param.config_dir, "highscore")) {
		Message ("could not load highscore list");
		return false;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		string course = SPStrN (line, "course", "unknown");
		TCourse* cidx = Course.GetCourse(course);

		TScore score;
		score.player = SPStrN (line, "plyr", "unknown");
		score.points = SPIntN (line, "pts", 0);
		score.herrings = SPIntN (line, "herr", 0);
		score.time = SPFloatN (line, "time", 0);

		AddScore (cidx, score);
	}
	return true;
}
Example #6
0
void CCredits::LoadCreditList () {
	CSPList list(MAX_CREDITS);

	if (!list.Load (param.data_dir, "credits.lst")) {
		Message ("could not load credits list");
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		TCredits credit;
		credit.text = SPStrN (line, "text", "");

		ETR_DOUBLE offset = SPFloatN (line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
		if (i>0) credit.offs = CreditList.back().offs + (int)offset;
		else credit.offs = offset;

		credit.col = SPIntN (line, "col", 0);
		credit.size = SPFloatN (line, "size", 1.0);
		CreditList.push_back(credit);
	}
}
Example #7
0
bool CKeyframe::Load (string dir, string filename) {
	if (loaded && loadedfile == filename) return true;
	CSPList list (1000);
	int i;
	string line;
	TVector2 pp;
	numFrames = 0;
	TVector3 posit;

	if (list.Load (dir, filename)) {
		for (i=0; i<list.Count(); i++) {
			line = list.Line (i);
			frames[numFrames] = new (TKeyframe2);
			frames[numFrames]->val[0] = SPFloatN (line, "time", 0);		
			posit = SPVector3N (line, "pos", MakeVector (0, 0, 0));
			frames[numFrames]->val[1] = posit.x;
			frames[numFrames]->val[2] = posit.y;
			frames[numFrames]->val[3] = posit.z;
			frames[numFrames]->val[4] = SPFloatN (line, "yaw", 0);
			frames[numFrames]->val[5] = SPFloatN (line, "pitch", 0);
			frames[numFrames]->val[6] = SPFloatN (line, "roll", 0);
			frames[numFrames]->val[7] = SPFloatN (line, "neck", 0);
			frames[numFrames]->val[8] = SPFloatN (line, "head", 0);
			pp = SPVector2N (line, "sh", MakeVector2 (0, 0));
			frames[numFrames]->val[9] = pp.x;
			frames[numFrames]->val[10] = pp.y;
			pp = SPVector2N (line, "arm", MakeVector2 (0, 0));
			frames[numFrames]->val[11] = pp.x;
			frames[numFrames]->val[12] = pp.y;
			pp = SPVector2N (line, "hip", MakeVector2 (0, 0));
			frames[numFrames]->val[13] = pp.x;
			frames[numFrames]->val[14] = pp.y;
			pp = SPVector2N (line, "knee", MakeVector2 (0, 0));
			frames[numFrames]->val[15] = pp.x;
			frames[numFrames]->val[16] = pp.y;
			pp = SPVector2N (line, "ankle", MakeVector2 (0, 0));
			frames[numFrames]->val[17] = pp.x;
			frames[numFrames]->val[18] = pp.y;

			numFrames++;
		}
		loaded = true;
		loadedfile = filename;
		return true;
	} else {
		MessageN ("keyframe not found:", filename);
		loaded = false;
		return false;
	}	
}
Example #8
0
void CCharShape::CreateMaterial (const char *line) {
	char matName[32];
	TVector3 diff = {0,0,0}; 
	TVector3 spec = {0,0,0};
	float exp = 100;

	string lin = line;	
	SPCharN (lin, "mat", matName);
	diff = SPVector3N (lin, "diff", MakeVector (0,0,0));
	spec = SPVector3N (lin, "spec", MakeVector (0,0,0));
	exp = SPFloatN (lin, "exp", 50);


/*
	TCharMaterial *matPtr = (TCharMaterial *) malloc (sizeof (TCharMaterial));
    matPtr->diffuse.r = diff.x;
    matPtr->diffuse.g = diff.y;
    matPtr->diffuse.b = diff.z;
    matPtr->diffuse.a = 1.0;
    matPtr->specular.r = spec.x;
    matPtr->specular.g = spec.y;
    matPtr->specular.b = spec.z;
    matPtr->specular.a = 1.0;
    matPtr->exp = exp;
*/
	Materials[numMaterials] = (TCharMaterial *) malloc (sizeof (TCharMaterial));
    Materials[numMaterials]->diffuse.r = diff.x;
    Materials[numMaterials]->diffuse.g = diff.y;
    Materials[numMaterials]->diffuse.b = diff.z;
    Materials[numMaterials]->diffuse.a = 1.0;
    Materials[numMaterials]->specular.r = spec.x;
    Materials[numMaterials]->specular.g = spec.y;
    Materials[numMaterials]->specular.b = spec.z;
    Materials[numMaterials]->specular.a = 1.0;
    Materials[numMaterials]->exp = exp;



	SPAddIntN (MaterialIndex, matName, numMaterials);
//	Materials[numMaterials] = matPtr;
	numMaterials++;
}
Example #9
0
void CCharShape::CreateMaterial (const string& line) {
	TVector3d diff = SPVector3d(line, "diff");
	TVector3d spec = SPVector3d(line, "spec");
	float exp = SPFloatN (line, "exp", 50);
	std::string mat = SPStrN(line, "mat");

	Materials.push_back(TCharMaterial());
	Materials.back().diffuse.r = diff.x;
	Materials.back().diffuse.g = diff.y;
	Materials.back().diffuse.b = diff.z;
	Materials.back().diffuse.a = 1.0;
	Materials.back().specular.r = spec.x;
	Materials.back().specular.g = spec.y;
	Materials.back().specular.b = spec.z;
	Materials.back().specular.a = 1.0;
	Materials.back().exp = exp;
	if (useActions)
		Materials.back().matline = line;

	MaterialIndex[mat] = Materials.size()-1;
}
bool CKeyframe::Load (const string& dir, const string& filename) {
	if (loaded && loadedfile == filename) return true;
	CSPList list (1000);

	if (list.Load (dir, filename)) {
		frames.resize(list.Count());
		for (size_t i=0; i<list.Count(); i++) {
			const string& line = list.Line(i);
			frames[i].val[0] = SPFloatN (line, "time", 0);
			TVector3 posit = SPVector3N (line, "pos", NullVec);
			frames[i].val[1] = posit.x;
			frames[i].val[2] = posit.y;
			frames[i].val[3] = posit.z;
			frames[i].val[4] = SPFloatN (line, "yaw", 0);
			frames[i].val[5] = SPFloatN (line, "pitch", 0);
			frames[i].val[6] = SPFloatN (line, "roll", 0);
			frames[i].val[7] = SPFloatN (line, "neck", 0);
			frames[i].val[8] = SPFloatN (line, "head", 0);
			TVector2 pp = SPVector2N (line, "sh", TVector2(0, 0));
			frames[i].val[9] = pp.x;
			frames[i].val[10] = pp.y;
			pp = SPVector2N (line, "arm", TVector2(0, 0));
			frames[i].val[11] = pp.x;
			frames[i].val[12] = pp.y;
			pp = SPVector2N (line, "hip", TVector2(0, 0));
			frames[i].val[13] = pp.x;
			frames[i].val[14] = pp.y;
			pp = SPVector2N (line, "knee", TVector2(0, 0));
			frames[i].val[15] = pp.x;
			frames[i].val[16] = pp.y;
			pp = SPVector2N (line, "ankle", TVector2(0, 0));
			frames[i].val[17] = pp.x;
			frames[i].val[18] = pp.y;
		}
		loaded = true;
		loadedfile = filename;
		return true;
	} else {
		Message ("keyframe not found:", filename);
		loaded = false;
		return false;
	}
}
Example #11
0
bool CKeyframe::Load(const std::string& dir, const std::string& filename) {
	if (loaded && loadedfile == filename) return true;
	CSPList list;

	if (list.Load(dir, filename)) {
		frames.resize(list.size());
		std::size_t i = 0;
		for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line, i++) {
			frames[i].val[0] = SPFloatN(*line, "time", 0);
			TVector3d posit = SPVector3d(*line, "pos");
			frames[i].val[1] = posit.x;
			frames[i].val[2] = posit.y;
			frames[i].val[3] = posit.z;
			frames[i].val[4] = SPFloatN(*line, "yaw", 0);
			frames[i].val[5] = SPFloatN(*line, "pitch", 0);
			frames[i].val[6] = SPFloatN(*line, "roll", 0);
			frames[i].val[7] = SPFloatN(*line, "neck", 0);
			frames[i].val[8] = SPFloatN(*line, "head", 0);
			TVector2d pp = SPVector2d(*line, "sh");
			frames[i].val[9] = pp.x;
			frames[i].val[10] = pp.y;
			pp = SPVector2d(*line, "arm");
			frames[i].val[11] = pp.x;
			frames[i].val[12] = pp.y;
			pp = SPVector2d(*line, "hip");
			frames[i].val[13] = pp.x;
			frames[i].val[14] = pp.y;
			pp = SPVector2d(*line, "knee");
			frames[i].val[15] = pp.x;
			frames[i].val[16] = pp.y;
			pp = SPVector2d(*line, "ankle");
			frames[i].val[17] = pp.x;
			frames[i].val[18] = pp.y;
		}
		loaded = true;
		loadedfile = filename;
		return true;
	} else {
		Message("keyframe not found:", filename);
		loaded = false;
		return false;
	}
}
Example #12
0
bool CCourse::LoadCourseList () {
	CSPList list (128);

	if (!list.Load (param.common_course_dir, "courses.lst")) {
		Message ("could not load courses.lst");
		return false;
	}

	CSPList paramlist (48);

	CourseList.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line1 = list.Line(i);
		CourseList[i].name = SPStrN (line1, "name", "noname");
		CourseList[i].dir = SPStrN (line1, "dir", "nodir");

		string desc = SPStrN (line1, "desc", "");
		FT.AutoSizeN (2);
		vector<string> desclist = FT.MakeLineList (desc.c_str(), 335 * Winsys.scale - 16.0);
		size_t cnt = desclist.size();
		if (cnt > MAX_DESCRIPTION_LINES) cnt = MAX_DESCRIPTION_LINES;
		CourseList[i].num_lines = cnt;
		for (size_t ll=0; ll<cnt; ll++) {
			CourseList[i].desc[ll] = desclist[ll];
		}

		string coursepath = param.common_course_dir + SEP + CourseList[i].dir;
		if (DirExists (coursepath.c_str())) {
			// preview
			string previewfile = coursepath + SEP + "preview.png";
			CourseList[i].preview = new TTexture();
			if (!CourseList[i].preview->LoadMipmap(previewfile, 0)) {
				Message ("couldn't load previewfile");
//				texid = Tex.TexID (NO_PREVIEW);
			}

			// params
			string paramfile = coursepath + SEP + "course.dim";
			if (!paramlist.Load (paramfile)) {
				Message ("could not load course.dim");
			}

			const string& line2 = paramlist.Line (0);
			CourseList[i].author = SPStrN (line2, "author", "unknown");
			CourseList[i].size.x = SPFloatN (line2, "width", 100);
			CourseList[i].size.y = SPFloatN (line2, "length", 1000);
			CourseList[i].play_size.x = SPFloatN (line2, "play_width", 90);
			CourseList[i].play_size.y = SPFloatN (line2, "play_length", 900);
			CourseList[i].angle = SPFloatN (line2, "angle", 10);
			CourseList[i].scale = SPFloatN (line2, "scale", 10);
			CourseList[i].start.x = SPFloatN (line2, "startx", 50);
			CourseList[i].start.y = SPFloatN (line2, "starty", 5);
			CourseList[i].env = Env.GetEnvIdx (SPStrN (line2, "env", "etr"));
			CourseList[i].music_theme = Music.GetThemeIdx (SPStrN (line2, "theme", "normal"));
			CourseList[i].use_keyframe = SPBoolN (line2, "use_keyframe", false);
			CourseList[i].finish_brake = SPFloatN (line2, "finish_brake", 20);
			paramlist.Clear ();	// the list is used several times
		}
	}
	list.MakeIndex (CourseIndex, "dir");
	return true;
}
Example #13
0
bool CCharShape::Load (const string& dir, const string& filename, bool with_actions) {
	CSPList list (500);

	useActions = with_actions;
	CreateRootNode ();
	newActions = true;

	if (!list.Load (dir, filename)) {
		Message ("could not load character", filename);
		return false;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int node_name = SPIntN (line, "node", -1);
		int parent_name = SPIntN (line, "par", -1);
		string mat_name = SPStrN (line, "mat");
		string name = SPStrN (line, "joint");
		string fullname = SPStrN (line, "name");

		if (SPIntN (line, "material", 0) > 0) {
			CreateMaterial (line);
		} else {
			float visible = SPFloatN (line, "vis", -1.0);
			bool shadow = SPBoolN (line, "shad", false);
			string order = SPStrN (line, "order");
			CreateCharNode (parent_name, node_name, name, fullname, order, shadow);
			TVector3d rot = SPVector3d(line, "rot");
			MaterialNode (node_name, mat_name);
			for (size_t ii = 0; ii < order.size(); ii++) {
				int act = order[ii]-48;
				switch (act) {
					case 0: {
						TVector3d trans = SPVector3d(line, "trans");
						TranslateNode (node_name, trans);
						break;
					}
					case 1:
						RotateNode (node_name, 1, rot.x);
						break;
					case 2:
						RotateNode (node_name, 2, rot.y);
						break;
					case 3:
						RotateNode (node_name, 3, rot.z);
						break;
					case 4: {
						TVector3d scale = SPVector3(line, "scale", TVector3d(1, 1, 1));
						ScaleNode (node_name, scale);
						break;
					}
					case 5:
						VisibleNode (node_name, visible);
						break;
					case 9:
						RotateNode (node_name, 2, rot.z);
						break;
					default:
						break;
				}
			}
		}
	}
	newActions = false;
	return true;
}
Example #14
0
bool CCharShape::Load (string dir, string filename, bool with_actions) {
	CSPList list (500);
	int i, ii, act;
	string line, order, name, mat_name, fullname;
	TVector3 scale, trans, rot;
	double visible;
	bool shadow;
	int node_name, parent_name;

	useActions = with_actions;
	CreateRootNode ();
	newActions = true;

	file_name = filename;
 	if (!list.Load (dir, filename)) {
		Message ("could not load character", filename.c_str());
		return false;
	}

	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		node_name = SPIntN (line, "node", -1); 
		parent_name = SPIntN (line, "par", -1);		
		mat_name = SPStrN (line, "mat", "");
		name = SPStrN (line, "joint", "");	
		fullname = SPStrN (line, "name", "");

		if (SPIntN (line, "material", 0) > 0) {
			CreateMaterial (line.c_str());
			if (useActions) {
				Matlines[numMatlines] = line;
				numMatlines++;
			}
		} else {
			visible = SPFloatN (line, "vis", -1.0);	
			shadow = SPBoolN (line, "shad", false);
			order = SPStrN (line, "order", "");
 			CreateCharNode (parent_name, node_name, name, fullname, order, shadow);					
			rot = SPVector3N (line, "rot", NullVec);
			MaterialNode (node_name, mat_name);
			for (ii=0; ii<(int)order.size(); ii++) {
				act = order.at(ii)-48;	
				switch (act) {
					case 0:
						trans = SPVector3N (line, "trans", MakeVector (0,0,0));
						TranslateNode (node_name, trans);
						break;
					case 1: RotateNode (node_name, 1, rot.x); break;
					case 2: RotateNode (node_name, 2, rot.y); break;
					case 3: RotateNode (node_name, 3, rot.z); break;
					case 4:
						scale = SPVector3N (line, "scale", MakeVector (1,1,1));
						ScaleNode (node_name, scale);
						break;
					case 5: VisibleNode (node_name, visible); break;
					case 9: RotateNode (node_name, 2, rot.z); break;
					default: break;
				}
			}
		}
	}
	newActions = false;
	return true;
}