float MagneticSensorLsm303::getNavigationAngle(void)
{
  if (_device == device_D)
  {
    return heading((vector<int>){1, 0, 0});
  }
  else
  {
    return heading((vector<int>){0, -1, 0});
  }
}
Beispiel #2
0
/*
Returns the angular difference in the horizontal plane between a
default vector and north, in degrees.

The default vector here is chosen to point along the surface of the
PCB, in the direction of the top of the text on the silkscreen.
This is the +X axis on the Pololu LSM303D carrier and the -Y axis on
the Pololu LSM303DLHC, LSM303DLM, and LSM303DLH carriers.
*/
float LSM303::heading(void)
{
  if (_device == device_D)
  {
    return heading((vector<int>){1, 0, 0});
  }
  else
  {
    return heading((vector<int>){0, -1, 0});
  }
}
Beispiel #3
0
int MSTableColumn::headingWidth(void) const
{
  unsigned n=heading().length();
  int tw=0;
  for (unsigned i=0;i<n;i++)
   {
     const MSString& aString=heading()[i];
     tw=MSUtil::max(tw,XTextWidth((XFontStruct *)headingFontStruct(),
				  (const char *)aString,aString.length()));
   }
  return tw;
}
void members :: mindividualoutput()
{
 clrscr();
 heading();
 textcolor(10);
 cout<<"\n\n";
 cprintf("MEMBER DETAILS (INDIVIDUAL DISPLAY)");
 cout<<"\n";
 cprintf("___________________________________");
 textcolor(3);
 cout<<"\n\n";
 cprintf("ID NUMBER     - ");
 cout<<" "<<memno;
 cout<<"\n\n";
 cprintf("NAME          - ");
 cout<<" "<<memname;
 cout<<"\n\n";
 cprintf("AGE           - ");
 cout<<" "<<age;
 cout<<"\n\n";
 cprintf("PHONE NUMBER  - ");
 cout<<" "<<mempno;
 cout<<"\n\n";
 cprintf("ADRESS        - ");
 cout<<" "<<memaddr;
 cout<<"\n\n";
 cprintf("TYPE          - ");
 cout<<" "<<memtype;
 textcolor(6);
 cout<<"\n\n\n";
 cprintf("*PRESS ANY KEY TO CONTINUE*");
 getch();
}
void MovementController::Accelerate(GLfloat a)
{
	float angle = mObject->GetAngle();
	GLVector3f heading(cos(DEG2RAD*angle), sin(DEG2RAD*angle), 0);
	mObject->SetAcceleration(heading * a);
	mAcceleration = a;
}
void library :: appendinput()
{
 heading();
 textcolor(10);
 cout<<"\n\n\n";
 cprintf("BOOK DETAILS (APPEND)");
 cout<<"\n";
 cprintf("_________________________");
 textcolor(6);
 cout<<"\n\n\n";
 cprintf("ENTER THE BOOK NUMBER");
 cin>>bkno;
 cout<<"\n\n";
 cprintf("ENTER THE BOOK NAME");
 gets(bkn);
 cout<<"\n\n";
 cprintf("ENTER THE AUTHOR");
 gets(author);
 cout<<"\n\n";
 cprintf("ENTER THE STOCK");
 cin>>stock;
 cout<<"\n\n";
 cprintf("ENTER THE PRICE");
 cin>>price;
 assign();
}
/*! \brief Creates and returns a deep copy clone of this object.
*
*/
TrackSpiralArcSpiral *
TrackSpiralArcSpiral::getClonedSpArcS() const
{
    TrackSpiralArcSpiral *sparcs = new TrackSpiralArcSpiral(inSpiral_->getClonedSpiral(), arc_->getClonedArc(), outSpiral_->getClonedSpiral());
    sparcs->setLocalTransform(pos(), heading());
    return sparcs;
}
void library :: individualoutput()
{
 clrscr();
  heading();
  textcolor(10);
 cout<<"\n\n";
 cprintf("BOOK DETAILS (INDIVIDUAL DISPLAY)");
 cout<<"\n";
 cprintf("_________________________________");
 textcolor(3);
 cout<<"\n\n";
 cprintf("BOOK NUMBER - ");
 cout<<"  "<<bkno;
 cout<<"\n\n";
 cprintf("NAME        - ");
 cout<<"  "<<bkn;
 cout<<"\n\n";
 cprintf("AUTHOR      - ");
 cout<<"  "<<author;
 cout<<"\n\n";
 cprintf("TYPE        - ");
 cout<<"  "<<type;
 cout<<"\n\n";
 cprintf("STOCK       - ");
 cout<<"  "<<stock;
 cout<<"\n\n";
 cprintf("PRICE       - ");
 cout<<"  "<<price;
 textcolor(6);
 cout<<"\n\n\n";
 cprintf("*PRESS ANY KEY TO CONTINUE*");
getch();
}
/*! \brief Convenience function.
*
*/
void
TrackSpiralArcSpiral::setLocalStartHeading(double startHeading)
{
    while (startHeading <= -180.0)
    {
        startHeading += 360.0;
    }
    while (startHeading > 180.0)
    {
        startHeading -= 360.0;
    }

    // Local to internal (Parameters are given in internal coordinates) //
    //
    double deltaHeading(startHeading - heading());

    QTransform trafo;
    trafo.rotate(deltaHeading);

    pa_->setEndHeadingDeg(pa_->getEndHeadingRad() * 360.0 / (2.0 * M_PI) - deltaHeading);
    pa_->setEndPoint(trafo.inverted().map(pa_->getEndPoint()));
    pa_->init();
    applyParameters();

    // Set local translation //
    //
    setLocalRotation(startHeading);
}
Beispiel #10
0
/** Decide where to drop a rescued kart
  */
void LinearWorld::moveKartAfterRescue(Kart* kart)
{
    KartInfo& info = m_kart_info[kart->getWorldKartId()];

    // If the kart is off road, rescue it to the last valid track position
    // instead of the current one (since the sector might be determined by
    // being closest to it, which allows shortcuts like drive towards another
    // part of the lap, press rescue, and be rescued to this other part of
    // the track (example: math class, drive towards the left after start,
    // when hitting the books, press rescue --> you are rescued to the
    // end of the track).
    if(!info.m_on_road)
    {
        info.m_track_sector = info.m_last_valid_sector;
    }
    info.m_race_lap =  info.m_last_valid_race_lap;
    // FIXME - removing 1 here makes it less likely to fall in a rescue loop since the kart
    // moves back on each attempt. This is still a weak hack. Also some other code depends
    // on 1 being substracted, like 'forceRescue'
    if ( info.m_track_sector > 0 ) info.m_track_sector-- ;
    info.m_last_valid_sector = info.m_track_sector;
    if ( info.m_last_valid_sector > 0 ) info.m_last_valid_sector --;

    kart->setXYZ( m_track->trackToSpatial(info.m_track_sector) );

    btQuaternion heading(btVector3(0.0f, 1.0f, 0.0f),
                         m_track->getAngle(info.m_track_sector) );
    kart->setRotation(heading);

    // A certain epsilon is added here to the Z coordinate, in case
    // that the drivelines are somewhat under the track. Otherwise, the
    // kart might be placed a little bit under the track, triggering
    // a rescue, ... (experimentally found value)
    float epsilon = 0.5f * kart->getKartHeight();

    btTransform pos;
    pos.setOrigin(kart->getXYZ()+btVector3(0, kart->getKartHeight() + epsilon, 0));
    pos.setRotation(btQuaternion(btVector3(0.0f, 1.0f, 0.0f),
                    m_track->getAngle(info.m_track_sector)));

    kart->getBody()->setCenterOfMassTransform(pos);

    //project kart to surface of track
    bool kart_over_ground = m_physics->projectKartDownwards(kart);

    if (kart_over_ground)
    {
        //add vertical offset so that the kart starts off above the track
        float vertical_offset = kart->getKartProperties()->getVertRescueOffset() *
                                kart->getKartHeight();
        kart->getBody()->translate(btVector3(0, vertical_offset, 0));
    }
    else
    {
        fprintf(stderr, "WARNING: invalid position after rescue for kart %s on track %s.\n",
                (kart->getIdent().c_str()), m_track->getIdent().c_str());
    }


}   // moveKartAfterRescue
void SimpleNetwork::printConfig(ostream& out) const 
{
  out << endl;
  out << heading("Network Configuration");
  out << "network: SIMPLE_NETWORK" << endl;
  out << endl;

  for (int i = 0; i < m_virtual_networks; i++) {
    out << "virtual_net_" << i << ": ";
    if (m_in_use[i]) {
      out << "active, ";
      if (m_ordered[i]) {
        out << "ordered" << endl;
      } else {
        out << "unordered" << endl;
      }
    } else {
      out << "inactive" << endl;
    }
  }
  out << endl;
  for(int i=0; i<m_switch_ptr_vector.size(); i++) {
    m_switch_ptr_vector[i]->printConfig(out);
  }
}
Beispiel #12
0
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    QString filename("unknown");
    if (argc == 2) {
        filename = argv[1];
    }

    RWindow window;
    QBoxLayout *layout = qobject_cast<QBoxLayout *>(window.layout());

    QLabel heading("Could not open file.");
    heading.setFont(QFont("Liberation Serif", 30));
    layout->addWidget(&heading);

    layout->addStrut(8);

    QLabel detail(
        QString("The file %1 is of an unrecognized type and cannot be opened.")
        .arg(runcible::quote(filename)));
    detail.setFont(QFont("Liberation Serif", 12));
    detail.setWordWrap(true);
    layout->addWidget(&detail);

    layout->addStretch(1);

    QObject::connect(&window, SIGNAL(back()), &app, SLOT(quit()));

    window.showMessage("How unfortunate.");
    window.showMaximized();

    return app.exec();
}
Beispiel #13
0
int FeOverlay::filters_dialog()
{
	sf::Vector2i size;
	sf::Vector2f text_scale;
	int char_size;
	get_common( size, text_scale, char_size );

	std::vector<std::string> list;
	m_feSettings.get_current_list_filter_names( list );

	if ( list.size() > 8 )
		char_size /= 2;

	std::vector<sf::Drawable *> draw_list;

	sf::RectangleShape bg( sf::Vector2f( size.x, size.y ) );
	bg.setFillColor( m_bgColour );
	bg.setOutlineColor( m_textColour );
	bg.setOutlineThickness( -2 );
	draw_list.push_back( &bg );

	FeTextPrimative heading( m_fePresent.get_font(), m_selColour, sf::Color::Transparent, char_size );
	heading.setSize( size.x, size.y / 8 );
	heading.setOutlineColor( m_textColour );
	heading.setOutlineThickness( -2 );
	heading.setTextScale( text_scale );

	std::string temp;
	m_feSettings.get_resource( "Filters", temp );
	heading.setString( temp );
	draw_list.push_back( &heading );

	FeListBox dialog(
		m_fePresent.get_font(),
		m_textColour,
		sf::Color::Transparent,
		m_selColour,
		m_selBgColour,
		char_size,
		size.y / ( char_size * 1.5 * text_scale.y ) );

	dialog.setPosition( 2, size.y / 8 );
	dialog.setSize( size.x - 4, size.y * 7 / 8 );
	dialog.init();
	dialog.setTextScale( text_scale );

	draw_list.push_back( &dialog );

	int current_i = m_feSettings.get_current_filter_index();
	int sel = current_i;
	dialog.setText( sel, list );

	FeEventLoopCtx c( draw_list, sel, current_i, list.size() - 1 );

	while ( event_loop( c ) == false )
		dialog.setText( sel, list );

	return sel;
}
Beispiel #14
0
void Camera::motionMouse(int x, int y) {
	if (!flag) return;
	float term = 0.1f;
	pitch((y - mousey) * term);
	heading((x - mousex) * term);
	mousex = x;
	mousey = y;
}
Beispiel #15
0
void MSTableColumn::heading(const MSStringVector& heading_) 
{ 
  if (heading()!=heading_)
   {
     _heading=heading_;
     updateHeading(); 
   }
}
Beispiel #16
0
void MSTableColumnGroup::print(ostream &os_,unsigned level_) const
{
    unsigned i;
    for (i=0; i<level_; i++) os_<<'\t';
    os_<<"(GROUP) ";
    if (heading().length()==0) os_<<endl;
    else os_<<heading();
    for (unsigned j=0; j<nodeList().length(); j++)
    {
        const Node &node=nodeList()[j];
        if (node.type()==Node::Group) node.group()->print(os_,level_+1);
        else if (node.type()==Node::Column)
        {
            for (i=0; i<=level_; i++) os_<<'\t';
            os_<<node.column()->heading();
        }
    }
}
void SimpleNetwork::printStats(ostream& out) const
{
  out << endl;
  out << heading("Network Stats");
  out << endl;
  for(int i=0; i<m_switch_ptr_vector.size(); i++) {
    m_switch_ptr_vector[i]->printStats(out);
  }
}
Beispiel #18
0
void DebugGlyph::print(Printer* p, const Allocation& a) const {
    if ((flags_ & trace_print) != 0) {
	heading("print ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::print(p, a);
}
Beispiel #19
0
void DebugGlyph::request(Requisition& r) const {
    MonoGlyph::request(r);
    if ((flags_ & trace_request) != 0) {
	heading("request ");
	print_requirement(r.requirement(Dimension_X));
	printf(", ");
	print_requirement(r.requirement(Dimension_Y));
	printf("\n");
    }
}
Beispiel #20
0
void DebugGlyph::allocate(Canvas* c, const Allocation& a, Extension& ext) {
    if ((flags_ & trace_allocate) != 0) {
	heading("allocate ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::allocate(c, a, ext);
}
Beispiel #21
0
void Driver::navigate(){
    static geodPoint curLocation;
    // get a gps fix
    while(!_gps.FixIs3d()); // spin until a gps fix is acquired
    curLocation = _gps.ReadDecGeodLoc();
    // get conversion factors for this location
    static double lon2m = getLon2meters(curLocation.longitude, curLocation.latitude, curLocation.altitude);
    static double lat2m = getLat2meters(curLocation.longitude, curLocation.latitude, curLocation.altitude);
    // find an initial heading to waypoint
    static double goalHeading = heading(lon2m, lat2m, curLocation.longitude, curLocation.latitude, goalLon, goalLat);
    static double goalDistance = distance(lon2m, lat2m, curLocation.longitude, curLocation.latitude, goalLon, goalLat);
    
    _car.setTorque(14);
    
    while(goalDistance > 20.00){
        // System tick has set the gps flag
        if(_updateGPS){
            _updateGPS = ! _updateGPS;
            if(_gps.GPSFixValid()){
                curLocation = _gps.ReadDecGeodLoc();
                goalHeading  = heading(lon2m, lat2m, curLocation.longitude, curLocation.latitude, goalLon, goalLat);
                goalDistance = distance(lon2m, lat2m, curLocation.longitude, curLocation.latitude, goalLon, goalLat);
            }
        }
        // Systrm  tick has set the compass flag
        if(_updateCompass){
            _updateCompass = !_updateCompass;
            turnToHeading((long)goalHeading);   
        }
        if(_updateLog){
            _updateLog = ! _updateLog;
            logger.printf("-----End of navigate loop----------------------------------------\n\r");
            logger.printf("Goal lat %f lon %f\r\n", goalLat, goalLon);
            logger.printf("Current lat %f lon %f\r\n", curLocation.latitude, curLocation.longitude);
            logger.printf("Goal heading %f distance %f\n\r", goalHeading, goalDistance);
            logger.printf("Compass heading %f\n\r", _compass.getHeadingXYDeg());
              
        }
    }
    while(1) _car.setTorque(0);
}
void BtCpUiDeviceDetailsView::setDeviceName(const QString &deviceName)
{
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
    //todo: use Localised string Id,If Loc ID is used
    //wrong string is displayed. Need to correct text map file.
    QString heading(hbTrId("%1 details"));
    
    if(mGroupBox) {
        mGroupBox->setHeading(heading.arg(deviceName));
    }
    BOstraceFunctionExit0(DUMMY_DEVLIST);
}
Beispiel #23
0
/* Settings draw */
void settings_draw(void)
{
	int wtype = 0, wname = 0;

	/* Figure out cal widths */
	for (cal_t *cal = CALS; cal; cal = cal->next) {
		if (strlen(cal->type) > wtype)
			wtype = strlen(cal->type);
		if (strlen(cal->name) > wname)
			wname = strlen(cal->name);
	}

	heading(win, "Current Settings\n");
	checkbox(win, "Compact layout\n", &COMPACT);

	heading(win, "\nLoaded Calendars\n");
	for (cal_t *cal = CALS; cal; cal = cal->next)
		wprintw(win, PAD "%s:%*s \"%s\"%*s - %s\n",
			cal->type, wtype-strlen(cal->type), "",
			cal->name, wname-strlen(cal->name), "",
			cal->desc ?: "(no description)");
}
Beispiel #24
0
void DebugGlyph::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if ((flags_ & trace_pick) != 0) {
	heading("pick ");
	printf(
	    "at (%.2f,%.2f,%.2f,%.2f) ",
	    h.left(), h.bottom(), h.right(), h.top()
	);
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::pick(c, a, depth, h);
}
Beispiel #25
0
void Car::updateGhosts() {
    static sf::Clock clock = sf::Clock();
    
    sf::Time time = clock.getElapsedTime();
    
    sf::Vector2f lastLocation = this->mLastLocation;
    if (this->mCarGhostDrawables.size() > 0) {
        lastLocation = this->mCarGhostDrawables.back().ghost.getPosition();
    }
    
    // add new ghost
    float ghostDistance = length(this->mCurrentLocation - lastLocation);
    if (ghostDistance >= Car::MAX_GHOSTS_DISTANCE && this->mVelocity > 0.0f) {
        sf::RectangleShape ghost(sf::Vector2f(Car::CAR_WIDTH, Car::CAR_HEIGHT));
        ghost.setOrigin(Car::CAR_WIDTH / 2.0f, Car::CAR_HEIGHT / 2.0f);
        
        sf::Vector2f dir = normalize(this->mCurrentDirection);
        ghost.setPosition(this->mCurrentLocation); // - (dir * (Car::MAX_GHOSTS_DISTANCE + 20.0f)));
        ghost.setRotation(RAD_TO_DEG(heading(dir)));
        
        ghost.setFillColor(this->mCarDrawable.getFillColor());
        
        this->mCarGhostDrawables.push_back(Ghost(ghost, time.asMilliseconds()));
        
        if (this->mCarGhostDrawables.size() >= Car::MAX_GHOSTS) {
            this->mCarGhostDrawables.erase(this->mCarGhostDrawables.begin());
        }
    }
    
    // do we need to remove some ghosts?
    std::list<Ghost>::iterator it = this->mCarGhostDrawables.begin();
    while (it != this->mCarGhostDrawables.end()) {
        if ((time.asMilliseconds() - (*it).age) >= Car::MAX_GHOSTS_AGE) {
            it = this->mCarGhostDrawables.erase(it);
        } else {
            ++it;
        }
    }
       
    // adjust alphas
    int i = this->mCarGhostDrawables.size()+1;
    //float steps = (80.0f - (80.0f * (MAX_VELOCITY / this->mVelocity))) / static_cast<float>(i);
    float steps = 80.0f / static_cast<float>(i);
    sf::Color color = this->mCarDrawable.getFillColor();
    for (std::list<Ghost>::reverse_iterator it = this->mCarGhostDrawables.rbegin(); it != this->mCarGhostDrawables.rend(); ++it) {
        color.a = steps * i--;
        (*it).ghost.setFillColor(color);
    }

}
Beispiel #26
0
void Car::update(const sf::Time & _time) {
    
    // keep location as last valid
    if (!this->mDriftedOffTrack) {
        this->mCurrentPassedDistance += length(this->mCurrentLocation - this->mLastLocation);
        this->mLastLocation = this->mCurrentLocation;
        
       // std::cout << "Passed Distance: " << this->mCurrentPassedDistance << std::endl;
    }
    
    // compute cars offset to the track segment and adjust it
    sf::Vector2f proj = project(this->mCurrentLocation, this->mTrack[this->mSegmentStart], this->mTrack[this->mSegmentEnd]);
    sf::Vector2f positionAdjust = proj - this->mCurrentLocation;
   
    // apply drag friction
    if (this->mVelocity > 0.0f) {
       // this->mForce -= abs(Car::FRICTION_FORCE * (this->mVelocity) * (this->mDriftedOffTrack ? Car::DRAG_FRICTION_OFF_TRACK : Car::DRAG_FRICTION_ON_TRACK));
        this->mForce -= abs(Car::FRICTION_FORCE * (this->mVelocity));
        this->mForce -= abs(this->mIsAccelerating ? 0.0f : Car::BREAK_FRICTION * this->mVelocity);
        this->mForce -= abs(!this->mDriftedOffTrack ? 0.0f : Car::DRAG_FRICTION_OFF_TRACK * this->mVelocity);
        
        this->mIsAccelerating = false;
    }
    
    // compute acceleration A = F / M
    float acceleration = this->mForce / Car::DEFAULT_MASS;
    
    // compute velocity
    this->mVelocity += acceleration * _time.asSeconds();
    this->mVelocity = fmax(fmin(this->mVelocity, Car::MAX_VELOCITY), 0.0f);
    //std::cout << "Velocity: " << this->mVelocity << std::endl;
        
    // compute new position
    this->mCurrentLocation += this->mCurrentDirection * (this->mVelocity * _time.asSeconds());
    this->mCurrentLocation += positionAdjust;
    
    this->keepOnTrack();
    this->updateGhosts();
    
    // compute rotation
    float angle = heading(this->mCurrentDirection);
    
    this->mCarDrawable.setRotation(RAD_TO_DEG(angle));
    this->mCarDrawable.setPosition(this->mCurrentLocation);
    
    // debug stuff
    this->mLocationPoint.setPosition(this->mCurrentLocation);
    this->mDirectionShape.setPosition(this->mCurrentLocation);
}
Beispiel #27
0
void hilbert_right (int len, int level)
{
  int bearing;
  
  if (level > 0) {
    
    bearing = heading ();
    turnright (90);
    hilbert_left (len, level - 1);
    
    setheading (bearing);
    forwd (len);
    
    bearing = heading ();
    hilbert_right (len, level - 1);
    
    setheading (bearing);
    turnright (90);
    forwd (len);
    
    bearing = heading ();
    turnleft (90);
    hilbert_right (len, level - 1);
    
    setheading (bearing);
    turnright (90);
    forwd (len);
    
    bearing = heading ();
    turnright (90);
    hilbert_left (len, level - 1);
    setheading (bearing);
    
  }

}
Beispiel #28
0
//------------------------------------------------------------------------------
// draw() --
//------------------------------------------------------------------------------
void Eadi3DPage::draw()
{
    BasicGL::Display* dsp = getDisplay();
    if (dsp != 0) {

        eadiObjs.makeObjects();

        GLsizei vpWidth;
        GLsizei vpHeight;
        dsp->getViewportSize(&vpWidth, &vpHeight);
        LCreal ratio = static_cast<LCreal>(vpWidth) / static_cast<LCreal>(vpHeight);

        bool depthTest = false;
        if (glIsEnabled(GL_DEPTH_TEST))
            depthTest = true;

        if (depthTest)
            glDisable(GL_DEPTH_TEST);

        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glOrtho(-2.635 * ratio, 2.635 * ratio, -2.635, 2.635, -3.51, 0.01);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
        globeBall(pitchDEG, rollDEG, pitchSteeringCmd, rollSteeringCmd, pitchSteeringValid, rollSteeringValid, landingMode);        

        background();

        const char* airSpeedType = "C";
        scales(glideslopeDevDOTS, localizerDevDOTS, turnRateDOTS, slipIndDOTS, glideslopeDevValid, localizerDevValid, landingMode);
        windows(airspeedKTS, altitudeFT, aoaDEG, machNo, vviFPM, airSpeedType, Gload);
        LCreal hdgCmd = 0.0;
        heading(headingDEG, hdgCmd);

        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
        if (depthTest)
            glEnable(GL_DEPTH_TEST);

        // now draw our components
        BaseClass::draw();
    }
}
/** Decide where to drop a rescued kart
  */
void LinearWorld::moveKartAfterRescue(AbstractKart* kart)
{
    KartInfo& info = m_kart_info[kart->getWorldKartId()];

    info.getSector()->rescue();
    int sector = info.getSector()->getCurrentGraphNode();
    kart->setXYZ( QuadGraph::get()
                  ->getQuadOfNode(sector).getCenter());

    btQuaternion heading(btVector3(0.0f, 1.0f, 0.0f),
                         m_track->getAngle(sector) );
    kart->setRotation(heading);

    // A certain epsilon is added here to the Z coordinate, in case
    // that the drivelines are somewhat under the track. Otherwise, the
    // kart might be placed a little bit under the track, triggering
    // a rescue, ... (experimentally found value)
    float epsilon = 0.5f * kart->getKartHeight();

    btTransform pos;
    pos.setOrigin(kart->getXYZ()+btVector3(0, kart->getKartHeight() + epsilon,
                                           0));
    pos.setRotation(btQuaternion(btVector3(0.0f, 1.0f, 0.0f),
                    m_track->getAngle(sector)));

    kart->getBody()->setCenterOfMassTransform(pos);

    //project kart to surface of track
    bool kart_over_ground = m_physics->projectKartDownwards(kart);

    if (kart_over_ground)
    {
        //add vertical offset so that the kart starts off above the track
        float vertical_offset = 
              kart->getKartProperties()->getVertRescueOffset() 
            * kart->getKartHeight();
        kart->getBody()->translate(btVector3(0, vertical_offset, 0));
    }
    else
    {
        fprintf(stderr, "WARNING: invalid position after rescue for kart %s "
                        "on track %s.\n",
                (kart->getIdent().c_str()), m_track->getIdent().c_str());
    }


}   // moveKartAfterRescue
Beispiel #30
0
	void Agent::BuildFeelers()
	{
		Matrix3 mat;
		Vector2 heading(0, 1); 
		heading *= FEELER_LENGTH;

		Vector2 northFeeler = heading;
		mat = mat.FromRotationZ(Clarity::RADIANS_PER_DEGREE * (headingAngle + NORTH_THETA));
		northFeeler = northFeeler.Transform(mat);
		sensor.feelerEnds[FEELER_NORTH] = this->position + northFeeler;
		sensor.feelers[FEELER_NORTH] = northFeeler;
		sensor.feelers[FEELER_NORTH].Normalise();

		// Build the east feeler.
		Vector2 eastFeeler = heading;
		mat = mat.FromRotationZ(Clarity::RADIANS_PER_DEGREE * (headingAngle + EAST_THETA));
		eastFeeler = eastFeeler.Transform(mat);
		sensor.feelerEnds[FEELER_EAST] = this->position + eastFeeler;
		sensor.feelers[FEELER_EAST] = eastFeeler;
		sensor.feelers[FEELER_EAST].Normalise();

		// Build the north east feeler.
		Vector2 northEastFeeler = heading;
		mat = mat.FromRotationZ(Clarity::RADIANS_PER_DEGREE * (headingAngle + NORTH_EAST_THETA));
		northEastFeeler = northEastFeeler.Transform(mat);
		sensor.feelerEnds[FEELER_NORTH_EAST] = this->position + northEastFeeler;
		sensor.feelers[FEELER_NORTH_EAST] = northEastFeeler;
		sensor.feelers[FEELER_NORTH_EAST].Normalise();

		// Build the north west feeler
		Vector2 northWestFeeler = heading;
		mat = mat.FromRotationZ(Clarity::RADIANS_PER_DEGREE * (headingAngle + NORTH_WEST_THETA));
		northWestFeeler = northWestFeeler.Transform(mat);
		sensor.feelerEnds[FEELER_NORTH_WEST] = this->position + northWestFeeler;
		sensor.feelers[FEELER_NORTH_WEST] = northWestFeeler;
		sensor.feelers[FEELER_NORTH_WEST].Normalise();

		// Build the west feeler.
		Vector2 westFeeler = heading;
		mat = mat.FromRotationZ(Clarity::RADIANS_PER_DEGREE * (headingAngle + WEST_THETA));
		westFeeler = westFeeler.Transform(mat);
		sensor.feelerEnds[FEELER_WEST] = this->position + westFeeler;
		sensor.feelers[FEELER_WEST] = westFeeler;
		sensor.feelers[FEELER_WEST].Normalise();
		
	}