MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetupImpactEffects

Method SetupImpactEffects

trinity/Eve/SpaceObjectFactory/EveSOF.cpp:2368–2513  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Add all kinds of effects to the ship --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2366// Add all kinds of effects to the ship
2367// --------------------------------------------------------------------------------
2368void EveSOF::SetupImpactEffects( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const
2369{
2370 EveSOFDataHull::ImpactEffectType impactType = dna->GetImpactEffectType();
2371 // todo - how do we create impact effects for instanced objects?
2372
2373 if( impactType != EveSOFDataHull::IMPACTEFFECT_NONE )
2374 {
2375 const EveSOFDataMgr::GenericDamageData* genericDamageData = dna->GetGenericDamageData();
2376 const EveSOFDataMgr::GenericHullDamageData* genericHullDamageData = dna->GetGenericHullDamageData();
2377 const EveSOFDataMgr::RaceDamageData* raceDamageData = dna->GetRaceDamageData();
2378 if( genericDamageData && raceDamageData )
2379 {
2380 // create impact effect
2381 EveImpactOverlayPtr impactOverlay;
2382 impactOverlay.CreateInstance();
2383
2384 impactOverlay->SetDamageLocatorCount( dna->GetLocatorCount( "damage" ) );
2385
2386 // shield impact effect via Tr2Mesh with LOD
2387 Tr2MeshPtr shieldMesh;
2388
2389 if( impactType == EveSOFDataHull::IMPACTEFFECT_ELLIPSOID )
2390 {
2391 // shield shader
2392 Tr2EffectPtr shieldShader;
2393 shieldShader.CreateInstance();
2394 shieldShader->StartUpdate();
2395 std::string shaderPath = dna->GetAreaShaderLocationResPath() + std::string( "/" ) + dna->GetImpactShieldShader();
2396 shieldShader->SetEffectPathName( shaderPath.c_str() );
2397 for( auto it = raceDamageData->shieldDamageParameters.begin(); it != raceDamageData->shieldDamageParameters.end(); ++it )
2398 {
2399 shieldShader->AddParameterVector4( it->first, &it->second );
2400 }
2401 for( auto it = raceDamageData->shieldDamageTextures.begin(); it != raceDamageData->shieldDamageTextures.end(); ++it )
2402 {
2403 shieldShader->AddResourceTexture2D( it->first, it->second.resFilePath.c_str() );
2404 }
2405 shieldShader->EndUpdate();
2406 Tr2MeshAreaPtr meshArea;
2407 meshArea.CreateInstance();
2408 meshArea->SetMaterial( shieldShader );
2409
2410 shieldMesh.CreateInstance();
2411 std::string geometryPath;
2412 // what type of shield effect determines the geometry resource
2413 if( impactType == EveSOFDataHull::IMPACTEFFECT_ELLIPSOID )
2414 {
2415 // only the ellpisoid geometry
2416 geometryPath = genericDamageData->shieldGeometryResFilePath;
2417 }
2418 else if( impactType == EveSOFDataHull::IMPACTEFFECT_HULL )
2419 {
2420 // use the ships main geometry incl LODs
2421 geometryPath = dna->GetHullGeometryResPath();
2422 // adjust mesharea count to that from the mesh
2423 meshArea->SetCount( 1 + dna->GetHighestMeshAreaIndex( TRIBATCHTYPE_OPAQUE ) );
2424 }
2425

Callers

nothing calls this directly

Calls 15

GetImpactEffectTypeMethod · 0.80
GetGenericDamageDataMethod · 0.80
GetRaceDamageDataMethod · 0.80
CreateInstanceMethod · 0.80
SetDamageLocatorCountMethod · 0.80
StartUpdateMethod · 0.80
GetImpactShieldShaderMethod · 0.80
SetEffectPathNameMethod · 0.80
AddParameterVector4Method · 0.80
AddResourceTexture2DMethod · 0.80

Tested by

no test coverage detected