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; }
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); } } }
bool CCourse::LoadObjectTypes () { CSPList list (MAX_OBJECT_TYPES+10); if (!list.Load (param.obj_dir, "object_types.lst")) { Message ("could not load object types"); return false; } ObjTypes.resize(list.Count()); for (size_t i=0; i<list.Count(); i++) { const string& line = list.Line(i); ObjTypes[i].name = SPStrN (line, "name", ""); ObjTypes[i].textureFile = ObjTypes[i].name; ObjTypes[i].texture = NULL; ObjTypes[i].drawable = SPBoolN (line, "draw", true); if (ObjTypes[i].drawable) { ObjTypes[i].textureFile = SPStrN (line, "texture", ""); } ObjTypes[i].collectable = SPBoolN (line, "snap", -1) != 0; if (ObjTypes[i].collectable == 0) { ObjTypes[i].collectable = -1; } ObjTypes[i].collidable = SPBoolN (line, "coll", false); ObjTypes[i].reset_point = SPBoolN (line, "reset", false); ObjTypes[i].use_normal = SPBoolN (line, "usenorm", false); if (ObjTypes[i].use_normal) { ObjTypes[i].normal = SPVector3N (line, "norm", TVector3(0, 1, 0)); NormVector ((ObjTypes[i].normal)); } ObjTypes[i].poly = 1; } list.MakeIndex (ObjectIndex, "name"); return true; }
void LoadConfigFile () { CSPList list(4); if (!list.Load (param.configfile)) { Message ("Could not load 'options'"); return; } for (size_t i=0; i<list.Count(); i++) { const string& line = list.Line(i); param.fullscreen = SPBoolN (line, "fullscreen", false); param.res_type = SPIntN (line, "res_type", 0); param.perf_level = SPIntN (line, "detail_level", 0); param.language = SPIntN (line, "language", 0); param.sound_volume = SPIntN (line, "sound_volume", 100); param.music_volume = SPIntN (line, "music_volume", 20); param.forward_clip_distance = SPIntN (line, "forward_clip_distance", 75); param.backward_clip_distance = SPIntN (line, "backward_clip_distance", 20); param.fov = SPIntN (line, "fov", 60); param.bpp_mode = SPIntN (line, "bpp_mode", 1); param.tree_detail_distance = SPIntN (line, "tree_detail_distance", 20); param.tux_sphere_divisions = SPIntN (line, "tux_sphere_divisions", 10); param.tux_shadow_sphere_divisions = SPIntN (line, "tux_shadow_sphere_div", 3); param.course_detail_level = SPIntN (line, "course_detail_level", 75); param.use_papercut_font = SPIntN (line, "use_papercut_font", 1); param.ice_cursor = SPBoolN (line, "ice_cursor", true); param.full_skybox = SPBoolN (line, "full_skybox", false); param.audio_freq = SPIntN (line, "audio_freq", 22050); param.audio_buffer_size = SPIntN (line, "audio_buffer_size", 512); param.use_quad_scale = SPBoolN (line, "use_quad_scale", false); param.menu_music = SPStrN (line, "menu_music", "start_1"); param.credits_music = SPStrN (line, "credits_music", "credits_1"); param.config_music = SPStrN (line, "config_music", "options_1"); } }
bool CTexture::LoadTextureList() { FreeTextureList(); CSPList list; if (list.Load(param.tex_dir, "textures.lst")) { for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) { int id = SPIntN(*line, "id", -1); CommonTex.resize(std::max(CommonTex.size(), (std::size_t)id+1)); std::string texfile = SPStrN(*line, "file"); bool rep = SPBoolN(*line, "repeat", false); if (id >= 0) { CommonTex[id] = new TTexture(); CommonTex[id]->Load(param.tex_dir, texfile, rep); } else Message("wrong texture id in textures.lst"); } } else { Message("failed to load common textures"); return false; } return true; }
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; }
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; }
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; }