Beispiel #1
0
void CPatternFunction::vfLoadEF(LPCSTR caFileName)
{
	string_path		caPath;
	if (!FS.exist(caPath,"$game_ai$",caFileName)) {
		Msg			("! Evaluation function : File not found \"%s\"",caPath);
		R_ASSERT	(false);
		return;
	}
	
	IReader			*F = FS.r_open(caPath);
	F->r			(&m_tEFHeader,sizeof(SEFHeader));

	if (EFC_VERSION != m_tEFHeader.dwBuilderVersion) {
		FS.r_close	(F);
		Msg			("! Evaluation function (%s) : Not supported version of the Evaluation Function Contructor",caPath);
		R_ASSERT	(false);
		return;
	}

	F->r			(&m_dwVariableCount,sizeof(m_dwVariableCount));
	m_dwaAtomicFeatureRange = xr_alloc<u32>(m_dwVariableCount);
	ZeroMemory		(m_dwaAtomicFeatureRange,m_dwVariableCount*sizeof(u32));
	u32				*m_dwaAtomicIndexes = xr_alloc<u32>(m_dwVariableCount);
	ZeroMemory		(m_dwaAtomicIndexes,m_dwVariableCount*sizeof(u32));

	for (u32 i=0; i<m_dwVariableCount; ++i) {
		F->r(m_dwaAtomicFeatureRange + i,sizeof(u32));
		if (i)
			m_dwaAtomicIndexes[i] = m_dwaAtomicIndexes[i-1] + m_dwaAtomicFeatureRange[i-1];
	}

	m_dwaVariableTypes = xr_alloc<u32>(m_dwVariableCount);
	F->r			(m_dwaVariableTypes,m_dwVariableCount*sizeof(u32));

	F->r			(&m_dwFunctionType,sizeof(u32));

	F->r			(&m_fMinResultValue,sizeof(float));
	F->r			(&m_fMaxResultValue,sizeof(float));

	F->r			(&m_dwPatternCount,sizeof(m_dwPatternCount));
	m_tpPatterns	= xr_alloc<SPattern>(m_dwPatternCount);
	m_dwaPatternIndexes = xr_alloc<u32>(m_dwPatternCount);
	ZeroMemory		(m_dwaPatternIndexes,m_dwPatternCount*sizeof(u32));
	m_dwParameterCount = 0;
	for (u32 i=0; i<m_dwPatternCount; ++i) {
		if (i)
			m_dwaPatternIndexes[i] = m_dwParameterCount;
		F->r		(&(m_tpPatterns[i].dwCardinality),sizeof(m_tpPatterns[i].dwCardinality));
		m_tpPatterns[i].dwaVariableIndexes = xr_alloc<u32>(m_tpPatterns[i].dwCardinality);
		F->r		(m_tpPatterns[i].dwaVariableIndexes,m_tpPatterns[i].dwCardinality*sizeof(u32));
		u32			m_dwComplexity = 1;
		for (int j=0; j<(int)m_tpPatterns[i].dwCardinality; ++j)
			m_dwComplexity *= m_dwaAtomicFeatureRange[m_tpPatterns[i].dwaVariableIndexes[j]];
		m_dwParameterCount += m_dwComplexity;
	}
	
	m_faParameters	= xr_alloc<float>(m_dwParameterCount);
	F->r			(m_faParameters,m_dwParameterCount*sizeof(float));
	FS.r_close		(F);

	m_dwaVariableValues = xr_alloc<u32>(m_dwVariableCount);
	
	xr_free			(m_dwaAtomicIndexes);
    
	ef_storage().m_fpaBaseFunctions[m_dwFunctionType] = this;
	
	_splitpath		(caPath,0,0,m_caName,0);

	// Msg			("* Evaluation function \"%s\" is successfully loaded",m_caName);
}
Beispiel #2
0
shell_root CPHShellSplitterHolder::ElementSingleSplit(const element_fracture &split_elem,const CPHElement* source_element)
{

	//const CPHShellSplitter& splitter=m_splitters[aspl];
	//CPHElement* element=m_pShell->elements[splitter.m_element];
	CPhysicsShell *new_shell_last=P_create_Shell();
	CPHShell	  *new_shell_last_desc=smart_cast<CPHShell*>(new_shell_last);
	new_shell_last->mXFORM.set(m_pShell->mXFORM);	const u16 start_joint=split_elem.second.m_start_jt_num;
	R_ASSERT(_valid(new_shell_last->mXFORM));
	const u16 end_joint=split_elem.second.m_end_jt_num;
	//it is not right for multiple joints attached to the unsplited part becource all these need to be reattached
	if(start_joint!=end_joint)
	{
		JOINT_STORAGE& joints=m_pShell->joints;
		JOINT_I i=joints.begin()+ start_joint,e=joints.begin()+ end_joint;
		for(;i!=e;++i)
		{
	
			CPHJoint* joint=(*i);
			if(joint->PFirst_element()==source_element)
			{
				IKinematics* K = m_pShell->PKinematics();
				dVector3 safe_pos1, safe_pos2;
				dQuaternion safe_q1, safe_q2;
				CPhysicsElement* el1=cast_PhysicsElement(split_elem.first),*el2=joint->PSecond_element();
				dBodyID body1=el1->get_body(), body2=el2->get_body();
				dVectorSet(safe_pos1,dBodyGetPosition(body1));
				dVectorSet(safe_pos2,dBodyGetPosition(body2));

				dQuaternionSet(safe_q1,dBodyGetQuaternion(body1));
				dQuaternionSet(safe_q2,dBodyGetQuaternion(body2));
				
				//m_pShell->PlaceBindToElForms();
				
				K->LL_GetBindTransform(bones_bind_forms);
				el1->SetTransform(bones_bind_forms[el1->m_SelfID]);
				el2->SetTransform(bones_bind_forms[el2->m_SelfID]);
				joint->ReattachFirstElement(split_elem.first);

				dVectorSet(const_cast<dReal*>(dBodyGetPosition(body1)),safe_pos1);
				dVectorSet(const_cast<dReal*>(dBodyGetPosition(body2)),safe_pos2);

				dQuaternionSet(const_cast<dReal*>(dBodyGetQuaternion(body1)),safe_q1);
				dQuaternionSet(const_cast<dReal*>(dBodyGetQuaternion(body2)),safe_q2);

				dBodySetPosition(body1,safe_pos1[0],safe_pos1[1],safe_pos1[2]);
				dBodySetPosition(body2,safe_pos2[0],safe_pos2[1],safe_pos2[2]);
				dBodySetQuaternion(body1,safe_q1);
				dBodySetQuaternion(body2,safe_q2);
			}
		}
	//	m_pShell->joints[split_elem.second.m_start_jt_num]->ReattachFirstElement(split_elem.first);
	}

	//the last new shell will have all splitted old elements end joints and one new element reattached to old joint
	//m_splitters.erase(m_splitters.begin()+aspl);
	//now aspl points to the next splitter
	if((split_elem.first)->FracturesHolder())//if this element can be splitted add a splitter for it
		new_shell_last_desc->AddSplitter(CPHShellSplitter::splElement,0,u16(-1));//
	
	new_shell_last_desc->add_Element(split_elem.first);
	//pass splitters taking into account that one element was olready added
	PassEndSplitters(split_elem.second,new_shell_last_desc,0,0);


	InitNewShell(new_shell_last_desc);
	m_pShell->PassEndElements(split_elem.second.m_start_el_num,split_elem.second.m_end_el_num,new_shell_last_desc);

	

	m_pShell->PassEndJoints(split_elem.second.m_start_jt_num,split_elem.second.m_end_jt_num,new_shell_last_desc);
	new_shell_last_desc->set_PhysicsRefObject(0);
///////////////////temporary for initialization set old Kinematics in new shell/////////////////
	new_shell_last->set_Kinematics(m_pShell->PKinematics());
	new_shell_last_desc->AfterSetActive();
	new_shell_last->set_Kinematics(NULL);
	VERIFY2(split_elem.second.m_bone_id<64,"strange root");
	VERIFY(_valid(new_shell_last->mXFORM));
	VERIFY(dBodyStateValide(source_element->get_bodyConst()));
	VERIFY(dBodyStateValide(split_elem.first->get_body()));
	new_shell_last->set_ObjectContactCallback(NULL);
	new_shell_last->set_PhysicsRefObject(NULL);
	return mk_pair(new_shell_last,split_elem.second.m_bone_id);

}
Beispiel #3
0
void CCustomZone::Load(LPCSTR section) 
{
	inherited::Load(section);

	m_iDisableHitTime		= pSettings->r_s32(section,				"disable_time");	
	m_iDisableHitTimeSmall	= pSettings->r_s32(section,				"disable_time_small");	
	m_iDisableIdleTime		= pSettings->r_s32(section,				"disable_idle_time");	
	m_fHitImpulseScale		= pSettings->r_float(section,			"hit_impulse_scale");
	m_fEffectiveRadius		= pSettings->r_float(section,			"effective_radius");
	m_eHitTypeBlowout		= ALife::g_tfString2HitType(pSettings->r_string(section, "hit_type"));

	m_zone_flags.set(eIgnoreNonAlive,	pSettings->r_bool(section,	"ignore_nonalive"));
	m_zone_flags.set(eIgnoreSmall,		pSettings->r_bool(section,	"ignore_small"));
	m_zone_flags.set(eIgnoreArtefact,	pSettings->r_bool(section,	"ignore_artefacts"));
	m_zone_flags.set(eVisibleByDetector,pSettings->r_bool(section,	"visible_by_detector"));
	



	//загрузить времена для зоны
	m_StateTime[eZoneStateIdle]			= -1;
	m_StateTime[eZoneStateAwaking]		= pSettings->r_s32(section, "awaking_time");
	m_StateTime[eZoneStateBlowout]		= pSettings->r_s32(section, "blowout_time");
	m_StateTime[eZoneStateAccumulate]	= pSettings->r_s32(section, "accamulate_time");
	
//////////////////////////////////////////////////////////////////////////
	ISpatial*		self				=	smart_cast<ISpatial*> (this);
	if (self)		self->spatial.type	|=	(STYPE_COLLIDEABLE|STYPE_SHAPE);
//////////////////////////////////////////////////////////////////////////

	LPCSTR sound_str = NULL;
	
	if(pSettings->line_exist(section,"idle_sound")) 
	{
		sound_str = pSettings->r_string(section,"idle_sound");
		m_idle_sound.create(sound_str, st_Effect,sg_SourceType);
	}
	
	if(pSettings->line_exist(section,"accum_sound")) 
	{
		sound_str = pSettings->r_string(section,"accum_sound");
		m_accum_sound.create(sound_str, st_Effect,sg_SourceType);
	}
	if(pSettings->line_exist(section,"awake_sound")) 
	{
		sound_str = pSettings->r_string(section,"awake_sound");
		m_awaking_sound.create(sound_str, st_Effect,sg_SourceType);
	}
	
	if(pSettings->line_exist(section,"blowout_sound")) 
	{
		sound_str = pSettings->r_string(section,"blowout_sound");
		m_blowout_sound.create(sound_str, st_Effect,sg_SourceType);
	}
	
	
	if(pSettings->line_exist(section,"hit_sound")) 
	{
		sound_str = pSettings->r_string(section,"hit_sound");
		m_hit_sound.create(sound_str, st_Effect,sg_SourceType);
	}

	if(pSettings->line_exist(section,"entrance_sound")) 
	{
		sound_str = pSettings->r_string(section,"entrance_sound");
		m_entrance_sound.create(sound_str, st_Effect,sg_SourceType);
	}


	if(pSettings->line_exist(section,"idle_particles")) 
		m_sIdleParticles	= pSettings->r_string(section,"idle_particles");
	if(pSettings->line_exist(section,"blowout_particles")) 
		m_sBlowoutParticles = pSettings->r_string(section,"blowout_particles");

	if(pSettings->line_exist(section,"accum_particles")) 
		m_sAccumParticles = pSettings->r_string(section,"accum_particles");

	if(pSettings->line_exist(section,"awake_particles")) 
		m_sAwakingParticles = pSettings->r_string(section,"awake_particles");
	

	if(pSettings->line_exist(section,"entrance_small_particles")) 
		m_sEntranceParticlesSmall = pSettings->r_string(section,"entrance_small_particles");
	if(pSettings->line_exist(section,"entrance_big_particles")) 
		m_sEntranceParticlesBig = pSettings->r_string(section,"entrance_big_particles");

	if(pSettings->line_exist(section,"hit_small_particles")) 
		m_sHitParticlesSmall = pSettings->r_string(section,"hit_small_particles");
	if(pSettings->line_exist(section,"hit_big_particles")) 
		m_sHitParticlesBig = pSettings->r_string(section,"hit_big_particles");

	if(pSettings->line_exist(section,"idle_small_particles")) 
		m_sIdleObjectParticlesBig = pSettings->r_string(section,"idle_big_particles");
	if(pSettings->line_exist(section,"idle_big_particles")) 
		m_sIdleObjectParticlesSmall = pSettings->r_string(section,"idle_small_particles");
	if(pSettings->line_exist(section,"idle_particles_dont_stop"))
		m_bIdleObjectParticlesDontStop=pSettings->r_bool(section,"idle_particles_dont_stop");

	if(pSettings->line_exist(section,"postprocess")) 
	{
		m_effector					= xr_new<CZoneEffector>();
		m_effector->Load			(pSettings->r_string(section,"postprocess"));
	};



	if(pSettings->line_exist(section,"blowout_particles_time")) 
	{
		m_dwBlowoutParticlesTime = pSettings->r_u32(section,"blowout_particles_time");
		if (s32(m_dwBlowoutParticlesTime)>m_StateTime[eZoneStateBlowout])	{
			m_dwBlowoutParticlesTime=m_StateTime[eZoneStateBlowout];
			Msg("! ERROR: invalid 'blowout_particles_time' in '%s'",section);
		}
	}
	else
		m_dwBlowoutParticlesTime = 0;

	if(pSettings->line_exist(section,"blowout_light_time")) 
	{
		m_dwBlowoutLightTime = pSettings->r_u32(section,"blowout_light_time");
		if (s32(m_dwBlowoutLightTime)>m_StateTime[eZoneStateBlowout])	{
			m_dwBlowoutLightTime=m_StateTime[eZoneStateBlowout];
			Msg("! ERROR: invalid 'blowout_light_time' in '%s'",section);
		}
	}
	else
		m_dwBlowoutLightTime = 0;

	if(pSettings->line_exist(section,"blowout_sound_time")) 
	{
		m_dwBlowoutSoundTime = pSettings->r_u32(section,"blowout_sound_time");
		if (s32(m_dwBlowoutSoundTime)>m_StateTime[eZoneStateBlowout])	{
			m_dwBlowoutSoundTime=m_StateTime[eZoneStateBlowout];
			Msg("! ERROR: invalid 'blowout_sound_time' in '%s'",section);
		}
	}
	else
		m_dwBlowoutSoundTime = 0;

	if(pSettings->line_exist(section,"blowout_explosion_time"))	{
		m_dwBlowoutExplosionTime = pSettings->r_u32(section,"blowout_explosion_time"); 
		if (s32(m_dwBlowoutExplosionTime)>m_StateTime[eZoneStateBlowout])	{
			m_dwBlowoutExplosionTime=m_StateTime[eZoneStateBlowout];
			Msg("! ERROR: invalid 'blowout_explosion_time' in '%s'",section);
		}
	}
	else
		m_dwBlowoutExplosionTime = 0;

	m_zone_flags.set(eBlowoutWind,  pSettings->r_bool(section,"blowout_wind"));
	if( m_zone_flags.test(eBlowoutWind) ){
		m_dwBlowoutWindTimeStart = pSettings->r_u32(section,"blowout_wind_time_start"); 
		m_dwBlowoutWindTimePeak = pSettings->r_u32(section,"blowout_wind_time_peak"); 
		m_dwBlowoutWindTimeEnd = pSettings->r_u32(section,"blowout_wind_time_end"); 
		R_ASSERT(m_dwBlowoutWindTimeStart < m_dwBlowoutWindTimePeak);
		R_ASSERT(m_dwBlowoutWindTimePeak < m_dwBlowoutWindTimeEnd);

		if((s32)m_dwBlowoutWindTimeEnd < m_StateTime[eZoneStateBlowout]){
			m_dwBlowoutWindTimeEnd =u32( m_StateTime[eZoneStateBlowout]-1);
			Msg("! ERROR: invalid 'blowout_wind_time_end' in '%s'",section);
		}

		
		m_fBlowoutWindPowerMax = pSettings->r_float(section,"blowout_wind_power");
	}

	//загрузить параметры световой вспышки от взрыва
	m_zone_flags.set(eBlowoutLight, pSettings->r_bool (section, "blowout_light"));

	if(m_zone_flags.test(eBlowoutLight) ){
		sscanf(pSettings->r_string(section,"light_color"), "%f,%f,%f", &m_LightColor.r, &m_LightColor.g, &m_LightColor.b);
		m_fLightRange			= pSettings->r_float(section,"light_range");
		m_fLightTime			= pSettings->r_float(section,"light_time");
		m_fLightTimeLeft		= 0;

		m_fLightHeight		= pSettings->r_float(section,"light_height");
	}

	//загрузить параметры idle подсветки
	m_zone_flags.set(eIdleLight,	pSettings->r_bool (section, "idle_light"));
	if( m_zone_flags.test(eIdleLight) )
	{
		m_fIdleLightRange = pSettings->r_float(section,"idle_light_range");
		m_fIdleLightRangeDelta = pSettings->r_float(section,"idle_light_range_delta");
		LPCSTR light_anim = pSettings->r_string(section,"idle_light_anim");
		m_pIdleLAnim	 = LALib.FindItem(light_anim);
		m_fIdleLightHeight = pSettings->r_float(section,"idle_light_height");
	}


	//загрузить параметры для разбрасывания артефактов
	m_zone_flags.set(eSpawnBlowoutArtefacts,	pSettings->r_bool(section,"spawn_blowout_artefacts"));
	if( m_zone_flags.test(eSpawnBlowoutArtefacts) )
	{
		m_fArtefactSpawnProbability	= pSettings->r_float (section,"artefact_spawn_probability");
		if(pSettings->line_exist(section,"artefact_spawn_particles")) 
			m_sArtefactSpawnParticles = pSettings->r_string(section,"artefact_spawn_particles");
		else
			m_sArtefactSpawnParticles = NULL;

		if(pSettings->line_exist(section,"artefact_born_sound"))
		{
			sound_str = pSettings->r_string(section,"artefact_born_sound");
			m_ArtefactBornSound.create(sound_str, st_Effect,sg_SourceType);
		}

		m_fThrowOutPower = pSettings->r_float (section,			"throw_out_power");
		m_fArtefactSpawnHeight = pSettings->r_float (section,	"artefact_spawn_height");

		LPCSTR						l_caParameters = pSettings->r_string(section, "artefacts");
		u16 m_wItemCount			= (u16)_GetItemCount(l_caParameters);
		R_ASSERT2					(!(m_wItemCount & 1),"Invalid number of parameters in string 'artefacts' in the 'system.ltx'!");
		m_wItemCount				>>= 1;

		m_ArtefactSpawn.clear();
		string512 l_caBuffer;

		float total_probability = 0.f;

		m_ArtefactSpawn.resize(m_wItemCount);
		for (u16 i=0; i<m_wItemCount; ++i) 
		{
			ARTEFACT_SPAWN& artefact_spawn = m_ArtefactSpawn[i];
			artefact_spawn.section = _GetItem(l_caParameters,i << 1,l_caBuffer);
			artefact_spawn.probability = (float)atof(_GetItem(l_caParameters,(i << 1) | 1,l_caBuffer));
			total_probability += artefact_spawn.probability;
		}

		R_ASSERT3(!fis_zero(total_probability), "The probability of artefact spawn is zero!",*cName());
		//нормализировать вероятности
		for(i=0; i<m_ArtefactSpawn.size(); ++i)
		{
			m_ArtefactSpawn[i].probability = m_ArtefactSpawn[i].probability/total_probability;
		}
	}
Beispiel #4
0
void CHW::CreateD3D	()
{
#ifndef DEDICATED_SERVER
	LPCSTR		_name			= "d3d9.dll";
#else
	LPCSTR		_name			= "xrd3d9-null.dll";
#endif

	hD3D9            			= LoadLibrary(_name);
	R_ASSERT2	           	 	(hD3D9,"Can't find 'd3d9.dll'\nPlease install latest version of DirectX before running this program");
    typedef IDirect3D9 * WINAPI _Direct3DCreate9(UINT SDKVersion);
	_Direct3DCreate9* createD3D	= (_Direct3DCreate9*)GetProcAddress(hD3D9,"Direct3DCreate9");	R_ASSERT(createD3D);
    this->pD3D 					= createD3D( D3D_SDK_VERSION );
    R_ASSERT2					(this->pD3D,"Please install DirectX 9.0c");
}
Beispiel #5
0
void game_sv_GameState::Create					(shared_str &options)
{
	string_path	fn_game;
	m_item_respawner.clear_respawns();
	if (FS.exist(fn_game, "$level$", "level.game")) 
	{
		IReader *F = FS.r_open	(fn_game);
		IReader *O = 0;

		// Load RPoints
		if (0!=(O = F->open_chunk	(RPOINT_CHUNK)))
		{ 
			for (int id=0; O->find_chunk(id); ++id)
			{
				RPoint					R;
				u8						team;
				u8						type;
				u16						GameType;
				shared_str				rp_profile;

				O->r_fvector3			(R.P);
				O->r_fvector3			(R.A);
				team					= O->r_u8	();	
				type					= O->r_u8	();
				GameType				= O->r_u16	();
				if(type==rptItemSpawn)
					O->r_stringZ		(rp_profile);

				if (GameType != EGameIDs(u16(-1)))
				{
					if ((Type() == eGameIDCaptureTheArtefact) && (GameType & eGameIDCaptureTheArtefact))
					{
						team = team - 1;
						R_ASSERT2( ((team >= 0) && (team < 4)) || 
							(type != rptActorSpawn), 
							"Problem with CTA Team indexes. Propably you have added rpoint of team 0 for cta game type.");
					}
					if ((!(GameType & eGameIDDeathmatch) && (Type() == eGameIDDeathmatch)) ||
						(!(GameType & eGameIDTeamDeathmatch) && (Type() == eGameIDTeamDeathmatch))	||
						(!(GameType & eGameIDArtefactHunt) && (Type() == eGameIDArtefactHunt)) ||
						(!(GameType & eGameIDCaptureTheArtefact) && (Type() == eGameIDCaptureTheArtefact))
						)
					{
						continue;
					};
				};
				switch (type)
				{
				case rptActorSpawn:
					{
						rpoints[team].push_back	(R);
						for (int i=0; i<int(rpoints[team].size())-1; i++)
						{
							RPoint rp = rpoints[team][i];
							float dist = R.P.distance_to_xz(rp.P)/2;
							if (dist<rpoints_MinDist[team])
								rpoints_MinDist[team] = dist;
							dist = R.P.distance_to(rp.P)/2;
							if (dist<rpoints_Dist[team])
								rpoints_Dist[team] = dist;
						};
					}break;
				case rptItemSpawn:
					{
						m_item_respawner.add_new_rpoint(rp_profile, R);
					}
				};
			};
			O->close();
		}

		FS.r_close	(F);
	}

	if (!g_dedicated_server)
	{
		// loading scripts
		ai().script_engine().remove_script_process(ScriptEngine::eScriptProcessorGame);
		string_path					S;
		FS.update_path				(S,"$game_config$","script.ltx");
		CInifile					*l_tpIniFile = xr_new<CInifile>(S);
		R_ASSERT					(l_tpIniFile);

		if( l_tpIniFile->section_exist( type_name() ) )
			if (l_tpIniFile->r_string(type_name(),"script"))
				ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",l_tpIniFile->r_string(type_name(),"script")));
			else
				ai().script_engine().add_script_process(ScriptEngine::eScriptProcessorGame,xr_new<CScriptProcess>("game",""));

		xr_delete					(l_tpIniFile);
	}

	//---------------------------------------------------------------------
	ConsoleCommands_Create();
	//---------------------------------------------------------------------
//	CCC_LoadCFG_custom*	pTmp = xr_new<CCC_LoadCFG_custom>("sv_");
//	pTmp->Execute				(Console->ConfigFile);
//	xr_delete					(pTmp);
	//---------------------------------------------------------------------
	LPCSTR		svcfg_ltx_name = "-svcfg ";
	if (strstr(Core.Params, svcfg_ltx_name))
	{
		string_path svcfg_name = "";
		int		sz = xr_strlen(svcfg_ltx_name);
		sscanf		(strstr(Core.Params,svcfg_ltx_name)+sz,"%[^ ] ",svcfg_name);
//		if (FS.exist(svcfg_name))
		{
			Console->ExecuteScript(svcfg_name);
		}
	};
	//---------------------------------------------------------------------
	ReadOptions(options);	
}
bool ESceneAIMapTool::LoadLTX(CInifile& ini)
{
	R_ASSERT(0);
	return true;
}
Beispiel #7
0
void xrCompressor::CompressOne(LPCSTR path)
{
	filesTOTAL		++;

	if (testSKIP(path))	
	{
		filesSKIP	++;
		printf		(" - a SKIP");
		Msg			("%-80s   - SKIP",path);
		return;
	}

	string_path		fn;				
	strconcat		(sizeof(fn), fn, target_name.c_str(), "\\", path);

	if (::GetFileAttributes(fn)==u32(-1))
	{
		filesSKIP	++;
		printf		(" - CAN'T OPEN");
		Msg			("%-80s   - CAN'T OPEN",path);
		return;
	}

	IReader*		src				=	FS.r_open	(fn);
	if (0==src)
	{
		filesSKIP	++;
		printf		(" - CAN'T OPEN");
		Msg			("%-80s   - CAN'T OPEN",path);
		return;
	}

	bytesSRC						+=	src->length	();
	u32			c_crc32				=	crc32		(src->pointer(),src->length());
	u32			c_ptr				=	0;
	u32			c_size_real			=	0;
	u32			c_size_compressed	=	0;
	u32			a_tests				=	0;

	ALIAS*		A					=	testALIAS	(src,c_crc32,a_tests);
	printf							("%3da ",a_tests);
	if(A) 
	{
		filesALIAS			++;
		printf				("ALIAS");
		Msg					("%-80s   - ALIAS (%s)",path,A->path);

		// Alias found
		c_ptr				= A->c_ptr;
		c_size_real			= A->c_size_real;
		c_size_compressed	= A->c_size_compressed;
	} else 
	{
		if (testVFS(path))	
		{
			filesVFS			++;

			// Write into BaseFS
			c_ptr				= fs_pack_writer->tell	();
			c_size_real			= src->length();
			c_size_compressed	= src->length();
			fs_pack_writer->w	(src->pointer(),c_size_real);
			printf				("VFS");
			Msg					("%-80s   - VFS",path);
		} else 
		{ //if(testVFS(path))
			// Compress into BaseFS
			c_ptr				=	fs_pack_writer->tell();
			c_size_real			=	src->length();
			if (0!=c_size_real)
			{
				u32 c_size_max		=	rtc_csize		(src->length());
				u8*	c_data			=	xr_alloc<u8>	(c_size_max);

				t_compress.Begin	();

				c_size_compressed	= c_size_max;
				if (bFast)
				{		
					R_ASSERT(LZO_E_OK == lzo1x_1_compress	((u8*)src->pointer(),c_size_real,c_data,&c_size_compressed,c_heap));
				}else
				{
					R_ASSERT(LZO_E_OK == lzo1x_999_compress	((u8*)src->pointer(),c_size_real,c_data,&c_size_compressed,c_heap));
				}

				t_compress.End		();

				if ((c_size_compressed+16) >= c_size_real)
				{
					// Failed to compress - revert to VFS
					filesVFS			++;
					c_size_compressed	= c_size_real;
					fs_pack_writer->w	(src->pointer(),c_size_real);
					printf				("VFS (R)");
					Msg					("%-80s   - VFS (R)",path);
				} else 
				{
					// Compressed OK - optimize
					if (!bFast)
					{
						u8*		c_out	= xr_alloc<u8>	(c_size_real);
						u32		c_orig	= c_size_real;
						R_ASSERT		(LZO_E_OK	== lzo1x_optimize	(c_data,c_size_compressed,c_out,&c_orig, NULL));
						R_ASSERT		(c_orig		== c_size_real		);
						xr_free			(c_out);
					}//bFast
					fs_pack_writer->w	(c_data,c_size_compressed);
					printf				("%3.1f%%",	100.f*float(c_size_compressed)/float(src->length()));
					Msg					("%-80s   - OK (%3.1f%%)",path,100.f*float(c_size_compressed)/float(src->length()));
				}

				// cleanup
				xr_free		(c_data);
			}else
			{ //0!=c_size_real
				filesVFS				++;
				c_size_compressed		= c_size_real;
				printf					("VFS (R)");
				Msg						("%-80s   - EMPTY FILE",path);
			}
		}//test VFS
	} //(A)

	// Write description
	write_file_header		(path,c_crc32,c_ptr,c_size_real,c_size_compressed);

	if (0==A)	
	{
		// Register for future aliasing
		ALIAS				R;
		R.path				= xr_strdup	(fn);
		R.crc				= c_crc32;
		R.c_ptr				= c_ptr;
		R.c_size_real		= c_size_real;
		R.c_size_compressed	= c_size_compressed;
		aliases.insert		(mk_pair(R.c_size_real,R));
	}

	FS.r_close	(src);
}
Beispiel #8
0
void CRT::create	(LPCSTR Name, u32 w, u32 h,	D3DFORMAT f)
{
	if (pSurface)	return;

	R_ASSERT	(HW.pDevice && Name && Name[0] && w && h);
	_order		= CPU::GetCLK()	;	//Device.GetTimerGlobal()->GetElapsed_clk();

	HRESULT		_hr;

	dwWidth		= w;
	dwHeight	= h;
	fmt			= f;

	// Get caps
	D3DCAPS9	caps;
	R_CHK		(HW.pDevice->GetDeviceCaps(&caps));

	// Pow2
	if (!btwIsPow2(w) || !btwIsPow2(h))
	{
		if (!HW.Caps.raster.bNonPow2)	return;
	}

	// Check width-and-height of render target surface
	if (w>caps.MaxTextureWidth)			return;
	if (h>caps.MaxTextureHeight)		return;

	// Select usage
	u32 usage	= 0;
	if (D3DFMT_D24X8==fmt)									usage = D3DUSAGE_DEPTHSTENCIL;
	else if (D3DFMT_D24S8		==fmt)						usage = D3DUSAGE_DEPTHSTENCIL;
	else if (D3DFMT_D15S1		==fmt)						usage = D3DUSAGE_DEPTHSTENCIL;
	else if (D3DFMT_D16			==fmt)						usage = D3DUSAGE_DEPTHSTENCIL;
	else if (D3DFMT_D16_LOCKABLE==fmt)						usage = D3DUSAGE_DEPTHSTENCIL;
	else if ((D3DFORMAT)MAKEFOURCC('D','F','2','4') == fmt)	usage = D3DUSAGE_DEPTHSTENCIL;
	else													usage = D3DUSAGE_RENDERTARGET;

	// Validate render-target usage
	_hr = HW.pD3D->CheckDeviceFormat(
		HW.DevAdapter,
		HW.DevT,
		HW.Caps.fTarget,
		usage,
		D3DRTYPE_TEXTURE,
		f
		);
	if (FAILED(_hr))					return;

	// Try to create texture/surface
	Device.Resources->Evict				();
	_hr = HW.pDevice->CreateTexture		(w, h, 1, usage, f, D3DPOOL_DEFAULT, &pSurface,NULL);
	if (FAILED(_hr) || (0==pSurface))	return;

	// OK
#ifdef DEBUG
	Msg			("* created RT(%s), %dx%d",Name,w,h);
#endif // DEBUG
	R_CHK		(pSurface->GetSurfaceLevel	(0,&pRT));
	pTexture	= Device.Resources->_CreateTexture	(Name);
	pTexture->surface_set	(pSurface);
}
Beispiel #9
0
//-----------------------------------------------------------------------
BOOL motions_value::load		(LPCSTR N, IReader *data, vecBones* bones)
{

	m_id						= N;

	bool bRes					= true;
	// Load definitions
	U16Vec rm_bones				(bones->size(),BI_NONE);
	IReader* MP 				= data->open_chunk(OGF_S_SMPARAMS);

	if (MP)
	{
		u16 vers 				= MP->r_u16();
		u16 part_bone_cnt		= 0;
		string128 				buf;
		R_ASSERT3				(vers<=xrOGF_SMParamsVersion,"Invalid OGF/OMF version:",N);
		
		// partitions
		u16						part_count;
		part_count 				= MP->r_u16();

		for (u16 part_i=0; part_i<part_count; part_i++)
		{
			CPartDef& PART		= m_partition[part_i];
			MP->r_stringZ		(buf,sizeof(buf));
			PART.Name			= _strlwr(buf);
			PART.bones.resize	(MP->r_u16());

			for (xr_vector<u32>::iterator b_it=PART.bones.begin(); b_it<PART.bones.end(); b_it++)
			{
				MP->r_stringZ	(buf,sizeof(buf));
				u16 m_idx 		= u16			(MP->r_u32());
				*b_it			= find_bone_id	(bones,buf);
#ifdef _EDITOR
				if (*b_it==BI_NONE )
                {
					bRes		= false;
					Msg			("! Can't find bone: '%s'", buf);
				}

				if (rm_bones.size() <= m_idx)
                {
					bRes		= false;
					Msg			("! Can't load: '%s' invalid bones count", N);
				}
#else
				VERIFY3			(*b_it!=BI_NONE,"Can't find bone:", buf);
#endif
				if (bRes)		rm_bones[m_idx] = u16(*b_it);
			}
			part_bone_cnt		= u16(part_bone_cnt + (u16)PART.bones.size());
		}

#ifdef _EDITOR
		if (part_bone_cnt!=(u16)bones->size()){
			bRes = false;
			Msg("! Different bone count[%s] [Object: '%d' <-> Motions: '%d']", N, bones->size(),part_bone_cnt);
		}
#else
		VERIFY3(part_bone_cnt==(u16)bones->size(),"Different bone count '%s'",N);
#endif
		if (bRes)
		{
			// motion defs (cycle&fx)
			u16 mot_count			= MP->r_u16();
            m_mdefs.resize			(mot_count);

			for (u16 mot_i=0; mot_i<mot_count; mot_i++)
			{
				MP->r_stringZ		(buf,sizeof(buf));
				shared_str nm		= _strlwr		(buf);
				u32 dwFlags			= MP->r_u32		();
				CMotionDef&	D		= m_mdefs[mot_i];
                D.Load				(MP,dwFlags,vers);
//.             m_mdefs.push_back	(D);
				
				if (dwFlags&esmFX)	
					m_fx.insert		(mk_pair(nm,mot_i));
				else				
					m_cycle.insert	(mk_pair(nm,mot_i));

                m_motion_map.insert	(mk_pair(nm,mot_i));
			}
		}
		MP->close();
	}else
	{
		xrDebug::Fatal	(DEBUG_INFO,"Old skinned model version unsupported! (%s)",N);
	}
	if (!bRes)	return false;

	// Load animation
	IReader*	MS		= data->open_chunk(OGF_S_MOTIONS);
	if (!MS) 			return false;

	u32			dwCNT	= 0;
	MS->r_chunk_safe	(0,&dwCNT,sizeof(dwCNT));
    VERIFY		(dwCNT<0x3FFF); // MotionID 2 bit - slot, 14 bit - motion index

	// set per bone motion size
	for (u32 i=0; i<bones->size(); i++)
		m_motions[bones->at(i)->name].resize(dwCNT);

	// load motions
	for (u16 m_idx=0; m_idx<(u16)dwCNT; m_idx++){
		string128			mname;
		R_ASSERT			(MS->find_chunk(m_idx+1));             
		MS->r_stringZ		(mname,sizeof(mname));
#ifdef _DEBUG        
		// sanity check
		xr_strlwr			(mname);
        accel_map::iterator I= m_motion_map.find(mname); 
        VERIFY3				(I!=m_motion_map.end(),"Can't find motion:",mname);
        VERIFY3				(I->second==m_idx,"Invalid motion index:",mname);
#endif
		u32 dwLen			= MS->r_u32();
		for (u32 i=0; i<bones->size(); i++){
			u16 bone_id		= rm_bones[i];
			VERIFY2			(bone_id!=BI_NONE,"Invalid remap index.");
			CMotion&		M	= m_motions[bones->at(bone_id)->name][m_idx];
			M.set_count			(dwLen);
			M.set_flags			(MS->r_u8());
            
            if (M.test_flag(flRKeyAbsent))	{
                CKeyQR* r 		= (CKeyQR*)MS->pointer();
				u32 crc_q		= crc32(r,sizeof(CKeyQR));
				M._keysR.create	(crc_q,1,r);
                MS->advance		(1 * sizeof(CKeyQR));
            }else{
                u32 crc_q		= MS->r_u32	();
                M._keysR.create	(crc_q,dwLen,(CKeyQR*)MS->pointer());
                MS->advance		(dwLen * sizeof(CKeyQR));
            }
            if (M.test_flag(flTKeyPresent))	
            {
                u32 crc_t		= MS->r_u32	();
                if(M.test_flag(flTKey16IsBit))
                {
                    M._keysT16.create	(crc_t,dwLen,(CKeyQT16*)MS->pointer());
                    MS->advance			(dwLen * sizeof(CKeyQT16));
                }else
                {
                    M._keysT8.create	(crc_t,dwLen,(CKeyQT8*)MS->pointer());
                    MS->advance			(dwLen * sizeof(CKeyQT8));
                };
                
                MS->r_fvector3	(M._sizeT);
                MS->r_fvector3	(M._initT);
            }else
            {
                MS->r_fvector3	(M._initT);
            }
		}
	}
//	Msg("Motions %d/%d %4d/%4d/%d, %s",p_cnt,m_cnt, m_load,m_total,m_r,N);
	MS->close();

	return bRes;
}
void ESceneAIMapTool::BuildNodes(bool bFromSelectedOnly)
{
	// begin
	m_Nodes.reserve	(1024*1024);

	// Initialize hash
//	hash_Initialize ();

    R_ASSERT(!m_Nodes.empty());
    // Estimate nodes
    Fvector	Pos,LevelSize;
    m_AIBBox.getsize	(LevelSize);
    float estimated_nodes	= (LevelSize.x/m_Params.fPatchSize)*(LevelSize.z/m_Params.fPatchSize);

    SPBItem* pb = UI->ProgressStart(1, "Building nodes...");
    // General cycle
    for (int k=0; k<(int)m_Nodes.size(); k++){
        SAINode* N 			= m_Nodes[k];
    	if (bFromSelectedOnly && !N->flags.is(SAINode::flSelected)) continue;
        // left 
        if (0==N->n1){
            Pos.set			(N->Pos);
            Pos.x			-=	m_Params.fPatchSize;
            N->n1			=	BuildNode(N->Pos,Pos,false);
        }
        // fwd
        if (0==N->n2){
            Pos.set			(N->Pos);
            Pos.z			+=	m_Params.fPatchSize;
            N->n2			=	BuildNode(N->Pos,Pos,false);
        }
        // right
        if (0==N->n3){
            Pos.set			(N->Pos);
            Pos.x			+=	m_Params.fPatchSize;
            N->n3			=	BuildNode(N->Pos,Pos,false);
        }
        // back
        if (0==N->n4){
            Pos.set			(N->Pos);
            Pos.z			-=	m_Params.fPatchSize;
            N->n4			=	BuildNode(N->Pos,Pos,false);
        }
    	if (bFromSelectedOnly){
	        // select neighbour nodes
            if (N->n1) N->n1->flags.set(SAINode::flSelected,TRUE);
            if (N->n2) N->n2->flags.set(SAINode::flSelected,TRUE);
            if (N->n3) N->n3->flags.set(SAINode::flSelected,TRUE);
            if (N->n4) N->n4->flags.set(SAINode::flSelected,TRUE);
        }
        
        if (k%512==0) {
            float	p1	= float(k)/float(m_Nodes.size());
            float	p2	= float(m_Nodes.size())/estimated_nodes;
            float	p	= 0.1f*p1+0.9f*p2;

            clamp	(p,0.f,1.f);
            pb->Update(p);
            // check need abort && redraw
            if (k%32768==0) UI->RedrawScene(true);
            if (UI->NeedAbort()) break;
        }
    }
    UI->ProgressEnd(pb);
}
void ESceneAIMapTool::SmoothNodes()
{
    SPBItem* pb = UI->ProgressStart(m_Nodes.size(), "Smoothing nodes...");

	AINodeVec	smoothed;	smoothed.reserve(m_Nodes.size());
	U8Vec		mark;		mark.assign		(m_Nodes.size(),0);

    int	sm_nodes=0;
    
    EnumerateNodes			();
	for (AINodeIt it=m_Nodes.begin(); it!=m_Nodes.end(); it++){
		SAINode& 	N 		= **it;
        Fvector		P1,P2,P3,P4,P,REF;
        int			c;

		if (N.flags.is(SAINode::flSelected)){
        	sm_nodes++;
        
            // smooth point LF
            {
                bool	bCorner	= false;

                c=1;	N.PointLF(REF,m_Params.fPatchSize);	P1.set(REF);
                if (N.nLeft()) {
                    SAINode& L = *N.nLeft();

                    L.PointFR(P,m_Params.fPatchSize);	merge(P1);
                    if (L.nForward()) {
                        bCorner = true;
                        SAINode& C = *L.nForward();

                        C.PointRB(P,m_Params.fPatchSize);	merge(P1);
                    }
                }
                if (N.nForward()) {
                    SAINode& F = *N.nForward();

                    F.PointBL(P,m_Params.fPatchSize);	merge(P1);
                    if ((!bCorner) && F.nLeft()) {
                        bCorner = true;

                        SAINode& C = *F.nLeft();
                        C.PointRB(P,m_Params.fPatchSize);	merge(P1);
                    }
                }
                R_ASSERT(c<=4);
                P1.div(float(c));
            }

            // smooth point FR
            {
                bool	bCorner = false;

                c=1;	N.PointFR(REF,m_Params.fPatchSize); P2.set(REF);
                if (N.nForward()) {
                    SAINode& F = *N.nForward();

                    F.PointRB(P,m_Params.fPatchSize);	merge(P2);
                    if (F.nRight()) {
                        bCorner = true;
                        SAINode& C = *F.nRight();

                        C.PointBL(P,m_Params.fPatchSize);	merge(P2);
                    }
                }
                if (N.nRight()) {
                    SAINode& R = *N.nRight();

                    R.PointLF(P,m_Params.fPatchSize);	merge(P2);
                    if ((!bCorner) && R.nForward()) {
                        bCorner = true;

                        SAINode& C = *R.nForward();
                        C.PointBL(P,m_Params.fPatchSize);	merge(P2);
                    }
                }
                R_ASSERT(c<=4);
                P2.div(float(c));
            }

            // smooth point RB
            {
                bool	bCorner = false;

                c=1;	N.PointRB(REF,m_Params.fPatchSize); P3.set(REF);
                if (N.nRight()) {
                    SAINode& R = *N.nRight();

                    R.PointBL(P,m_Params.fPatchSize);	merge(P3);
                    if (R.nBack()) {
                        bCorner = true;
                        SAINode& C = *R.nBack();

                        C.PointLF(P,m_Params.fPatchSize);	merge(P3);
                    }
                }
                if (N.nBack()) {
                    SAINode& B = *N.nBack();

                    B.PointFR(P,m_Params.fPatchSize);	merge(P3);
                    if ((!bCorner) && B.nRight()) {
                        bCorner = true;

                        SAINode& C = *B.nRight();
                        C.PointLF(P,m_Params.fPatchSize);	merge(P3);
                    }
                }
                R_ASSERT(c<=4);
                P3.div(float(c));
            }

            // smooth point BL
            {
                bool	bCorner = false;

                c=1;	N.PointBL(REF,m_Params.fPatchSize); P4.set(REF);
                if (N.nBack()) {
                    SAINode& B = *N.nBack();

                    B.PointLF(P,m_Params.fPatchSize);	merge(P4);
                    if (B.nLeft()) {
                        bCorner = true;
                        SAINode& C = *B.nLeft();

                        C.PointFR(P,m_Params.fPatchSize);	merge(P4);
                    }
                }
                if (N.nLeft()) {
                    SAINode& L = *N.nLeft();

                    L.PointRB(P,m_Params.fPatchSize);	merge(P4);
                    if ((!bCorner) && L.nBack()) {
                        bCorner = true;

                        SAINode& C = *L.nBack();
                        C.PointFR(P,m_Params.fPatchSize);	merge(P4);
                    }
                }
                R_ASSERT(c<=4);
                P4.div(float(c));
            }

            // align plane
            Fvector data[4]; data[0]=P1; data[1]=P2; data[2]=P3; data[3]=P4;
            Fvector vOffs,vNorm,D;
            vNorm.set(N.Plane.n);
            vOffs.set(N.Pos);
            Mgc::OrthogonalPlaneFit(
                4,(Mgc::Vector3*)data,
                *((Mgc::Vector3*)&vOffs),
                *((Mgc::Vector3*)&vNorm)
            );
            if (vNorm.y<0) vNorm.invert();
            // create _new node
            SAINode* NEW 	= xr_new<SAINode>(N);
            NEW->n1 		= (SAINode*)(N.n1?N.n1->idx:InvalidNode);
            NEW->n2 		= (SAINode*)(N.n2?N.n2->idx:InvalidNode);
            NEW->n3 		= (SAINode*)(N.n3?N.n3->idx:InvalidNode);
            NEW->n4 		= (SAINode*)(N.n4?N.n4->idx:InvalidNode);
            NEW->Plane.build(vOffs,vNorm);
            D.set			(0,1,0);
            N.Plane.intersectRayPoint(N.Pos,D,NEW->Pos);	// "project" position
            smoothed.push_back	(NEW);
        }else{
            // create _new node
            SAINode* NEW 	= xr_new<SAINode>(N);
            NEW->n1 		= (SAINode*)(N.n1?N.n1->idx:InvalidNode);
            NEW->n2 		= (SAINode*)(N.n2?N.n2->idx:InvalidNode);
            NEW->n3 		= (SAINode*)(N.n3?N.n3->idx:InvalidNode);
            NEW->n4 		= (SAINode*)(N.n4?N.n4->idx:InvalidNode);
            smoothed.push_back	(NEW);
        }

        int k = it-m_Nodes.begin();
        if (k%128==0) {
            pb->Update(k);
            if (UI->NeedAbort()) break;
        }
    }
    UI->ProgressEnd(pb);
    Clear				(true);
    m_Nodes 			= smoothed;
	DenumerateNodes		();
    hash_FillFromNodes	();

    UpdateHLSelected	();
    
	if (sm_nodes) 		Scene->UndoSave();
}
Beispiel #12
0
void	CKinematics::Load(const char* N, IReader *data, u32 dwFlags)
{
	//Msg				("skeleton: %s",N);
	inherited::Load	(N, data, dwFlags);

    pUserData		= NULL;
    m_lod			= NULL;
    // loading lods

	IReader* LD 	= data->open_chunk(OGF_S_LODS);
    if (LD)
	{
        string_path		short_name;
        strcpy_s		(short_name,sizeof(short_name),N);

        if (strext(short_name)) *strext(short_name)=0;
        // From stream
		{
			string_path		lod_name;
			LD->r_string	(lod_name, sizeof(lod_name));
//.         strconcat		(sizeof(name_load),name_load, short_name, ":lod:", lod_name.c_str());
            m_lod 			= ::Render->model_CreateChild(lod_name, NULL);
            VERIFY3(m_lod,"Cant create LOD model for", N);
//.			VERIFY2			(m_lod->Type==MT_HIERRARHY || m_lod->Type==MT_PROGRESSIVE || m_lod->Type==MT_NORMAL,lod_name.c_str());
/*
			strconcat		(name_load, short_name, ":lod:1");
            m_lod 			= ::Render->model_CreateChild(name_load,LD);
			VERIFY			(m_lod->Type==MT_SKELETON_GEOMDEF_PM || m_lod->Type==MT_SKELETON_GEOMDEF_ST);
*/
        }
        LD->close	();
    }

#ifndef _EDITOR    
	// User data
	IReader* UD 	= data->open_chunk(OGF_S_USERDATA);
    pUserData		= UD?xr_new<CInifile>(UD,FS.get_path("$game_config$")->m_Path):0;
    if (UD)			UD->close();
#endif

	// Globals
	bone_map_N		= xr_new<accel>		();
	bone_map_P		= xr_new<accel>		();
	bones			= xr_new<vecBones>	();
	bone_instances	= NULL;

	// Load bones
#pragma todo("container is created in stack!")
	xr_vector<shared_str>	L_parents;

	R_ASSERT		(data->find_chunk(OGF_S_BONE_NAMES));

    visimask.zero	();
	int dwCount 	= data->r_u32();
	// Msg				("!!! %d bones",dwCount);
	// if (dwCount >= 64)	Msg			("!!! More than 64 bones is a crazy thing! (%d), %s",dwCount,N);
	VERIFY3			(dwCount < 64, "More than 64 bones is a crazy thing!",N);
	for (; dwCount; dwCount--)		{
		string256	buf;

		// Bone
		u16			ID				= u16(bones->size());
		data->r_stringZ				(buf,sizeof(buf));	strlwr(buf);
		CBoneData* pBone 			= CreateBoneData(ID);
		pBone->name					= shared_str(buf);
		pBone->child_faces.resize	(children.size());
		bones->push_back			(pBone);
		bone_map_N->push_back		(mk_pair(pBone->name,ID));
		bone_map_P->push_back		(mk_pair(pBone->name,ID));

		// It's parent
		data->r_stringZ				(buf,sizeof(buf));	strlwr(buf);
		L_parents.push_back			(buf);

		data->r						(&pBone->obb,sizeof(Fobb));
        visimask.set				(u64(1)<<ID,TRUE);
	}
	std::sort	(bone_map_N->begin(),bone_map_N->end(),pred_sort_N);
	std::sort	(bone_map_P->begin(),bone_map_P->end(),pred_sort_P);

	// Attach bones to their parents
	iRoot = BI_NONE;
	for (u32 i=0; i<bones->size(); i++) {
		shared_str	P 		= L_parents[i];
		CBoneData* B	= (*bones)[i];
		if (!P||!P[0]) {
			// no parent - this is root bone
			R_ASSERT	(BI_NONE==iRoot);
			iRoot		= u16(i);
			B->SetParentID(BI_NONE);
			continue;
		} else {
			u16 ID		= LL_BoneID(P);
			R_ASSERT	(ID!=BI_NONE);
			(*bones)[ID]->children.push_back(B);
			B->SetParentID(ID);
		}
	}
	R_ASSERT	(BI_NONE != iRoot);

	// Free parents
    L_parents.clear();

    // IK data
	IReader* IKD 	= data->open_chunk(OGF_S_IKDATA);
    if (IKD){
        for (u32 i=0; i<bones->size(); i++) {
            CBoneData*	B 	= (*bones)[i];
            u16 vers		= (u16)IKD->r_u32();
            IKD->r_stringZ	(B->game_mtl_name);
            IKD->r			(&B->shape,sizeof(SBoneShape));
            B->IK_data.Import(*IKD,vers);
            Fvector vXYZ,vT;
            IKD->r_fvector3	(vXYZ);
            IKD->r_fvector3	(vT);
            B->bind_transform.setXYZi(vXYZ);
            B->bind_transform.translate_over(vT);
	        B->mass			= IKD->r_float();
    	    IKD->r_fvector3	(B->center_of_mass);
        }
        // calculate model to bone converting matrix
        (*bones)[LL_GetBoneRoot()]->CalculateM2B(Fidentity);
    	IKD->close();
    }

	// after load process
	{
		for (u16 child_idx=0; child_idx<(u16)children.size(); child_idx++)
			LL_GetChild(child_idx)->AfterLoad	(this,child_idx);
	}

	// unique bone faces
	{
		for (u32 bone_idx=0; bone_idx<bones->size(); bone_idx++) {
			CBoneData*	B 	= (*bones)[bone_idx];
			for (u32 child_idx=0; child_idx<children.size(); child_idx++){
				CBoneData::FacesVec faces		= B->child_faces[child_idx];
				std::sort						(faces.begin(),faces.end());
				CBoneData::FacesVecIt new_end	= std::unique(faces.begin(),faces.end());
				faces.erase						(new_end,faces.end());
				B->child_faces[child_idx].clear_and_free();
				B->child_faces[child_idx]		= faces;
			}
		}
	}

	// reset update_callback
	Update_Callback	= NULL;
	// reset update frame
	wm_frame		= u32(-1);

    LL_Validate		();
}
void xrMU_Reference::export_ogf()
{
	xr_vector<u32>		generated_ids;

	// Export nodes
	{
		for (xrMU_Model::v_subdivs_it it=model->m_subdivs.begin(); it!=model->m_subdivs.end(); it++)
		{
			OGF_Reference*	pOGF	= xr_new<OGF_Reference> ();
			b_material*		M		= &(pBuild->materials[it->material]);	// and it's material
			R_ASSERT		(M);

			// Common data
			pOGF->Sector			= sector;
			pOGF->material			= it->material;

			// Collect textures
			OGF_Texture				T;
			TRY(T.name		= pBuild->textures[M->surfidx].name);
			TRY(T.pSurface	= &(pBuild->textures[M->surfidx]));
			TRY(pOGF->textures.push_back(T));

			// Special
			pOGF->model				= it->ogf;
			pOGF->vb_id				= it->vb_id;
			pOGF->vb_start			= it->vb_start;
			pOGF->ib_id				= it->ib_id;
			pOGF->ib_start			= it->ib_start;
			pOGF->xform.set			(xform);
			pOGF->c_scale			= c_scale;
			pOGF->c_bias			= c_bias;
			pOGF->sw_id				= it->sw_id;

			pOGF->CalcBounds		();
			generated_ids.push_back	((u32)g_tree.size());
			g_tree.push_back		(pOGF);
		}
	}

	// Now, let's f**k with LODs
	if (u16(-1) == model->m_lod_ID)	return;
	{
		// Create Node and fill it with information
		b_lod&		LOD		= pBuild->lods	[model->m_lod_ID];
		OGF_LOD*	pNode	= xr_new<OGF_LOD> (1,sector);
		pNode->lod_Material	= LOD.dwMaterial;
		for (int lf=0; lf<8; lf++)
		{
			b_lod_face&		F = LOD.faces[lf];
			OGF_LOD::_face& D = pNode->lod_faces[lf];
			for (int lv=0; lv<4; lv++)
			{
				xform.transform_tiny(D.v[lv].v,F.v[lv]);
				D.v[lv].t			= F.t[lv];
				D.v[lv].c_rgb_hemi	= 0xffffffff;
				D.v[lv].c_sun		= 0xff;
			}
		}

		// Add all 'OGFs' with such LOD-id
		for (u32 o=0; o<generated_ids.size(); o++)
			pNode->AddChield(generated_ids[o]);

		// Register node
		R_ASSERT						(pNode->chields.size());
		pNode->CalcBounds				();
		g_tree.push_back				(pNode);

		// Calculate colors
		const float sm_range		= 5.f;
		for (int lf=0; lf<8; lf++)
		{
			OGF_LOD::_face& F = pNode->lod_faces[lf];
			for (int lv=0; lv<4; lv++)
			{
				Fvector	ptPos	= F.v[lv].v;

				base_color_c	_C;
				float 			_N	= 0;

				for (u32 v_it=0; v_it<model->m_vertices.size(); v_it++)
				{
					// get base
					Fvector			baseP;	xform.transform_tiny	(baseP,model->m_vertices[v_it]->P);
					base_color_c	baseC;	color[v_it]._get(baseC);

					base_color_c	vC;
					float			oD	= ptPos.distance_to	(baseP);
					float			oA  = 1/(1+100*oD*oD);
					vC = 			(baseC);
					vC.mul			(oA);
					_C.add			(vC);
					_N				+= oA;
				}

				float	s			= 1/(_N+EPS);
				_C.mul				(s);
				F.v[lv].c_rgb_hemi	= color_rgba(u8_clr(_C.rgb.x),u8_clr(_C.rgb.y),u8_clr(_C.rgb.z),u8_clr(_C.hemi));
				F.v[lv].c_sun		= u8_clr	(_C.sun);
			}
		}
	}
}
Beispiel #14
0
void CStepManager::reload(LPCSTR section)
{
	m_legs_count		= pSettings->r_u8		(section, "LegsCount");
	LPCSTR anim_section = pSettings->r_string	(section, "step_params");

	if (!pSettings->section_exist(anim_section))
	{
#ifdef	DEBUG
		Msg( "! no step_params section for :%s section :s", m_object->cName().c_str(), section );
#endif
		return;
	}
	VERIFY((m_legs_count>=MIN_LEGS_COUNT) && (m_legs_count<=MAX_LEGS_COUNT));

	SStepParam			param; 
	param.step[0].time = 0.1f;	// avoid warning

	LPCSTR				anim_name, val;
	string16			cur_elem;

	IKinematicsAnimated	*skeleton_animated = smart_cast<IKinematicsAnimated*>(m_object->Visual());

	VERIFY3(skeleton_animated, "object is not animated", m_object->cNameVisual().c_str());
#ifdef	DEBUG
		if( debug_step_info_load )
			Msg( "loading step_params for object :%s, visual: %s, section: %s, step_params section: %s  ", m_object->cName().c_str(), m_object->cNameVisual().c_str(), section, anim_section );
#endif

	for (u32 i=0; pSettings->r_line(anim_section,i,&anim_name,&val); ++i) {
		_GetItem (val,0,cur_elem);

		param.cycles = u8(atoi(cur_elem));
		R_ASSERT(param.cycles >= 1);

		for (u32 j=0;j<m_legs_count;j++) {
			_GetItem	(val,1+j*2,		cur_elem);		param.step[j].time	= float(atof(cur_elem));
			_GetItem	(val,1+j*2+1,	cur_elem);		param.step[j].power	= float(atof(cur_elem));
			VERIFY		(_valid(param.step[j].power));			
		}
		
		MotionID motion_id = skeleton_animated->ID_Cycle_Safe(anim_name);
		if (!motion_id) 
		{
#ifdef	DEBUG

			IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated*>(m_object->Visual());
			VERIFY( KA );
			
			Msg( "! (CStepManager::reload) no anim :%s object:%s, visual: %s, step_params section: %s ", anim_name, m_object->cName().c_str(), m_object->cNameVisual().c_str(), anim_section );

#endif		
			continue;
		}
#ifdef	DEBUG
		if( debug_step_info_load )
		{
			IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated*>(m_object->Visual());
			VERIFY( KA );
			std::pair<LPCSTR,LPCSTR> anim_name = KA->LL_MotionDefName_dbg( motion_id );
			Msg( "step_params loaded for object :%s, visual: %s, motion: %s, anim set: %s  ", m_object->cName().c_str(), m_object->cNameVisual().c_str(), anim_name.first, anim_name.second );
		}
#endif
		m_steps_map.insert(mk_pair(motion_id, param));
	}

#ifdef	DEBUG
	if( m_steps_map.empty() )
		Msg( "! no steps info loaded for :%s, section :s, step_params section: %s ", m_object->cName().c_str(), section, anim_section );
#endif
	// reload foot bones
	for (u32 i = 0; i < MAX_LEGS_COUNT; i++) m_foot_bones[i] = BI_NONE;
	reload_foot_bones	();

	
	m_time_anim_started	= 0;
	m_blend				= 0;
}
Beispiel #15
0
Shader*	CResourceManager::_cpp_Create	(IBlender* B, LPCSTR s_shader, LPCSTR s_textures, LPCSTR s_constants, LPCSTR s_matrices)
{
	CBlender_Compile	C;
	Shader				S;

	//.
	// if (strstr(s_shader,"transparent"))	__asm int 3;

	// Access to template
	C.BT				= B;
	C.bEditor			= FALSE;
	C.bDetail			= FALSE;
#ifdef _EDITOR
	if (!C.BT)			{ ELog.Msg(mtError,"Can't find shader '%s'",s_shader); return 0; }
	C.bEditor			= TRUE;
#endif

	// Parse names
	_ParseList			(C.L_textures,	s_textures	);
	_ParseList			(C.L_constants,	s_constants	);
	_ParseList			(C.L_matrices,	s_matrices	);

	// Compile element	(LOD0 - HQ)
	{
		C.iElement			= 0;		
#if defined(DEBUG) && _SECURE_SCL		
#pragma message("alpet: вылету здесь удивляться не стоит")
		R_ASSERT(C.L_textures._Myfirst);
		R_ASSERT(C.L_textures._Myproxy);
#endif		
		C.bDetail			= m_textures_description.GetDetailTexture(C.L_textures[0],C.detail_texture,C.detail_scaler);
//.		C.bDetail			= _GetDetailTexture(*C.L_textures[0],C.detail_texture,C.detail_scaler);
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[0]				= _CreateElement	(E);
	}

	// Compile element	(LOD1)
	{
		C.iElement			= 1;
//.		C.bDetail			= _GetDetailTexture(*C.L_textures[0],C.detail_texture,C.detail_scaler);
		C.bDetail			= m_textures_description.GetDetailTexture(C.L_textures[0],C.detail_texture,C.detail_scaler);
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[1]				= _CreateElement	(E);
	}

	// Compile element
	{
		C.iElement			= 2;
		C.bDetail			= FALSE;
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[2]				= _CreateElement	(E);
	}

	// Compile element
	{
		C.iElement			= 3;
		C.bDetail			= FALSE;
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[3]				= _CreateElement	(E);
	}

	// Compile element
	{
		C.iElement			= 4;
		C.bDetail			= TRUE;	//.$$$ HACK :)
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[4]				= _CreateElement	(E);
	}

	// Compile element
	{
		C.iElement			= 5;
		C.bDetail			= FALSE;
		ShaderElement		E;
		C._cpp_Compile		(&E);
		S.E[5]				= _CreateElement	(E);
	}

	// Search equal in shaders array
	for (u32 it=0; it<v_shaders.size(); it++)
		if (S.equal(v_shaders[it]))	return v_shaders[it];

	// Create _new_ entry
	Shader*		N			=	xr_new<Shader>(S);
	N->dwFlags				|=	xr_resource_flagged::RF_REGISTERED;
	v_shaders.push_back		(N);
	return N;
}
Beispiel #16
0
void CUIStatsWnd::SelectItem(const u32 uItem)
{
	R_ASSERT(static_cast<int>(uItem) < UIStatsList.GetItemsCount());
	UIStatsList.SetFocusedItem(static_cast<signed int>(uItem));
}
Beispiel #17
0
u32 attachable_hud_item::anim_play(const shared_str& anm_name_b, BOOL bMixIn, const CMotionDef*& md, u8& rnd_idx)
{
	float speed				= CalcMotionSpeed(anm_name_b);

	R_ASSERT				(strstr(anm_name_b.c_str(),"anm_")==anm_name_b.c_str());
	string256				anim_name_r;
	bool is_16x9			= UI().is_widescreen();
	xr_sprintf				(anim_name_r,"%s%s",anm_name_b.c_str(),((m_attach_place_idx==1)&&is_16x9)?"_16x9":"");

	player_hud_motion* anm	= m_hand_motions.find_motion(anim_name_r);
	R_ASSERT2				(anm, make_string("model [%s] has no motion alias defined [%s]", m_sect_name.c_str(), anim_name_r).c_str());
	R_ASSERT2				(anm->m_animations.size(), make_string("model [%s] has no motion defined in motion_alias [%s]", pSettings->r_string(m_sect_name, "item_visual"), anim_name_r).c_str());
	
	rnd_idx					= (u8)Random.randI(anm->m_animations.size()) ;
	const motion_descr& M	= anm->m_animations[ rnd_idx ];

	u32 ret					= g_player_hud->anim_play(m_attach_place_idx, M.mid, bMixIn, md, speed);
	
	if(m_model->dcast_PKinematicsAnimated())
	{
		IKinematicsAnimated* ka			= m_model->dcast_PKinematicsAnimated();

		shared_str item_anm_name;
		if(anm->m_base_name!=anm->m_additional_name)
			item_anm_name = anm->m_additional_name;
		else
			item_anm_name = M.name;

		MotionID M2						= ka->ID_Cycle_Safe(item_anm_name);
		if(!M2.valid())
			M2							= ka->ID_Cycle_Safe("idle");
		else
			if(bDebug)
				Msg						("playing item animation [%s]",item_anm_name.c_str());
		
		R_ASSERT3(M2.valid(),"model has no motion [idle] ", pSettings->r_string(m_sect_name, "item_visual"));

		u16 root_id						= m_model->LL_GetBoneRoot();
		CBoneInstance& root_binst		= m_model->LL_GetBoneInstance(root_id);
		root_binst.set_callback_overwrite(TRUE);
		root_binst.mTransform.identity	();

		u16 pc							= ka->partitions().count();
		for(u16 pid=0; pid<pc; ++pid)
		{
			CBlend* B					= ka->PlayCycle(pid, M2, bMixIn);
			R_ASSERT					(B);
			B->speed					*= speed;
		}

		m_model->CalculateBones_Invalidate	();
	}

	R_ASSERT2		(m_parent_hud_item, "parent hud item is NULL");
	CPhysicItem&	parent_object = m_parent_hud_item->object();
	//R_ASSERT2		(parent_object, "object has no parent actor");
	//CObject*		parent_object = static_cast_checked<CObject*>(&m_parent_hud_item->object());

	if (IsGameTypeSingle() && parent_object.H_Parent() == Level().CurrentControlEntity())
	{
		CActor* current_actor	= static_cast_checked<CActor*>(Level().CurrentControlEntity());
		VERIFY					(current_actor);
		CEffectorCam* ec		= current_actor->Cameras().GetCamEffector(eCEWeaponAction);

	
		if(NULL==ec)
		{
			string_path			ce_path;
			string_path			anm_name;
			strconcat			(sizeof(anm_name),anm_name,"camera_effects\\weapon\\", M.name.c_str(),".anm");
			if (FS.exist( ce_path, "$game_anims$", anm_name))
			{
				CAnimatorCamEffector* e		= xr_new<CAnimatorCamEffector>();
				e->SetType					(eCEWeaponAction);
				e->SetHudAffect				(false);
				e->SetCyclic				(false);
				e->Start					(anm_name);
				current_actor->Cameras().AddCamEffector(e);
			}
		}
	}
	return ret;
}
Beispiel #18
0
void CUIStatsListItem::SetSubItemColor(u32 uItemIndex, u32 uColor)
{
	R_ASSERT(uItemIndex < FieldsVector.size());
	FieldsVector[uItemIndex]->SetTextColor(uColor);
}
void SAINode::LoadLTX(CInifile& ini, LPCSTR sect_name, ESceneAIMapTool* tools)
{
	R_ASSERT(0);
}
Beispiel #20
0
void xrServer::Process_event	(NET_Packet& P, ClientID sender)
{
#	ifdef SLOW_VERIFY_ENTITIES
			VERIFY					(verify_entities());
#	endif

	u32			timestamp;
	u16			type;
	u16			destination;
	u32			MODE			= net_flags(TRUE,TRUE);

	// correct timestamp with server-unique-time (note: direct message correction)
	P.r_u32		(timestamp	);

	// read generic info
	P.r_u16		(type		);
	P.r_u16		(destination);

	CSE_Abstract*	receiver	= game->get_entity_from_eid	(destination);
	if (receiver)	
	{
		R_ASSERT(receiver->owner);
		receiver->OnEvent						(P,type,timestamp,sender);

	};

	switch		(type)
	{
	case GE_GAME_EVENT:
		{
			u16		game_event_type;
			P.r_u16(game_event_type);
			game->AddDelayedEvent(P,game_event_type,timestamp,sender);
		}break;
	case GE_INFO_TRANSFER:
	case GE_WPN_STATE_CHANGE:
	case GE_ZONE_STATE_CHANGE:
	case GE_ACTOR_JUMPING:
	case GEG_PLAYER_PLAY_HEADSHOT_PARTICLE:
	case GEG_PLAYER_ATTACH_HOLDER:
	case GEG_PLAYER_DETACH_HOLDER:
	case GEG_PLAYER_ITEM2SLOT:
	case GEG_PLAYER_ITEM2BELT:
	case GEG_PLAYER_ITEM2RUCK:
	case GE_GRENADE_EXPLODE:
		{
		SendBroadcast			(BroadcastCID,P,MODE);
		}break;
	case GEG_PLAYER_ACTIVATEARTEFACT:
		{
			Process_event_activate	(P,sender,timestamp,destination,P.r_u16(), true);
			break;
		};
	case GE_INV_ACTION:
		{
			xrClientData* CL		= ID_to_client(sender);
			if (CL)	CL->net_Ready	= TRUE;
			if (SV_Client) SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE));
		}break;
	case GE_RESPAWN:
		{
			CSE_Abstract*		E	= receiver;
			if (E) 
			{
				R_ASSERT			(E->s_flags.is(M_SPAWN_OBJECT_PHANTOM));

				svs_respawn			R;
				R.timestamp			= timestamp	+ E->RespawnTime*1000;
				R.phantom			= destination;
				q_respawn.insert	(R);
			}
		}
		break;
	case GE_TRADE_BUY:
	case GE_OWNERSHIP_TAKE:
		{
			Process_event_ownership	(P,sender,timestamp,destination);
			VERIFY					(verify_entities());
		}break;
	case GE_OWNERSHIP_TAKE_MP_FORCED:
		{
			Process_event_ownership	(P,sender,timestamp,destination,TRUE);
			VERIFY					(verify_entities());
		}break;
	case GE_TRADE_SELL:
	case GE_OWNERSHIP_REJECT:
	case GE_LAUNCH_ROCKET:
		{
			Process_event_reject	(P,sender,timestamp,destination,P.r_u16());
			VERIFY					(verify_entities());
		}break;
	case GE_DESTROY:
		{
			Process_event_destroy	(P,sender,timestamp,destination, NULL);
			VERIFY					(verify_entities());
		}
		break;
	case GE_TRANSFER_AMMO:
		{
			u16					id_entity;
			P.r_u16				(id_entity);
			CSE_Abstract*		e_parent	= receiver;	// кто забирает (для своих нужд)
			CSE_Abstract*		e_entity	= game->get_entity_from_eid	(id_entity);	// кто отдает
			if (!e_entity)		break;
			if (0xffff != e_entity->ID_Parent)	break;						// this item already taken
			xrClientData*		c_parent	= e_parent->owner;
			xrClientData*		c_from		= ID_to_client	(sender);
			R_ASSERT			(c_from == c_parent);						// assure client ownership of event

			// Signal to everyone (including sender)
			SendBroadcast		(BroadcastCID,P,MODE);

			// Perfrom real destroy
			entity_Destroy		(e_entity	);
			VERIFY				(verify_entities());
		}
		break;
	case GE_HIT:
	case GE_HIT_STATISTIC:
		{
			P.r_pos -=2;
			if (type == GE_HIT_STATISTIC) 
			{
				P.B.count -= 4;
				P.w_u32(sender.value());
			};
			game->AddDelayedEvent(P,GAME_EVENT_ON_HIT, 0, ClientID() );
		} break;
	case GE_ASSIGN_KILLER: {
		u16							id_src;
		P.r_u16						(id_src);
		
		CSE_Abstract				*e_dest = receiver;	// кто умер
		// this is possible when hit event is sent before destroy event
		if (!e_dest)
			break;

		CSE_ALifeCreatureAbstract	*creature = smart_cast<CSE_ALifeCreatureAbstract*>(e_dest);
		if (creature)
			creature->set_killer_id( id_src );

//		Msg							("[%d][%s] killed [%d][%s]",id_src,id_src==u16(-1) ? "UNKNOWN" : game->get_entity_from_eid(id_src)->name_replace(),id_dest,e_dest->name_replace());

		break;
	}
	case GE_CHANGE_VISUAL:
		{
			CSE_Visual* visual		= smart_cast<CSE_Visual*>(receiver); VERIFY(visual);
			string256 tmp;
			P.r_stringZ				(tmp);
			visual->set_visual		(tmp);
		}break;
	case GE_DIE:
		{
			// Parse message
			u16					id_dest		=	destination, id_src;
			P.r_u16				(id_src);


			xrClientData *l_pC	= ID_to_client(sender);
			VERIFY				(game && l_pC);
#ifndef MASTER_GOLD
			if ((game->Type() != eGameIDSingle) && l_pC && l_pC->owner)
			{
				Msg					("* [%2d] killed by [%2d] - sended by [%s:%2d]", id_dest, id_src, game->get_option_s(*l_pC->name,"name","Player"), l_pC->owner->ID);
			}
#endif // #ifndef MASTER_GOLD

			CSE_Abstract*		e_dest		= receiver;	// кто умер
			// this is possible when hit event is sent before destroy event
			if (!e_dest)
				break;

#ifndef MASTER_GOLD
			if (game->Type() != eGameIDSingle)
				Msg				("* [%2d] is [%s:%s]", id_dest, *e_dest->s_name, e_dest->name_replace());
#endif // #ifndef MASTER_GOLD

			CSE_Abstract*		e_src		= game->get_entity_from_eid	(id_src	);	// кто убил
			if (!e_src) {
				xrClientData*	C = (xrClientData*)	game->get_client(id_src);
				if (C) e_src = C->owner;
			};
			VERIFY				(e_src);
			if (!e_src)
			{
				Msg("! ERROR: SV: src killer not exist.");
				return;
			}
//			R_ASSERT2			(e_dest && e_src, "Killer or/and being killed are offline or not exist at all :(");
#ifndef MASTER_GOLD
			if (game->Type() != eGameIDSingle)
				Msg				("* [%2d] is [%s:%s]", id_src, *e_src->s_name, e_src->name_replace());
#endif // #ifndef MASTER_GOLD

			game->on_death		(e_dest,e_src);

			xrClientData*		c_src		= e_src->owner;				// клиент, чей юнит убил

			if (c_src->owner->ID == id_src) {
				// Main unit
				P.w_begin			(M_EVENT);
				P.w_u32				(timestamp);
				P.w_u16				(type);
				P.w_u16				(destination);
				P.w_u16				(id_src);
				P.w_clientID		(c_src->ID);
			}

			SendBroadcast			(BroadcastCID,P,MODE);

			//////////////////////////////////////////////////////////////////////////
			// 
			if (game->Type() == eGameIDSingle) {
				P.w_begin			(M_EVENT);
				P.w_u32				(timestamp);
				P.w_u16				(GE_KILL_SOMEONE);
				P.w_u16				(id_src);
				P.w_u16				(destination);
				SendTo				(c_src->ID, P, net_flags(TRUE, TRUE));
			}
			//////////////////////////////////////////////////////////////////////////

			VERIFY					(verify_entities());
		}
		break;
	case GE_ADDON_ATTACH:
	case GE_ADDON_DETACH:
	case GE_CHANGE_POS:
		{			
			SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE));
		}break;
	case GE_INSTALL_UPGRADE:
		{
			shared_str				upgrade_id;
			P.r_stringZ				( upgrade_id );
			CSE_ALifeInventoryItem* iitem = smart_cast<CSE_ALifeInventoryItem*>( receiver );
			if ( !iitem )
			{
				break;
			}
			iitem->add_upgrade		( upgrade_id );
		}break;

	case GEG_PLAYER_DISABLE_SPRINT:
	case GEG_PLAYER_WEAPON_HIDE_STATE:
		{
			SendTo		(SV_Client->ID, P, net_flags(TRUE, TRUE));

#	ifdef SLOW_VERIFY_ENTITIES
			VERIFY					(verify_entities());
#	endif
		}break;
	case GEG_PLAYER_ACTIVATE_SLOT:
	case GEG_PLAYER_ITEM_EAT:
		{
			SendTo(SV_Client->ID, P, net_flags(TRUE, TRUE));
#	ifdef SLOW_VERIFY_ENTITIES
			VERIFY					(verify_entities());
#	endif
		}break;	
	case GEG_PLAYER_ITEM_SELL:
		{
			game->OnPlayer_Sell_Item(sender, P);
		}break;
	case GE_TELEPORT_OBJECT:
		{
			game->teleport_object	(P,destination);
		}break;
	case GE_ADD_RESTRICTION:
		{
			game->add_restriction	(P,destination);
		}break;
	case GE_REMOVE_RESTRICTION:
		{
			game->remove_restriction(P,destination);
		}break;
	case GE_REMOVE_ALL_RESTRICTIONS:
		{
			game->remove_all_restrictions(P,destination);
		}break;
	case GE_MONEY:
		{
			CSE_Abstract				*e_dest = receiver;
			CSE_ALifeTraderAbstract*	pTa = smart_cast<CSE_ALifeTraderAbstract*>(e_dest);
			pTa->m_dwMoney				= P.r_u32();
						
		}break;
	case GE_FREEZE_OBJECT:
		break;
	default:
		R_ASSERT2	(0,"Game Event not implemented!!!");
		break;
	}
}
Beispiel #21
0
void CBuild::BuildSectors()
{
	Status("Determining sectors...");
	Progress(0);
	u32 SectorMax=0;
	for (u32 I=0; I<g_tree.size(); I++)
		if (g_tree[I]->Sector>SectorMax) SectorMax=g_tree[I]->Sector;
	R_ASSERT(SectorMax<0xffff);

	u32 SectorCount = SectorMax+1; 
	g_sectors.resize(SectorCount);
	ZeroMemory(&*g_sectors.begin(),(u32)g_sectors.size()*sizeof(void*));
	clMsg("%d sectors accepted.",SectorCount);

	Status("Spatializing geometry...");
	for (u32 I=0; I<g_tree.size(); I++)
	{
		u32 Sector = g_tree[I]->Sector;
		if (0==g_sectors[Sector]) g_sectors[Sector] = xr_new<CSector> (Sector);
	}

	Status("Building hierrarhy...");
	for (u32 I=0; I<g_sectors.size(); I++)
	{
		R_ASSERT(g_sectors[I]);
		g_sectors[I]->BuildHierrarhy();
		Progress(float(I)/float(g_sectors.size()));
	}

	Status("Assigning portals, occluders, glows, lights...");
	// portals
	for (u32 I=0; I<portals.size(); I++)
	{
		b_portal &P = portals[I];
		R_ASSERT(u32(P.sector_front)<g_sectors.size());
		R_ASSERT(u32(P.sector_back) <g_sectors.size());
		g_sectors[u32(P.sector_front)]->add_portal	(u16(I));
		g_sectors[u32(P.sector_back)]->add_portal		(u16(I));
	}
	// glows
	for (u32 I=0; I<glows.size(); I++)
	{
		b_glow		&G = glows[I];
		b_material	&M = materials[G.dwMaterial];
		R_ASSERT(M.sector<g_sectors.size());
		g_sectors[M.sector]->add_glow			(u16(I));
	}
	// lights
	for (u32 I=0; I<L_dynamic.size(); I++)
	{
		b_light_dynamic	&L = L_dynamic[I];
		if (L.data.type == D3DLIGHT_DIRECTIONAL)
		{
			for (u32 j=0; j<g_sectors.size(); j++)
			{
				R_ASSERT(g_sectors[j]);
				g_sectors[j]->add_light(u16(I));
			}
		} else {
			if	(L.sectors.size()) {
				for (u32 j=0; j<L.sectors.size(); j++)
				{
					R_ASSERT	(L.sectors[j]<g_sectors.size());
					g_sectors	[L.sectors[j]]->add_light(u16(I));
				}
			} else {
				clMsg("F**k!!! Light at position %f,%f,%f non associated!!!",
					L.data.position.x,L.data.position.y,L.data.position.z
					);
			}
		}
	}
}
bool ESceneObjectTool::ExportBreakableObjects(SExportStreams* F)
{
	bool bResult = true;
    CGeomPartExtractor* extractor=0;

    Fbox 		bb;
    if (!GetBox(bb)) return false;

    extractor	= xr_new<CGeomPartExtractor>();
    extractor->Initialize(bb,EPS_L,2);

    UI->SetStatus	("Export breakable objects...");
	// collect verts&&faces
    {
	    SPBItem* pb = UI->ProgressStart(m_Objects.size(),"Prepare geometry...");
        for (ObjectIt it=m_Objects.begin(); it!=m_Objects.end(); it++){
	        pb->Inc();
            CSceneObject* obj 		= dynamic_cast<CSceneObject*>(*it); VERIFY(obj);
            if (obj->IsStatic()){
                CEditableObject *O 	= obj->GetReference();
                const Fmatrix& T 	= obj->_Transform();
                for(EditMeshIt M=O->FirstMesh();M!=O->LastMesh();M++)
                    if (!build_mesh	(T,*M,extractor,SGameMtl::flBreakable,FALSE)){bResult=false;break;}
            }
        }
	    UI->ProgressEnd(pb);
    }
    if (!extractor->Process())		bResult = false;
    // export parts
    if (bResult){
    	SBPartVec& parts			= extractor->GetParts();
	    SPBItem* pb = UI->ProgressStart(parts.size(),"Export Parts...");
        for (SBPartVecIt p_it=parts.begin(); p_it!=parts.end(); p_it++){
	        pb->Inc();
            SBPart*	P				= *p_it;
        	if (P->Valid()){
                // export visual
                AnsiString sn		= AnsiString().sprintf("meshes\\brkbl#%d.ogf",(p_it-parts.begin()));
                xr_string fn		= Scene->LevelPath()+sn.c_str();
                IWriter* W			= FS.w_open(fn.c_str()); R_ASSERT(W);
                if (!P->Export(*W,1)){
                    ELog.DlgMsg		(mtError,"Invalid breakable object.");
                    bResult 		= false;
                    break;
                }
                FS.w_close			(W);
                // export spawn object
                {
                    AnsiString entity_ref		= "breakable_object";
                    ISE_Abstract*	m_Data		= create_entity(entity_ref.c_str()); 	VERIFY(m_Data);
                    CSE_Visual* m_Visual		= m_Data->visual();	VERIFY(m_Visual);
                    // set params
                    m_Data->set_name			(entity_ref.c_str());
                    m_Data->set_name_replace	(sn.c_str());
                    m_Data->position().set		(P->m_RefOffset);
                    m_Data->angle().set			(P->m_RefRotate);
                    m_Visual->set_visual		(sn.c_str(),false);

					if (s_draw_dbg){
                        Fmatrix MX;
                        MX.setXYZi				(P->m_RefRotate);
                        MX.translate_over		(P->m_RefOffset);
                        Fvector DR				= {0,0,1};
                        MX.transform_dir		(DR);
                        Tools->m_DebugDraw.AppendLine(P->m_RefOffset,Fvector().mad(P->m_RefOffset,MX.k,1.f),0xFF0000FF,false,false);
                    }

                    NET_Packet					Packet;
                    m_Data->Spawn_Write			(Packet,TRUE);

                    F->spawn.stream.open_chunk	(F->spawn.chunk++);
                    F->spawn.stream.w			(Packet.B.data,Packet.B.count);
                    F->spawn.stream.close_chunk	();
                    destroy_entity				(m_Data);
                }
            }else{
            	ELog.Msg(mtError,"Can't export invalid part #%d",p_it-parts.begin());
            }
        }
	    UI->ProgressEnd(pb);
    }
    // clean up
    xr_delete(extractor);

    return bResult;
}
Beispiel #23
0
void CKinematicsAnimated::Load(const char* N, IReader *data, u32 dwFlags)
{
	inherited::Load	(N, data, dwFlags);

	// Globals
	blend_instances		= NULL;
    m_Partition			= NULL;
	Update_LastTime 	= 0;

	// Load animation
    if (data->find_chunk(OGF_S_MOTION_REFS)){
    	string_path		items_nm;
        data->r_stringZ	(items_nm,sizeof(items_nm));
        u32 set_cnt		= _GetItemCount(items_nm);
        R_ASSERT		(set_cnt<MAX_ANIM_SLOT);
		m_Motions.reserve(set_cnt);
    	string_path		nm;
        for (u32 k=0; k<set_cnt; k++){
        	_GetItem	(items_nm,k,nm);
            strcat		(nm,".omf");
            string_path	fn;
            if (!FS.exist(fn, "$level$", nm)){
                if (!FS.exist(fn, "$game_meshes$", nm)){
#ifdef _EDITOR
                    Msg			("!Can't find motion file '%s'.",nm);
                    return;
#else            
                    Debug.fatal	(DEBUG_INFO,"Can't find motion file '%s'.",nm);
#endif
                }
            }
            // Check compatibility
            m_Motions.push_back				(SMotionsSlot());
            if( !g_pMotionsContainer->has(nm) ) //optimize fs operations
			{
				IReader* MS						= FS.r_open(fn);
				m_Motions.back().motions.create	(nm,MS,bones);
				FS.r_close						(MS);
			}
			m_Motions.back().motions.create	(nm,NULL,bones);
    	}
    }else{
		string_path	nm;
		strconcat			(sizeof(nm),nm,N,".ogf");
		m_Motions.push_back(SMotionsSlot());
		m_Motions.back().motions.create(nm,data,bones);
    }

    R_ASSERT				(m_Motions.size());

    m_Partition				= m_Motions[0].motions.partition();
    
	// initialize motions
	for (MotionsSlotVecIt m_it=m_Motions.begin(); m_it!=m_Motions.end(); m_it++){
		SMotionsSlot& MS	= *m_it;
		MS.bone_motions.resize(bones->size());
		for (u32 i=0; i<bones->size(); i++){
			CBoneData* BD		= (*bones)[i];
			MS.bone_motions[i]	= MS.motions.bone_motions(BD->name);
		}
	}

	// Init blend pool
	IBlend_Startup	();

//.	if (motions.cycle()->size()<2)			
//.		Msg("* WARNING: model '%s' has only one motion. Candidate for SkeletonRigid???",N);
}
Beispiel #24
0
void Startup(LPSTR     lpCmdLine)
{
	char cmd[512],name[256];
	BOOL bModifyOptions		= FALSE;

	strcpy(cmd,lpCmdLine);
	strlwr(cmd);
	if (strstr(cmd,"-?") || strstr(cmd,"-h"))			{ Help(); return; }
	if (strstr(cmd,"-f")==0)							{ Help(); return; }
	if (strstr(cmd,"-o"))								bModifyOptions	= TRUE;
	if (strstr(cmd,"-gi"))								b_radiosity		= TRUE;
	if (strstr(cmd,"-noise"))							b_noise			= TRUE;
	if (strstr(cmd,"-nosun"))							b_nosun			= TRUE;
	
	// Give a LOG-thread a chance to startup
	//_set_sbh_threshold(1920);
	InitCommonControls		();
	thread_spawn			(logThread, "log-update",	1024*1024,0);
	Sleep					(150);
	
	// Faster FPU 
	SetPriorityClass		(GetCurrentProcess(),NORMAL_PRIORITY_CLASS);

	/*
	u32	dwMin			= 1800*(1024*1024);
	u32	dwMax			= 1900*(1024*1024);
	if (0==SetProcessWorkingSetSize(GetCurrentProcess(),dwMin,dwMax))
	{
		clMsg("*** Failed to expand working set");
	};
	*/
	
	// Load project
	name[0]=0;				sscanf(strstr(cmd,"-f")+2,"%s",name);
	string256				prjName;
	FS.update_path			(prjName,"$game_levels$",strconcat(prjName,name,"\\build.prj"));
	string256				phaseName;
	Phase					(strconcat(phaseName,"Reading project [",name,"]..."));

	string256 inf;
	extern  HWND logWindow;
	IReader*	F			= FS.r_open(prjName);
	if (NULL==F){
		sprintf				(inf,"Build failed!\nCan't find level: '%s'",name);
		clMsg				(inf);
		MessageBox			(logWindow,inf,"Error!",MB_OK|MB_ICONERROR);
		return;
	}

	// Version
	u32 version;
	F->r_chunk			(EB_Version,&version);
	clMsg				("version: %d",version);
	R_ASSERT(XRCL_CURRENT_VERSION==version);

	// Header
	b_params				Params;
	F->r_chunk			(EB_Parameters,&Params);

	// Show options if needed
	if (bModifyOptions)		
	{
		Phase		("Project options...");
		HMODULE		L = LoadLibrary		("xrLC_Options.dll");
		void*		P = GetProcAddress	(L,"_frmScenePropertiesRun");
		R_ASSERT	(P);
		xrOptions*	O = (xrOptions*)P;
		int			R = O(&Params,version,false);
		FreeLibrary	(L);
		if (R==2)	{
			ExitProcess(0);
		}
	}
	
	// Conversion
	Phase					("Converting data structures...");
	pBuild					= xr_new<CBuild>();
	pBuild->Load			(Params,*F);
	xr_delete				(F);
	
	// Call for builder
	string256				lfn;
	CTimer	dwStartupTime;	dwStartupTime.Start();
	FS.update_path			(lfn,_game_levels_,name);
	pBuild->Run				(lfn);
	xr_delete				(pBuild);

	// Show statistic
	extern	std::string make_time(u32 sec);
	u32	dwEndTime			= dwStartupTime.GetElapsed_ms();
	sprintf					(inf,"Time elapsed: %s",make_time(dwEndTime/1000).c_str());
	clMsg					("Build succesful!\n%s",inf);
	MessageBox				(logWindow,inf,"Congratulation!",MB_OK|MB_ICONINFORMATION);

	// Close log
	bClose					= TRUE;
	Sleep					(500);
}
Beispiel #25
0
void				game_sv_GameState::SetPointFreezed		(RPoint* rp)
{
	R_ASSERT(rp);
	rp->TimeToUnfreeze	= Level().timeServer() + g_sv_base_dwRPointFreezeTime;
}
void xrServer::Process_event_destroy	(NET_Packet& P, ClientID sender, u32 time, u16 ID, NET_Packet* pEPack)
{
	u32								MODE = net_flags(TRUE,TRUE);
	// Parse message
	u16								id_dest	= ID;
#ifdef DEBUG
	if( dbg_net_Draw_Flags.test( dbg_destroy ) )
		Msg								("sv destroy object %s [%d]", ent_name_safe(id_dest).c_str(), Device.dwFrame);
#endif

	CSE_Abstract*					e_dest = game->get_entity_from_eid	(id_dest);	// кто должен быть уничтожен
	if (!e_dest) 
	{
#ifndef MASTER_GOLD
		Msg							("! SV:ge_destroy: [%d] not found on server",id_dest);
#endif // #ifndef MASTER_GOLD
		return;
	};

	R_ASSERT						(e_dest);
	xrClientData					*c_dest = e_dest->owner;				// клиент, чей юнит
	R_ASSERT						(c_dest);
	xrClientData					*c_from = ID_to_client(sender);	// клиент, кто прислал
	R_ASSERT						(c_dest == c_from);							// assure client ownership of event
	u16								parent_id = e_dest->ID_Parent;

#ifdef MP_LOGGING
	Msg("- SV: Process destroy: parent [%d] item [%d][%s]", 
		parent_id, id_dest, e_dest->name());
#endif //#ifdef MP_LOGGING

	//---------------------------------------------
	NET_Packet	P2, *pEventPack = pEPack;
	P2.w_begin	(M_EVENT_PACK);
	//---------------------------------------------
	// check if we have children 
	if (!e_dest->children.empty()) {
		if (!pEventPack) pEventPack = &P2;

		while (!e_dest->children.empty())
			Process_event_destroy		(P,sender,time,*e_dest->children.begin(), pEventPack);
	};

	if (0xffff == parent_id && NULL == pEventPack) 
	{
		SendBroadcast				(BroadcastCID,P,MODE);
	}
	else 
	{
		NET_Packet	tmpP;
		if (0xffff != parent_id && Process_event_reject(P,sender,time,parent_id,ID,false)) 
		{
			game->u_EventGen(tmpP, GE_OWNERSHIP_REJECT, parent_id);
			tmpP.w_u16(id_dest);
			tmpP.w_u8(1);
		
			if (!pEventPack) pEventPack = &P2;
			
			pEventPack->w_u8(u8(tmpP.B.count));
			pEventPack->w(&tmpP.B.data, tmpP.B.count);
		};
		
 		game->u_EventGen(tmpP, GE_DESTROY, id_dest);
		
		pEventPack->w_u8(u8(tmpP.B.count));
		pEventPack->w(&tmpP.B.data, tmpP.B.count);
	};

	if (NULL == pEPack && NULL != pEventPack)
	{
		SendBroadcast				(BroadcastCID, *pEventPack, MODE);
	}

	// Everything OK, so perform entity-destroy
	if (e_dest->m_bALifeControl && ai().get_alife()) {
		game_sv_Single				*_game = smart_cast<game_sv_Single*>(game);
		VERIFY						(_game);
		if (ai().alife().objects().object(id_dest,true))
			_game->alife().release	(e_dest,false);
	}

	if (game)
		game->OnDestroyObject		(e_dest->ID);

	entity_Destroy					(e_dest);
}
Beispiel #27
0
void	CBuild::xrPhase_UVmap()
{
	// Main loop
	Status					("Processing...");
	g_deflectors.reserve	(64*1024);
	float		p_cost	= 1.f / float(g_XSplit.size());
	float		p_total	= 0.f;
	vecFace		faces_affected;
	for (int SP = 0; SP<int(g_XSplit.size()); SP++) 
	{
		Progress			(p_total+=p_cost);
		IsolateVertices		(FALSE);
		
		// Detect vertex-lighting and avoid this subdivision
		R_ASSERT	(!g_XSplit[SP]->empty());
		Face*		Fvl = g_XSplit[SP]->front();
		if (Fvl->Shader().flags.bLIGHT_Vertex) 	continue;	// do-not touch (skip)
		if (!Fvl->Shader().flags.bRendering) 	continue;	// do-not touch (skip)
		if (Fvl->hasImplicitLighting())			continue;	// do-not touch (skip)
		
		//   find first poly that doesn't has mapping and start recursion
		while (TRUE) {
			// Select maximal sized poly
			Face *	msF		= NULL;
			float	msA		= 0;
			for (vecFaceIt it = g_XSplit[SP]->begin(); it!=g_XSplit[SP]->end(); it++)
			{
				if ( (*it)->pDeflector == NULL ) {
					float a = (*it)->CalcArea();
					if (a>msA) {
						msF = (*it);
						msA = a;
					}
				}
			}
			if (msF) {
				g_deflectors.push_back	(xr_new<CDeflector>());
				
				// Start recursion from this face
				affected				= 1;
				Deflector->OA_SetNormal	(msF->N);
				msF->OA_Unwarp			();
				
				// break the cycle to startup again
				Deflector->OA_Export	();
				
				// Detach affected faces
				faces_affected.clear	();
				for (int i=0; i<int(g_XSplit[SP]->size()); i++) {
					Face *F = (*g_XSplit[SP])[i];
					if ( F->pDeflector==Deflector ) {
						faces_affected.push_back(F);
						g_XSplit[SP]->erase		(g_XSplit[SP]->begin()+i); 
						i--;
					}
				}
				
				// detaching itself
				Detach				(&faces_affected);
				g_XSplit.push_back	(xr_new<vecFace> (faces_affected));
			} else {
				if (g_XSplit[SP]->empty()) 
				{
					xr_delete		(g_XSplit[SP]);
					g_XSplit.erase	(g_XSplit.begin()+SP);
					SP--;
				}
				// Cancel infine loop (while)
				break;
			}
		}
	}
	clMsg("%d subdivisions...",g_XSplit.size());
}
Beispiel #28
0
void CBuild::Flex2OGF()
{
	float p_total	= 0;
	float p_cost	= 1/float(g_XSplit.size());

	validate_splits	();

	g_tree.clear	();
	g_tree.reserve	(4096);
	for (splitIt it=g_XSplit.begin(); it!=g_XSplit.end(); it++)
	{
		R_ASSERT			( ! (*it)->empty() );
		
		u32 MODEL_ID		= u32(it-g_XSplit.begin());
		
		OGF*		pOGF	= new OGF();
		Face*		F		= *((*it)->begin());			// first face
		b_material*	M		= &(materials()[F->dwMaterial]);	// and it's material
		R_ASSERT	(F && M);
		
		try {
			// Common data
			pOGF->Sector		= M->sector;
			pOGF->material		= F->dwMaterial;
			
			// Collect textures
			OGF_Texture			T;
			//pOGF->shader		= M->shader;
			//pOGF->shader_xrlc	= &F->Shader();
			
			TRY(T.name		= textures()[M->surfidx].name);
			TRY(T.pSurface	= &(textures()[M->surfidx]));
			TRY(pOGF->textures.push_back(T));
			
			try {
				if (F->hasImplicitLighting())
				{
					// specific lmap
					string_path		tn;
					strconcat		(sizeof(tn),tn,*T.name,"_lm.dds");
					T.name			= tn;
					T.pSurface		= T.pSurface;	// Leave surface intact
					R_ASSERT		(pOGF);
					pOGF->textures.push_back(T);
				} else {
					// If lightmaps persist
					CLightmap*	LM	= F->lmap_layer;
					if (LM)		{
						string_path	fn;
						sprintf_s		(fn,"%s_1",LM->lm_texture.name); 
						T.name		= fn;
						T.pSurface	= &(LM->lm_texture);
						R_ASSERT	(T.pSurface);
						R_ASSERT	(pOGF);
						pOGF->textures.push_back(T);					//.
						sprintf		(fn,"%s_2",LM->lm_texture.name); 
						T.name		= fn;
						pOGF->textures.push_back(T);
					}
				}
			} catch (...) {  clMsg("* ERROR: Flex2OGF, model# %d, *textures*",MODEL_ID); }
			
			// Collect faces & vertices
			F->CacheOpacity	();
			bool	_tc_	= !(F->flags.bOpaque);
			try {
				BuildOGFGeom( *pOGF, *(*it), _tc_ );
			} catch (...) {  clMsg("* ERROR: Flex2OGF, model# %d, *faces*",MODEL_ID); }

		} catch (...)
		{
			clMsg("* ERROR: Flex2OGF, 1st part, model# %d",MODEL_ID);
		}
		
		try {
			clMsg		("%3d: opt : v(%d)-f(%d)",	MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size());
			pOGF->Optimize						();
			clMsg		("%3d: cb  : v(%d)-f(%d)",	MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size());
			pOGF->CalcBounds					();
			clMsg		("%3d: prog: v(%d)-f(%d)",	MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size());
			if (!b_noise) pOGF->MakeProgressive	(c_PM_MetricLimit_static);
			clMsg		("%3d: strp: v(%d)-f(%d)",	MODEL_ID,pOGF->data.vertices.size(),pOGF->data.faces.size());
			pOGF->Stripify						();
		} catch (...)	{
			clMsg("* ERROR: Flex2OGF, 2nd part, model# %d",MODEL_ID);
		}
		
		g_tree.push_back	(pOGF);
		xr_delete			(*it);
		Progress			(p_total+=p_cost);
	}
	g_XSplit.clear	();
}
Beispiel #29
0
CUIMultiTextStatic::SinglePhrase * CUIMultiTextStatic::GetPhraseByIndex(u32 idx)
{
	R_ASSERT(idx < m_vPhrases.size());

	return &m_vPhrases[idx];
}
Beispiel #30
0
bool ESoundSource::Load(IReader& F)
{
	u32 version 	= 0;

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

	inherited::Load			(F);

    R_ASSERT(F.find_chunk(SOUND_CHUNK_TYPE));
	m_Type					= ESoundType(F.r_u32());

    R_ASSERT(F.find_chunk(SOUND_CHUNK_SOURCE_NAME));
    F.r_stringZ		(m_WAVName);

    
    if (F.find_chunk(SOUND_CHUNK_SOURCE_PARAMS3)){
       	m_Params.base_volume	= 1.f;
    	F.r_fvector3			(m_Params.position);
       	m_Params.volume			= F.r_float();
        m_Params.freq			= F.r_float();
        m_Params.min_distance	= F.r_float();
        m_Params.max_distance	= F.r_float();
        m_Params.max_ai_distance= F.r_float();
    }else if (F.find_chunk(SOUND_CHUNK_SOURCE_PARAMS2)){
       	m_Params.base_volume	= 1.f;
    	F.r_fvector3			(m_Params.position);
       	m_Params.volume			= F.r_float();
        m_Params.freq			= F.r_float();
        m_Params.min_distance	= F.r_float();
        m_Params.max_distance	= F.r_float();
        m_Params.max_ai_distance= F.r_float();
    }else{
    	if (!F.find_chunk(SOUND_CHUNK_SOURCE_PARAMS)){
            ELog.DlgMsg( mtError, "ESoundSource: Can't load Sound Source '%s'. Unsupported version.",*m_WAVName);
            return false;
        }
       	m_Params.base_volume	= 1.f;
    	F.r_fvector3			(m_Params.position);
       	m_Params.volume			= F.r_float();
        m_Params.freq			= F.r_float();
        m_Params.min_distance	= F.r_float();
        m_Params.max_distance	= F.r_float();
        m_Params.max_ai_distance= m_Params.max_distance;
    }

    if(F.find_chunk(SOUND_CHUNK_SOURCE_FLAGS))
		F.r			(&m_Flags,sizeof(m_Flags));
    

    if(F.find_chunk(SOUND_CHUNK_GAME_PARAMS)){
	    F.r_fvector2			(m_RandomPause);
    	F.r_fvector2			(m_ActiveTime);
	    F.r_fvector2			(m_PlayTime);
	}
    
    ResetSource		();

    switch (m_Type){
    case stStaticSource: 
    	if (m_Flags.is(flPlaying)) 		Play(); 
    	if (m_Flags.is(flSimulating)) 	Simulate(); 
    break;
    default: THROW;
    }
    return true;
}