Beispiel #1
0
void ProcessLTX(LPCSTR tgt_name, LPCSTR params, BOOL bFast)
{
	xr_string		ltx_name;
	LPCSTR ltx_nm	= strstr(params,".ltx");				VERIFY(ltx_nm!=0);
	string_path		ltx_fn;
	string_path		tmp;
	strncpy			(tmp,params,ltx_nm-params); tmp[ltx_nm-params]=0;
	_Trim			(tmp);
	strcat			(tmp,".ltx");
	strcpy			(ltx_fn,tmp);

	// append ltx path (if exist)
	string_path		fn,dr,di;
	_splitpath		(ltx_fn,dr,di,0,0);
	strconcat		(sizeof(fn),fn,dr,di);  
	if (0!=fn[0])
		FS.append_path	("ltx_path",fn,0,false);
	
	if (!FS.exist(ltx_fn)&&!FS.exist(ltx_fn,"$app_root$",tmp)) 
		Debug.fatal	(DEBUG_INFO,"ERROR: Can't find ltx file: '%s'",ltx_fn);

	CInifile ltx	(ltx_fn);
	printf			("Processing LTX...\n");

	BOOL make_pack	= ltx.line_exist("options","make_pack") ? ltx.r_bool("options","make_pack") : true;
	LPCSTR copy_path= ltx.line_exist("options","copy_path") ? ltx.r_string("options","copy_path") : 0;
	if (ltx.line_exist("options","exclude_exts"))
		_SequenceToList(exclude_exts,ltx.r_string("options","exclude_exts"));

	xr_vector<char*> list;
	xr_vector<char*> fl_list;
	if(ltx.section_exist("include_folders"))
	{
	CInifile::Sect& if_sect	= ltx.r_section("include_folders");
	for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); if_it++)
	{
		BOOL ifRecurse		= CInifile::IsBOOL(if_it->second.c_str());
		u32 folder_mask		= FS_ListFolders | (ifRecurse?0:FS_RootOnly);

		string_path path;
		LPCSTR _path		= 0==xr_strcmp(if_it->first.c_str(),".\\")?"":if_it->first.c_str();
		strcpy				(path,_path);
		u32 path_len		= xr_strlen(path);
		if ((0!=path_len)&&(path[path_len-1]!='\\')) strcat(path,"\\");

		Log					("");
		OUT_LOG				("Processing folder: '%s'",path);
		BOOL efRecurse;
		BOOL val			= IsFolderAccepted(ltx,path,efRecurse);
		if (val || (!val&&!efRecurse))
		{ 
			if (val)		ProcessFolder	(list,path);

			xr_vector<char*>*	i_fl_list	= FS.file_list_open	("$target_folder$",path,folder_mask);
			if (!i_fl_list)
			{
				Log			("ERROR: Unable to open folder list:", path);
				continue;
			}

			xr_vector<char*>::iterator it	= i_fl_list->begin();
			xr_vector<char*>::iterator itE	= i_fl_list->end();
			for (;it!=itE;++it){ 
				xr_string tmp_path	= xr_string(path)+xr_string(*it);
				bool val		= IsFolderAccepted(ltx,tmp_path.c_str(),efRecurse);
				if (val)
				{
					fl_list.push_back(xr_strdup(tmp_path.c_str()));
					Msg			("+F: %s",tmp_path.c_str());
					// collect files
					if (ifRecurse) 
						ProcessFolder (list,tmp_path.c_str());
				}else
				{
					Msg			("-F: %s",tmp_path.c_str());
				}
			}
			FS.file_list_close	(i_fl_list);
		}else
		{
			Msg					("-F: %s",path);
		}
	}
}//if(ltx.section_exist("include_folders"))
	// compress
	{
		if(ltx.section_exist("include_files"))
		{
		CInifile::Sect& if_sect	= ltx.r_section("include_files");
		for (CInifile::SectCIt if_it=if_sect.Data.begin(); if_it!=if_sect.Data.end(); if_it++)
			{
				  list.push_back	(xr_strdup(if_it->first.c_str()));
			}	
		}
	
	}
	CompressList	(tgt_name,&list,&fl_list,bFast,make_pack,copy_path);

	// free
	xr_vector<char*>::iterator it	= list.begin();
	xr_vector<char*>::iterator itE	= list.end();
	for (;it!=itE;++it) xr_free(*it);
	it				= fl_list.begin();
	itE				= fl_list.end();
	for (;it!=itE;++it) xr_free(*it);

	exclude_exts.clear_and_free();
}
Beispiel #2
0
void CPhysicObject::create_collision_model			( )
{
	xr_delete( collidable.model );
	
	VERIFY( Visual() );
	IKinematics *K = Visual()->dcast_PKinematics	();
	VERIFY( K );
	
	CInifile* ini = K->LL_UserData();
	if( ini && ini->section_exist( "collide" ) && ini->line_exist("collide", "mesh" ) && ini->r_bool("collide", "mesh" ) )
	{
		collidable.model = xr_new<CCF_DynamicMesh>( this );
		return;
	}

	collidable.model = xr_new<CCF_Skeleton>(this);

	/*
	switch(m_type) {
		case epotBox:			
		case epotFixedChain:
		case epotFreeChain :
		case epotSkeleton  :	collidable.model = xr_new<CCF_Skeleton>(this);	break;

		default: NODEFAULT; 
		
	}
	*/
}
Beispiel #3
0
void CCar::ParseDefinitions()
{
	 
	
	bone_map.clear();

	IKinematics* pKinematics=smart_cast<IKinematics*>(Visual());
	bone_map.insert(mk_pair(pKinematics->LL_GetBoneRoot(),physicsBone()));
	CInifile* ini = pKinematics->LL_UserData();
	R_ASSERT2(ini,"Car has no description !!! See ActorEditor Object - UserData");
	CExplosive::Load(ini,"explosion");
	//CExplosive::SetInitiator(ID());
	m_camera_position			= ini->r_fvector3("car_definition","camera_pos");
	///////////////////////////car definition///////////////////////////////////////////////////
	fill_wheel_vector			(ini->r_string	("car_definition","driving_wheels"),m_driving_wheels);
	fill_wheel_vector			(ini->r_string	("car_definition","steering_wheels"),m_steering_wheels);
	fill_wheel_vector			(ini->r_string	("car_definition","breaking_wheels"),m_breaking_wheels);
	fill_exhaust_vector			(ini->r_string	("car_definition","exhausts"),m_exhausts);
	fill_doors_map				(ini->r_string	("car_definition","doors"),m_doors);

	///////////////////////////car properties///////////////////////////////


	m_max_power			=		ini->r_float("car_definition","engine_power");
	m_max_power			*=		(0.8f*1000.f);

	m_max_rpm			=		ini->r_float("car_definition","max_engine_rpm");
	m_max_rpm			*=		(1.f/60.f*2.f*M_PI);


	m_min_rpm					=		ini->r_float("car_definition","idling_engine_rpm");
	m_min_rpm					*=		(1.f/60.f*2.f*M_PI);

	m_power_rpm					=		ini->r_float("car_definition","max_power_rpm");
	m_power_rpm					*=		(1.f/60.f*2.f*M_PI);//

	m_torque_rpm				=		ini->r_float("car_definition","max_torque_rpm");
	m_torque_rpm				*=		(1.f/60.f*2.f*M_PI);//

	m_power_increment_factor	=		READ_IF_EXISTS(ini,r_float,"car_definition","power_increment_factor",m_power_increment_factor);
	m_rpm_increment_factor		=		READ_IF_EXISTS(ini,r_float,"car_definition","rpm_increment_factor",m_rpm_increment_factor);
	m_power_decrement_factor	=		READ_IF_EXISTS(ini,r_float,"car_definition","power_decrement_factor",m_power_increment_factor);
	m_rpm_decrement_factor		=		READ_IF_EXISTS(ini,r_float,"car_definition","rpm_decrement_factor",m_rpm_increment_factor);
	m_power_neutral_factor		=		READ_IF_EXISTS(ini,r_float,"car_definition","power_neutral_factor",m_power_neutral_factor);
	R_ASSERT2(m_power_neutral_factor>0.1f&&m_power_neutral_factor<1.f,"power_neutral_factor must be 0 - 1 !!");
	if(ini->line_exist("car_definition","exhaust_particles"))
	{
		m_exhaust_particles =ini->r_string("car_definition","exhaust_particles");
	}
			
	b_auto_switch_transmission= !!ini->r_bool("car_definition","auto_transmission");

	InitParabola		();

	m_axle_friction		=		ini->r_float("car_definition","axle_friction");
	m_steering_speed	=		ini->r_float("car_definition","steering_speed");

	if(ini->line_exist("car_definition","break_time"))
	{
		m_break_time=ini->r_float("car_definition","break_time");
	}
	/////////////////////////transmission////////////////////////////////////////////////////////////////////////
	float main_gear_ratio=ini->r_float("car_definition","main_gear_ratio");

	R_ASSERT2(ini->section_exist("transmission_gear_ratio"),"no section transmission_gear_ratio");
	m_gear_ratious.push_back(ini->r_fvector3("transmission_gear_ratio","R"));
	m_gear_ratious[0][0]=-m_gear_ratious[0][0]*main_gear_ratio;
	string32 rat_num;
	for(int i=1;true;++i)
	{
		xr_sprintf(rat_num,"N%d",i);
		if(!ini->line_exist("transmission_gear_ratio",rat_num)) break;
		Fvector gear_rat=ini->r_fvector3("transmission_gear_ratio",rat_num);
		gear_rat[0]*=main_gear_ratio;
		gear_rat[1]*=(1.f/60.f*2.f*M_PI);
		gear_rat[2]*=(1.f/60.f*2.f*M_PI);
		m_gear_ratious.push_back(gear_rat);
	}

	///////////////////////////////sound///////////////////////////////////////////////////////
	m_car_sound->Init();
	///////////////////////////////fuel///////////////////////////////////////////////////
	m_fuel_tank=ini->r_float("car_definition","fuel_tank");
	m_fuel=m_fuel_tank;
	m_fuel_consumption=ini->r_float("car_definition","fuel_consumption");
	m_fuel_consumption/=100000.f;
	if(ini->line_exist("car_definition","exhaust_particles"))
		m_exhaust_particles = ini->r_string("car_definition","exhaust_particles");
	///////////////////////////////lights///////////////////////////////////////////////////
	m_lights.Init(this);
	m_lights.ParseDefinitions();


	
	if(ini->section_exist("animations"))
	{
		m_driver_anim_type=ini->r_u16("animations","driver_animation_type");
	}

	
	if(ini->section_exist("doors"))
	{
		m_doors_torque_factor=ini->r_u16("doors","open_torque_factor");
	}

	m_damage_particles.Init(this);
}