RESULT ParticleManager::Start( IN ParticleEmitter* pParticleEmitter ) { RESULT rval = S_OK; CPR(pParticleEmitter); /* if (!pParticleEmitter->IsStarted()) { pParticleEmitter->Start(); m_runningParticleEmittersList.push_front( pParticleEmitter ); } else { RETAILMSG(ZONE_ERROR, "ERROR: ParticleEmitterManager::Start( %s ): already started", pParticleEmitter->GetName().c_str()); rval = E_FAIL; } */ if (!pParticleEmitter->IsStarted()) { m_runningParticleEmittersList.push_front( pParticleEmitter ); } pParticleEmitter->Start(); Exit: return rval; }
void activate(int y, int x) { /* Set the cell alive in the array */ CPR(y,x); /* And show it visually too */ mvwaddch(life, y, x, 'X'); }
RESULT ParticleManager::Pause( IN ParticleEmitter* pParticleEmitter ) { RESULT rval = S_OK; CPR(pParticleEmitter); if (pParticleEmitter->IsStarted()) { // pParticleEmitter->Pause(); ParticleEmitterListIterator ppParticleEmitter; ppParticleEmitter = find( m_runningParticleEmittersList.begin(), m_runningParticleEmittersList.end(), pParticleEmitter ); if (ppParticleEmitter != m_runningParticleEmittersList.end()) { m_runningParticleEmittersList.erase( ppParticleEmitter ); } } else { // RETAILMSG(ZONE_WARN, "WARNING: ParticleEmitterManager::Pause( %s ): already paused", pParticleEmitter->GetName().c_str()); rval = E_INVALID_OPERATION; } pParticleEmitter->Pause(); Exit: return rval; }
RESULT ParticleManager::Init( IN const string& settingsFilename ) { RETAILMSG(ZONE_PARTICLES, "ParticleManager::Init( %s )", settingsFilename.c_str()); RESULT rval = S_OK; char path[MAX_PATH]; // // Create a Settings object and load the file. // Settings mySettings; if ( FAILED(mySettings.Read( settingsFilename )) ) { RETAILMSG(ZONE_ERROR, "ERROR: ParticleManager::Init( %s ): failed to load settings file", settingsFilename.c_str() ); return E_UNEXPECTED; } // // Create each ParticleEmitter. // UINT32 numParticleEmitters = mySettings.GetInt("/ParticleEmitters.NumParticleEmitters"); for (int i = 0; i < numParticleEmitters; ++i) { sprintf(path, "/ParticleEmitters/ParticleEmitter%d", i); ParticleEmitter *pParticleEmitter = new ParticleEmitter(); CPR(pParticleEmitter); string name = mySettings.GetString( string(path) + ".Name" ); string filename = mySettings.GetString( string(path) + ".Filename" ); bool deleteOnFinish = mySettings.GetBool ( string(path) + ".DeleteOnFinish", false ); pParticleEmitter->SetDeleteOnFinish( deleteOnFinish ); if ( FAILED(pParticleEmitter->InitFromFile( filename ))) { RETAILMSG(ZONE_ERROR, "ERROR: ParticleManager::Init( %s ): failed to init ParticleEmitter from file %s", filename.c_str()); // Continue loading other ParticleEmitters rather than aborting. continue; } RETAILMSG(ZONE_INFO, "ParticleEmitter[%4d]: \"%-32s\"", pParticleEmitter->GetID(), pParticleEmitter->GetName().c_str()); CHR(Add(name, pParticleEmitter)); } Exit: return rval; }
RESULT ParticleManager::ReleaseOnNextFrame( IN ParticleEmitter* pParticleEmitter ) { RESULT rval = S_OK; CPR(pParticleEmitter) m_pendingReleaseParticleEmittersList.push_back( pParticleEmitter ); // TEST: DEBUGMSG(ZONE_PARTICLES, "ParticleManager::ReleaseOnNextFrame( \"%s\" )", pParticleEmitter->GetName().c_str()); Exit: return rval; }
RESULT ParticleManager::Draw( IN ParticleEmitter* pParticleEmitter, IN const mat4& matParentWorld ) { RESULT rval = S_OK; CPR(pParticleEmitter); if ( !pParticleEmitter->GetVisible() || !pParticleEmitter->IsStarted() ) { return S_OK; } pParticleEmitter->Draw( matParentWorld ); Exit: return rval; }
//==========================================================================* // Function: InitNetworkListView // // Purpose: Initialize the wireless network list view // // Arguments: // [IN] psInfo - pointer to the WLAN_INFO structure // // Return Values: // HRESULT - S_OK for succeed //==========================================================================* static HRESULT InitNetworkListView(PWLAN_INFO psInfo) { HRESULT hr = S_OK; LV_COLUMN lvc = {0}; DWORD dwStyle; RECT rc; HWND hwndNetList; INT nStatusColumnWidth; hwndNetList = psInfo->hwndNetList = GetDlgItem(psInfo->hDlg, IDC_WZC_LIST_NETWORKS); GetClientRect(hwndNetList, &rc); // // Change the Style and StyleEx dwStyle = GetWindowLong(hwndNetList, GWL_STYLE); SetWindowLong(hwndNetList, GWL_STYLE, (dwStyle | LVS_SHAREIMAGELISTS)); ListView_SetExtendedListViewStyleEx(hwndNetList, LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE, LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE); // // Create state image lists psInfo->hImgs = DPI_ImageList_LoadImage(HINST_RESDLL, MAKEINTRESOURCE(IDB_WZC_STATE), AM_NETUI_WZCSTATEICONS_CX, 0, CLR_NONE, IMAGE_BITMAP, 0); CPR(psInfo->hImgs); ListView_SetImageList(hwndNetList, psInfo->hImgs, LVSIL_SMALL); // // Insert two columns network name and network state lvc.mask = LVCF_FMT | LVCF_WIDTH; lvc.fmt = LVCFMT_LEFT; // nStatusColumnWidth = CalculateStatusColumnWidth(psInfo); // Network name column lvc.cx = rc.right - GetSystemMetrics(SM_CXVSCROLL) - nStatusColumnWidth; ListView_InsertColumn(hwndNetList, 0, &lvc); // Network state lvc.cx = nStatusColumnWidth; ListView_InsertColumn(hwndNetList, 1, &lvc); Error: return hr; }
RESULT LayerManager::Draw( IN Layer* pLayer, IN const mat4& matParentWorld ) { RESULT rval = S_OK; CPR(pLayer); if ( !pLayer->GetVisible() ) { return S_OK; } if (Log::IsZoneEnabled(ZONE_LAYER) && (pLayer->GetNumSprites() || pLayer->GetNumGameObjects() || (pLayer->GetNumLayers()))) { RETAILMSG(ZONE_LAYER, "LayerManager::Draw(): \"%s\" %d sprites %d GOs %d emitters %d layers", pLayer->GetName().c_str(), pLayer->GetNumSprites(), pLayer->GetNumGameObjects(), pLayer->GetNumEmitters(), pLayer->GetNumLayers()); char str[256]; sprintf(str, "%s %lu %lu %lu Effect: %s", pLayer->GetName().c_str(), pLayer->GetNumSprites(), pLayer->GetNumGameObjects(), pLayer->GetNumEmitters(), pLayer->GetEffect().GetName().c_str()); DebugRender.Text(str, Color::Green(), 1.0f, 1.0f); } pLayer->Draw( GameCamera.GetViewMatrix() ); // DEBUGMSG(ZONE_LAYER, "LayerManager::Draw(): \"%s\" DONE", // pLayer->GetName().c_str()); Exit: return rval; }
HRESULT COpenGLRenderer::Create( __deref_out IRenderer** ppRenderer ) { RETAILMSG(ZONE_FUNCTION, (TEXT("COpenGLRenderer::Create()"))); HRESULT hr = S_OK; COpenGLRenderer* pOpenGLRenderer = NULL; pOpenGLRenderer = new COpenGLRenderer(); CPR(pOpenGLRenderer); *ppRenderer = pOpenGLRenderer; pOpenGLRenderer = NULL; Error: SAFE_DELETE(pOpenGLRenderer); return hr; }
HRESULT RegValueSZ(HKEY hKey, LPCTSTR szName, LPTSTR* ppszValue, DWORD cbLen) { HRESULT hr = S_OK; DWORD dwRet, cbBufLen; BOOL fDelete = FALSE; CBR(hKey != NULL && ppszValue != NULL); cbBufLen = 0; dwRet = RegQueryValueEx(hKey, szName, NULL, NULL, NULL, &cbBufLen); CBR(dwRet == ERROR_SUCCESS); if (!cbLen) { *ppszValue = (LPTSTR)LocalAlloc(LPTR, cbBufLen); CPR(*ppszValue); cbLen = cbBufLen; // This flag is to only free space // allocated here if RegQuery fails below // We should not free space being passed in. fDelete = TRUE; } dwRet = RegQueryValueEx(hKey, szName, NULL, NULL, (LPBYTE)*ppszValue, &cbLen); if (dwRet != ERROR_SUCCESS && !cbLen) { if(fDelete) { LocalFree(*ppszValue); // Avoid a potential double free in the calling function *ppszValue = NULL; } } CBR(dwRet == ERROR_SUCCESS); Error: return hr; }
RESULT LayerManager::CreateLayer( IN const Settings* pSettings, IN const string& settingsPath, INOUT Layer** ppLayer ) { RESULT rval = S_OK; string name; if (!pSettings || "" == settingsPath || !ppLayer) { RETAILMSG(ZONE_ERROR, "ERROR: LayerManager::CreateLayer(): invalid argument"); return E_INVALID_ARG; } Layer *pLayer = new Layer(); CPR(pLayer); name = pSettings->GetString( settingsPath + ".Name" ); pLayer->Init( name ); // Caller must AddRef() *ppLayer = pLayer; Exit: return rval; }
void OnEAPProps(HWND hDlg, PWLAN_CFG_PROPS psProp) { HRESULT hr = S_OK; HINSTANCE hinstEAPDll = NULL; WZC_EAP_CB_ITEMDATA *pEapCbItemData; PEAP_EXTENSION_INFO pCurExt=NULL; HWND hwndCbEAPType = GetDlgItem(hDlg, IDC_WZC_COMBO_EAP_TYPE); int iListIndex = ComboBox_GetCurSel(hwndCbEAPType); DWORD dwError = (DWORD)-1; UCHAR *pConnectionDataOut=NULL; DWORD dwSizeOfConnectionDataOut=0; UNREFERENCED_PARAMETER(psProp); pEapCbItemData = (WZC_EAP_CB_ITEMDATA *)ComboBox_GetItemData(hwndCbEAPType,iListIndex); if (pEapCbItemData) { pCurExt = pEapCbItemData->pEapExtInfo; } if (pCurExt && pCurExt->wszConfigUIPath) { RASEAPINVOKECONFIGUI pfnEapConfig; RASEAPFREE pfnEapFreeMem; hinstEAPDll = LoadLibrary(pCurExt->wszConfigUIPath); CBR(hinstEAPDll != NULL); pfnEapConfig = (RASEAPINVOKECONFIGUI)GetProcAddress(hinstEAPDll,TEXT("RasEapInvokeConfigUI")); pfnEapFreeMem= (RASEAPFREE)GetProcAddress(hinstEAPDll,TEXT("RasEapFreeMemory")); CBR((pfnEapConfig != NULL) && (pfnEapFreeMem != NULL)); // Call into config UI __try { dwError = pfnEapConfig(pCurExt->dwExtensionType, hDlg, 0, // flags TBD pEapCbItemData->pbAuthData, pEapCbItemData->dwAuthDataLen, &pConnectionDataOut, &dwSizeOfConnectionDataOut); } __except(WatsonReportFault(GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER)) { } CBR(dwError == ERROR_SUCCESS); if (dwSizeOfConnectionDataOut && pConnectionDataOut) { if (pEapCbItemData->pbAuthData) { LocalFree(pEapCbItemData->pbAuthData); } pEapCbItemData->pbAuthData = LocalAlloc(LPTR, dwSizeOfConnectionDataOut); CPR(pEapCbItemData->pbAuthData); pEapCbItemData->dwAuthDataLen = dwSizeOfConnectionDataOut; __try { memcpy(pEapCbItemData->pbAuthData, pConnectionDataOut,dwSizeOfConnectionDataOut); } __except(WatsonReportFault(GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER)) { LocalFree(pEapCbItemData->pbAuthData); pEapCbItemData->pbAuthData = NULL; pEapCbItemData->dwAuthDataLen = 0; } __try { pfnEapFreeMem(pConnectionDataOut); } __except(WatsonReportFault(GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER)) { ; } } }
DWORD EapTlsInvokeConfigUI( IN DWORD dwEapTypeId, IN HWND hwndParent, IN DWORD dwFlags, IN BYTE* pConnectionDataIn, IN DWORD dwSizeOfConnectionDataIn, OUT BYTE** ppConnectionDataOut, OUT DWORD* pdwSizeOfConnectionDataOut ) { UNREFERENCED_PARAMETER(dwFlags); EAPTLS_CONN_PROPERTIES_V1* pConnProp = NULL; PCCERT_CONTEXT pCertContext = NULL; HCERTSTORE hMyStore = NULL; DWORD dwErr = NO_ERROR; HRESULT hr = S_OK; DWORD cbHash = 0, dwConnFlags; BYTE bHash[MAX_HASH_SIZE], *pbHashCert = NULL; BOOL bSuccess, fCapi2 = FALSE; INT cnCerts = 0, nSelected = -1; DWORD dwValidServerClert, dwType, cb; hr = LoadCAPI2(); CHR(hr); fCapi2 = TRUE; dwConnFlags = (dwEapTypeId == PPP_EAP_PEAP) ? EAPTLS_CONN_FLAG_NO_CLIENT_CERT : 0; cb = sizeof(dwValidServerClert); if (ERROR_SUCCESS == SHRegQueryValueEx(HKEY_CURRENT_USER, c_szValidateServerCert, (DWORD *)c_szRegistryKey, &dwType, (BYTE *)&dwValidServerClert, &cb)) { CBR(REG_DWORD == dwType); // dwValidServerClert = 0 - don't validate server certification if (dwValidServerClert == 0) { dwConnFlags |= EAPTLS_CONN_FLAG_NO_VALIDATE_CERT; // we do not validate server cert by default } } else { // We dvalidates server cert by default } pConnProp = InitConnectionData(pConnectionDataIn, dwSizeOfConnectionDataIn, dwConnFlags); CPR(pConnProp); hMyStore = pfnCertOpenStore(CERT_STORE_PROV_SYSTEM_W, CRYPT_ASN_ENCODING, 0, CERT_SYSTEM_STORE_CURRENT_USER, TEXT("MY")); CBR(hMyStore); // Enum on personal cert store while (NULL != (pCertContext = pfnCertEnumCertificatesInStore(hMyStore, pCertContext))) { BYTE bHashTemp[MAX_HASH_SIZE]; DWORD cbHashTemp = ARRAYSIZE(bHashTemp); bSuccess = pfnCertGetCertificateContextProperty(pCertContext, CERT_HASH_PROP_ID, bHashTemp, &cbHashTemp); if ( nSelected < 0 // There is matched cert && cbHashTemp && cbHashTemp == pConnProp->UserHash.cbHash // The size of certs are equal && memcmp(bHashTemp, pConnProp->UserHash.pbHash, cbHashTemp) == 0) { nSelected = cnCerts; cbHash = cbHashTemp; memcpy(bHash, bHashTemp, cbHash); } cnCerts++; } if (cnCerts == 0) { // There is no cert on the device, warrning! MessageBox(SHGetLastActiveWindow(hwndParent), (PTSTR)LoadString(HINST_RESDLL, IDS_NETUI_EAPTLS_NO_CERT, NULL, 0), (PTSTR)LoadString(HINST_RESDLL, IDS_NETUI_WRN_TITLE_WARNING, NULL, 0), MB_OK | MB_SETFOREGROUND); dwErr = ERROR_NOT_FOUND; } else if (cnCerts > 0) { DWORD cbHashCert = 0; // Need to let user choice one hr = PickCertificateDlg(NULL, TEXT("MY"), c_szPickCertHelpLink, (PTSTR)LoadString(HINST_RESDLL, IDS_NETUI_EAPTLS_DESC, NULL, 0), bHash, cbHash, &pbHashCert, &cbHashCert); CHR(hr); CBRA(cbHashCert <= MAX_HASH_SIZE); memcpy(pConnProp->UserHash.pbHash, pbHashCert, cbHashCert); pConnProp->UserHash.cbHash = cbHashCert; *ppConnectionDataOut = (BYTE*)pConnProp; *pdwSizeOfConnectionDataOut = pConnProp->dwSize; } Error: pfnCertFreeCertificateContext(pCertContext); pfnCertCloseStore(hMyStore, 0); LocalFree(pbHashCert); if (fCapi2) { FreeCAPI2(); } return FAILED(hr) ? ERROR_NOT_FOUND : dwErr; }
//==========================================================================* // Function: OnMenuPopup // // Purpose: Enable and disable wireless network context menu items. // We need to show/hide connect or disconnect items according to // the connection state of the network. // The first listview item "add new setting..." doesn't have a context menu // // Arguments: // [IN] psInfo - pointer to the WLAN_INFO structure // [IN] hMenu - HANDLE to the menu // [IN] iItem - item need to show menu // // Return Values: // BOOL - TRUE for handle it successfully //==========================================================================* static void OnMenuPopup(PWLAN_INFO psInfo, HMENU hMenu, INT iItem) { HRESULT hr = S_OK; PCSHWZCNET pwzcnet; DWORD dwState = 0, dwSize; BOOL fEnableConnect = BOOLIFY(iItem); BOOL fEnableRemove = BOOLIFY(iItem); BOOL fEnableEdit = BOOLIFY(iItem); LPTSTR pNetwork; // "Turn Wi-Fi Off/On" RemoveMenu(hMenu, IDM_WZC_WIFI_POWERCMD, MF_BYCOMMAND); InsertMenu(hMenu, (UINT)-1, MF_BYPOSITION|MF_STRING, IDM_WZC_WIFI_POWERCMD, LoadStringEtc(HINST_RESDLL, IDS_WZC_WIFI_POWERON + ((psInfo->dwHWFlags & SHWZCF_HW_ON) ? 1:0), NULL)); pwzcnet = (PCSHWZCNET)GetListItemLPARAM(psInfo->hwndNetList, iItem); CBR(pwzcnet != NULL); dwSize = ARRAYSIZE(pwzcnet->szName); pNetwork = (LPTSTR)LocalAlloc(NONZEROLPTR, dwSize * sizeof(TCHAR)); CPR(pNetwork); StringCchCopy(pNetwork, dwSize, pwzcnet->szName); ((CNetworkObject*)(psInfo->pNetworkObject))->SetData(pNetwork, CF_UNICODETEXT); SHQueryMenuExtensions(psInfo->hContextExt ? psInfo->hContextExt : psInfo->hSoftKeyExt, hMenu, 0xFFFFFFFF, IDM_WZC_MENU_EXT_FIRST, IDM_WZC_MENU_EXT_LAST, CMF_NORMAL); // Get the current state SHWZCGetState(psInfo->hshwzc, &dwState); // If the selected network is ad-hoc, but there are infrastructure networks // airing, we can't connect, since ad-hoc networks are always considered // connected, unless the hardware is limited to use ONLY ad-hoc networks. if ((SHWZCF_NET_ADHOC & pwzcnet->dwFlags) && SHWZCF_ALLOW_ADHOC != (SHWZCF_ALLOW_MASK & dwState) && psInfo->fAPAir) { fEnableConnect = FALSE; } // If we're already connected to the selected network, we can't // "re-connect" else if (SHWZCF_NET_CONNECT_MASK & pwzcnet->dwFlags) { fEnableConnect = FALSE; } // If the selected network isn't preferred, disable the "Remove Settings" if (0 == (SHWZCF_NET_PREFERRED & pwzcnet->dwFlags)) { fEnableRemove = FALSE; } // If the selected network is a "permanent" non-editable network, disable both // "Remove Settings" and "Edit" if (SHWZCIsPermanentNetwork(pwzcnet->szName, BOOLIFY(SHWZCF_NET_ADHOC & pwzcnet->dwFlags))) { fEnableRemove = FALSE; fEnableEdit = FALSE; } Error: EnableMenuItem(hMenu, IDM_WZC_NETWORK_CONNECT, fEnableConnect ? MF_ENABLED : MF_GRAYED); EnableMenuItem(hMenu, IDM_WZC_NETWORK_REMOVE, fEnableRemove ? MF_ENABLED : MF_GRAYED); EnableMenuItem(hMenu, IDM_WZC_NETWORK_PROPERTIES, fEnableEdit ? MF_ENABLED : MF_GRAYED); return; }
IPSTATE GetIPState(LPCTSTR pszAdapter, LPTSTR pszAddress, UINT cchAddress) { HRESULT hr = S_OK; IPSTATE state = IPSTATE_DHCP; ULONG ulAdapterIndex; PIP_ADAPTER_INFO paiBuffer = NULL; ULONG cbBuffer = 0; DWORD dwError; PIP_ADAPTER_INFO paiCurrent; PIP_PER_ADAPTER_INFO pper = NULL; // Check inputs CBRAEx(NULL != pszAdapter, E_INVALIDARG); // Get the adapter index CBR(NO_ERROR == GetAdapterIndex(const_cast<LPWSTR>(pszAdapter), &ulAdapterIndex)); // Get the status of all connected adapters cbBuffer = sizeof(IP_ADAPTER_INFO); paiBuffer = (PIP_ADAPTER_INFO)LocalAlloc(LMEM_FIXED, cbBuffer); CPR(paiBuffer); while (ERROR_BUFFER_OVERFLOW == (dwError = GetAdaptersInfo(paiBuffer, &cbBuffer))) { PIP_ADAPTER_INFO paiTemp = (PIP_ADAPTER_INFO)LocalReAlloc(paiBuffer, cbBuffer, LMEM_MOVEABLE); CPR(paiTemp); paiBuffer = paiTemp; } CBR(NO_ERROR == dwError); // Find our adapter index for (paiCurrent = paiBuffer; paiCurrent; paiCurrent = paiCurrent->Next) { if (paiCurrent->Index == ulAdapterIndex) { break; } } CBR(NULL != paiCurrent); // did we find it? CBR(NULL != paiCurrent->CurrentIpAddress); // Is this adapter using DHCP? if (!paiCurrent->DhcpEnabled) { state = IPSTATE_CONNECTED; } else { // Get the per-adapter info cbBuffer = sizeof(IP_PER_ADAPTER_INFO); pper = (PIP_PER_ADAPTER_INFO)LocalAlloc(LMEM_FIXED, cbBuffer); CPR(pper); while (ERROR_BUFFER_OVERFLOW == (dwError = GetPerAdapterInfo(ulAdapterIndex, pper, &cbBuffer))) { PIP_PER_ADAPTER_INFO pperTemp = (PIP_PER_ADAPTER_INFO)LocalReAlloc(pper, cbBuffer, LMEM_MOVEABLE); CPR(pperTemp); pper = pperTemp; } CBR(NO_ERROR == dwError); // Are we using an automatic IP? if (pper->AutoconfigActive || IsAutoIPAddr(paiCurrent->CurrentIpAddress->IpAddress.String)) { state = IPSTATE_AUTOIP; } } // Optionally copy the IP address string to the output if (NULL != pszAddress && 0 != cchAddress) { UINT cchInput = strlen(paiCurrent->CurrentIpAddress->IpAddress.String); if (cchInput >= cchAddress) { cchInput = cchAddress - 1; } MultiByteToWideChar(CP_ACP, 0, paiCurrent->CurrentIpAddress->IpAddress.String, cchInput, pszAddress, cchAddress); pszAddress[cchAddress-1] = TEXT('\0'); } Error: LocalFree(pper); LocalFree(paiBuffer); return (SUCCEEDED(hr) ? state : IPSTATE_DISCONNECTED); }
RESULT Animation::Init ( IN const string& name, IN const string& propertyName, IN PropertyType propertyType, IN InterpolatorType interpolatorType, IN KeyFrameType keyFrameType, IN const KeyFrame* pKeyFrames, IN UINT8 numKeyFrames, IN bool isRelative ) { RESULT rval = S_OK; if (!pKeyFrames || !numKeyFrames) { RETAILMSG(ZONE_ERROR, "ERROR: Animation::Init(): must pass pKeyFrames, numKeyFrames."); rval = E_INVALID_DATA; goto Exit; } if (name == "") { char randomName[MAX_NAME]; sprintf(randomName, "Animation_%X", (unsigned int)Platform::Random()); m_name = randomName; } else { m_name = name; } m_propertyName = propertyName; switch (propertyType) { case PROPERTY_FLOAT: case PROPERTY_UINT32: case PROPERTY_BOOL: case PROPERTY_VEC2: case PROPERTY_VEC3: case PROPERTY_VEC4: case PROPERTY_IVEC2: case PROPERTY_IVEC3: case PROPERTY_IVEC4: m_propertyType = propertyType; break; default: RETAILMSG(ZONE_ERROR, "ERROR: Animation::Init(): unknown property type [%d]", propertyType); rval = E_INVALID_DATA; goto Exit; } switch (interpolatorType) { case INTERPOLATOR_TYPE_LINEAR: case INTERPOLATOR_TYPE_QUADRATIC_IN: case INTERPOLATOR_TYPE_QUADRATIC_OUT: case INTERPOLATOR_TYPE_QUADRATIC_INOUT: case INTERPOLATOR_TYPE_ELASTIC_IN: m_interpolatorType = interpolatorType; break; default: RETAILMSG(ZONE_ERROR, "ERROR: Animation::Init(): unknown interpolator type [%d]", interpolatorType); rval = E_INVALID_DATA; goto Exit; } switch (keyFrameType) { case KEYFRAME_TYPE_FLOAT: case KEYFRAME_TYPE_UINT32: case KEYFRAME_TYPE_VEC2: case KEYFRAME_TYPE_VEC3: case KEYFRAME_TYPE_VEC4: case KEYFRAME_TYPE_COLOR: m_keyFrameType = keyFrameType; break; default: RETAILMSG(ZONE_ERROR, "ERROR: Animation::Init(): unknown keyframe type [%d]", keyFrameType); DEBUGCHK(0); rval = E_INVALID_DATA; goto Exit; } m_pKeyFrames = new KeyFrame[ numKeyFrames ]; CPR(m_pKeyFrames); memcpy( m_pKeyFrames, pKeyFrames, numKeyFrames*sizeof(KeyFrame) ); m_numKeyFrames = numKeyFrames; m_relativeToCurrentState = isRelative; m_durationMS = m_pKeyFrames[ m_numKeyFrames-1 ].GetTimeMS(); RETAILMSG(ZONE_ANIMATION, "Animation[%4d]: %2d frames %d MSec \"%-32s\"", m_ID, m_numKeyFrames, m_durationMS, m_name.c_str()); Exit: return rval; }
RESULT Animation::UpdateTarget( KeyFrame* pFrame1, KeyFrame* pFrame2, float progress ) { RESULT rval = S_OK; CPR(pFrame1); CPR(pFrame2); if (!m_isBoundToProperty) { DEBUGCHK(0); rval = E_INVALID_OPERATION; goto Exit; } DEBUGCHK(m_pTargetProperty); switch (m_keyFrameType) { case KEYFRAME_TYPE_UINT32: { UINT32 value = (*m_pInterpolator)( (UINT32)pFrame1->GetIntValue(), (UINT32)pFrame2->GetIntValue(), progress ); value += m_startingValue.GetIntValue(); m_pTargetProperty->SetInteger( value ); } break; case KEYFRAME_TYPE_FLOAT: { float value = (*m_pInterpolator)( (float)pFrame1->GetFloatValue(), (float)pFrame2->GetFloatValue(), progress ); value += m_startingValue.GetFloatValue(); m_pTargetProperty->SetFloat( value ); } break; case KEYFRAME_TYPE_VEC2: { vec2 value = (*m_pInterpolator)( (vec2)pFrame1->GetVec2Value(), (vec2)pFrame2->GetVec2Value(), progress ); value += m_startingValue.GetVec2Value(); m_pTargetProperty->SetVec2( value ); } break; case KEYFRAME_TYPE_VEC3: { vec3 value = (*m_pInterpolator)( (vec3)pFrame1->GetVec3Value(), (vec3)pFrame2->GetVec3Value(), progress ); value += m_startingValue.GetVec3Value(); m_pTargetProperty->SetVec3( value ); } break; case KEYFRAME_TYPE_VEC4: { vec4 value = (*m_pInterpolator)( (vec4)pFrame1->GetVec4Value(), (vec4)pFrame2->GetVec4Value(), progress ); value += m_startingValue.GetVec4Value(); m_pTargetProperty->SetVec4( value ); } break; case KEYFRAME_TYPE_COLOR: { Color value = (*m_pInterpolator)( (Color)pFrame1->GetColorValue(), (Color)pFrame2->GetColorValue(), progress ); value += m_startingValue.GetColorValue(); m_pTargetProperty->SetColor( value ); } break; default: DEBUGCHK(0); break; } Exit: return rval; }