/* virtual */ void ICreature::StartDying(DyingControl& dyingControl) { Base::StartDying(dyingControl); CastEigenToInduced(); ResetTarget(); dyingControl.SetDyingDelay(StartDyingAnimation()); }
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); }
static void WriteDevice(int theTTY,int fd) // read the tty, send characters to the serial device { char buffer[2048]; int action, // indicates if external action is to be taken -- don't send the command characters to the device numRead, idx; while(!done) { // read some characters from the tty numRead=read(theTTY,buffer,2048); if(numRead>0) { // scan for the exit and reset codes action=0; for(idx=0;!done&&idx<numRead;idx++) { if(buffer[idx]==exitCode) { action=1; done=1; } if(buffer[idx]==resetCode) { // reset the target, if able if(ResetTarget(fd)>=0) { action=1; ReportString(REPORT_INFO,"\n resetting target...\n"); } } } // send characters to the serial device (read return value to silence the compiler) if(!action) { numRead=write(fd,buffer,numRead); } } } }
void Prey::ChaseLeader() { try { mCurTarget = MyLeader; if (GetLeaderDistance()>(LeaderRadius - LeaderBuffer)) { //cout<<"Chasing Leader"<<endl; Chase(); } else { //cout<<"Within Normal range"<<endl; FSTATE = FS_NORMAL; PatrolMode(); ResetTarget(); } } catch (...) { MessageBox(NULL, "ChaseLeader", "something happened", MB_OK); } }
void CreatureMotionSys::ResetToDefaults() { ResetTarget(); m_PrevMotionTaskState = MotionTaskState::INVALID; }