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

Method BuildFromDNA

trinity/Eve/SpaceObjectFactory/EveSOF.cpp:176–304  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Build a ship from a dna string --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

174// Build a ship from a dna string
175// --------------------------------------------------------------------------------
176IRootPtr EveSOF::BuildFromDNA( const char* dnaString )
177{
178 std::string s = "BuildFromDna ";
179 s += std::string( dnaString );
180 CCP_STATS_ZONE( s.c_str() );
181
182 EveSOFDNAPtr dna = CreateDna( dnaString );
183 if( dna == nullptr )
184 {
185 return nullptr;
186 }
187
188 // create what we need to build
189 EveSpaceObject2Ptr newObj = CreateSpaceObject( dna );
190 if( newObj == nullptr )
191 {
192 return nullptr;
193 }
194
195 // set all easy consts
196 SetupConsts( newObj, dna );
197
198 auto centerOffset = std::vector<Matrix>( 1, IdentityMatrix() );
199 if( dna->GetBuildClass() == EveSOFDataHull::BUILDCLASS_EXTENSION )
200 {
201 // for extension we do things differently, since it is an EveChildMesh
202 newObj->SetBoundingSphereInformation( dna->GetHullBoundingSphere() );
203 EveSOFDataMgr::LocatorDirectionData center;
204 center.boneIndex = -1;
205 center.position = Vector3( 0, 0, 0 );
206 center.rotation = Quaternion( 0, 0, 0, 1 );
207 center.scaling = Vector3( 1, 1, 1 );
208 // Create a fake placement
209 EveSOFDataMgr::ExtensionPlacementData fakePlacement;
210 fakePlacement.isInstanced = false;
211 fakePlacement.name = BlueSharedString( "Solo Placement" );
212 fakePlacement.offset = Vector3( 0, 0, 0 );
213 fakePlacement.hasDistribution = false;
214 fakePlacement.extendsBoundingSphere = false;
215 fakePlacement.extendsShieldEllipsoid = false;
216
217 EveChildContainerPtr extensionContainer;
218 extensionContainer.CreateInstance();
219 extensionContainer->SetName( "Extension Container" );
220 extensionContainer->SetOrigin( EveChildMesh::SOF );
221 extensionContainer->SetAlwaysOn( true );
222 extensionContainer->SetIsPlacementRoot( true );
223
224 EveChildInstancedMeshesPtr sharedMeshes;
225 CreatePlacement( newObj, sharedMeshes, dna, dna, fakePlacement, std::vector<EveSOFDataMgr::LocatorDirectionData>( 1, center ), centerOffset, extensionContainer );
226
227 newObj->AddToEffectChildrenList( extensionContainer );
228 // create an empty mesh...
229 Tr2MeshPtr mesh;
230 mesh.CreateInstance();
231 newObj->SetMesh( mesh );
232
233 // ships needs a final ::Initialize call

Callers

nothing calls this directly

Calls 15

GetBuildClassMethod · 0.80
GetHullBoundingSphereMethod · 0.80
CreateInstanceMethod · 0.80
SetAlwaysOnMethod · 0.80
SetIsPlacementRootMethod · 0.80
GetColorSetMethod · 0.80
sizeMethod · 0.80
QueryInterfaceMethod · 0.80
SetBehaviorMethod · 0.80
Vector3Class · 0.50

Tested by

no test coverage detected