LTBOOL CAIButeMgr::Init(ILTCSBase *pInterface, const char* szAttributeFile) { if (g_pAIButeMgr || !szAttributeFile) return LTFALSE; if (!Parse(pInterface, szAttributeFile)) return LTFALSE; // Set up global pointer g_pAIButeMgr = this; // See how many attribute templates there are m_cTemplateID = 0; sprintf(s_aTagName, "%s%d", "AttributeTemplate", m_cTemplateID); while (m_buteMgr.Exist(s_aTagName)) { m_cTemplateID++; sprintf(s_aTagName, "%s%d", "AttributeTemplate", m_cTemplateID); } m_aTemplates = debug_newa(AIBM_Template, m_cTemplateID); for ( int iTemplate = 0 ; iTemplate < m_cTemplateID ; iTemplate++ ) { SetTemplate(iTemplate); } // See how many brains there are m_cBrainID = 0; sprintf(s_aTagName, "%s%d", "Brain", m_cBrainID); while (m_buteMgr.Exist(s_aTagName)) { m_cBrainID++; sprintf(s_aTagName, "%s%d", "Brain", m_cBrainID); } m_aBrains = debug_newa(AIBM_Brain, m_cBrainID); for ( int iBrain = 0 ; iBrain < m_cBrainID ; iBrain++ ) { SetBrain(iBrain); } SetSenses(); SetAttract(); SetDEdit(); m_buteMgr.Term(); return LTTRUE; }
// Sort the render resolution based on screen width and height void CFolderDisplay::SortRenderModes(int nRendererIndex) { // Build a temporary array of render modes int nResolutions=m_rendererArray[nRendererIndex].m_resolutionArray.GetSize(); if ( nResolutions < 1 ) { return; } FolderDisplayResolution *pResolutions = debug_newa(FolderDisplayResolution, nResolutions); int i; for (i=0; i < nResolutions; i++) { pResolutions[i]=m_rendererArray[nRendererIndex].m_resolutionArray[i]; } // Sort the array qsort(pResolutions, nResolutions, sizeof(FolderDisplayResolution), FolderDisplayCompare); // Clear the current renderer resolutions array m_rendererArray[nRendererIndex].m_resolutionArray.SetSize(0); // Copy the sorted array back to the resolutions array for (i=0; i < nResolutions; i++) { m_rendererArray[nRendererIndex].m_resolutionArray.Add(pResolutions[i]); } debug_deletea(pResolutions); }
// Sort the render resolution based on screen width and height void CScreenDisplay::SortRenderModes( ScreenDisplayRenderer& rendererData ) { // Build a temporary array of render modes int nResolutions=rendererData.m_resolutionArray.GetSize(); if ( nResolutions < 1 ) { return; } ScreenDisplayResolution *pResolutions = debug_newa(ScreenDisplayResolution, nResolutions); int i; for (i=0; i < nResolutions; i++) { pResolutions[i]=rendererData.m_resolutionArray[i]; } // Sort the array qsort(pResolutions, nResolutions, sizeof(ScreenDisplayResolution), ScreenDisplayCompare); // Clear the current renderer resolutions array rendererData.m_resolutionArray.SetSize(0); // Copy the sorted array back to the resolutions array for (i=0; i < nResolutions; i++) { rendererData.m_resolutionArray.Add(pResolutions[i]); } delete []pResolutions; }
LTBOOL CLineSystemFX::CreateObject(ILTClient *pClientDE) { if (!pClientDE ) return LTFALSE; LTBOOL bRet = CBaseLineSystemFX::CreateObject(pClientDE); if (bRet && m_hObject && m_hServerObject) { uint32 dwUserFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); } } // Create lines... m_nTotalNumLines = int(m_cs.fLinesPerSecond * m_cs.fLineLifetime); if (m_nTotalNumLines > MAX_SYSTEM_LINES) { m_nTotalNumLines = MAX_SYSTEM_LINES; } m_pLines = debug_newa(LSLineStruct, m_nTotalNumLines); SetupSystem(); s_cvarTweak.Init(g_pLTClient, "TweakLines", NULL, 0.0f); return bRet; }
void CAnimationContext::Init(uint32 cAnimationInstances, uint32 cTransitionInstances) { m_hObject = LTNULL; m_eState = eStateNormal; m_bLocked = LTFALSE; m_aAnimationInstances = debug_newa(CAnimationInstance, cAnimationInstances); m_iAnimation = 0; m_aTransitionInstances = debug_newa(CTransitionInstance, cTransitionInstances); m_iTransition = 0; m_bHackToAvoidTheUsualOneFrameOffBullshit = LTFALSE; }
void CAIGoalButeMgr::GetEnumItems(uint32*& aItems, uint32& cItems, const char* szAttribute, const uint32 nNumEnums, const char** aszEnums) { AIASSERT(aItems == LTNULL, LTNULL, "CAIGoalButeMgr::GetEnumItems: aItems is not NULL."); char szItem[128]; uint32 iEnum; uint8 iItem = 0; // Count all existing items, listed Item0, Item1, ..., ItemN while ( true ) { sprintf(s_aAttName, "%s%d", szAttribute, cItems); if( !m_buteMgr.Exist(s_aTagName, s_aAttName)) break; ++cItems; } if(cItems == 0) { return; } // Allocate space for items. aItems = debug_newa(uint32, cItems); // Read in all existing items, listed Item0, Item1, ..., ItemN while ( true ) { sprintf(s_aAttName, "%s%d", szAttribute, iItem); m_buteMgr.GetString(s_aTagName, s_aAttName, "", szItem, sizeof(szItem) ); if( !m_buteMgr.Success( )) break; // Find flag with matching string. for(iEnum=0; iEnum < nNumEnums; ++iEnum) { if( 0 == stricmp(szItem, aszEnums[iEnum]) ) { break; } } AIASSERT(iEnum < nNumEnums, LTNULL, "CAIGoalButeMgr::GetEnumItems: No matching enum."); aItems[iItem] = iEnum; ++iItem; } }
void CAIVolume::InitNeighbors(CAIVolume** apVolumeNeighbors, uint32 cNeighbors) { LTBOOL abValidNeighbors[32]; {for ( uint32 iNeighbor = 0 ; iNeighbor < cNeighbors ; iNeighbor++ ) { LTVector vFrontLeft(0,0,0); LTVector vBackRight(0,0,0); CAIVolume* pNeighbor = apVolumeNeighbors[iNeighbor]; vFrontLeft.x = Max<LTFLOAT>(GetFrontTopLeft().x, pNeighbor->GetFrontTopLeft().x); vFrontLeft.z = Min<LTFLOAT>(GetFrontTopLeft().z, pNeighbor->GetFrontTopLeft().z); vBackRight.x = Min<LTFLOAT>(GetBackTopRight().x, pNeighbor->GetBackTopRight().x); vBackRight.z = Max<LTFLOAT>(GetBackTopRight().z, pNeighbor->GetBackTopRight().z); // Make sure this isn't an unintended intersection if ( vFrontLeft.DistSqr(vBackRight) < c_fNeighborThreshhold ) { abValidNeighbors[iNeighbor] = LTFALSE; } else { abValidNeighbors[iNeighbor] = LTTRUE; m_cNeighbors++; } }} m_aNeighbors = debug_newa(CAIVolumeNeighbor, m_cNeighbors); m_cNeighbors = 0; {for ( uint32 iNeighbor = 0 ; iNeighbor < cNeighbors ; iNeighbor++ ) { if ( abValidNeighbors[iNeighbor] ) { m_aNeighbors[m_cNeighbors].Init(this, apVolumeNeighbors[iNeighbor]); m_cNeighbors++; } }} }
bool CClientFXDB::ReadFXGroups( bool bText, ILTStream* pFxFile, CLinkList<FX_GROUP *> &collGroupFx ) { // Read in the number of FX groups in this file uint32 dwNumGroups; if( bText ) { ReadTextFile( pFxFile, "%s %lu", &dwNumGroups ); } else { pFxFile->Read(&dwNumGroups, sizeof(uint32)); } //allocate a working buffer that keys can read properties into static const uint32 knMaxKeyProps = 512; FX_PROP* pPropBuffer = debug_newa(FX_PROP, knMaxKeyProps); if(!pPropBuffer) return false; for( uint32 i = 0; i < dwNumGroups; i ++ ) { // Create a new group. FX_GROUP *pFxGroup = debug_new( FX_GROUP ); if( !ReadFXGroup( bText, pFxFile, pFxGroup, pPropBuffer, knMaxKeyProps )) { debug_deletea(pPropBuffer); return false; } collGroupFx.AddTail(pFxGroup); } //free our working buffer debug_deletea(pPropBuffer); return true; }
void CAIVolume::Load(HMESSAGEREAD hRead) { LOAD_HSTRING(m_hstrName); LOAD_INT(m_iVolume); LOAD_DWORD(m_iRegion); LOAD_VECTOR(m_vFrontTopLeft); LOAD_VECTOR(m_vFrontTopRight); LOAD_VECTOR(m_vBackTopLeft); LOAD_VECTOR(m_vBackTopRight); LOAD_VECTOR(m_vFrontBottomLeft); LOAD_VECTOR(m_vFrontBottomRight); LOAD_VECTOR(m_vBackBottomLeft); LOAD_VECTOR(m_vBackBottomRight); LOAD_INT(m_cNeighbors); LOAD_BOOL(m_bHadDoors); LOAD_INT(m_cDoors); LOAD_HOBJECT(m_hLift); LOAD_BOOL(m_bStairs); LOAD_BOOL(m_bLedge); LOAD_BOOL(m_bVertical); LOAD_VECTOR(m_vStairsDir); LOAD_VECTOR(m_vLedgeDir); m_aNeighbors = debug_newa(CAIVolumeNeighbor, m_cNeighbors); for ( uint32 iNeighbor = 0 ; iNeighbor < m_cNeighbors ; iNeighbor++ ) { m_aNeighbors[iNeighbor].Load(hRead); } for ( uint32 iDoor = 0 ; iDoor < cm_nMaxDoors ; iDoor++ ) { LOAD_HOBJECT(m_ahDoors[iDoor]); } for ( uint32 iViewNode = 0 ; iViewNode < kMaxViewNodes ; iViewNode++ ) { LOAD_DWORD(m_adwViewNodes[iViewNode]); } }
LTBOOL CLeashFX::SetupLeash() { // Allocate our verts if necessary... if (!m_pVerts) { m_pVerts = debug_newa(LeashVerts, m_cs.cSegments+1); } if (!m_pVerts) return LTFALSE; // LTVector vPos = m_cs.vStartPos; // LTVector vDir = (m_cs.vEndPos - m_cs.vStartPos); // float fDist = vDir.Mag(); // vDir.Norm(); for (int i=0; i < m_cs.cSegments; i++) { } return LTTRUE; }
void CAIVolumeMgr::Load(HMESSAGEREAD hRead) { LOAD_BOOL(m_bInitialized); LOAD_INT(m_cVolumes); if ( 0 == m_cVolumes ) { if ( m_aVolumes ) { debug_deletea(m_aVolumes); m_aVolumes = LTNULL; } return; } m_aVolumes = debug_newa(CAIVolume, m_cVolumes); for ( int32 iVolume = 0 ; iVolume < m_cVolumes ; iVolume++ ) { m_aVolumes[iVolume].Load(hRead); } }
// get a pointer to a block of particles bool CSnowFXParticleMgr::AllocateParticles( uint32 numParticles, CSnowFXParticle*& particles ) { // if this is the first time particles have been requested, initialize the particle array if( !m_Particles ) { m_NumParticles = SNOWFX_PARTICLEPOOLSIZE; m_Particles = debug_newa( CSnowFXParticle, m_NumParticles ); if( !m_Particles ) { ASSERT(0); m_NumParticles = 0; } srand( 101374 ); for( uint32 i = 0; i < m_NumParticles; i++ ) { m_Particles[i].id = (uint32)(((float)rand() / (float)RAND_MAX) * (SNOWFX_TABLESIZE - 1)); m_Particles[i].pos.x = ((float)rand() / (float)RAND_MAX) * 2.0f - 1.0f; m_Particles[i].pos.y = ((float)rand() / (float)RAND_MAX) * 2.0f - 1.0f; m_Particles[i].pos.z = ((float)rand() / (float)RAND_MAX) * 2.0f - 1.0f; } } if( !m_Particles || (numParticles > m_NumParticles) ) return false; float offsetAmt = (float)rand() / (float)RAND_MAX; uint32 startRange = m_NumParticles - numParticles; uint32 start = (uint32)(offsetAmt * startRange); particles = &(m_Particles[start]); return true; }
void CAIVolumeMgr::Init() { Term(); // First, we count up the number of volumes in the level HCLASS hAIVolume = g_pLTServer->GetClass("AIVolume"); HOBJECT hCurObject = LTNULL; while (hCurObject = g_pLTServer->GetNextObject(hCurObject)) { if (g_pLTServer->IsKindOf(g_pLTServer->GetObjectClass(hCurObject), hAIVolume)) { m_cVolumes++; } } hCurObject = LTNULL; while (hCurObject = g_pLTServer->GetNextInactiveObject(hCurObject)) { if (g_pLTServer->IsKindOf(g_pLTServer->GetObjectClass(hCurObject), hAIVolume)) { m_cVolumes++; } } if ( 0 == m_cVolumes ) return; m_aVolumes = debug_newa(CAIVolume, m_cVolumes); int32 iVolume = 0; // Now we put the Volumes int32o our array hCurObject = LTNULL; while (hCurObject = g_pLTServer->GetNextObject(hCurObject)) { if (g_pLTServer->IsKindOf(g_pLTServer->GetObjectClass(hCurObject), hAIVolume)) { // Setup the volume m_aVolumes[iVolume].Init(iVolume, *(AIVolume*)g_pLTServer->HandleToObject(hCurObject)); iVolume++; // Remove the object g_pLTServer->RemoveObject(hCurObject); } } hCurObject = LTNULL; while (hCurObject = g_pLTServer->GetNextInactiveObject(hCurObject)) { if (g_pLTServer->IsKindOf(g_pLTServer->GetObjectClass(hCurObject), hAIVolume)) { // Setup the volume m_aVolumes[iVolume].Init(iVolume, *(AIVolume*)g_pLTServer->HandleToObject(hCurObject)); iVolume++; // Remove the object g_pLTServer->RemoveObject(hCurObject); } } // Build the neighboring connections int32 cTotalNeighbors = 0; {for ( int32 iVolume = 0 ; iVolume < m_cVolumes ; iVolume++ ) { const static int32 c_nMaxNeighbors = 16; CAIVolume* apVolumeNeighbors[c_nMaxNeighbors]; int32 cNeighbors = 0; {for ( int32 iNeighborVolume = 0 ; iNeighborVolume < m_cVolumes ; iNeighborVolume++ ) { if ( iVolume != iNeighborVolume ) { if ( m_aVolumes[iVolume].Intersects(m_aVolumes[iNeighborVolume]) ) { /* char szDebug[128]; sprint32f(szDebug, "%s neighbors %s", m_aVolumes[iVolume].GetName(), m_aVolumes[iNeighborVolume].GetName()); OutputDebugString(szDebug); */ if ( cNeighbors >= c_nMaxNeighbors ) { _ASSERT(!"Max number of neighboring volumes exceeded!!!!"); g_pLTServer->CPrint("Max number of neighboring volumes exceeded!!!!"); break; } apVolumeNeighbors[cNeighbors++] = &m_aVolumes[iNeighborVolume]; cTotalNeighbors++; } } }} m_aVolumes[iVolume].InitNeighbors(apVolumeNeighbors, cNeighbors); /* g_pLTServer->CPrint("restated: %s has %d neighbors", m_aVolumes[iVolume].GetName(), m_aVolumes[iVolume].GetNumNeighbors()); {for ( int32 iNeighborVolume = 0 ; iNeighborVolume < m_aVolumes[iVolume].GetNumNeighbors() ; iNeighborVolume++ ) { int32 iNeighbor = m_aVolumes[iVolume].GetNeighborByIndex(iNeighborVolume)->GetIndex(); g_pLTServer->CPrint(" %s", m_aVolumes[iNeighbor].GetName()); }}*/ }} // All done #ifndef _FINAL g_pLTServer->CPrint("Added %d volumes, %d connections", m_cVolumes, cTotalNeighbors); #endif m_bInitialized = LTTRUE; }
LTBOOL CSnowFX::CreateObject( ILTClient* pClientDE ) { if( !CSpecialFX::CreateObject( pClientDE ) ) return LTFALSE; m_hObject = LTNULL; // get the bounds for this snow volume LTVector pos; g_pLTClient->GetObjectPos( m_hServerObject, &pos ); LTVector min = pos - m_vDims; LTVector size = m_vDims * 2.0f; m_vMinBounds = pos - m_vDims; m_vMaxBounds = pos + m_vDims; // determine how many airspaces it will divide into uint32 numXAirspaces = (uint32)((m_vDims.x * 2.0f) / SNOWFX_AIRSPACEDIMS) + 1; uint32 numZAirspaces = (uint32)((m_vDims.z * 2.0f) / SNOWFX_AIRSPACEDIMS) + 1; // don't add sliver airspaces on boundaries if( fmod( (m_vDims.x * 2.0f), SNOWFX_AIRSPACEDIMS ) < 1.0f ) numXAirspaces--; if( fmod( (m_vDims.z * 2.0f), SNOWFX_AIRSPACEDIMS ) < 1.0f ) numZAirspaces--; m_nNumAirspaces = numXAirspaces * numZAirspaces; // create the airspaces if( m_nNumAirspaces ) m_pAirspaces = debug_newa( CSnowFXAirspace, m_nNumAirspaces ); // intialize each airspace with it's position and size float remainingZSize = size.z; float curZMin = min.z; for( uint32 z = 0; z < numZAirspaces; z++ ) { float curZSize = remainingZSize; if( curZSize >= SNOWFX_AIRSPACEDIMS ) { curZSize = SNOWFX_AIRSPACEDIMS; remainingZSize -= SNOWFX_AIRSPACEDIMS; } curZSize *= 0.5f; float remainingXSize = size.x; float curXMin = min.x; for( uint32 x = 0; x < numXAirspaces; x++ ) { float curXSize = remainingXSize; if( curXSize >= SNOWFX_AIRSPACEDIMS ) { curXSize = SNOWFX_AIRSPACEDIMS; remainingXSize -= SNOWFX_AIRSPACEDIMS; } curXSize *= 0.5f; LTVector curPos; curPos.x = curXMin + curXSize; curPos.y = pos.y; curPos.z = curZMin + curZSize; LTVector curDims; curDims.x = curXSize; curDims.y = m_vDims.y; curDims.z = curZSize; m_pAirspaces[numXAirspaces*z + x].Init( this, curPos, curDims ); curXMin += SNOWFX_AIRSPACEDIMS; } curZMin += SNOWFX_AIRSPACEDIMS; } return LTTRUE; }
LTBOOL CScatterFX::CreateObject( ILTClient* pClientDE ) { if( !CSpecialFX::CreateObject( pClientDE ) ) return LTFALSE; m_hObject = LTNULL; LTVector pos; g_pLTClient->GetObjectPos( m_hServerObject, &pos ); m_vMinBounds = pos - m_vDims; m_vMaxBounds = pos + m_vDims; // grab the subvolumes and particles from the blind object data uint32 numVolumes = 0; if( m_nBlindDataIndex != 0xffffffff ) { // grab the blind data uint8* blindData = NULL; uint32 blindDataSize = 0; if( m_pClientDE->GetBlindObjectData( m_nBlindDataIndex, SCATTER_BLINDOBJECTID, blindData, blindDataSize ) != LT_OK ) return LTFALSE; uint8* curBlindData = blindData; uint32 fltSz = sizeof(float); // get the number of subvolumes numVolumes = *((uint32*)curBlindData); curBlindData += 4; if( numVolumes ) m_pSubVolumes = debug_newa( CScatterFXSubVolume, numVolumes ); m_nNumSubVolumes = numVolumes; for( uint32 i = 0; i < numVolumes; i++ ) { // get the position of this subvolume LTVector pos; pos.x = *((float*)curBlindData); curBlindData += fltSz; pos.y = *((float*)curBlindData); curBlindData += fltSz; pos.z = *((float*)curBlindData); curBlindData += fltSz; // get the dimensions of this subvolume LTVector dims; dims.x = *((float*)curBlindData); curBlindData += fltSz; dims.y = *((float*)curBlindData); curBlindData += fltSz; dims.z = *((float*)curBlindData); curBlindData += fltSz; // get the number of particles in this volume uint32 numParticles = *((uint32*)curBlindData); curBlindData += 4; ASSERT( numParticles ); // this will be dealloced by the subvolume it is passed down to CScatterFXParticle* particles = debug_newa( CScatterFXParticle, numParticles ); for( uint32 j = 0; j < numParticles; j++ ) { particles[j].pos.x = *((float*)curBlindData); curBlindData += fltSz; particles[j].pos.y = *((float*)curBlindData); curBlindData += fltSz; particles[j].pos.z = *((float*)curBlindData); curBlindData += fltSz; particles[j].color = *((uint32*)curBlindData) & 0x00ffffff; curBlindData += 4; particles[j].scale = *((float*)curBlindData); curBlindData += fltSz; particles[j].waveRot = *curBlindData; curBlindData++; particles[j].waveStart = *curBlindData; curBlindData++; //-0---- float tmp = (float)rand() / (float)RAND_MAX; tmp *= 2.0f * PI; particles[j].xoffset = (float)sin( tmp ) * m_fWidth * particles[j].scale; particles[j].yoffset = (float)cos( tmp ) * m_fWidth * particles[j].scale; //------ } AdjustBounds( pos, dims ); m_pSubVolumes[i].Init( this, pos, dims, numParticles, particles ); } // we're done with the blind data for this object, free it m_pClientDE->FreeBlindObjectData( m_nBlindDataIndex, SCATTER_BLINDOBJECTID ); } return LTTRUE; }
LTBOOL CAnimationMgr::Init(Animation::CAnimationParser& AnimationParser) { const char* aszPropertyNames[kMaxProps]; uint32 aiPropertyIndices[kMaxProps]; int32 anPropertyValues[kMaxProps]; AnimationParser.EnumerateProperties(aszPropertyNames, aiPropertyIndices, anPropertyValues, &m_cAnimationProps); for ( uint32 iAnimationProp = 0 ; iAnimationProp < m_cAnimationProps ; iAnimationProp++ ) { strcpy(m_aszAnimationPropNames[iAnimationProp], aszPropertyNames[iAnimationProp]); m_aAnimationProps[iAnimationProp].m_nValue = anPropertyValues[iAnimationProp]; m_aAnimationProps[iAnimationProp].m_iIndex = aiPropertyIndices[iAnimationProp]; } const char* aszAnimationNames[kMaxAnimations]; const char* aszAnimationProperties[kMaxAnimations][kMaxPropsPerAnimation]; uint32 acAnimationProperties[kMaxAnimations]; AnimationParser.EnumerateAnimations(aszAnimationNames, aszAnimationProperties, acAnimationProperties, &m_cAnimations); m_aAnimations = debug_newa(CAnimation, m_cAnimations); for ( uint32 iAnimation = 0 ; iAnimation < m_cAnimations ; iAnimation++ ) { m_aAnimations[iAnimation].m_iIndex = iAnimation; strcpy(m_aAnimations[iAnimation].m_szName, aszAnimationNames[iAnimation]); for ( uint32 iAnimationProperty = 0 ; iAnimationProperty < acAnimationProperties[iAnimation] ; iAnimationProperty++ ) { m_aAnimations[iAnimation].m_Props.Set(FindAnimationProp(aszAnimationProperties[iAnimation][iAnimationProperty])); } } const char* aszTransitionNames[kMaxTransitions]; const char* aszTransitionProperties[kMaxTransitions][kMaxPropsPerTransition][5]; uint32 acTransitionProperties[kMaxTransitions][5]; AnimationParser.EnumerateTransitions(aszTransitionNames, aszTransitionProperties, acTransitionProperties, &m_cTransitions); m_aTransitions = debug_newa(CTransition, m_cTransitions); for ( uint32 iTransition = 0 ; iTransition < m_cTransitions ; iTransition++ ) { m_aTransitions[iTransition].m_iIndex = iTransition; strcpy(m_aTransitions[iTransition].m_szName, aszTransitionNames[iTransition]); CAnimationProps* apProps[5] = { &m_aTransitions[iTransition].m_PropsInitial, &m_aTransitions[iTransition].m_PropsAdd, &m_aTransitions[iTransition].m_PropsRemove, &m_aTransitions[iTransition].m_PropsConstant, &m_aTransitions[iTransition].m_PropsNot }; for ( uint32 iSet = 0 ; iSet < 5 ; iSet++ ) { for ( uint32 iTransitionProperty = 0 ; iTransitionProperty < acTransitionProperties[iTransition][iSet] ; iTransitionProperty++ ) { apProps[iSet]->Set(FindAnimationProp(aszTransitionProperties[iTransition][iTransitionProperty][iSet])); } } } m_bInitialized = LTTRUE; return LTTRUE; }
LTBOOL CAIGoalButeMgr::Init(const char* szAttributeFile) { if (g_pAIGoalButeMgr || !szAttributeFile) return LTFALSE; if (!Parse(szAttributeFile)) { AIASSERT1( 0, NULL, "CAIGoalButeMgr::Init: Failed to parse %s", szAttributeFile ); return LTFALSE; } // Set up global pointer g_pAIGoalButeMgr = this; // Read Goal Sets. uint32 iGoalSet = 0; sprintf(s_aTagName, "%s%d", "GoalSet", iGoalSet); while (m_buteMgr.Exist(s_aTagName)) { ReadGoalSet(); ++iGoalSet; sprintf(s_aTagName, "%s%d", "GoalSet", iGoalSet); } // Create an array as big as the goal type enum list. m_aTemplates = debug_newa(AIGBM_GoalTemplate, kGoal_Count); // See how many goal templates there are uint32 cTemplates = 0; sprintf(s_aTagName, "%s%d", "Goal", cTemplates); while (m_buteMgr.Exist(s_aTagName)) { ++cTemplates; sprintf(s_aTagName, "%s%d", "Goal", cTemplates); } // Read the goal templates. for ( uint32 iTemplate = 0 ; iTemplate < cTemplates ; ++iTemplate ) { ReadGoalTemplate(iTemplate); } // Read SmartObject templates. uint32 iSmartObject = 0; sprintf(s_aTagName, "%s%d", "SmartObject", iSmartObject); while (m_buteMgr.Exist(s_aTagName)) { ReadSmartObjectTemplate(iSmartObject); ++iSmartObject; sprintf(s_aTagName, "%s%d", "SmartObject", iSmartObject); } m_buteMgr.Term(); return LTTRUE; }
//this will take a list of properties and convert it to internal values bool CBaseFXProps::ParseProperties(FX_PROP* pProps, uint32 nNumProps) { //counts of how many of each key uint32 nNumColorKeys = 0; uint32 nNumScaleKeys = 0; //go through the property list and parse in all the known variables and //count up how many of each key type we have uint32 nCurrProp = 0; for(nCurrProp = 0; nCurrProp < nNumProps; nCurrProp++) { FX_PROP& fxProp = pProps[nCurrProp]; if( !_stricmp( fxProp.m_sName, FXPROP_UPDATEPOS )) { m_nFollowType = (uint32)fxProp.GetComboVal(); } else if( !_stricmp( fxProp.m_sName, FXPROP_ATTACHNAME )) { fxProp.GetStringVal( m_szAttach ); } else if( !_stricmp( fxProp.m_sName, FXPROP_OFFSET )) { m_vOffset = fxProp.GetVector(); } else if( !_stricmp( fxProp.m_sName, FXPROP_ROTATEADD )) { m_vRotAdd = fxProp.GetVector(); } else if( !_stricmp( fxProp.m_sName, FXPROP_MENULAYER )) { m_nMenuLayer = fxProp.GetIntegerVal(); } else if( !_stricmp( fxProp.m_sName, "Ck" )) { nNumColorKeys++; } else if( !_stricmp( fxProp.m_sName, "Sk" )) { nNumScaleKeys++; } } //allocate our arrays of key types debug_deletea( m_pColorKeys ); m_pColorKeys = debug_newa( FX_COLOURKEY, nNumColorKeys ); m_nNumColorKeys = 0; debug_deletea( m_pScaleKeys ); m_pScaleKeys = debug_newa( FX_SCALEKEY, nNumScaleKeys ); m_nNumScaleKeys = 0; //now actually read in each key type for(nCurrProp = 0; nCurrProp < nNumProps; nCurrProp++) { FX_PROP& fxProp = pProps[nCurrProp]; if( !_stricmp( fxProp.m_sName, "Ck" )) { // Add this key to the list of keys FX_COLOURKEY fxClrKey; fxClrKey.m_tmKey = fxProp.m_data.m_clrKey.m_tmKey; fxClrKey.m_red = (float) (fxProp.m_data.m_clrKey.m_dwCol & 0x000000FF); fxClrKey.m_green = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0x0000FF00) >> 8); fxClrKey.m_blue = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0x00FF0000) >> 16); fxClrKey.m_alpha = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0xFF000000) >> 24); if(m_pColorKeys) m_pColorKeys[m_nNumColorKeys++] = fxClrKey; } else if( !_stricmp( fxProp.m_sName, "Sk" ))
void CTrackedNodeContext::_Init(EnumTrackedNodeGroup eGroup, bool bTrackOnAnim) { UBER_ASSERT( eGroup != kTrack_None, "CTrackedNodeContext::_Init: No tracking group specified." ); // Tracking node groups are optional per skeleton in ModelButes.txt. // A skeleton may not specify all (or any) tracking nodes. if( m_eTrackingNodes[eGroup] == eModelTrackingNodeGroupInvalid ) { return; } HTRACKEDNODE hTrackedNode, hTrackedNodeClone; const char* szName; LTVector vForward, vUp; LTFLOAT fDiscomfortX, fDiscomfortY, fMaxX, fMaxY, fMaxVel; uint32 iNode, iHNode; // Get the number of nodes. // Cloned nodes are specified within the node being cloned. uint32 cNodes = g_pModelButeMgr->GetNumTrackingNodes( m_eTrackingNodes[eGroup] ); uint32 cClonedNodes = g_pModelButeMgr->GetNumClonedTrackingNodes( m_eTrackingNodes[eGroup] ); UBER_ASSERT( cNodes + cClonedNodes > 0, "CTrackedNodeContext::_Init: No tracking nodes in group." ); m_cTrackedNodesPerGroup[eGroup] = cNodes + cClonedNodes; m_aTrackedNodeGroups[eGroup] = debug_newa( HTRACKEDNODE, cNodes + cClonedNodes ); // Keep separate index counters for nodes and node handles. // This is necessary because cloned nodes are specified within nodes being cloned, // so there are more iHNodes than iNodes. iHNode = 0; for( iNode=0; iNode < cNodes; ++iNode ) { // Create a tracking node. szName = g_pModelButeMgr->GetTrackingNodeName( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); hTrackedNode = m_pTrackedNodeMgr->CreateTrackingNode( m_hModel, szName ); // Get tracked node constraints from modelbutes.txt. fDiscomfortX = g_pModelButeMgr->GetTrackingNodeDiscomfortAngleX( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); fDiscomfortY = g_pModelButeMgr->GetTrackingNodeDiscomfortAngleY( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); fMaxX = g_pModelButeMgr->GetTrackingNodeMaxAngleX( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); fMaxY = g_pModelButeMgr->GetTrackingNodeMaxAngleY( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); fMaxVel = g_pModelButeMgr->GetTrackingNodeMaxVelocity( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); // Set tracked node constraints. // Specifying the forward and up vectors are optional. if( g_pModelButeMgr->GetTrackingNodeAxesSpecified( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ) ) { g_pModelButeMgr->GetTrackingNodeForward( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode, &vForward ); g_pModelButeMgr->GetTrackingNodeUp( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode, &vUp ); m_pTrackedNodeMgr->SetNodeConstraints( hTrackedNode, vForward, vUp, DEG2RAD(fDiscomfortX), DEG2RAD(fDiscomfortY), DEG2RAD(fMaxX), DEG2RAD(fMaxY), DEG2RAD(fMaxVel) ); } else { m_pTrackedNodeMgr->SetNodeConstraints( hTrackedNode, DEG2RAD(fDiscomfortX), DEG2RAD(fDiscomfortY), DEG2RAD(fMaxX), DEG2RAD(fMaxY), DEG2RAD(fMaxVel) ); } // Each node in modelbutes.txt is a child of the subsequent node. if( iNode > 0 ) { m_pTrackedNodeMgr->LinkNodes( m_aTrackedNodeGroups[eGroup][iHNode-1], hTrackedNode ); } // It is optional for a node to have a cloned node (e.g. left eye clones right eye orientation). szName = g_pModelButeMgr->GetTrackingNodeClonedName( m_eTrackingNodes[eGroup], (ModelTrackingNode)iNode ); if( szName[0] ) { hTrackedNodeClone = m_pTrackedNodeMgr->CreateTrackingNode( m_hModel, szName ); m_pTrackedNodeMgr->LinkNodeOrientation( hTrackedNodeClone, hTrackedNode ); m_aTrackedNodeGroups[eGroup][iHNode++] = hTrackedNodeClone; } // Record the new node handle. m_aTrackedNodeGroups[eGroup][iHNode++] = hTrackedNode; } // Track with rotations relative to animation rotations. SetOrientOnAnim( eGroup, bTrackOnAnim ); }
LTBOOL CModelButeMgr::Init(ILTCSBase *pInterface, const char* szAttributeFile) { if (g_pModelButeMgr || !szAttributeFile) return LTFALSE; if (!Parse(pInterface, szAttributeFile)) return LTFALSE; // Set up global pointer g_pModelButeMgr = this; // Count the node groups m_cSkeletons = 0; sprintf(s_aTagName, "%s%d", MODELBMGR_SKELETON, m_cSkeletons); while (m_buteMgr.Exist(s_aTagName)) { m_cSkeletons++; sprintf(s_aTagName, "%s%d", MODELBMGR_SKELETON, m_cSkeletons); } m_aSkeletons = debug_newa(CModelButeMgr::CSkeleton, m_cSkeletons); // Read in the nodegroups for ( int iSkeleton = 0 ; iSkeleton < m_cSkeletons ; iSkeleton++ ) { sprintf(s_aTagName, "%s%d", MODELBMGR_SKELETON, iSkeleton); // Get the skeleton's default death/long recoil anis strcpy(m_aSkeletons[iSkeleton].m_szDefaultFrontDeathAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_FRONT_DEATH_ANI)); strcpy(m_aSkeletons[iSkeleton].m_szDefaultBackDeathAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_BACK_DEATH_ANI)); strcpy(m_aSkeletons[iSkeleton].m_szDefaultFrontLongRecoilAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_FRONT_LONGRECOIL_ANI)); strcpy(m_aSkeletons[iSkeleton].m_szDefaultBackLongRecoilAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_BACK_LONGRECOIL_ANI)); strcpy(m_aSkeletons[iSkeleton].m_szDefaultFrontShortRecoilAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_FRONT_SHORTRECOIL_ANI)); strcpy(m_aSkeletons[iSkeleton].m_szDefaultBackShortRecoilAni, m_buteMgr.GetString(s_aTagName, MODELBMGR_SKELETON_DEFAULT_BACK_SHORTRECOIL_ANI)); // Get the skeleton's default hit node m_aSkeletons[iSkeleton].m_eModelNodeDefaultHit = (ModelNode)(uint8)m_buteMgr.GetInt(s_aTagName, MODELBMGR_SKELETON_DEFAULT_HIT_NODE); // Count the number of nodes m_aSkeletons[iSkeleton].m_cNodes = 0; sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_NAME, m_aSkeletons[iSkeleton].m_cNodes); while (m_buteMgr.Exist(s_aTagName, s_aAttName)) { m_aSkeletons[iSkeleton].m_cNodes++; sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_NAME, m_aSkeletons[iSkeleton].m_cNodes); } // Get all of our nodes m_aSkeletons[iSkeleton].m_aNodes = debug_newa(CModelButeMgr::CNode, m_aSkeletons[iSkeleton].m_cNodes); for ( int iNode = 0 ; iNode < m_aSkeletons[iSkeleton].m_cNodes ; iNode++ ) { // Get the node's name sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_NAME, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szName, m_buteMgr.GetString(s_aTagName, s_aAttName)); // Get the node's special flags sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_FLAGS, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_dwFlags = m_buteMgr.GetDword(s_aTagName, s_aAttName); // Get the node's death/long recoil animations sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_FRONT_DEATH_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szFrontDeathAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_BACK_DEATH_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szBackDeathAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_FRONT_LONGRECOIL_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szFrontLongRecoilAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_BACK_LONGRECOIL_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szBackLongRecoilAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_FRONT_SHORTRECOIL_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szFrontShortRecoilAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_BACK_SHORTRECOIL_ANI, iNode); strcpy(m_aSkeletons[iSkeleton].m_aNodes[iNode].m_szBackShortRecoilAni, m_buteMgr.GetString(s_aTagName, s_aAttName)); // Get the node's damage factor sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_DAMAGE_FACTOR, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_fDamageFactor = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, s_aAttName); // Get the node's parent sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_PARENT, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_eModelNodeParent = (ModelNode)(uint8)m_buteMgr.GetInt(s_aTagName, s_aAttName); // Get the node's recoil parent sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_RECOILPARENT, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_eModelNodeRecoilParent = (ModelNode)(uint8)m_buteMgr.GetInt(s_aTagName, s_aAttName); // Get the node's hit location sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_LOCATION, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_eHitLocation = (HitLocation)(uint8)m_buteMgr.GetInt(s_aTagName, s_aAttName, HL_UNKNOWN); // Get the node's hit radius sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_RADIUS, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_fHitRadius = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, s_aAttName); // Get the node's hit radius sprintf(s_aAttName, MODELBMGR_SKELETON_NODE_PRIORITY, iNode); m_aSkeletons[iSkeleton].m_aNodes[iNode].m_fHitPriority = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, s_aAttName); } } // Count the scripts m_cNScripts = 0; sprintf(s_aTagName, "%s%d", MODELBMGR_NODE_SCRIPT, m_cNScripts); while (m_buteMgr.Exist(s_aTagName)) { m_cNScripts++; sprintf(s_aTagName, "%s%d", MODELBMGR_NODE_SCRIPT, m_cNScripts); } m_aNScripts = debug_newa(CModelButeMgr::CNScript, m_cNScripts); // Read in the scripts for ( int iNScript = 0 ; iNScript < m_cNScripts ; iNScript++ ) { sprintf(s_aTagName, "%s%d", MODELBMGR_NODE_SCRIPT, iNScript); // Get the node's name strcpy(m_aNScripts[iNScript].m_szName, m_buteMgr.GetString(s_aTagName, MODELBMGR_NSCRIPT_NODE_NAME)); // Get the scripts flags m_aNScripts[iNScript].m_bFlags = (uint8)m_buteMgr.GetInt(s_aTagName, MODELBMGR_NSCRIPT_FLAGS); // Count the number of script sections m_aNScripts[iNScript].m_cNScriptPts = 0; sprintf(s_aAttName, MODELBMGR_NSCRIPT_NODE_TIME, m_aNScripts[iNScript].m_cNScriptPts); while (m_buteMgr.Exist(s_aTagName, s_aAttName)) { m_aNScripts[iNScript].m_cNScriptPts++; sprintf(s_aAttName, MODELBMGR_NSCRIPT_NODE_TIME, m_aNScripts[iNScript].m_cNScriptPts); } // Get all of our script sections m_aNScripts[iNScript].m_aNScriptPts = debug_newa(CModelButeMgr::CNScriptPt, m_aNScripts[iNScript].m_cNScriptPts); for ( int iNScriptPt = 0 ; iNScriptPt < m_aNScripts[iNScript].m_cNScriptPts ; iNScriptPt++ ) { // Get the node's time sprintf(s_aAttName, MODELBMGR_NSCRIPT_NODE_TIME, iNScriptPt); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_fTime = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, s_aAttName); // Each time must be greater than the previous... and the first one must be zero if(iNScriptPt > 0) _ASSERT(m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_fTime > m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt - 1].m_fTime); else _ASSERT(m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_fTime == 0.0f); // Get the node's offset position sprintf(s_aAttName, MODELBMGR_NSCRIPT_NODE_POSITION_OFFSET, iNScriptPt); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_vPosOffset = m_buteMgr.GetVector(s_aTagName, s_aAttName); // Get the node's offset rotation sprintf(s_aAttName, MODELBMGR_NSCRIPT_NODE_ROTATION_OFFSET, iNScriptPt); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_vRotOffset = m_buteMgr.GetVector(s_aTagName, s_aAttName); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_vRotOffset.x *= (MATH_PI / 180.0f); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_vRotOffset.y *= (MATH_PI / 180.0f); m_aNScripts[iNScript].m_aNScriptPts[iNScriptPt].m_vRotOffset.z *= (MATH_PI / 180.0f); } } // Count the styles m_cStyles = 0; sprintf(s_aTagName, "%s%d", MODELBMGR_STYLE, m_cStyles); while (m_buteMgr.Exist(s_aTagName)) { m_cStyles++; sprintf(s_aTagName, "%s%d", MODELBMGR_STYLE, m_cStyles); } m_aStyles = debug_newa(CModelButeMgr::CStyle, m_cStyles); // Read in the styles for ( int iStyle = 0 ; iStyle < m_cStyles ; iStyle++ ) { sprintf(s_aTagName, "%s%d", MODELBMGR_STYLE, iStyle); strcpy(m_aStyles[iStyle].m_szName, m_buteMgr.GetString(s_aTagName, MODELBMGR_STYLE_NAME)); } // Count the models m_cModels = 0; sprintf(s_aTagName, "%s%d", MODELBMGR_MODEL, m_cModels); while (m_buteMgr.Exist(s_aTagName)) { m_cModels++; sprintf(s_aTagName, "%s%d", MODELBMGR_MODEL, m_cModels); } m_aModels = debug_newa(CModelButeMgr::CModel, m_cModels); // Read in the models for ( int iModel = 0 ; iModel < m_cModels ; iModel++ ) { sprintf(s_aTagName, "%s%d", MODELBMGR_MODEL, iModel); strcpy(m_aModels[iModel].m_szName, m_buteMgr.GetString(s_aTagName, MODELBMGR_MODEL_NAME)); strcpy(m_aModels[iModel].m_szSex, m_buteMgr.GetString(s_aTagName, MODELBMGR_MODEL_SEX)); strcpy(m_aModels[iModel].m_szNationality, m_buteMgr.GetString(s_aTagName, MODELBMGR_MODEL_NATIONALITY)); m_aModels[iModel].m_eModelSkeleton = (ModelSkeleton)(uint8)m_buteMgr.GetInt(s_aTagName, MODELBMGR_MODEL_SKELETON); m_aModels[iModel].m_eModelType = (ModelType)(uint8)m_buteMgr.GetInt(s_aTagName, MODELBMGR_MODEL_TYPE); m_aModels[iModel].m_bModelEnvironmentMap = (LTBOOL)m_buteMgr.GetBool(s_aTagName, MODELBMGR_MODEL_ENVIRONMENTMAP); m_aModels[iModel].m_fModelMass = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, MODELBMGR_MODEL_MASS); m_aModels[iModel].m_fModelHitPoints = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, MODELBMGR_MODEL_HIT_POINTS); m_aModels[iModel].m_fModelMaxHitPoints = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, MODELBMGR_MODEL_MAX_HIT_POINTS); m_aModels[iModel].m_fModelArmor = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, MODELBMGR_MODEL_ARMOR); m_aModels[iModel].m_fModelMaxArmor = (LTFLOAT)m_buteMgr.GetDouble(s_aTagName, MODELBMGR_MODEL_MAX_ARMOR); } // Free up butemgr's memory and what-not. m_buteMgr.Term(); return LTTRUE; }
//loads the effect DLL bool CClientFXDB::LoadFxDll() { #ifdef WIN32 //make sure that we don't have any other dll's already bound UnloadFxDll(); // Load the library const char *sName = "ClientFX.fxd"; char sTmp[MAX_PATH + 1]; LTSNPrintF(sTmp, sizeof(sTmp), "Game\\%s", sName); //if we have a local copy use it if( CWinUtil::FileExist( sTmp )) { m_hDLLInst = ::LoadLibrary(sTmp); if (!m_hDLLInst) return false; } else { //otherwise copy it out of the rez file if (!strlen(sDLLTmpFile)) { DWORD sz = ::GetTempPath(sizeof(sTmp),sTmp); if (sz > sizeof(sTmp)) return false; ::GetTempFileName(sTmp,"cfx",0, sDLLTmpFile); if (LT_OK != g_pLTClient->CopyFile(sName,sDLLTmpFile)) return false; } m_hDLLInst = ::LoadLibrary(sDLLTmpFile); if (!m_hDLLInst) return false; } //merge our interface database with the database in the DLL we just loaded. TSetMasterFn pSetMasterFn = (TSetMasterFn)GetProcAddress(m_hDLLInst, "SetMasterDatabase"); //check if the function existed. if (pSetMasterFn != NULL) { //merge our database with theirs pSetMasterFn(GetMasterDatabase()); } // Attempt to retrieve the FX reference structure function FX_GETNUM pfnNum = (FX_GETNUM)::GetProcAddress(m_hDLLInst, "fxGetNum"); if (!pfnNum) return false; FX_GETREF pfnRef = (FX_GETREF)::GetProcAddress(m_hDLLInst, "fxGetRef"); if (!pfnRef) return false; FX_SETPLAYERFUNC pfnSetPlayer = (FX_SETPLAYERFUNC)::GetProcAddress(m_hDLLInst, "fxSetPlayer"); if (!pfnSetPlayer) return false; FX_SETAPPFOCUS pfnSetAppFocus = (FX_SETAPPFOCUS)::GetProcAddress(m_hDLLInst, "fxSetAppFocus"); if (!pfnSetAppFocus) return false; FX_DELETEFUNC pfnDelete = (FX_DELETEFUNC)::GetProcAddress(m_hDLLInst, "fxDelete"); if( !pfnDelete) return false; FX_SETCREATEFUNCTION pfnSetCreateFunction = (FX_SETCREATEFUNCTION)::GetProcAddress(m_hDLLInst, "fxSetCreateFunction"); if( !pfnSetCreateFunction) return false; FX_CREATEPROPLIST pfnCreatePropList = (FX_CREATEPROPLIST)::GetProcAddress(m_hDLLInst, "fxCreatePropList"); if( !pfnCreatePropList) return false; FX_FREEPROPLIST pfnFreePropList = (FX_FREEPROPLIST)::GetProcAddress(m_hDLLInst, "fxFreePropList"); if( !pfnFreePropList) return false; m_pfnSetPlayer = pfnSetPlayer; m_pfnSetAppFocus = pfnSetAppFocus; m_pfnDeleteFX = pfnDelete; m_pfnSetCreateFunction = pfnSetCreateFunction; m_pfnCreatePropList = pfnCreatePropList; m_pfnFreePropList = pfnFreePropList; // Okay, if we got here then this is a valid dll with some special // fx in it.... m_nNumEffectTypes = pfnNum(); //allocate our list of effect types m_pEffectTypes = debug_newa(FX_REF, m_nNumEffectTypes); if(!m_pEffectTypes) { m_nNumEffectTypes = 0; } else { for (uint32 nCurrEffect = 0; nCurrEffect < m_nNumEffectTypes; nCurrEffect ++) { // Retrieve the FX reference structure m_pEffectTypes[nCurrEffect] = pfnRef(nCurrEffect); } } #endif // Success !! return true; }
void CAIMgr::SetupNavMesh() { // The NavMesh only needs to be processed if we are // changing worlds. If we did not change worlds, // these functions will bail, because the NavMesh // will still have m_bNMInitialized set to true. if( !m_pAINavMesh->IsNavMeshInitialized() ) { m_pAINavMesh->SortAINavMeshLinks(); // Pack the NavMesh in-game. // This should be toggle-able once we can pack the NavMesh in the tools. CAINavMeshGen AINavMeshGen(NULL); // get the blind object data uint8* pDataRaw = NULL; uint32 nDataRawSize = 0; if( !CAINavMesh::GetNavMeshBlindObjectData(pDataRaw, nDataRawSize) ) { m_pAINavMesh->TermNavMesh(); m_pAIQuadTree->SetQuadTreeRoot( NULL ); return; } // contains the navmesh data after the header uint8* pNavMeshData = pDataRaw + sizeof(uint32); uint32 nNavMeshDataSize = nDataRawSize - sizeof(uint32); if( CAINavMesh::IsNavMeshBlindDataProcessed(pDataRaw, nDataRawSize) ) { // Handle endian conversion, as tools pack in little endian. // Everything in the nav mesh is 32-bit so convert it all in a single // operation. LTASSERT( ( (uint32)pNavMeshData % sizeof(uint32) ) == 0, "Unaligned nav mesh pointer encountered" ); LTASSERT( ( ( ( (uint32)pNavMeshData + nNavMeshDataSize ) ) % sizeof(uint32) ) == 0, "Unaligned nav mesh size encountered" ); #if defined(PLATFORM_XENON) // XENON: Swap data at runtime LittleEndianToNative( (uint32*)pNavMeshData, nNavMeshDataSize / sizeof(uint32) ); #endif // PLATFORM_XENON // it's already processed m_pAINavMesh->RuntimeSetup( pNavMeshData, false ); } else { if( AINavMeshGen.ImportRawNavMesh(pNavMeshData) ) { Tuint8List ProcessedData; ILTOutStream* pProcessedStream = streamsim_OutMemStream(ProcessedData); if(!pProcessedStream) { m_pAINavMesh->TermNavMesh(); m_pAIQuadTree->SetQuadTreeRoot( NULL ); return; } ILTOutConverter* pProcessedConverter = new LTOutNullConverter(*pProcessedStream); if(!pProcessedConverter) { m_pAINavMesh->TermNavMesh(); m_pAIQuadTree->SetQuadTreeRoot( NULL ); return; } AINavMeshGen.InitNavMeshGen( LTVector( 0.f, 0.f, 0.f ) ); if( !AINavMeshGen.ExportPackedNavMesh(*pProcessedConverter) ) { m_pAINavMesh->TermNavMesh(); m_pAIQuadTree->SetQuadTreeRoot( NULL ); return; } AINavMeshGen.TermNavMeshGen(); //release our converter stream LTSafeRelease(pProcessedConverter); // copy buffer uint32 nDataSize = ProcessedData.size(); uint8* pDataBuffer = debug_newa(uint8, nDataSize); if( !pDataBuffer ) { m_pAINavMesh->TermNavMesh(); m_pAIQuadTree->SetQuadTreeRoot( NULL ); return; } memcpy( pDataBuffer, &ProcessedData[0], nDataSize ); // Initialize the run-time NavMesh with the packed data. m_pAINavMesh->RuntimeSetup( pDataBuffer, true ); } } } }
bool CClientFXDB::ReadFXGroup( bool bText, ILTStream* pFxFile, FX_GROUP* pFxGroup, FX_PROP* pPropBuffer, uint32 nBuffLen ) { assert(pFxGroup); //make sure to clear out any data already in the effect group pFxGroup->Term(); // Read in the number of FX in this group uint32 dwNumFx = 0; uint32 dwPhaseLen = 0; if( bText ) { // Read in the name of this FX group ReadTextFile( pFxFile, "%s %s", pFxGroup->m_sName ); ReadTextFile( pFxFile, "%s %lu", &dwNumFx ); // Read in the phase length ReadTextFile( pFxFile, "%s %lu", &dwPhaseLen ); } else { pFxFile->Read(&dwNumFx, sizeof(uint32)); // Read in the name of this FX group pFxFile->Read(pFxGroup->m_sName, 128); // Read in the phase length pFxFile->Read(&dwPhaseLen, sizeof(dwPhaseLen)); } // Initialize total time to zero, then find the total time // as we read in the keys. pFxGroup->m_tmTotalTime = dwPhaseLen / 1000.0f; //allocate room for the FX pFxGroup->m_pKeys = debug_newa(FX_KEY, dwNumFx); if(!pFxGroup->m_pKeys) return false; //save the number of keys pFxGroup->m_nNumKeys = dwNumFx; // Read in the FXKey for( uint32 nCurrEffect = 0; nCurrEffect < dwNumFx; nCurrEffect ++ ) { ReadFXKey( bText, pFxFile, pFxGroup->m_tmTotalTime, &pFxGroup->m_pKeys[nCurrEffect], pPropBuffer, nBuffLen ); } //we need to sort the effects based upon the order that they need to be created in. The creation //order needs to have any effects that are motion linked come last so that they can have the //effects that they are linked to created before them //This sort is a sort of bubble sort where it will go through and if it finds any effects //that violate this property, it will correct them. It needs to take care to properly handle //cyclic graphs though, which are invalid for(uint32 nCurrPass = 0; nCurrPass < dwNumFx; nCurrPass++) { bool bDoneSorting = true; //take a pass through to sort... for(uint32 nCurrKey = 0; nCurrKey < dwNumFx; nCurrKey++) { //see if this effect is motion linked, if not we don't need to worry if(!pFxGroup->m_pKeys[nCurrKey].m_bLinked) continue; //get the ID of the node we are linked to uint32 nLinkID = pFxGroup->m_pKeys[nCurrKey].m_dwLinkedID; //it is linked, we need to see if the effect that it is linked to comes after for(uint32 nCurrLink = nCurrKey + 1; nCurrLink < dwNumFx; nCurrLink++) { if(pFxGroup->m_pKeys[nCurrLink].m_dwID == nLinkID) { //this is the effect and it does come after, so we need to swap it FX_KEY TempKey = pFxGroup->m_pKeys[nCurrKey]; pFxGroup->m_pKeys[nCurrKey] = pFxGroup->m_pKeys[nCurrLink]; pFxGroup->m_pKeys[nCurrLink] = TempKey; //we have to take another pass again just to make sure bDoneSorting = false; break; } } } //see if we are done sorting if(bDoneSorting) break; } //alright, by this time either we are in order, or there is a cyclic dependency return true; }