예제 #1
0
void SETTINGS::Load(std::string sfile)
{
	CONFIGFILE c;  c.Load(sfile);
	Serialize(false, c);
}
예제 #2
0
void CarModel::LoadConfig(const std::string & pathCar)
{
	Defaults();

	///  load  -----
	CONFIGFILE cf;
	if (!cf.Load(pathCar))
	{  LogO("!! CarModel: Can't load .car "+pathCar);  return;  }


	//-  custom interior model offset
	cf.GetParam("model_ofs.interior-x", interiorOffset[0]);
	cf.GetParam("model_ofs.interior-y", interiorOffset[1]);
	cf.GetParam("model_ofs.interior-z", interiorOffset[2]);
	cf.GetParam("model_ofs.rot_fix", bRotFix);

	//~  boost offset
	cf.GetParam("model_ofs.boost-x", boostOffset[0]);
	cf.GetParam("model_ofs.boost-y", boostOffset[1]);
	cf.GetParam("model_ofs.boost-z", boostOffset[2]);
	cf.GetParam("model_ofs.boost-size-z", boostSizeZ);
	cf.GetParam("model_ofs.boost-name", sBoostParName);
	
	//  thruster  spaceship hover
	cf.GetParam("model_ofs.thrust-x", thrusterOfs[0]);
	cf.GetParam("model_ofs.thrust-y", thrusterOfs[1]);
	cf.GetParam("model_ofs.thrust-z", thrusterOfs[2]);
	cf.GetParam("model_ofs.thrust-size-z", thrusterSizeZ);
	cf.GetParam("model_ofs.thrust-name", sThrusterPar);
	

	//~  brake flares
	float pos[3];  bool ok=true;  int i=0;
	while (ok)
	{	ok = cf.GetParam("flares.brake-pos"+toStr(i), pos);  ++i;
		if (ok)  brakePos.push_back(bRotFix ? Vector3(-pos[0],pos[2],pos[1]) : Vector3(-pos[1],-pos[2],pos[0]));
	}
	cf.GetParam("flares.brake-color", pos);
	brakeClr = ColourValue(pos[0],pos[1],pos[2]);
	cf.GetParam("flares.brake-size", brakeSize);
	
	
	//-  custom exhaust pos for boost particles
	if (cf.GetParam("model_ofs.exhaust-x", exhaustPos[0]))
	{
		manualExhaustPos = true;
		cf.GetParam("model_ofs.exhaust-y", exhaustPos[1]);
		cf.GetParam("model_ofs.exhaust-z", exhaustPos[2]);
	}else
		manualExhaustPos = false;
	if (!cf.GetParam("model_ofs.exhaust-mirror-second", has2exhausts))
		has2exhausts = false;


	//- load cameras pos
	cf.GetParam("driver.view-position", pos, pGame->error_output);
	driver_view[0]=pos[1]; driver_view[1]=-pos[0]; driver_view[2]=pos[2];
	
	cf.GetParam("driver.hood-position", pos, pGame->error_output);
	hood_view[0]=pos[1]; hood_view[1]=-pos[0]; hood_view[2]=pos[2];


	//  tire params
	WHEEL_POSITION leftside = FRONT_LEFT, rightside = FRONT_RIGHT;
	float value;
	bool both = cf.GetParam("tire-both.radius", value);
	std::string posstr = both ? "both" : "front";

	for (int p = 0; p < 2; ++p)
	{
		if (p == 1)
		{
			leftside = REAR_LEFT;
			rightside = REAR_RIGHT;
			if (!both)  posstr = "rear";
		}
		float radius;
		cf.GetParam("tire-"+posstr+".radius", radius, pGame->error_output);
		whRadius[leftside] = radius;
		whRadius[rightside] = radius;
		
		float width = 0.2f;
		cf.GetParam("tire-"+posstr+".width-trail", width);
		whWidth[leftside] = width;
		whWidth[rightside] = width;
	}
	
	//  wheel pos
	//  for track's ghost or garage view
	int version(1);
	cf.GetParam("version", version);
	for (int i = 0; i < 4; ++i)
	{
		std::string sPos;
		if (i == 0)			sPos = "FL";
		else if (i == 1)	sPos = "FR";
		else if (i == 2)	sPos = "RL";
		else				sPos = "RR";

		float pos[3];
		MATHVECTOR<float,3> vec;

		cf.GetParam("wheel-"+sPos+".position", pos, pGame->error_output);
		if (version == 2)  ConvertV2to1(pos[0],pos[1],pos[2]);
		vec.Set(pos[0],pos[1], pos[2]);
		whPos[i] = vec;
	}
	//  steer angle
	maxangle = 26.f;
	cf.GetParam("steering.max-angle", maxangle, pGame->error_output);
	maxangle *= pGame->GetSteerRange();
}
예제 #3
0
void SETTINGS::Save(std::string sfile)
{
	CONFIGFILE c;  c.Load(sfile);  version = SET_VER;
	Serialize(true, c);  c.Write();
}
예제 #4
0
파일: main.cpp 프로젝트: VDrift/trackeditor
bool LoadWorld()
{
	UnloadWorld();
	
	editordata.helppage = 0;
	editordata.numbezinput = 0;
	editordata.mousebounce[1] = false;
	
	//teststrip = track.AddNewRoad();
	
	//begin loading world
	
	LoadingScreen("Loading...\nConfiguration files");
	
	CONFIGFILE setupfile;
	setupfile.Load(settings.GetDataDir() + "/tracks/editor.config");
	setupfile.GetParam("active track", editordata.activetrack);
	if (editordata.activetrack == "")
		editordata.activetrack = "default";
	
	objects.LoadObjectsFromFolder(settings.GetDataDir() + "/tracks/" + 
			editordata.activetrack + "/objects/");
	
	track.Load(editordata.activetrack);
	
	//float aangle[] = {0, 1, 0, 0};
	//track.GetStartOrientation(0).GetAxisAngle(aangle);
	//cam.Rotate(aangle[0], aangle[1], aangle[2], aangle[3]);
	VERTEX start = track.GetStart(0);
	cam.Move(-start.x, -start.y, -start.z);
	cam.Update();
	cam.LoadVelocityIdentity();
	
	//car_file = "s2000";
	//ifstream csfile;
	//car_file = "";
	//csfile.open((settings.GetSettingsDir() + "/selected_car").c_str());
	//car_paint = 0;
/*	if (csfile)
	{
		state.SetCarName(0, utility.sGetLine(csfile));
		state.SetCarPaint(0, utility.iGetParam(csfile));
		csfile.close();
	}
*/
	
	//LoadingScreen("Loading...\nLoading scenery objects");
	//objects.LoadObjectsFromFolder(settings.GetDataDir() + "/tracks/" + state.GetTrackName() + "/objects");
	
	/*trees.DeleteAll();
	int numtrees = 200;
	for (i = 0; i < numtrees/2; i++)
	{
		VERTEX tp;
		tp.x = ((float) rand()/RAND_MAX)*(param[0]/2.0)+param[0]/4.0;
		tp.z = ((float) rand()/RAND_MAX)*(param[2]/2.0)+param[2]/4.0;
		tp.x += param[3];
		tp.z += param[4];
		tp.y = terrain.GetHeight(tp.x, tp.z);
		trees.Add(tp, 40.0, 0, 5);
	}
	
	for (i = 0; i < numtrees/2; i++)
	{
		VERTEX tp;
		tp.x = ((float) rand()/RAND_MAX)*(param[0]/2.0)+param[0]/4.0;
		tp.z = ((float) rand()/RAND_MAX)*(param[2]/2.0)+param[2]/4.0;
		tp.x += param[3];
		tp.z += param[4];
		tp.y = terrain.GetHeight(tp.x, tp.z);
		trees.Add(tp, 60.0, 1, 5);
	}*/
	
	LoadingScreen("Loading...\nDone");
	
	mq1.AddMessage("Editor started, press H for help");
	
	return true;
}