예제 #1
0
void PDomain::Load2(CInifile& ini, const shared_str& sect)
{
	type		= PDomainEnum(ini.r_u32(sect,"type"));
	v[0]		= ini.r_fvector3(sect,"v0");
	v[1]		= ini.r_fvector3(sect,"v1");
	v[2]		= ini.r_fvector3(sect,"v2");
}
예제 #2
0
void CGameFont::Initialize		(LPCSTR cShader, LPCSTR cTextureName)
{
	string_path					cTexture;

	LPCSTR _lang				= pSettings->r_string("string_table", "font_prefix");
	bool is_di					= strstr(cTextureName, "ui_font_hud_01") || 
								  strstr(cTextureName, "ui_font_hud_02") ||
								  strstr(cTextureName, "ui_font_console_02");
	if(_lang && !is_di)
		strconcat				(cTexture, cTextureName, _lang);
	else
		strcpy					(cTexture, cTextureName);

	uFlags						&=~fsValid;
	vTS.set						(1.f,1.f); // обязательно !!!

	eCurrentAlignment			= alLeft;
	vInterval.set				(1.f,1.f);

	for (int i=0; i<256; i++)	CharMap[i] = i;
	strings.reserve				(128);

	// check ini exist
	string256 fn,buf;
	strcpy		(buf,cTexture); if (strext(buf)) *strext(buf)=0;
	R_ASSERT2	(FS.exist(fn,"$game_textures$",buf,".ini"),fn);
	CInifile* ini				= CInifile::Create(fn);
	if (ini->section_exist("symbol_coords")){
		for (int i=0; i<256; i++){
			sprintf					(buf,"%03d",i);
			Fvector v				= ini->r_fvector3("symbol_coords",buf);
			TCMap[i].set			(v.x,v.y,v[2]-v[0]);
		}
		fHeight						= ini->r_float("symbol_coords","height");
	}else{
		if (ini->section_exist("char widths")){
			fHeight					= ini->r_float("char widths","height");
			int cpl					= 16;
			for (int i=0; i<256; i++){
				sprintf				(buf,"%d",i);
				float w				= ini->r_float("char widths",buf);
				TCMap[i].set		((i%cpl)*fHeight,(i/cpl)*fHeight,w);
			}
		}else{
			R_ASSERT(ini->section_exist("font_size"));
			fHeight					= ini->r_float("font_size","height");
			float width				= ini->r_float("font_size","width");
			const int cpl			= ini->r_s32	("font_size","cpl");
			for (int i=0; i<256; i++)
				TCMap[i].set		((i%cpl)*width,(i/cpl)*fHeight,width);
		}
	}
	fCurrentHeight				= fHeight;

	CInifile::Destroy			(ini);

	// Shading
	pShader.create				(cShader,cTexture);
	pGeom.create				(FVF::F_TL, RCache.Vertex.Buffer(), RCache.QuadIB);
}
예제 #3
0
파일: EShape.cpp 프로젝트: 2asoft/xray
bool CEditShape::LoadLTX(CInifile& ini, LPCSTR sect_name)
{
    u32 vers		= ini.r_u32(sect_name, "version");

 	inherited::LoadLTX	(ini, sect_name);

    u32 count 			= ini.r_u32			(sect_name, "shapes_count");
    if(vers>0x0001)
    	m_shape_type	= ini.r_u8			(sect_name, "shape_type");
        
    string128			buff;
    shapes.resize		(count);
    for(u32 i=0; i<count; ++i)
    {
       sprintf			(buff,"shape_type_%d", i);
       shapes[i].type	= ini.r_u8(sect_name, buff);
       if(shapes[i].type==CShapeData::cfSphere)
       {
       	sprintf			(buff,"shape_center_%d", i);
		shapes[i].data.sphere.P = ini.r_fvector3	(sect_name, buff);

       	sprintf			(buff,"shape_radius_%d", i);
		shapes[i].data.sphere.R = ini.r_float		(sect_name, buff);
       }else
       {
       	 R_ASSERT		(shapes[i].type==CShapeData::cfBox);
         sprintf			(buff,"shape_matrix_i_%d", i);
         shapes[i].data.box.i = ini.r_fvector3	(sect_name, buff);

         sprintf			(buff,"shape_matrix_j_%d", i);
         shapes[i].data.box.j = ini.r_fvector3	(sect_name, buff);

         sprintf			(buff,"shape_matrix_k_%d", i);
         shapes[i].data.box.k = ini.r_fvector3	(sect_name, buff);

         sprintf			(buff,"shape_matrix_c_%d", i);
         shapes[i].data.box.c = ini.r_fvector3	(sect_name, buff);
       }
    }


	ComputeBounds();
	return true;
}
예제 #4
0
//----------------------------------------------------
bool ESoundSource::LoadLTX(CInifile& ini, LPCSTR sect_name)
{
	u32 version =  ini.r_u32(sect_name, "version");

    if(version!=SOUND_SOURCE_VERSION)
    {
        ELog.Msg( mtError, "ESoundSource: Unsupported version.");
        return false;
    }

	inherited::LoadLTX	(ini, sect_name);

    m_Type				= ini.r_u32			(sect_name, "snd_type");

    m_WAVName			= ini.r_string		(sect_name, "snd_name");

    m_Flags.assign		(ini.r_u32			(sect_name, "flags"));

    m_Params.position	= ini.r_fvector3		(sect_name, "snd_position");
    m_Params.volume		= ini.r_float			(sect_name, "volume");
    m_Params.freq		= ini.r_float			(sect_name, "freq");
    m_Params.min_distance=ini.r_float			(sect_name, "min_dist");
    m_Params.max_distance= ini.r_float			(sect_name, "max_dist");
    m_Params.max_ai_distance=ini.r_float			(sect_name, "max_ai_dist");

    m_RandomPause		= ini.r_fvector2		(sect_name, "random_pause");
    m_ActiveTime		= ini.r_fvector2		(sect_name, "active_time");
    m_PlayTime			= ini.r_fvector2		(sect_name, "play_time");

    ResetSource		();

    switch (m_Type)
    {
    case stStaticSource:
    	if (m_Flags.is(flPlaying)) 		Play();
//.    	if (m_Flags.is(flSimulating)) 	Simulate();
    break;
    default: THROW;
    }
    return true;
}
예제 #5
0
BOOL CPEDef::Load2(CInifile& ini)
{
//.	u16 version		= ini.r_u16("_effect", "version");
	m_MaxParticles	= ini.r_u32("_effect", "max_particles");
	m_Flags.assign	(ini.r_u32("_effect", "flags"));

	if (m_Flags.is(dfSprite))
	{
		m_ShaderName	= ini.r_string	("sprite", "shader");
		m_TextureName	= ini.r_string	("sprite", "texture");
	}

	if (m_Flags.is(dfFramed))
	{
		m_Frame.m_fTexSize		= ini.r_fvector2		("frame",	"tex_size");
		m_Frame.reserved		= ini.r_fvector2		("frame",	"reserved");
		m_Frame.m_iFrameDimX	= ini.r_s32				("frame",	"dim_x");
		m_Frame.m_iFrameCount	= ini.r_s32				("frame",	"frame_count");
		m_Frame.m_fSpeed		= ini.r_float			("frame",	"speed");
	}

	if (m_Flags.is(dfTimeLimit))
	{
		m_fTimeLimit			= ini.r_float			("timelimit", "value");
	}

	if (m_Flags.is(dfCollision))
	{
		m_fCollideOneMinusFriction	= ini.r_float		("collision", "one_minus_friction");
		m_fCollideResilience		= ini.r_float		("collision", "collide_resilence");
		m_fCollideSqrCutoff			= ini.r_float		("collision", "collide_sqr_cutoff");
	}

	if (m_Flags.is(dfVelocityScale))
	{
		m_VelocityScale				= ini.r_fvector3	("velocity_scale", "value");
	}

	if (m_Flags.is(dfAlignToPath))
	{
		m_APDefaultRotation			= ini.r_fvector3	("align_to_path", "default_rotation");
	}
#ifdef _EDITOR
	if(pCreateEAction)
	{
		u32 count		= ini.r_u32("_effect", "action_count");
        m_EActionList.resize(count);
		u32 action_id	= 0;
        for (EPAVecIt it=m_EActionList.begin(); it!=m_EActionList.end(); ++it,++action_id)
		{
			string256					sect;
			xr_sprintf					(sect, sizeof(sect), "action_%04d", action_id);
            PAPI::PActionEnum type		= (PAPI::PActionEnum)(ini.r_u32(sect,"action_type"));
            (*it)						= pCreateEAction(type);
            (*it)->Load2				(ini, sect);
        }
		Compile							(m_EActionList);
    }
#endif

	return TRUE;
}
예제 #6
0
파일: GameFont.cpp 프로젝트: 2asoft/xray
void CGameFont::Initialize		(LPCSTR cShader, LPCSTR cTextureName)
{
	string_path					cTexture;

	LPCSTR _lang				= pSettings->r_string("string_table", "font_prefix");
	bool is_di					= strstr(cTextureName, "ui_font_hud_01") || 
								  strstr(cTextureName, "ui_font_hud_02") ||
								  strstr(cTextureName, "ui_font_console_02");
	if(_lang && !is_di)
		strconcat				(sizeof(cTexture),cTexture, cTextureName, _lang);
	else
		strcpy_s				(cTexture, sizeof(cTexture), cTextureName);

	uFlags						&=~fsValid;
	vTS.set						(1.f,1.f); // обязательно !!!

	eCurrentAlignment			= alLeft;
	vInterval.set				(1.f,1.f);

	strings.reserve				(128);

	// check ini exist
	string_path fn,buf;
	strcpy_s		(buf,cTexture); if (strext(buf)) *strext(buf)=0;
	R_ASSERT2	(FS.exist(fn,"$game_textures$",buf,".ini"),fn);
	CInifile* ini				= CInifile::Create(fn);

	nNumChars = 0x100;
	TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) );

	if ( ini->section_exist( "mb_symbol_coords" ) ) {
		nNumChars = 0x10000;
		TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) );
		uFlags |= fsMultibyte;
		fHeight = ini->r_float( "mb_symbol_coords" , "height" );
		
		fXStep = ceil( fHeight / 2.0f );

		// Searching for the first valid character

		Fvector vFirstValid = {0,0,0};

		if ( ini->line_exist( "mb_symbol_coords" , "09608" ) ) {
			Fvector v = ini->r_fvector3( "mb_symbol_coords" , "09608" );
			vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] );
		} else 
		for ( u32 i=0 ; i < nNumChars ; i++ ) {
			sprintf_s( buf ,sizeof(buf), "%05d" , i );
			if ( ini->line_exist( "mb_symbol_coords" , buf ) ) {
				Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf );
				vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] );
				break;
			}
		}

		// Filling entire character table

		for ( u32 i=0 ; i < nNumChars ; i++ ) {
			sprintf_s( buf ,sizeof(buf), "%05d" , i );
			if ( ini->line_exist( "mb_symbol_coords" , buf ) ) {
				Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf );
				TCMap[i].set( v.x , v.y , 1 + v[2] - v[0] );
			} else
				TCMap[i] = vFirstValid; // "unassigned" unprintable characters
		}

		// Special case for space
		TCMap[ 0x0020 ].set( 0 , 0 , 0 );
		// Special case for ideographic space
		TCMap[ 0x3000 ].set( 0 , 0 , 0 );


	}else
	if (ini->section_exist("symbol_coords"))
	{
		float d						= 0.0f;
//.		if(ini->section_exist("width_correction"))
//.			d						= ini->r_float("width_correction", "value");

		fHeight						= ini->r_float("symbol_coords","height");
		for (u32 i=0; i<nNumChars; i++){
			sprintf_s				(buf,sizeof(buf),"%03d",i);
			Fvector v				= ini->r_fvector3("symbol_coords",buf);
			TCMap[i].set			(v.x,v.y,v[2]-v[0]+d);
		}
	}else{
	if (ini->section_exist("char widths")){
		fHeight					= ini->r_float("char widths","height");
		int cpl					= 16;
		for (u32 i=0; i<nNumChars; i++){
			sprintf_s			(buf,sizeof(buf),"%d",i);
			float w				= ini->r_float("char widths",buf);
			TCMap[i].set		((i%cpl)*fHeight,(i/cpl)*fHeight,w);
		}
	}else{
		R_ASSERT(ini->section_exist("font_size"));
		fHeight					= ini->r_float("font_size","height");
		float width				= ini->r_float("font_size","width");
		const int cpl			= ini->r_s32	("font_size","cpl");
		for (u32 i=0; i<nNumChars; i++)
			TCMap[i].set		((i%cpl)*width,(i/cpl)*fHeight,width);
		}
	}

	fCurrentHeight				= fHeight;

	CInifile::Destroy			(ini);

	// Shading
	pFontRender->Initialize(cShader, cTexture);
}
예제 #7
0
void CEnvDescriptor::load(CEnvironment& environment, CInifile& config)
{
    Ivector3 tm = {0, 0, 0};
    sscanf(m_identifier.c_str(), "%d:%d:%d", &tm.x, &tm.y, &tm.z);
    R_ASSERT3((tm.x >= 0) && (tm.x < 24) && (tm.y >= 0) && (tm.y < 60) && (tm.z >= 0) && (tm.z < 60), "Incorrect weather time", m_identifier.c_str());
    exec_time = tm.x*3600.f + tm.y*60.f + tm.z;
    exec_time_loaded = exec_time;
    string_path st, st_env;
    xr_strcpy(st, config.r_string(m_identifier.c_str(), "sky_texture"));
    strconcat(sizeof(st_env), st_env, st, "#small");
    sky_texture_name = st;
    sky_texture_env_name = st_env;
    clouds_texture_name = config.r_string(m_identifier.c_str(), "clouds_texture");
    LPCSTR cldclr = config.r_string(m_identifier.c_str(), "clouds_color");
    float multiplier = 0, save = 0;
    sscanf(cldclr, "%f,%f,%f,%f,%f", &clouds_color.x, &clouds_color.y, &clouds_color.z, &clouds_color.w, &multiplier);
    save = clouds_color.w;
    clouds_color.mul(.5f*multiplier);
    clouds_color.w = save;

    sky_color = config.r_fvector3(m_identifier.c_str(), "sky_color");

    if (config.line_exist(m_identifier.c_str(), "sky_rotation")) sky_rotation = deg2rad(config.r_float(m_identifier.c_str(), "sky_rotation"));
    else sky_rotation = 0;
    far_plane = config.r_float(m_identifier.c_str(), "far_plane");
    fog_color = config.r_fvector3(m_identifier.c_str(), "fog_color");
    fog_density = config.r_float(m_identifier.c_str(), "fog_density");
    fog_distance = config.r_float(m_identifier.c_str(), "fog_distance");
    rain_density = config.r_float(m_identifier.c_str(), "rain_density");
    clamp(rain_density, 0.f, 1.f);
    rain_color = config.r_fvector3(m_identifier.c_str(), "rain_color");
    wind_velocity = config.r_float(m_identifier.c_str(), "wind_velocity");
    wind_direction = deg2rad(config.r_float(m_identifier.c_str(), "wind_direction"));
    ambient = config.r_fvector3(m_identifier.c_str(), "ambient_color");
    hemi_color = config.r_fvector4(m_identifier.c_str(), "hemisphere_color");
    sun_color = config.r_fvector3(m_identifier.c_str(), "sun_color");
    // if (config.line_exist(m_identifier.c_str(),"sun_altitude"))
    sun_dir.setHP(
        deg2rad(config.r_float(m_identifier.c_str(), "sun_altitude")),
        deg2rad(config.r_float(m_identifier.c_str(), "sun_longitude"))
        );
    R_ASSERT(_valid(sun_dir));
    // else
    // sun_dir.setHP (
    // deg2rad(config.r_fvector2(m_identifier.c_str(),"sun_dir").y),
    // deg2rad(config.r_fvector2(m_identifier.c_str(),"sun_dir").x)
    // );
    //AVO: commented to allow COC run in debug. I belive Cromm set longtitude to negative value in AF3 and that's why it is failing here
    //VERIFY2(sun_dir.y < 0, "Invalid sun direction settings while loading");

    lens_flare_id = environment.eff_LensFlare->AppendDef(environment, environment.m_suns_config, config.r_string(m_identifier.c_str(), "sun"));
    tb_id = environment.eff_Thunderbolt->AppendDef(environment, environment.m_thunderbolt_collections_config, environment.m_thunderbolts_config, config.r_string(m_identifier.c_str(), "thunderbolt_collection"));
    bolt_period = (tb_id.size()) ? config.r_float(m_identifier.c_str(), "thunderbolt_period") : 0.f;
    bolt_duration = (tb_id.size()) ? config.r_float(m_identifier.c_str(), "thunderbolt_duration") : 0.f;
    env_ambient = config.line_exist(m_identifier.c_str(), "ambient") ? environment.AppendEnvAmb(config.r_string(m_identifier.c_str(), "ambient")) : 0;

    if (config.line_exist(m_identifier.c_str(), "sun_shafts_intensity"))
        m_fSunShaftsIntensity = config.r_float(m_identifier.c_str(), "sun_shafts_intensity");

    if (config.line_exist(m_identifier.c_str(), "water_intensity"))
        m_fWaterIntensity = config.r_float(m_identifier.c_str(), "water_intensity");

#ifdef TREE_WIND_EFFECT
    if (config.line_exist(m_identifier.c_str(), "tree_amplitude_intensity"))
        m_fTreeAmplitudeIntensity = config.r_float(m_identifier.c_str(), "tree_amplitude_intensity");
#endif

    C_CHECK(clouds_color);
    C_CHECK(sky_color);
    C_CHECK(fog_color);
    C_CHECK(rain_color);
    C_CHECK(ambient);
    C_CHECK(hemi_color);
    C_CHECK(sun_color);
    on_device_create();
}
예제 #8
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);
}