Пример #1
0
void CPEDef::Save2(CInifile& ini)
{
	ini.w_u16		("_effect", "version",			PED_VERSION);
//.	ini.w_string	("_effect", "name",				m_Name.c_str());
	ini.w_u32		("_effect", "max_particles",	m_MaxParticles);
//.!!	F.w				(m_Actions.pointer(),m_Actions.size());
	ini.w_u32		("_effect", "flags",				m_Flags.get());

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

	if (m_Flags.is(dfFramed))
	{
		ini.w_fvector2		("frame",	"tex_size", 	m_Frame.m_fTexSize);
		ini.w_fvector2		("frame",	"reserved", 	m_Frame.reserved);
		ini.w_s32			("frame",	"dim_x", 		m_Frame.m_iFrameDimX);
		ini.w_s32			("frame",	"frame_count",	m_Frame.m_iFrameCount);
		ini.w_float			("frame",	"speed",		m_Frame.m_fSpeed);
	}

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

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

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

	if (m_Flags.is(dfAlignToPath))
	{
		ini.w_fvector3	("align_to_path", "default_rotation", m_APDefaultRotation);
	}
#ifdef _EDITOR
    ini.w_u32			("_effect", "action_count", m_EActionList.size());
    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);
		ini.w_u32		(sect, "action_type", (*it)->type);
    	(*it)->Save2	(ini, sect);
    }
#endif
}
Пример #2
0
void CDemoPlay::stat_Stop	()
{
	if (!stat_started)		return;
	stat_started			= FALSE;
	float	stat_total		= stat_Timer_total.GetElapsed_sec	();

	float	rfps_min, rfps_max, rfps_middlepoint, rfps_average	;

	// total
	u32	dwFramesTotal		= Device.dwFrame-stat_StartFrame	;
	rfps_average			= float(dwFramesTotal)/stat_total	;

	// min/max/average
	rfps_min				= flt_max;
	rfps_max				= flt_min;
	rfps_middlepoint		= 0;
	for (u32	it=1; it<stat_table.size(); it++)
	{
		float	fps	= 1.f / stat_table[it];
		if		(fps<rfps_min)	rfps_min = fps;
		if		(fps>rfps_max)	rfps_max = fps;
		rfps_middlepoint	+=	fps;
	}
	rfps_middlepoint		/= float(stat_table.size()-1);

	Msg("* [DEMO] FPS: average[%f], min[%f], max[%f], middle[%f]",rfps_average,rfps_min,rfps_max,rfps_middlepoint);

	if(g_bBenchmark){
		string_path			fname;

		if(xr_strlen(g_sBenchmarkName))
			sprintf_s	(fname,sizeof(fname),"%s.result",g_sBenchmarkName);
		else
			strcpy_s	(fname,sizeof(fname),"benchmark.result");


		FS.update_path		(fname,"$app_data_root$",fname);
		CInifile			res		(fname,FALSE,FALSE,TRUE);
		res.w_float			("general","renderer",	float(::Render->get_generation())/10.f,	"dx-level required"		);
		res.w_float			("general","min",		rfps_min,								"absolute minimum"		);
		res.w_float			("general","max",		rfps_max,								"absolute maximum"		);
		res.w_float			("general","average",	rfps_average,							"average for this run"	);
		res.w_float			("general","middle",	rfps_middlepoint,						"per-frame middle-point");
		for (u32	it=1; it<stat_table.size(); it++)
		{
			string32		id;
			sprintf_s		(id,sizeof(id),"%7d",it);
			for (u32 c=0; id[c]; c++) if (' '==id[c]) id[c] = '0';
			res.w_float		("per_frame_stats",	id, 1.f / stat_table[it]);
		}

		Console->Execute	("quit");
	}
}
Пример #3
0
void CEditShape::SaveLTX(CInifile& ini, LPCSTR sect_name)
{
	inherited::SaveLTX	(ini, sect_name);

	ini.w_u32			(sect_name, "version", SHAPE_CURRENT_VERSION);

    ini.w_u32			(sect_name, "shapes_count", shapes.size());
    ini.w_u8			(sect_name, "shape_type", m_shape_type);

    string128			buff;
    for(u32 i=0; i<shapes.size(); ++i)
    {
       sprintf			(buff,"shape_type_%d", i);
       ini.w_u8			(sect_name, buff, shapes[i].type);
       if(shapes[i].type==CShapeData::cfSphere)
       {
       	sprintf			(buff,"shape_center_%d", i);
		ini.w_fvector3	(sect_name, buff, shapes[i].data.sphere.P);

       	sprintf			(buff,"shape_radius_%d", i);
		ini.w_float		(sect_name, buff, shapes[i].data.sphere.R);
       }else
       {
       		R_ASSERT		(shapes[i].type==CShapeData::cfBox);
            sprintf			(buff,"shape_matrix_i_%d", i);
            ini.w_fvector3	(sect_name, buff, shapes[i].data.box.i);
            sprintf			(buff,"shape_matrix_j_%d", i);
            ini.w_fvector3	(sect_name, buff, shapes[i].data.box.j);
            sprintf			(buff,"shape_matrix_k_%d", i);
            ini.w_fvector3	(sect_name, buff, shapes[i].data.box.k);
            sprintf			(buff,"shape_matrix_c_%d", i);
            ini.w_fvector3	(sect_name, buff, shapes[i].data.box.c);
       }
    }
}
Пример #4
0
void ESceneAIMapTool::SaveLTX(CInifile& ini)
{
	inherited::SaveLTX	(ini);

	ini.w_u32			("main", "version", AIMAP_VERSION);
	ini.w_u32			("main", "flags", m_Flags.get());

    ini.w_fvector3		("main", "bbox_min", m_AIBBox.min);
    ini.w_fvector3		("main", "bbox_max", m_AIBBox.max);

    ini.w_float			("params", "patch_size", m_Params.fPatchSize);
    ini.w_float			("params", "test_height", m_Params.fTestHeight);
    ini.w_float			("params", "can_up", m_Params.fCanUP);
    ini.w_float			("params", "can_down", m_Params.fCanDOWN);

    EnumerateNodes		();
    ini.w_u32			("main", "nodes_count", m_Nodes.size());

    u32 i 				= 0;
    string128			buff;
	for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); ++it, ++i)
    {
    	sprintf			(buff,"n_%d", i);
    	(*it)->SaveLTX	(ini, buff, this);
    }

    ini.w_float			("main", "vis_radius", m_VisRadius);
    ini.w_u32			("main", "brush_size", m_BrushSize);

    ini.w_float			("main", "smooth_height", m_SmoothHeight);

    for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); ++o_it)
    	ini.w_string	("snap_objects", (*o_it)->Name, NULL);
}
Пример #5
0
void ESoundSource::SaveLTX(CInifile& ini, LPCSTR sect_name)
{
	inherited::SaveLTX	(ini, sect_name);

	ini.w_u32			(sect_name, "version", SOUND_SOURCE_VERSION);

    ini.w_u32			(sect_name, "snd_type", m_Type);

    ini.w_string		(sect_name, "snd_name", m_WAVName.c_str());

    ini.w_u32			(sect_name, "flags", m_Flags.get());

    ini.w_fvector3		(sect_name, "snd_position", m_Params.position);
    ini.w_float			(sect_name, "volume", m_Params.volume);
    ini.w_float			(sect_name, "freq", m_Params.freq);
    ini.w_float			(sect_name, "min_dist", m_Params.min_distance);
    ini.w_float			(sect_name, "max_dist", m_Params.max_distance);
    ini.w_float			(sect_name, "max_ai_dist", m_Params.max_ai_distance);

    ini.w_fvector2		(sect_name, "random_pause", m_RandomPause);
    ini.w_fvector2		(sect_name, "active_time", m_ActiveTime);
    ini.w_fvector2		(sect_name, "play_time", m_PlayTime);
}
void ambient::save			(CInifile& config)
{
	u32						count = 1;
	LPSTR					temp = 0;
	{
		sound_container_type::const_iterator	b = m_sound_channels_ids.begin(), i = b;
		sound_container_type::const_iterator	e = m_sound_channels_ids.end();
		for ( ; i != e; ++i)
			count			+= (*i)->id().size() + 2;

		temp				= (LPSTR)_alloca(count*sizeof(char));
		*temp				= 0;
		for (i = b; i != e; ++i) {
			if (i == b) {
				strcpy_s	(temp, count, (*i)->id().c_str());
				continue;
			}

			strcat_s		(temp, count, ", ");
			strcat_s		(temp, count, (*i)->id().c_str());
		}
	}

	config.w_string			(m_load_section.c_str(), "sound_channels",	  temp);
	config.w_float			(m_load_section.c_str(), "min_effect_period", float(m_effect_period.x)/1000.f);
	config.w_float			(m_load_section.c_str(), "max_effect_period", float(m_effect_period.y)/1000.f);

	{
		count				= 1;
		effect_container_type::const_iterator	b = m_effects_ids.begin(), i = b;
		effect_container_type::const_iterator	e = m_effects_ids.end();
		for ( ; i != e; ++i)
			count			+= (*i)->id().size() + 2;

		temp				= (LPSTR)_alloca(count*sizeof(char));
		*temp				= 0;
		for (i = b; i != e; ++i) {
			if (i == b) {
				strcpy_s	(temp, count, (*i)->id().c_str());
				continue;
			}

			strcat_s		(temp, count, ", ");
			strcat_s		(temp, count, (*i)->id().c_str());
		}
	}
	config.w_string			(m_load_section.c_str(), "effects", temp);
}
void time::save				(CInifile& config)
{
	config.w_string				(m_identifier.c_str(),"ambient", m_ambient.c_str());
	config.w_fvector3			(m_identifier.c_str(),"ambient_color", ambient);
	config.w_string				(m_identifier.c_str(),"clouds_texture", clouds_texture_name.c_str());
	config.w_float				(m_identifier.c_str(),"far_plane", far_plane);
	config.w_float				(m_identifier.c_str(),"fog_distance", fog_distance);
	config.w_float				(m_identifier.c_str(),"fog_density", fog_density);
	config.w_fvector3			(m_identifier.c_str(),"fog_color", fog_color);
	config.w_fvector3			(m_identifier.c_str(),"rain_color", rain_color);
	config.w_float				(m_identifier.c_str(),"rain_density", rain_density);
	config.w_fvector3			(m_identifier.c_str(),"sky_color", sky_color);
	config.w_float				(m_identifier.c_str(),"sky_rotation", rad2deg(sky_rotation));
	config.w_string				(m_identifier.c_str(),"sky_texture", sky_texture_name.c_str());
	config.w_fvector3			(m_identifier.c_str(),"sun_color", sun_color);
	config.w_float				(m_identifier.c_str(),"sun_shafts_intensity", m_fSunShaftsIntensity);
	config.w_string				(m_identifier.c_str(),"sun", m_sun.c_str());
	config.w_string				(m_identifier.c_str(),"thunderbolt_collection", m_thunderbolt_collection.c_str());
	config.w_float				(m_identifier.c_str(),"thunderbolt_duration", bolt_duration);
	config.w_float				(m_identifier.c_str(),"thunderbolt_period", bolt_period);
	config.w_float				(m_identifier.c_str(),"water_intensity", m_fWaterIntensity);
	config.w_float				(m_identifier.c_str(),"wind_direction", rad2deg(wind_direction));
	config.w_float				(m_identifier.c_str(),"wind_velocity", wind_velocity);
	config.w_fvector4			(m_identifier.c_str(),"hemisphere_color", hemi_color);
	config.w_float				(m_identifier.c_str(),"sun_altitude", rad2deg(sun_dir.getH()));
	config.w_float				(m_identifier.c_str(),"sun_longitude", rad2deg(sun_dir.getP()));
	config.w_fvector4			(m_identifier.c_str(),"clouds_color", clouds_color);
}