virtual void animateNode(ISceneNode* node, u32 timeMs) { if ( !node ) return; if ( static_cast<s32>(timeMs) < this->startTime_ ) return; if ( waypoints_.size() < 2 ) { this->smgr_->addToAnimatorDeletionQueue(this, node); return; } if( timeMs - this->startTime_ >= this->duration_ ) { /* we can add periodic callback here. if( this->periodic_cb() ) this->periodic_callback(); */ this->startTime_ = timeMs; //or should be += this->duration_ ? if( this->loop_ == 0 ) { float const& pos = Eq<float>::calculate(1, this->start_, this->distance_, 1, node); calculateCurrentWaypoint(node, pos); this->smgr_->addToAnimatorDeletionQueue(this, node); if( this->cb_ ) this->cb_(); return; } else if( this->loop_ > 0 ) this->loop_ -= 1; } float const& pos = this->updatePos(node, timeMs); calculateCurrentWaypoint(node, pos); }
task main() { nMotorEncoder[motorC] = 0; getIntoCorridor(); int currentWaypoint = calculateCurrentWaypoint(); nxtDisplayCenteredTextLine(3, "WP: %d", currentWaypoint); //wait1Msec(3000); if(currentWaypoint == 1) { first = 2; second = 3; third = 1; } else if(currentWaypoint == 2) { first = 3; second = 1; third = 2; } else //currentWaypoint == 3 { first = 1; second = 2; third = 3; } // First corridorTurn(currentWaypoint, first); downCorridor(currentWaypoint, first); nxtDisplayCenteredTextLine(1, "About To Turn"); //wait1Msec(3000); turnToWaypoint(currentWaypoint, first); nxtDisplayCenteredTextLine(1, "Turned."); //wait1Msec(3000); driveToBackWall(); chamberAdjust(); beep(); // End First wait1Msec(500); // Second currentWaypoint = first; getIntoCorridor(); corridorTurn(currentWaypoint, second); downCorridor(currentWaypoint, second); turnToWaypoint(currentWaypoint, second); driveToBackWall(); chamberAdjust(); beep(); // End Second wait1Msec(500); // Third currentWaypoint = second; getIntoCorridor(); corridorTurn(currentWaypoint, third); downCorridor(currentWaypoint, third); turnToWaypoint(currentWaypoint, third); driveToBackWall(); chamberAdjust(); beep(); // End Third wait1Msec(500); }