void CsShipObject::Update() { btVector3 vel = mRigidBody->getLinearVelocity(); float linVel = vel.length(); // jet sound mJetSound.SetPosition(mRigidBody->getWorldTransform().getOrigin()); mJetSound.SetVelocity(vel); mJetSound.UpdateSound(); float pitchf = 1 + (linVel - 150) / 300.0f; alSourcef(mJetSound.mSource, AL_PITCH, pitchf); if (mAIShip == true) { UpdateAI(); return; } // perform radar upadates (target autolocking) if (((int)CsGame::GetSingletonPtr()->GetGameTime()) % TARGET_SCAN_DELAY == 0) FindNewTarget(this); if (mTarget) { if (!mTarget->IsActive()) ResetTarget(); } //SetTarget(CsGame::GetSingletonPtr()->GetGroundEnemyManager()->at(0)->GetNode()); // clear and set forces (and torques as well) mRigidBody->clearForces(); btQuaternion btQuat = GetConvertedTrans().getRotation(); Ogre::Quaternion quat(btQuat.w(), btQuat.x(), btQuat.y(), btQuat.z()); Ogre::Vector3 ogreZ = quat.zAxis(); btVector3 zAxis = btVector3(ogreZ.x, ogreZ.y, ogreZ.z); Ogre::Vector3 ogreX = quat.xAxis(); btVector3 xAxis = btVector3(ogreX.x, ogreX.y, ogreX.z); btVector3 yAxis = OgretoBullet(quat.yAxis()); mRigidBody->applyCentralForce(-zAxis * mThrottleForce); // tweak velocity //float vel = mRigidBody->getLinearVelocity().length(); mRigidBody->setLinearVelocity( -zAxis * 0.05 * linVel + 0.95 * mRigidBody->getLinearVelocity() ); // roll; if (mRollTorque != 0) { mRigidBody->applyTorque(zAxis * mRollTorque); //mRigidBody->applyTorque(yAxis * mRollTorque / 2.0); } //if (mRollTorque != 0) mRigidBody->applyTorque(zAxis * mRollTorque / 100 * mass); // pitch //if (mPitchTorque != 0) mRigidBody->applyTorque(xAxis * mPitchTorque / 100 * mass); if (mPitchTorque != 0) mRigidBody->applyTorque(xAxis * mPitchTorque); }
void AIRobot::Update(float elapsedTime) { // Step 1 : check for enemy // TODO : Finish this part and decide what to do CheckForEnemy(); // Step 2 : check if we reached target if (isCloseEnough()) { mGridPos = mGridTarget; FindNewTarget(); } // Step 3 : move towards target MoveToTarget(elapsedTime); }
void CCameraView::OnFindBTS() { m_ctrlCameraTree.SetActiveWindow(); m_ctrlCameraTree.SetFocus(); CString str; m_pEdtFind ->GetWindowText(str); if ( str.IsEmpty() ) return; if (str == m_sFindStr) FindNextTarget(); else { BOOL bFind = FindNewTarget( str ); if (!bFind) AfxMessageBox("没有找到!"); } }