void Camera::Move3D() { if (m_moveState.forward) { Walk(m_speed * m_msec); } if (m_moveState.back) { Walk(-m_speed * m_msec); } if (m_moveState.left) { Strafe(m_speed * m_msec); } if (m_moveState.right) { Strafe(-m_speed * m_msec); } if (m_moveState.up) { Lift(m_speed * m_msec); } if (m_moveState.down) { Lift(-m_speed * m_msec); } }
task autonomous() { /*while (bIfiAutonomousMode) { getInput(); processAutonomous(); //doOutput(); }*/ /*Drive(FORWARD); //Drive Lift(UP); //Raise Lift wait1Msec(2000); SingleTurnRight(127); //Wiggle Right wait1Msec(700); Drive(STOP); wait1Msec(100); SingleTurnLeft(127); //Wiggle Left wait1Msec(900); SingleTurnRight(127); //Wiggle Back Right wait1Msec(200); Drive(FORWARD); //Drive wait1Msec(700); SingleTurnRight(127); //Turn More Right wait1Msec(500); Drive(FORWARD); //Drive into goal wait1Msec(1500); Drive(BACKWARD); //Back up a bit wait1Msec(500); Drive(STOP); Intake(OUT); //Release the Muffins! wait1Msec(1500); wait1Msec(1500); Intake(OUT); wait1Msec(1500); Intake(STOP);*/ Lift(UP); //Raise Lift wait1Msec(1100); while(true) { Drive(FORWARD); //Drive wait1Msec(1500); Drive(STOP); wait1Msec(500); Lift(20); //Hold the cage up wait1Msec(500); Intake(OUT); //Release the Muffins! wait1Msec(5000); Intake(STOP); Drive(BACKWARD); wait1Msec(1800); Drive(STOP); //Again again! while (nLCDButtons == 0) { } wait1Msec(200); } }
void Aircraft::Update(float elapsedTime) { Move(); Lift(); Bank(); UpdateWorld(); }
int main() { initialize(); Wait(); Lift(); Wait(); ArmStack(); }
int main() { create_connect(); enable_servos(); set_create_total_angle(0); set_create_distance(0); WhichSide(); CenterCamera(); Lift(); }
template <class cCRNode> void cTplCoxRoyAlgo<cCRNode>::Discharge(const cRoyPt & aPU) { mNbDischarge++; /* stats */ cCRNode & aNodU = NodeOfP(aPU); while( aNodU.Excess() > 0 ) { /* special case : push back to source */ if( aNodU.SourceConnected() && aNodU.Height()==mSourceHeight+1 ) { /* push back into source */ //printf("*** returned %d to source from (%d,%d,%d) ***\n",mLNodes[u].e,x,y,d); aNodU.SetExcess(0); break; } /* special case : push to sink */ if ( aNodU.SinkConnected() && aNodU.Height()==mSinkHeight+1 ) { /* push into sink */ /** printf("*** added %d to sink from (%d,%d,%d) ***\n",mLNodes[u].e,x,y,d); **/ mSinkFlow+=aNodU.Excess(); aNodU.SetExcess(0); break; } int ed = aNodU.CurrentEdge(); if( ( aNodU.EdgeIsValide(ed) ) && ( aNodU.Over1(NodeOfP(cRoyPt(aPU,ed)))) && ( aNodU.UnSatured(ed)) ) { Push(aPU,ed); continue; } aNodU.SetCurrentEdge(ed+1); if( aNodU.CurrentEdge()==eNbEdges ) { bool OkLift = Lift(aPU); aNodU.SetCurrentEdge(0); /** special case **/ /** if node at or above source, remove excess **/ if( aNodU.Height() > mSourceHeight ) { aNodU.SetExcess(0); break; } if (!OkLift) return; } } }
//------------------------------------------------------------------------ void CVehicleMovementStdBoat::Reset() { CVehicleMovementBase::Reset(); Lift(false); m_waveTimer = Random()*gf_PI; m_prevAngle = 0.0f; m_diving = false; m_wakeSlot = -1; m_rpmPitchDir = 0; m_waveSoundPitch = 0.f; m_inWater = false; }
//------------------------------------------------------------------------ void CVehicleMovementStdBoat::Reset() { CVehicleMovementBase::Reset(); Lift(false); m_waveTimer = cry_random(0.0f, gf_PI); m_prevAngle = 0.0f; m_diving = false; m_wakeSlot = -1; m_rpmPitchDir = 0; m_waveSoundPitch = 0.f; m_inWater = false; m_factorMaxSpeed = 1.f; m_factorAccel = 1.f; }
void Control(){ Base(); Lift(); lcd(); }
void small_Energy_Progress_Measure(node** nodes, int N) { int i; lista_bidirezionale** lista_L = (lista_bidirezionale**) malloc(sizeof(lista_bidirezionale*)); int* inlistaL = calloc(N,sizeof(int)); for (i=0; i<N; i++){ //printlist(nodes[i]->out_neighbour); edgeList* iteratore; // = malloc(sizeof(edgeList)); iteratore = nodes[i]->out_neighbour; if (nodes[i]->player == 0){ int counter = 0; while(iteratore != NULL){ if (iteratore->weight < 0){ counter++; iteratore = iteratore->next; } else { break; } } if (counter == nodes[i]->out_degree){ lista_L = aggiungiNodo(lista_L, nodes[i]->id); inlistaL[nodes[i]->id]=1; } }else { while(iteratore != NULL){ if (iteratore->weight < 0){ lista_L = aggiungiNodo(lista_L, nodes[i]->id); inlistaL[nodes[i]->id]=1; break; }else{ iteratore = iteratore->next; } } } //printlist(nodes[i]->out_neighbour); } int* f = calloc(N,sizeof(int)); int* count = malloc(N*sizeof(int)); int T = makeTop(nodes,N); printf("Il top è %i \n", T); printL(*lista_L,nodes); for (i=0; i<N; i++){ if (nodes[i]-> player == 0){ if (inLista(nodes[i]->id, *lista_L)){ count[i] = 0; } else { count[i] = setCount_v(nodes,nodes[i]->id,T,f); } } } printL(*lista_L,nodes); /* lista_bidirezionale* it = *lista_L; while (it != NULL){ fprintf(stderr, " %i \n",it->id); it = it-> next; } */ int old_f, v; lista_bidirezionale* it = *lista_L; while (it != NULL){ v = (*lista_L) -> id; old_f = f[v]; it = eliminaNodo(*lista_L, lista_L); inlistaL[v]=0; f[v] = Lift(f,v,nodes,T); printf("f[%s] vale %i \n",nodes[v]->label,f[v]); if (nodes[v]->player == 0) count[v] = setCount_v(nodes,v,T,f); edgeList* v_1 = nodes[v]->in_neighbour; while (v_1 != NULL){ //fprintf(stderr,"v_1 e' %s \n",nodes[v_1->id]->label); if (f[v_1->id] < confronta_misure(f[v],v_1->weight,T)){ if (nodes[v_1->id]->player == 0) { if (f[v_1->id] >= confronta_misure(old_f,v_1->weight,T)) count[v_1->id]-= 1; if (count[v_1->id] <= 0){ //fprintf(stderr,"count[%s] <= 0 Aggiungo il nodo %s a L\n",nodes[v_1->id]->label,nodes[v_1->id]->label); if (inlistaL[nodes[v_1->id]->id]==0){ lista_L = aggiungiNodo(lista_L, nodes[v_1->id]->id); inlistaL[nodes[v_1->id]->id]=1; it = *lista_L; } } } else{ if (inlistaL[nodes[v_1->id]->id]==0){ lista_L = aggiungiNodo(lista_L, nodes[v_1->id]->id); inlistaL[nodes[v_1->id]->id]=1; it = *lista_L; } } } v_1 = v_1 -> next; } printL(*lista_L,nodes); } for (i=0; i<N; i++){ if (f[i] == T) fprintf(stdout, "Il nodo %s ha misura = T \n",nodes[i]->label); else fprintf(stdout, "Il nodo %s ha misura = %i \n",nodes[i]->label , f[i]); } }
////////////////////////////////////////////////////////////////////////// // NOTE: This function must be thread-safe. Before adding stuff contact MarcoC. void CVehicleMovementStdBoat::ProcessMovement(const float deltaTime) { FUNCTION_PROFILER( GetISystem(), PROFILE_GAME ); static const float fWaterLevelMaxDiff = 0.15f; // max allowed height difference between propeller center and water level static const float fSubmergedMin = 0.01f; static const float fMinSpeedForTurn = 0.5f; // min speed so that turning becomes possible if (m_bNetSync) m_netActionSync.UpdateObject(this); CryAutoCriticalSection lk(m_lock); CVehicleMovementBase::ProcessMovement(deltaTime); IEntity* pEntity = m_pVehicle->GetEntity(); IPhysicalEntity* pPhysics = pEntity->GetPhysics(); SVehiclePhysicsStatus* physStatus = &m_physStatus[k_physicsThread]; assert(pPhysics); float frameTime = min(deltaTime, 0.1f); if (abs(m_movementAction.power) < 0.001f) m_movementAction.power = 0.f; if (abs(m_movementAction.rotateYaw) < 0.001f) m_movementAction.rotateYaw = 0.f; Matrix34 wTM( physStatus->q ); wTM.AddTranslation( physStatus->pos ); Matrix34 wTMInv = wTM.GetInvertedFast(); Vec3 localVel = wTMInv.TransformVector( physStatus->v ); Vec3 localW = wTMInv.TransformVector( physStatus->w ); const Vec3 xAxis = wTM.GetColumn0(); const Vec3 yAxis = wTM.GetColumn1(); const Vec3 zAxis = wTM.GetColumn2(); // check if propeller is in water Vec3 worldPropPos = wTM * m_pushOffset; float waterLevelWorld = gEnv->p3DEngine->GetWaterLevel( &worldPropPos ); float fWaterLevelDiff = worldPropPos.z - waterLevelWorld; bool submerged = physStatus->submergedFraction > fSubmergedMin; m_inWater = submerged && fWaterLevelDiff < fWaterLevelMaxDiff; float speed = physStatus->v.len2() > 0.001f ? physStatus->v.len() : 0.f; float speedRatio = min(1.f, speed/(m_maxSpeed*m_factorMaxSpeed)); float absPedal = abs(m_movementAction.power); float absSteer = abs(m_movementAction.rotateYaw); // wave stuff float waveFreq = 1.f; waveFreq += 3.f*speedRatio; float waveTimerPrev = m_waveTimer; m_waveTimer += frameTime*waveFreq; // new randomized amount for this oscillation if (m_waveTimer >= gf_PI && waveTimerPrev < gf_PI) m_waveRandomMult = cry_random(0.0f, 1.0f); if (m_waveTimer >= 2*gf_PI) m_waveTimer -= 2*gf_PI; float kx = m_waveIdleStrength.x*(m_waveRandomMult+0.3f) * (1.f-speedRatio + m_waveSpeedMult*speedRatio); float ky = m_waveIdleStrength.y * (1.f - 0.5f*absPedal - 0.5f*absSteer); Vec3 waveLoc = m_massOffset; waveLoc.y += speedRatio*min(0.f, m_pushOffset.y-m_massOffset.y); waveLoc = wTM * waveLoc; bool visible = m_pVehicle->GetGameObject()->IsProbablyVisible(); bool doWave = visible && submerged && physStatus->submergedFraction < 0.99f; if (doWave && !m_isEnginePowered) m_pVehicle->NeedsUpdate(IVehicle::eVUF_AwakePhysics); if (m_isEnginePowered || (visible && !m_pVehicle->IsProbablyDistant())) { if (doWave && (m_isEnginePowered || g_pGameCVars->v_rockBoats)) { pe_action_impulse waveImp; waveImp.angImpulse.x = Boosting() ? 0.f : sinf(m_waveTimer) * frameTime * m_Inertia.x * kx; if (isneg(waveImp.angImpulse.x)) waveImp.angImpulse.x *= (1.f - min(1.f, 2.f*speedRatio)); // less amplitude for negative impulse waveImp.angImpulse.y = sinf(m_waveTimer-0.5f*gf_PI) * frameTime * m_Inertia.y * ky; waveImp.angImpulse.z = 0.f; waveImp.angImpulse = wTM.TransformVector(waveImp.angImpulse); waveImp.point = waveLoc; if (!m_movementAction.isAI) pPhysics->Action(&waveImp, 1); } } // ~wave stuff if (!m_isEnginePowered) return; pe_action_impulse linearImp, angularImp, dampImp, liftImp; float turnAccel = 0, turnAccelNorm = 0; if (m_inWater) { // Lateral damping if (m_lateralDamping>0.f) { pe_action_impulse impulse; impulse.impulse = - physStatus->mass * xAxis * (localVel.x * (frameTime * m_lateralDamping)/(1.f + frameTime*m_lateralDamping)); pPhysics->Action(&impulse, 1); } // optional lifting (catamarans) if (m_velLift > 0.f) { if (localVel.y > m_velLift && !IsLifted()) Lift(true); else if (localVel.y < m_velLift && IsLifted()) Lift(false); } if (Boosting() && IsLifted()) { // additional lift force liftImp.impulse = Vec3(0,0,physStatus->mass*frameTime*(localVel.y/(m_velMax*m_factorMaxSpeed))*3.f); liftImp.point = wTM * m_massOffset; pPhysics->Action(&liftImp, 1); } // apply driving force float a = m_movementAction.power; if (sgn(a)*sgn(localVel.y) > 0) { // reduce acceleration with increasing speed float ratio = (localVel.y > 0.f) ? localVel.y/(m_velMax*m_factorMaxSpeed) : -localVel.y/(m_velMaxReverse*m_factorMaxSpeed); a = (ratio>1.f) ? 0.f : sgn(a)*min(abs(a), 1.f-((1.f-m_accelVelMax)*sqr(ratio))); } if (a != 0) { if (sgn(a) * sgn(localVel.y) < 0) // "braking" a *= m_accelCoeff; else a = max(a, -m_pedalLimitReverse); Vec3 pushDir(FORWARD_DIRECTION); // apply force downwards a bit for more realistic response if (a > 0) pushDir = Quat_tpl<float>::CreateRotationAA( DEG2RAD(m_pushTilt), Vec3(-1,0,0) ) * pushDir; pushDir = wTM.TransformVector( pushDir ); linearImp.impulse = pushDir * physStatus->mass * a * m_accel * m_factorAccel * frameTime; linearImp.point = m_pushOffset; linearImp.point.x = m_massOffset.x; linearImp.point = wTM * linearImp.point; pPhysics->Action(&linearImp, 1); } float roll = (float)__fsel(zAxis.z - 0.2f, xAxis.z / (frameTime + frameTime*frameTime), 0.f); // Roll damping (with a exp. time constant of 1 sec) // apply steering if (m_movementAction.rotateYaw != 0) { if (abs(localVel.y) < fMinSpeedForTurn){ // if forward speed too small, no turning possible turnAccel = 0; } else { int iDir = m_movementAction.power != 0.f ? sgn(m_movementAction.power) : sgn(localVel.y); turnAccelNorm = m_movementAction.rotateYaw * iDir * max(1.f, m_turnVelocityMult * speedRatio); // steering and current w in same direction? int sgnSteerW = sgn(m_movementAction.rotateYaw) * iDir * sgn(-localW.z); if (sgnSteerW < 0) { // "braking" turnAccelNorm *= m_turnAccelCoeff; } else { // reduce turn vel towards max float maxRatio = 1.f - 0.15f*min(1.f, abs(localW.z)/m_turnRateMax); turnAccelNorm = sgn(turnAccelNorm) * min(abs(turnAccelNorm), maxRatio); } turnAccel = turnAccelNorm * m_turnAccel; //roll = 0.2f * turnAccel; // slight roll } } // Use the centripetal acceleration to determine the amount of roll float centripetalAccel = clamp_tpl(speed * localW.z, -10.f, +10.f); roll -= (1.f - 2.f*fabsf(xAxis.z)) * m_rollAccel * centripetalAccel; // Always damp rotation! turnAccel += localW.z * m_turnDamping; if (turnAccel != 0) { Vec3& angImp = angularImp.angImpulse; angImp.x = 0.f; angImp.y = roll * frameTime * m_Inertia.y; angImp.z = -turnAccel * frameTime * m_Inertia.z; angImp = wTM.TransformVector( angImp ); pPhysics->Action(&angularImp, 1); } if (abs(localVel.x) > 0.01f) { // lateral force Vec3& cornerForce = dampImp.impulse; cornerForce.x = -localVel.x * m_cornerForceCoeff * physStatus->mass * frameTime; cornerForce.y = 0.f; cornerForce.z = 0.f; if (m_cornerTilt != 0) cornerForce = Quat_tpl<float>::CreateRotationAA( sgn(localVel.x)*DEG2RAD(m_cornerTilt), Vec3(0,1,0) ) * cornerForce; dampImp.impulse = wTM.TransformVector(cornerForce); dampImp.point = m_cornerOffset; dampImp.point.x = m_massOffset.x; dampImp.point = wTM.TransformPoint( dampImp.point ); pPhysics->Action(&dampImp, 1); } } EjectionTest(deltaTime); if (!m_pVehicle->GetStatus().doingNetPrediction) { if (m_bNetSync && m_netActionSync.PublishActions( CNetworkMovementStdBoat(this) )) CHANGED_NETWORK_STATE(m_pVehicle, CNetworkMovementStdBoat::CONTROLLED_ASPECT ); } }