bool CDynaLightFX::Update(float tmFrameTime) { //track our performance CTimedSystemBlock TimingBlock(g_tsClientFXLight); // Base class update first BaseUpdate(tmFrameTime); //update our light position LTRigidTransform tObjTrans; GetCurrentTransform(GetUnitLifetime(), tObjTrans.m_vPos, tObjTrans.m_rRot); g_pLTClient->SetObjectTransform(m_hLight, tObjTrans); //if we are shutting down, clear the radius of this light if (IsShuttingDown()) { g_pLTClient->SetLightRadius(m_hLight, 0.0f); return true; } float fUnitLifetime = GetUnitLifetime(); UpdateDynamicProperties(fUnitLifetime); return true; }
void Application::Run() { if (!BaseStartup()) { return; } while (BaseUpdate()) { //Update } }
bool CBaseSpriteFX::Update(float tmFrameTime) { // Base class update first BaseUpdate(tmFrameTime); //update our object position LTRigidTransform tObjTrans; GetCurrentTransform(GetUnitLifetime(), tObjTrans.m_vPos, tObjTrans.m_rRot); g_pLTClient->SetObjectTransform(m_hObject, tObjTrans); //update our rotation and keep it in a reasonable numerical range m_fCurrRotationRad += GetProps()->m_fRotationVelRad * tmFrameTime; m_fCurrRotationRad = fmodf(m_fCurrRotationRad, MATH_TWOPI); return true; }
bool CDebrisSystemFX::Update( float tmFrameTime ) { //track our performance CTimedSystemBlock TimingBlock(g_tsClientFXDebrisSystem); //allow the base effect to handle any updates BaseUpdate(tmFrameTime); //determine if this is our initial update and we need to create our debris. We do this //after the update since the newly created effects will already be in place if(IsInitialFrame()) { CreateDebrisEmission(); } return true; }
void XnVMessageListener::Run(XnUInt32 nSessionMaxLength) { if (!IsInActivityThread()) { return; } XnUInt32 nSessionLength = 0; while (!m_pMessageQueue->IsEmpty() && nSessionLength < nSessionMaxLength) { XnVMessage* pMessage = NULL; XnStatus rc = m_pMessageQueue->Pop(pMessage); if (rc == XN_STATUS_OK && pMessage != NULL) { xnLogVerbose(XNV_NITE_MASK_MT_QUEUE, "Listener %s [%08x]: Read from queue (%s)", GetListenerName(), this, pMessage->GetType()); BaseUpdate(pMessage); XN_DELETE(pMessage); nSessionLength++; } } } // XnVMessageListener::Run
bool CTracerFX::Update(float tmFrameTime) { //track our performance CTimedSystemBlock TimingBlock(g_tsClientFXTracer); // Base class update first BaseUpdate(tmFrameTime); //determine the length of this tracer float fTracerLen = GetTracerLength(); //update the position along the ray m_fRayPosition += GetProps()->m_fVelocity * tmFrameTime; float fTracerHead = m_fRayPosition; float fTracerTail = m_fRayPosition - fTracerLen; //now we need to find the extents of the segment float fSegmentStart = LTCLAMP(fTracerHead, 0.0f, m_fRayLength); float fSegmentEnd = LTCLAMP(fTracerTail, 0.0f, m_fRayLength); //now we generate a bounding box around these points LTVector vCenter = m_vStartPos + m_vDirection * ((fSegmentStart + fSegmentEnd) * 0.5f); //and now the half dimensions that encompass the tracer LTVector vHalfDims = m_vDirection * ((fSegmentStart - fSegmentEnd) * 0.5f); //make sure that this half dims represents the maximum extents vHalfDims.Max(-vHalfDims); //extend the half dims to include the thickness of the tracer float fUnitLifetime = GetUnitLifetime(); float fHalfThickness = GetProps()->m_ffcThickness.GetValue(fUnitLifetime) * 0.5f; vHalfDims += LTVector(fHalfThickness, fHalfThickness, fHalfThickness); //and now setup the object position and visibility g_pLTClient->SetObjectPos(m_hObject, vCenter); g_pLTClient->GetCustomRender()->SetVisBoundingBox(m_hObject, -vHalfDims, vHalfDims); //handle updating the light if we have one if(m_hTracerLight) { //the light needs to be moved to the center of the tracer g_pLTClient->SetObjectPos(m_hTracerLight, vCenter); //and have the intensity controlled by how much of the tracer is visible float fVisible = (fSegmentStart - fSegmentEnd) / fTracerLen; if(fVisible > 0.01f) { g_pLTClient->Common()->SetObjectFlags(m_hTracerLight, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); g_pLTClient->SetLightIntensityScale(m_hTracerLight, fVisible); } else { g_pLTClient->Common()->SetObjectFlags(m_hTracerLight, OFT_Flags, 0, FLAG_VISIBLE); } } //we are done if the tracer is past the end of the ray return (m_fRayPosition - GetTracerLength() < m_fRayLength); }
bool CCreateRayFX::Update( float tmFrameTime ) { //track our performance CTimedSystemBlock TimingBlock(g_tsClientFXCreateRayFX); //update our base object BaseUpdate(tmFrameTime); //we only want to create the effect as we become active if(IsInitialFrame() && (GetProps()->m_nNumToCreate > 0)) { //determine the object position and orientation of our object LTVector vObjPos; LTRotation rObjRot; GetCurrentTransform(GetUnitLifetime(), vObjPos, rObjRot); //handle two special pipelines to gain performance when there is no scattering if(MATH_RADIANS_TO_DEGREES(GetProps()->m_fRandomCone) < 1.0f) { LTRigidTransform tHitTrans; HOBJECT hHitObj; //no scattering, just do a single intersection for all effects if(DetermineIntersection(vObjPos, rObjRot.Forward(), hHitObj, tHitTrans)) { //and now generate all of our effects for(uint32 nCurrEffect = 0; nCurrEffect < GetProps()->m_nNumToCreate; nCurrEffect++) { CLIENTFX_CREATESTRUCT CreateStruct("", GetProps()->m_nFXFlags, hHitObj, tHitTrans); CBaseCreateFX::CreateEffect(CreateStruct); } } } else { //we need to scatter //extract our vectors from the orientation LTVector vObjRight, vObjUp, vObjForward; rObjRot.GetVectors(vObjRight, vObjUp, vObjForward); //and now generate all of our effects for(uint32 nCurrEffect = 0; nCurrEffect < GetProps()->m_nNumToCreate; nCurrEffect++) { LTRigidTransform tHitTrans; HOBJECT hHitObj; //now build up the forward within a specified cone //first off spin it randomly around the forward float fPlaneAngle = GetRandom(0.0f, MATH_CIRCLE); LTVector vPlaneVector = vObjRight * cosf(fPlaneAngle) + vObjUp * sinf(fPlaneAngle); //now tilt it away from the forward vector float fTiltPercent = powf(GetRandom(0.0f, 1.0f), GetProps()->m_fCenterBias); float fTiltAngle = fTiltPercent * GetProps()->m_fRandomCone; LTVector vRandomForward = vObjForward * cosf(fTiltAngle) + vPlaneVector * sinf(fTiltAngle); if(DetermineIntersection(vObjPos, vRandomForward, hHitObj, tHitTrans)) { CLIENTFX_CREATESTRUCT CreateStruct("", GetProps()->m_nFXFlags, hHitObj, tHitTrans); CBaseCreateFX::CreateEffect(CreateStruct); } } } } //we always return false because we always want to be placed into a shutting down state since //we just emit and then do nothing return false; }