Esempio n. 1
0
// __________________________________________________________________________________________________
void KikiBot::render ()
{
    float radius	= 0.5;
    float tireRadius	= 0.15;

    if (died) getDeadColor().glColor();
    else getTireColor().glColor();

    KMatrix(current_orientation).glMultMatrix();
    glPushMatrix(); // tires
    glRotated(90.0, 0.0, 1.0, 0.0);
    glTranslated(0.0, 0.0, radius-tireRadius);
    glRotated(left_tire_rot * 180.0, 0.0, 0.0, 1.0);

    render_tire;

    glPopMatrix();
    glPushMatrix();
    glRotated(90.0, 0.0, 1.0, 0.0);
    glTranslated(0.0, 0.0, -(radius-tireRadius));
    glRotated(right_tire_rot * 180.0, 0.0, 0.0, 1.0);

    render_tire;

    glPopMatrix();

    if (died == false) getBodyColor().glColor();

    render_body;

    if ((move_action || rotate_action) && died == false)
    {
        unsigned int now = Controller.getTime();
        if ((int)(now - last_fume) > Controller.mapMsTime (40))
        {
            KikiBotFume * fume = new KikiBotFume ();
            Controller.world->addObject (fume);
            fume->setPosition (current_position - getCurrentDir() * 0.4);
            last_fume = now;
        }
    }
}
Esempio n. 2
0
Surface8u colorizeBodyIndex( const Channel8u& bodyIndexChannel )
{
    Surface8u surface;
    if ( bodyIndexChannel ) {
        surface = Surface8u( bodyIndexChannel.getWidth(), bodyIndexChannel.getHeight(), true, SurfaceChannelOrder::RGBA );
        Channel8u::ConstIter iterChannel	= bodyIndexChannel.getIter();
        Surface8u::Iter iterSurface			= surface.getIter();
        while ( iterChannel.line() && iterSurface.line() ) {
            while ( iterChannel.pixel() && iterSurface.pixel() ) {
                size_t index				= (size_t)iterChannel.v();
                ColorA8u color( getBodyColor( index ), 0xFF );
                if ( index == 0 || index > BODY_COUNT ) {
                    color.a					= 0x00;
                }
                iterSurface.r()				= color.r;
                iterSurface.g()				= color.g;
                iterSurface.b()				= color.b;
                iterSurface.a()				= color.a;
            }
        }
    }
    return surface;
}