Esempio n. 1
0
int CBoidObject::GetGeometrySurfaceType()
{
	if(m_object)
	{
		ISurfaceType *pSurfaceType = gEnv->pEntitySystem->GetBreakableManager()->GetFirstSurfaceType(m_object);

		if(pSurfaceType)
			return pSurfaceType->GetId();
	}
	else
	{
		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);

		if(pEntity)
		{
			IStatObj *pStatObj = pEntity->GetStatObj(0|ENTITY_SLOT_ACTUAL);

			if(pStatObj)
			{
				ISurfaceType *pSurfaceType = gEnv->pEntitySystem->GetBreakableManager()->GetFirstSurfaceType(pStatObj);

				if(pSurfaceType)
					return pSurfaceType->GetId();
			}
		}
	}

	return 0;
}
	int FindSurfaceIdByName(const char* surfaceTypeName)
	{
		CRY_ASSERT(surfaceTypeName != NULL);

		ISurfaceType* pSurfaceType = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetSurfaceTypeByName(surfaceTypeName);
		if (pSurfaceType != NULL)
		{
			return (int)pSurfaceType->GetId();
		}
		
		return -1;
	}
Esempio n. 3
0
void CBoidObject::Physicalize( SBoidContext &bc )
{
	pe_params_particle ppart;
	//ppart.gravity = Vec3(0,0,0);
	ppart.flags = particle_traceable | particle_no_roll | pef_never_affect_triggers | pef_log_collisions;
	ppart.mass = 0;
	ppart.size = max(bc.fBoidRadius,0.01f);
	ppart.thickness = max(bc.fBoidThickness,0.01f);
	ppart.gravity = Vec3(0,0,0);
	ppart.kAirResistance = 0.0f;

	if(m_object)
	{
		IMaterial* pMat = m_object->GetIMaterial();
		if(pMat->GetSubMtlCount() > 0)
		{
			ppart.surface_idx = pMat->GetSubMtl(0)->GetSurfaceTypeId();
		}
		else
		{
			ppart.surface_idx = pMat->GetSurfaceTypeId();
		}
	}
	else
	{
		// just like in GetGeometrySurfaceType()
		ppart.surface_idx = 0;
		IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
		if (pEntity)
		{
			IStatObj *pStatObj = pEntity->GetStatObj(0|ENTITY_SLOT_ACTUAL);
			if (pStatObj)
			{
				ISurfaceType *pSurfaceType = gEnv->pEntitySystem->GetBreakableManager()->GetFirstSurfaceType(pStatObj);
				if (pSurfaceType)
					ppart.surface_idx = pSurfaceType->GetId();
			}
		}
	}

	IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_entity);
	if (pEntity)
	{
		SEntityPhysicalizeParams params;
		params.pParticle = &ppart;
		params.type = PE_PARTICLE;
		pEntity->Physicalize(params);
		m_pPhysics = pEntity->GetPhysics();
	}
}
Esempio n. 4
0
void SMikeBulletParams::CacheMaterialIds()
{
	if (m_covertedIndexes)
		return;

	m_covertedIndexes = true;
	for (TBurnSurfaceIndexMap::iterator burnIt = m_burnSurfaceIndices.begin(); burnIt != m_burnSurfaceIndices.end(); ++burnIt)
	{
		ISurfaceType* pSurfaceType = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetSurfaceTypeByName(burnIt->first.m_materialTypeName.c_str());
		if (pSurfaceType)
		{
			burnIt->first.m_materialTypeId = pSurfaceType->GetId();
		}
	}
}
Esempio n. 5
0
void SAmmoParams::CacheResources() const
{
	CItemResourceCache& resourceCache = g_pGame->GetGameSharedParametersStorage()->GetItemResourceCache();
	if(resourceCache.AreClassResourcesCached(pEntityClass))
		return;

	CItemParticleEffectCache& particleCache = resourceCache.GetParticleEffectCache();
	CItemMaterialAndTextureCache& materialCache = resourceCache.GetMaterialsAndTextureCache();

	resourceCache.GetAmmoGeometryCache().CacheGeometry(fpGeometryName.c_str(), true);

	if (!material_name.empty() && (surfaceTypeId == -1))
	{
		ISurfaceType* pSurfaceType = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeByName(material_name.c_str());
		if (pSurfaceType)
			surfaceTypeId = pSurfaceType->GetId();
	}

	if(pCollision)
	{
		pCollision->PreCacheLevelResources(particleCache);
	}
	if(pExplosions)
	{
		//t count = ARRAY_COUNT(pExplosions);
		for(int i = 0; i < m_explosion_count; ++i)
		{
			pExplosions[i]->PreCacheLevelResources(particleCache);
		}
	}
	if (pTrail)
	{
		pTrail->PreCacheLevelResources(particleCache);
	}
	if (pTrailUnderWater)
	{
		pTrailUnderWater->PreCacheLevelResources(particleCache);
	}
	if (pWhiz)
	{
		pWhiz->PreCacheLevelResources();
	}
	if (pRicochet)
	{
		pRicochet->PreCacheLevelResources();
	}
	if (pLTagParams)
	{
		pLTagParams->m_ricochet.PreCacheLevelResources(particleCache, materialCache);
		pLTagParams->m_sticky.PreCacheLevelResources(particleCache, materialCache);
	}
	if (pMikeBulletParams)
	{
		pMikeBulletParams->PreCacheLevelResources(particleCache);
	}
	if (pHomingParams)
	{
		pHomingParams->PreCacheLevelResources(particleCache);
	}
	if(pKvoltParams)
	{
		pKvoltParams->PreCacheLevelResources(particleCache);
	}
	if (pBulletTimeParams)
	{
		pBulletTimeParams->PreCacheLevelResources(resourceCache);
	}
	if (pLightningBoltParams)
	{
		pLightningBoltParams->PreCacheLevelResources(materialCache, particleCache);
	}
	if (pC4ExplosiveParams)
	{
		pC4ExplosiveParams->PreCacheLevelResources(resourceCache);
	}
	if (pElectricProjectileParams)
	{
		pElectricProjectileParams->PreCacheLevelResources(particleCache);
	}

	resourceCache.CachedResourcesForClassDone(pEntityClass);

}
bool CScriptSurfaceTypesLoader::LoadSurfaceTypes( const char *sFolder,bool bReload )
{
	{
		if (!gEnv->p3DEngine)
			return false;

		I3DEngine *pEngine = gEnv->p3DEngine;
		ISurfaceTypeEnumerator *pEnum = pEngine->GetMaterialManager()->GetSurfaceTypeManager()->GetEnumerator();
		if (pEnum)
		{
			for (ISurfaceType *pSurfaceType = pEnum->GetFirst(); pSurfaceType; pSurfaceType = pEnum->GetNext())
			{
				SmartScriptTable mtlTable(gEnv->pScriptSystem);
				gEnv->pScriptSystem->SetGlobalValue( pSurfaceType->GetName(),mtlTable );

				SmartScriptTable aiTable(gEnv->pScriptSystem);
				mtlTable->SetValue("AI",aiTable);
				aiTable->SetValue( "fImpactRadius",5.0f );
				aiTable->SetValue( "fFootStepRadius",15.0f );
				aiTable->SetValue( "proneMult",0.2f );
				aiTable->SetValue( "crouchMult",0.5f );
				aiTable->SetValue( "movingMult",2.5f );
			}

			pEnum->Release();
		}
	}

	return true; // Do not load surface types from script anymore.

	m_root = GetISystem()->CreateXmlNode("SurfaceTypes");

	IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
	//////////////////////////////////////////////////////////////////////////
	// Make sure Materials table exist.
	//////////////////////////////////////////////////////////////////////////
	SmartScriptTable mtlTable;

	if (!pScriptSystem->GetGlobalValue("Materials", mtlTable) || bReload)
	{
		mtlTable = pScriptSystem->CreateTable();
		pScriptSystem->SetGlobalValue("Materials", mtlTable);
	}

	ICryPak *pIPak = gEnv->pCryPak;

	ISurfaceTypeManager *pSurfaceManager = gEnv->p3DEngine->GetMaterialManager()->GetSurfaceTypeManager();

	if (!bReload)
		stl::push_back_unique( m_folders,sFolder );

	string searchFolder = string(sFolder) + "/";;
	string searchFilter = searchFolder + "mat_*.lua";

	gEnv->pScriptSystem->ExecuteFile(searchFolder+"common.lua", false, bReload);

	_finddata_t fd;
	intptr_t fhandle;
	fhandle = pIPak->FindFirst( searchFilter,&fd );
	if (fhandle != -1)
	{
		do {
			// Skip back folders.
			if (fd.attrib & _A_SUBDIR) // skip if directory.
				continue;

			char name[_MAX_PATH];
			_splitpath( fd.name,NULL,NULL,name,NULL );

			if (strlen(name) == 0)
				continue;

			if (bReload)
			{
				ISurfaceType *pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(name);
				if (pSurfaceType)
				{
					pSurfaceType->Load( pSurfaceType->GetId() );
					continue;
				}
			}

			ISurfaceType *pSurfaceType = new CScriptSurfaceType( this,name,searchFolder+fd.name,0 );
			if (pSurfaceManager->RegisterSurfaceType( pSurfaceType ))
				m_surfaceTypes.push_back(pSurfaceType);
			else
				pSurfaceType->Release();
		} while (pIPak->FindNext( fhandle,&fd ) == 0);
		pIPak->FindClose(fhandle);
	}

	if (m_root)
	{
		m_root->saveToFile( "SurfaceTypes.xml" );
	}

	return true;
}