//---------------------------------------------------------------------------- bool WaterDropFormation::OnInitialize () { if ( !Application::OnInitialize() ) return false; // create scene m_spkScene = new Node; m_spkTrnNode = new Node(3); m_spkScene->AttachChild(m_spkTrnNode); CreatePlane(); CreateWall(); CreateWaterRoot(); // wireframe m_spkWireframe = new WireframeState; m_spkScene->SetRenderState(m_spkWireframe); // depth buffer ZBufferState* pkZBuffer = new ZBufferState; pkZBuffer->Enabled() = true; pkZBuffer->Writeable() = true; pkZBuffer->Compare() = ZBufferState::CF_LEQUAL; m_spkScene->SetRenderState(pkZBuffer); Configuration0(); // center-and-fit for camera viewing m_spkScene->UpdateGS(0.0f); Bound kWBound = m_spkScene->WorldBound(); m_spkTrnNode->Translate() = -kWBound.Center(); ms_spkCamera->SetFrustum(0.1f,1000.0f,-0.055f,0.055f,0.04125f,-0.04125f); float fAngle = 0.01f*Mathf::PI; float fCos = Mathf::Cos(fAngle), fSin = Mathf::Sin(fAngle); Vector3f kCUp(fSin,0.0f,-fCos); Vector3f kCDir(-fCos,0.0f,-fSin); Vector3f kCLeft(0.0f,1.0f,0.0f); Vector3f kCLoc = -0.9f*kWBound.Radius()*kCDir; ms_spkCamera->SetFrame(kCLoc,kCLeft,kCUp,kCDir); // initial update of objects ms_spkCamera->Update(); m_spkScene->UpdateGS(0.0f); m_spkScene->UpdateRS(); m_spkMotionObject = m_spkScene; m_bTurretActive = true; SetTurretAxes(); m_fTrnSpeed = 0.01f; m_fRotSpeed = 0.001f; m_fLastSeconds = GetTimeInSeconds(); return true; }
//---------------------------------------------------------------------------- void WaterDropFormation::CreateScene () { mScene = new0 Node(); mTrnNode = new0 Node(); mScene->AttachChild(mTrnNode); mWireState = new0 WireState(); mRenderer->SetOverrideWireState(mWireState); CreatePlane(); CreateWall(); CreateWaterRoot(); Configuration0(); }
//---------------------------------------------------------------------------- void WaterDropFormation::PhysicsTick () { mSimTime += mSimDelta; if (mSimTime <= 1.0f) { // Water surface extruded to form a water drop. DoPhysical1(); } else if (mSimTime <= 2.0f) { // Water drop splits from water surface. DoPhysical2(); } else if (mSimTime <= 4.0f) { // Water drop continues downward motion, surface no longer changes. DoPhysical3(); } else { // Restart the animation. Configuration0(); } }
//---------------------------------------------------------------------------- void WaterDropFormation::DoPhysical () { m_fSimTime += m_fSimDelta; if ( m_fSimTime <= 1.0f ) { // water surface extruded to form a water drop DoPhysical1(); } else if ( m_fSimTime <= 2.0f ) { // water drop splits from water surface DoPhysical2(); } else if ( m_fSimTime <= 4.0f ) { // water drop continues downward motion, surface no longer changes DoPhysical3(); } else { // restart Configuration0(); } }