void KillableTargetActor::SetCurrentHealth(int currentHealth) { currentHealth = dtUtil::Max(currentHealth, 0); if (currentHealth == 0 && mCurrentHealth > currentHealth && mCurrentHealth != 0) { mLargeExplosion->SetEnabled(true); SwitchVisitor switchVisitor("Destroyed"); GetOSGNode()->accept(switchVisitor); mCurrentShaderName = "Normal"; ApplyMyShader(); } else if (currentHealth != 0 && mCurrentHealth > currentHealth) { mSmallExplosion->SetEnabled(true); } else if (currentHealth > 0 && mCurrentHealth == 0) { SwitchVisitor switchVisitor("Good"); GetOSGNode()->accept(switchVisitor); } mCurrentHealth = currentHealth; GetGameActorProxy().NotifyFullActorUpdate(); }
void BezierController::RenderProxyNode(bool pEnable) { mRenderGeode = pEnable; if (mRenderGeode) { GetOSGNode()->asGroup()->addChild(mGeode.get()); } else { GetOSGNode()->asGroup()->removeChild(mGeode.get()); } }
osg::Matrix RocketLauncher::GetLaunchLocation() { osg::Matrix launchLocation; dtCore::RefPtr<dtUtil::NodeCollector> collect = new dtUtil::NodeCollector(GetOSGNode(), dtUtil::NodeCollector::MatrixTransformFlag); osg::MatrixTransform* launchTransform = collect->GetMatrixTransform(GetRocketNodeToFire()); if (launchTransform != NULL) { launchLocation = SMK::GetAbsoluteMatrix(GetOSGNode(), launchTransform); } else { dtCore::Transform currentTransform; GetTransform(currentTransform); currentTransform.Get(launchLocation); } return launchLocation; }
void MineActor::OnEnteredWorld() { SetupFloaterComponent(); SetMeshResource("Boat:Mine_LG.ive"); // Retrieve the shader from the shader manager and assign it to this stateset dtCore::ShaderManager& shaderManager = dtCore::ShaderManager::GetInstance(); const dtCore::ShaderProgram* prototypeProgram = shaderManager.FindShaderPrototype("BumpedPhong"); dtCore::ShaderProgram* program = shaderManager.AssignShaderFromPrototype(*prototypeProgram, *GetOSGNode()); assert(program); }
void KillableTargetActor::ApplyMyShader() { float prevTime = 0.0, prevX = 0.0, prevY = 0.0, prevZ = 0.0; dtCore::ShaderParamOscillator* timerParam = NULL; if (mCurrentShader != NULL && mCurrentShader->GetName() == mCurrentShaderName) { // don't reload stuff or we kill our processing. return; } // if we had a previous shader, then get the current values of our float timers. Then, // after we reassign them, we can put them back where they were. Avoids 'jumping' if (mCurrentShader != NULL) { // TIME DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("TimeDilation")); if (timerParam != NULL) { prevTime = timerParam->GetValue(); } // X DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveXDilation")); if (timerParam != NULL) { prevX = timerParam->GetValue(); } // Y DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveYDilation")); if (timerParam != NULL) { prevY = timerParam->GetValue(); } // Z DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveZDilation")); if (timerParam != NULL) { prevZ = timerParam->GetValue(); } } // clean up any previous shaders, if any dtCore::ShaderManager::GetInstance().UnassignShaderFromNode(*GetOSGNode()); dtCore::ShaderProgram* templateShader = dtCore::ShaderManager::GetInstance(). FindShaderPrototype(mCurrentShaderName,"TargetShaders"); if (templateShader != NULL) { mCurrentShader = dtCore::ShaderManager::GetInstance(). AssignShaderFromPrototype(*templateShader, *GetOSGNode()); // Put the shader values back (again, to avoid jumping since we are moving XYZ in our shader) // TIME DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("TimeDilation")); if (timerParam != NULL) { timerParam->SetValue(prevTime); } // X DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveXDilation")); if (timerParam != NULL) { timerParam->SetValue(prevX); } // Y DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveYDilation")); if (timerParam != NULL) { timerParam->SetValue(prevY); } // Z DILATION timerParam = dynamic_cast<dtCore::ShaderParamOscillator*> (mCurrentShader->FindParameter("MoveZDilation")); if (timerParam != NULL) { timerParam->SetValue(prevZ); } } else { LOG_ERROR("KillableTargetActor could not load shader for group[TargetShaders] with name [" + mCurrentShaderName + "]"); mCurrentShader = NULL; } }