void Render( int realX, int realY, bool highlighted, bool clicked)
    {
        Building *b = g_app->m_location->GetBuilding(g_app->m_locationEditor->m_selectionId);
        if( b )
        {
            if( b->m_id.GetTeamId() == m_teamId )
            {
                DarwiniaButton::Render( realX, realY, true, clicked );
            }
            else
            {
                DarwiniaButton::Render( realX, realY, highlighted, clicked );
            }
        }

        if( m_teamId == 255 )
        {
            glColor3ub( 100, 100, 100 );
        }
        else
        {
            RGBAColour col = g_app->m_location->m_teams[ m_teamId ].m_colour;
            glColor3ubv( col.GetData() );
        }

        glBegin( GL_QUADS );
            glVertex2i( realX + 30, realY + 4 );
            glVertex2i( realX + 40, realY + 4 );
            glVertex2i( realX + 40, realY + 12 );
            glVertex2i( realX + 30, realY + 12 );
        glEnd();
    }
예제 #2
0
void ColourFilterObjectData::render(const GraphicsObject& go,
                                    const GraphicsObject* parent,
                                    std::ostream* tree) {
  if (go.width() != 100 || go.height() != 100) {
    static bool printed = false;
    if (!printed) {
      printed = true;
      cerr << "We can't yet scaling colour filters." << endl;
    }
  }

  // Lazily create colour object.
  if (!colour_filer_) {
    colour_filer_.reset(graphics_system_.BuildColourFiller(screen_rect_));
  }

  RGBAColour colour = go.colour();
  colour.setAlpha(
      static_cast<int>(colour.a_float() * go.computedAlpha()));
  colour_filer_->Fill(go, colour);

  if (tree) {
    *tree << "  ColourFilterObjectData" << std::endl
          << "  Screen rect: " << screen_rect_ << std::endl
          << "  Colour: " << colour << std::endl
          << "  Properties: ";
    PrintGraphicsObjectToTree(go, tree);
    *tree << endl;
  }
}
void SafeArea::Render( double predictionTime )
{
    if( g_app->m_editing )
    {
        RGBAColour colour;

        if( m_id.GetTeamId() != 255 )
        {
            colour = g_app->m_location->m_teams[ m_id.GetTeamId() ]->m_colour;    
        }
        colour.a = 255;

#ifdef DEBUG_RENDER_ENABLED
        RenderSphere( m_pos, 20.0, colour );
#endif
        int numSteps = 30;
        double angle = 0.0;

        glColor4ubv(colour.GetData() );
        glLineWidth( 2.0 );
        glBegin( GL_LINE_LOOP );
        for( int i = 0; i <= numSteps; ++i )
        {
            double xDiff = m_size * iv_sin(angle);
            double zDiff = m_size * iv_cos(angle);
            Vector3 pos = m_pos + Vector3(xDiff,5,zDiff);
	        pos.y = g_app->m_location->m_landscape.m_heightMap->GetValue(pos.x, pos.z) + 10.0;
            if( pos.y < 2 ) pos.y = 2;
            glVertex3dv( pos.GetData() );
            angle += 2.0 * M_PI / (double) numSteps;
        }
        glEnd();
    }
    else
    {
/*
        double angle = g_gameTime * 2.0;
        Vector3 dif( m_size * iv_sin(angle), 0.0, m_size * iv_cos(angle) );
        
        Vector3 pos = m_pos + dif;
        pos.y = g_app->m_location->m_landscape.m_heightMap->GetValue( pos.x, pos.z ) + 5.0;
        g_app->m_particleSystem->CreateParticle( pos, g_upVector*2 + dif/30, Particle::TypeMuzzleFlash, 100.0 );

        pos = m_pos - dif;
        pos.y = g_app->m_location->m_landscape.m_heightMap->GetValue( pos.x, pos.z ) + 5.0;
        g_app->m_particleSystem->CreateParticle( pos, g_upVector*2 - dif/30, Particle::TypeMuzzleFlash, 100.0 );
*/
    }
    

    //char *entityTypeRequired = Entity::GetTypeName( m_entityTypeRequired );
    //g_editorFont.DrawText3DCentre( m_pos + Vector3(0,m_size/2,0), 10.0, "%d / %d %ss", m_entitiesCounted, m_entitiesRequired, entityTypeRequired );
}
void Nuke::RenderSub( double _predictionTime )
{
    if( m_subPos.y <= -35.0f ) return;

    glEnable        ( GL_TEXTURE_2D );
	glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
 	glEnable		( GL_BLEND );
    glDepthMask     ( false );    
    glDisable       ( GL_CULL_FACE );

    float size = 100.0f;
    Vector3 pos = m_subPos + m_subVel * _predictionTime;      

    Vector3 up = g_app->m_camera->GetUp();
    Vector3 right = g_app->m_camera->GetRight();

    char filename[256];
    char shadow[256];

    sprintf( filename, "sprites/sub.bmp" );
    sprintf(shadow, "sprites/subshadow.bmp");

    float alpha = max(m_subPos.y,0.0) / 30.0f;

    glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR );
    glBindTexture   (GL_TEXTURE_2D, g_app->m_resource->GetTexture(shadow));
    glColor4f   ( 1.0f, 1.0f, 1.0f, 0.0f );
    glBegin( GL_QUADS );
        glTexCoord2i( 0, 0 );       glVertex3dv( (pos - right * size - up * size).GetData() );
        glTexCoord2i( 0, 1 );       glVertex3dv( (pos - right * size + up * size).GetData() );
        glTexCoord2i( 1, 1 );       glVertex3dv( (pos + right * size + up * size).GetData() );
        glTexCoord2i( 1, 0 );       glVertex3dv( (pos + right * size - up * size).GetData() );    
    glEnd();

    RGBAColour col = g_app->m_location->m_teams[m_id.GetTeamId()]->m_colour;
    col.a = alpha * 255;
    glBlendFunc     ( GL_SRC_ALPHA, GL_ONE );
    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( filename ) );
    glColor4ubv( col.GetData() );  
    glBegin( GL_QUADS );
        glTexCoord2i( 0, 0 );       glVertex3dv( (pos - right * size - up * size).GetData() );
        glTexCoord2i( 0, 1 );       glVertex3dv( (pos - right * size + up * size).GetData() );
        glTexCoord2i( 1, 1 );       glVertex3dv( (pos + right * size + up * size).GetData() );
        glTexCoord2i( 1, 0 );       glVertex3dv( (pos + right * size - up * size).GetData() );    
    glEnd();
    
    glEnable        ( GL_CULL_FACE );
	glDisable       ( GL_BLEND );
    glDisable       ( GL_TEXTURE_2D );
    glDepthMask     ( true );
    glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
예제 #5
0
void ColourFilterObjectData::render(const GraphicsObject& go,
                                    const GraphicsObject* parent,
                                    std::ostream* tree) {
  if (go.mono() == 0) {
    RGBAColour colour = go.colour();
    colour.setAlpha(
        static_cast<int>(colour.a_float() * go.computedAlpha()));

    graphics_system_.fillScreenArea(screen_rect_, colour);

    if (tree)
      objectInfo(*tree);
  } else {
    static bool printed = false;
    if (!printed) {
      printed = true;
      cerr << "We don't yet deal with objMono() and colour filters." << endl;
    }
  }
}
예제 #6
0
void SDLGraphicsSystem::fillScreenArea(const Rect& rect,
                                       const RGBAColour& colour) {
  if (colour.a()) {
    glDisable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glBegin(GL_QUADS); {
      glColorRGBA(colour);
      glVertex2f(rect.x(), rect.y());
      glVertex2f(rect.x(), rect.y() + rect.height());
      glVertex2f(rect.x() + rect.width(), rect.y() + rect.height());
      glVertex2f(rect.x() + rect.width(), rect.y());
    }
    glEnd();

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_ONE, GL_ZERO);
  }
}
void RocketStatusPanel::Render()
{
    //
    // Determine our rocket status

    EscapeRocket *rocket = GetMyRocket();
    if( !rocket ) return;

    Team *team = g_app->m_location->m_teams[ m_teamId ];
    if( !team ) return;

    float fuelPercent = rocket->m_fuel / 100.0f;
    int darwiniansInside = rocket->m_passengers;

    if( rocket->m_damage > m_lastDamage )
    {
        m_damageTimer = GetHighResTime();
    }
    m_lastDamage = rocket->m_damage;

    if( fuelPercent > 1.0f ) fuelPercent = 1.0f;

    double refuelRate = rocket->m_fuel - m_previousFuelLevel;
    m_previousFuelLevel = rocket->m_fuel;

    float h = m_w * 1.5f;
    glShadeModel( GL_SMOOTH );


    //
    // Background team colour

    glColor4ub( team->m_colour.r*0.2f, team->m_colour.g*0.2f, team->m_colour.b*0.2f, 200 );

    glBegin( GL_QUADS );
        glVertex2f( m_x, m_y );
        glVertex2f( m_x + m_w, m_y );
        glVertex2f( m_x + m_w, m_y + h );
        glVertex2f( m_x, m_y + h );
    glEnd();


    //
    // Refueling effect

    float fuelBase = m_y + h * 0.97f;
    float fuelFullH = h * 0.95f;
    float fuelH = fuelFullH * fuelPercent;
    int refuelAlpha = 128;

    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    glEnable        ( GL_TEXTURE_2D );
    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "textures/laser.bmp" ) );
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );


    if( fuelPercent < 1.0f )
    {
        glColor4ub( team->m_colour.r, team->m_colour.g, team->m_colour.b, refuelAlpha );

        float texY = fuelPercent * -100 + 0.5f;
        float texH = 1.0f;

        glBegin( GL_QUADS );
            glTexCoord2f(0,texY);       glVertex2f( m_x, fuelBase );
            glTexCoord2f(1,texY);       glVertex2f( m_x + m_w, fuelBase );
            glTexCoord2f(1,texY+texH);  glVertex2f( m_x + m_w, fuelBase - fuelFullH );
            glTexCoord2f(0,texY+texH);  glVertex2f( m_x, fuelBase - fuelFullH );
        glEnd();

    }


    //
    // Fuel level

    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "textures/laser-long.bmp" ) );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    int fuelAlpha = 200;

    glBegin( GL_QUADS );
        glColor4ub( 0,0,0, fuelAlpha );
        glTexCoord2f( 0, 0.3f );       glVertex2f( m_x, fuelBase );
        glTexCoord2f( 0, 0.7f );       glVertex2f( m_x + m_w, fuelBase );
        
        glColor4ub( team->m_colour.r, team->m_colour.g, team->m_colour.b, fuelAlpha );
        glTexCoord2f( 1, 0.7f );       glVertex2f( m_x + m_w, fuelBase - fuelH );
        glTexCoord2f( 1, 0.3f );       glVertex2f( m_x, fuelBase - fuelH );
    glEnd();

    glDisable( GL_TEXTURE_2D );


    //
    // Shadow above fuel level

    glBegin( GL_QUADS );
        glColor4ub( 0,0,0, fuelAlpha*0.5f );
        glVertex2f( m_x, fuelBase - fuelH );
        glVertex2f( m_x + m_w, fuelBase - fuelH );
        glColor4ub( 0,0,0, 0 );
        glVertex2f( m_x + m_w, fuelBase - fuelH - h * 0.05f );
        glVertex2f( m_x, fuelBase - fuelH - 10 - h * 0.05f );
    glEnd();


    //
    // Rocket bitmap overlay

    glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

    glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable        ( GL_TEXTURE_2D );
    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "icons/rocketstatuspanel.bmp" ) );
    
    glBegin( GL_QUADS );
        glTexCoord2i(0,1);      glVertex2f( m_x, m_y );
        glTexCoord2i(1,1);      glVertex2f( m_x + m_w, m_y );
        glTexCoord2i(1,0);      glVertex2f( m_x + m_w, m_y + h );
        glTexCoord2i(0,0);      glVertex2f( m_x, m_y + h );
    glEnd();
    
    glDisable       ( GL_TEXTURE_2D );



    //
    // Damage effect

    glColor4f( 1.0f, 1.0f, 1.0f, rocket->m_damage/100.0f );

    glBlendFunc     ( GL_SRC_ALPHA, GL_ONE );
    glEnable        ( GL_TEXTURE_2D );
    glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "icons/rocketcracked.bmp" ) );

    glBegin( GL_QUADS );
    glTexCoord2i(0,1);      glVertex2f( m_x, m_y );
    glTexCoord2i(1,1);      glVertex2f( m_x + m_w, m_y );
    glTexCoord2i(1,0);      glVertex2f( m_x + m_w, m_y + h );
    glTexCoord2i(0,0);      glVertex2f( m_x, m_y + h );
    glEnd();

    glDisable       ( GL_TEXTURE_2D );



    //
    // Darwinians inside
    
    glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    if( fuelPercent >= 1.0f || darwiniansInside > 0 )
    {
        float dwX = m_x + m_w * 0.25f;
        float dwW = m_w * 0.45f;
        float dwY = m_y + h * 0.225f;
        float dwH = h * 0.55f;
        float s = h * 0.04f;
        int astronautAlpha = 255;

        glEnable        ( GL_TEXTURE_2D );
        glBindTexture   ( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "sprites/darwinian.bmp" ) );

        for( int i = 99; i >= 0; i-- )
        {
            int xIndex = ( i % 10 );
            int yIndex = 9 - int( i / 10 );
            float xPos = dwX + dwW * xIndex/10;
            float yPos = dwY + dwH * yIndex/10;

            if( yIndex % 2 == 0 ) xPos += dwW/20.0f;

            RGBAColour astronautCol = team->m_colour;
            astronautCol.AddWithClamp( RGBAColour(50,50,50,255) );
            astronautCol.a = astronautAlpha;

            if( i <  darwiniansInside )     glColor4ub( team->m_colour.r, team->m_colour.g, team->m_colour.b, astronautAlpha );
            else                            glColor4ub( team->m_colour.r*0.3f, team->m_colour.g*0.3f, team->m_colour.b*0.3f, astronautAlpha*0.2f );

            Vector3 pos( xPos+s/2.0f, yPos+s/2.0f, 0 );
            pos.x += sinf(i + GetHighResTime()) * 1.0f;
            pos.y += cosf(i + i + GetHighResTime()) * 1.0f;

            Vector3 offset( -s/2.0f, -s, 0 );
            
            glBegin( GL_QUADS );
                glTexCoord2f(0,1);      glVertex2dv( (pos+offset).GetData() );      offset.RotateAroundZ(0.5f * M_PI);
                glTexCoord2f(1,1);      glVertex2dv( (pos+offset).GetData() );      offset.RotateAroundZ(0.5f * M_PI);
                glTexCoord2f(1,0);      glVertex2dv( (pos+offset).GetData() );      offset.RotateAroundZ(0.5f * M_PI);
                glTexCoord2f(0,0);      glVertex2dv( (pos+offset).GetData() );      offset.RotateAroundZ(0.5f * M_PI);
            glEnd();
        }

        glDisable( GL_TEXTURE_2D );
    }


    //
    // Engine effect

    if( rocket->m_state == EscapeRocket::StateReady ||
        rocket->m_state == EscapeRocket::StateCountdown ||
        rocket->m_state == EscapeRocket::StateFlight)
    {
        float flameX = m_x + m_w * 0.35f;
        float flameY = m_y + h * 0.8f;
        float flameW = m_w * 0.3f;
        float flameH = m_w * 0.3f;

        glBlendFunc     ( GL_SRC_ALPHA, GL_ONE );

        glEnable( GL_TEXTURE_2D );
        glBindTexture( GL_TEXTURE_2D, g_app->m_resource->GetTexture("textures/muzzleflash.bmp" ) );

        if( fmodf( GetHighResTime()*30, 1.0f ) < 0.5f ) glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
        else                                             glColor4f( 1.0f, 1.0f, 1.0f, 0.2f );

        glBegin( GL_QUADS );
            glTexCoord2i(0,0);      glVertex2f( flameX, flameY );
            glTexCoord2i(0,1);      glVertex2f( flameX+flameW, flameY );
            glTexCoord2i(1,1);      glVertex2f( flameX+flameW, flameY+flameH );
            glTexCoord2i(1,0);      glVertex2f( flameX, flameY+flameH );
        glEnd();

        glDisable( GL_TEXTURE_2D );
    }


    //
    // Captions at the bottom
    // Determine our caption

    float mainCaptionY = m_y + h * 0.6f;
    float mainCaptionH = h * 0.05f;
    float mainCaptionG = mainCaptionH * 0.1f;

    bool timeFlashEffect = (fmodf( GetHighResTime() * 2, 1.0f ) > 0.55f);

    UnicodeString caption;
    RGBAColour captionColour(255,255,255,255);

    if( GetHighResTime() - m_damageTimer < 10.0f && 
        rocket->m_state != EscapeRocket::StateExploding )
    {
        char damage[256];
        sprintf( damage, "%d%%", int(rocket->m_damage) );
        caption = LANGUAGEPHRASE("multiwinia_rr_status_c");
        caption.ReplaceStringFlag( L'T', damage );

        captionColour.Set(255,0,0,255);  
        if( timeFlashEffect ) captionColour.a *= 0.5f;
    }
    else if( rocket->m_state == EscapeRocket::StateCountdown )
    {        
        char captionC[256];
        sprintf( captionC, "%d", (int)rocket->m_countdown + 1 );
        caption = captionC;
        mainCaptionH *= 4;
    }
    else if( rocket->m_state == EscapeRocket::StateFlight )
    {
        caption = LANGUAGEPHRASE("multiwinia_rr_status_d" );
        mainCaptionH *= 1.5f;
        if( timeFlashEffect ) captionColour.a *= 0.25f;
    }
    else if( rocket->m_state == EscapeRocket::StateExploding )
    {
        caption = LANGUAGEPHRASE("multiwinia_rr_status_e" );
        if( timeFlashEffect ) captionColour.a *= 0.25f;
    }
    else if( fuelPercent >= 1.0f && darwiniansInside < 5 )
    {
        caption = LANGUAGEPHRASE("multiwinia_rr_status_b");
        if( timeFlashEffect ) captionColour.a *= 0.25f;
    } 
    else if( rocket->m_refuelRate < 0.05f && fuelPercent < 0.01f )
    {
        caption = LANGUAGEPHRASE("multiwinia_rr_status_a");        
        if( timeFlashEffect ) captionColour.a *= 0.25f;
    }
    else if( fuelPercent < 1.0f )
    {
        char captionC[256];
        sprintf( captionC, "%2.1f%%", fuelPercent * 100 );
        
        caption = LANGUAGEPHRASE("multiwinia_rr_status_f");
        caption.ReplaceStringFlag( L'T', captionC );

        captionColour.a *= 0.75f;
    }
       


    //
    // Render our caption

    if( caption.Length() )
    {
        LList<UnicodeString *> *wrapped = WordWrapText( caption, 1000, mainCaptionH, false, false );

        for( int i = 0; i < wrapped->Size(); ++i )
        {
            UnicodeString *thisString = wrapped->GetData(i);

            glColor4ub( captionColour.a, captionColour.a, captionColour.a, 0 );
            g_titleFont.SetRenderOutline(true);
            g_titleFont.DrawText2DCentre( m_x + m_w/2, mainCaptionY, mainCaptionH, *thisString );

            glColor4ubv( captionColour.GetData() );
            g_titleFont.SetRenderOutline(false);
            g_titleFont.DrawText2DCentre( m_x + m_w/2, mainCaptionY, mainCaptionH, *thisString );

            mainCaptionY += mainCaptionH;
            mainCaptionY += mainCaptionG;
        }

        wrapped->EmptyAndDelete();
        delete wrapped;
    }


    //
    // White border

    glColor4f( 1.0f, 1.0f, 1.0f, 0.2f );

    glBegin( GL_LINE_LOOP );
        glVertex2f( m_x, m_y );
        glVertex2f( m_x + m_w, m_y );
        glVertex2f( m_x + m_w, m_y + h );
        glVertex2f( m_x, m_y + h );
    glEnd();

    glShadeModel( GL_FLAT );
}
void LocationEditor::RenderUnit(InstantUnit *_iu)
{
	char *typeName = Entity::GetTypeName(_iu->m_type);
	
	float landHeight = g_app->m_location->m_landscape.m_heightMap->GetValue(_iu->m_posX, _iu->m_posZ);
	glColor4f( 1.0, 1.0, 1.0, 1.0 );
    g_editorFont.DrawText3DCentre(Vector3(_iu->m_posX, landHeight + 15.0, _iu->m_posZ),
								  15.0, "%d %s(s)", _iu->m_number, typeName);


	// Render troops
	int maxX = (int)iv_sqrt(_iu->m_number);
	int maxZ = _iu->m_number / maxX;
	float pitch = 10.0;
	float offsetX = -maxX * pitch * 0.5;
	float offsetZ = -maxZ * pitch * 0.5;
	RGBAColour colour;
    if( _iu->m_teamId >= 0 ) colour = g_app->m_location->m_teams[_iu->m_teamId]->m_colour;
	colour.a = 200;
    glColor4ubv(colour.GetData());
    
    Vector3 camUp = g_app->m_camera->GetUp() * 5.0;
    Vector3 camRight = g_app->m_camera->GetRight() * 5.0;

    glDisable   (GL_CULL_FACE );
    glEnable    (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE);
    glDepthMask (false);
	glBegin     (GL_QUADS);
    
    //
    // Render dots for the number and team of the unit

	for (int x = 0; x < maxX; ++x)
	{
		for (int z = 0; z < maxZ; ++z)
		{
			Vector3 pos(_iu->m_posX + offsetX + x * pitch, 0,
						_iu->m_posZ + offsetZ + z * pitch);
			pos.y = g_app->m_location->m_landscape.m_heightMap->GetValue(pos.x, pos.z) + 2.0;
			glVertex3dv( (pos - camUp - camRight).GetData() );
            glVertex3dv( (pos - camUp + camRight).GetData() );
            glVertex3dv( (pos + camUp + camRight).GetData() );
            glVertex3dv( (pos + camUp - camRight).GetData() );
		}
	}

    glEnd();


    //
    // Render our spread circle

    if( m_mode == ModeInstantUnit )
    {
        int numSteps = 30;
        float angle = 0.0;

        colour.a = 100;
        glColor4ubv(colour.GetData() );
        glLineWidth( 2.0 );
        glBegin( GL_LINE_LOOP );
        for( int i = 0; i <= numSteps; ++i )
        {
            float xDiff = _iu->m_spread * iv_sin(angle);
            float zDiff = _iu->m_spread * iv_cos(angle);
            Vector3 pos = Vector3(_iu->m_posX, 0.0, _iu->m_posZ) + Vector3(xDiff,5,zDiff);
	        pos.y = g_app->m_location->m_landscape.m_heightMap->GetValue(pos.x, pos.z) + 10.0;
            if( pos.y < 2 ) pos.y = 2;
            glVertex3dv( pos.GetData() );
            angle += 2.0 * M_PI / (float) numSteps;
        }
        glEnd();
    }
    

    glDisable   (GL_BLEND);
    glDepthMask (true);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable    (GL_CULL_FACE );

}
예제 #9
0
void glColorRGBA(const RGBAColour& rgba) {
    glColor4ub(rgba.r(), rgba.g(), rgba.b(), rgba.a());
}
예제 #10
0
Uint32 MapRGBA(SDL_PixelFormat *fmt, const RGBAColour& in) {
  return SDL_MapRGBA(fmt, in.r(), in.g(), in.b(), in.a());
}
void AIObjectiveMarker::RenderAlphas( double _predictionTime )
{
    bool objectiveActive = m_objectiveId == -1 || ((AIObjective *)g_app->m_location->GetBuilding( m_objectiveId ))->m_active;
    bool render = (!g_app->m_editing && g_prefsManager->GetInt( "RenderAIInfo", 0 ) != 0 && objectiveActive );
    if( g_app->m_editing || render)
    {
#ifdef LOCATION_EDITOR
        Building::RenderAlphas( _predictionTime );
        RGBAColour col;
        if( g_app->m_editing )
        {
            col.Set( 255, 0, 0 );
        }
        else if( m_id.GetTeamId() == 255 )
        {
            col.Set( 150, 150, 150 );
        }
        else
        {
            if( m_objectiveBuildingId != -1 &&
                fabs(sin(g_gameTime)) < 0.5)
            {
                col = RGBAColour(255, 255, 255, 255);
            }
            else
            {
                col = g_app->m_location->m_teams[ m_id.GetTeamId() ]->m_colour;
            }
        }
        RenderSphere( m_pos, 25.0, col );

        Building *b = g_app->m_location->GetBuilding( m_objectiveBuildingId );
        if( b )
        {
            RenderArrow( m_pos, b->m_pos, 5.0, col );
        }

        if( g_app->m_editing &&
            g_app->m_locationEditor->m_mode == LocationEditor::ModeBuilding &&
            g_app->m_locationEditor->m_selectionId == m_id.GetUniqueId() )
        {
            RenderSphere( m_pos, 30.0, RGBAColour( 255, 0, 0 ) );

            Vector3 triggerPos = m_pos;
            int numSteps = 20;
            glBegin( GL_LINE_LOOP );
            glLineWidth( 1.0 );
            glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
            for( int i = 0; i < numSteps; ++i )
            {
                float angle = 2.0f * M_PI * (float)i / (float) numSteps;
                Vector3 thisPos = triggerPos + Vector3( sinf(angle)*m_scanRange, 0.0f,
                                                        cosf(angle)*m_scanRange );
                thisPos.y = g_app->m_location->m_landscape.m_heightMap->GetValue( thisPos.x, thisPos.z );
                thisPos.y += 10.0f;
                glVertex3dv( thisPos.GetData() );
            }
            glEnd();
        }
#endif
    }
}
void Nuke::RenderHistory( double _predictionTime )
{
    if( m_history.Size() > 0 && m_id.GetTeamId() != 255 )
    {
        glBindTexture( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "textures/laser.bmp" ) );

        Vector3 predictedPos = m_pos + m_vel * SERVER_ADVANCE_PERIOD;
        Vector3 lastPos = predictedPos;

        RGBAColour colour = g_app->m_location->m_teams[m_id.GetTeamId()]->m_colour;
        if( m_id.GetTeamId() == g_app->m_location->GetMonsterTeamId() )
        {
            glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR );
            colour.Set( 255, 255, 255, 0 );
        }

        for( int i = 0; i < m_history.Size(); ++i )
        {
            Vector3 historyPos, thisPos;
			thisPos = historyPos = *m_history[i];

            Vector3 diff = thisPos - lastPos;
            lastPos += diff * 0.1f;
            if( m_id.GetTeamId() != g_app->m_location->GetMonsterTeamId() )
            {
                colour.a = 255 - 255 * (float) i / (float) m_history.Size();
            }

            glColor4ubv( colour.GetData() );

            Vector3 lengthVector = (thisPos - lastPos).Normalise();
	        lengthVector.SetLength((thisPos - lastPos).Mag());
            Vector3 fromPos = lastPos;
            Vector3 toPos = thisPos;//lastPos - lengthVector;

            Vector3 midPoint        = fromPos + (toPos - fromPos)/2.0f;
            Vector3 camToMidPoint   = g_app->m_camera->GetPos() - midPoint;
            float   camDistSqd      = camToMidPoint.MagSquared();
            Vector3 rightAngle      = (camToMidPoint ^ ( midPoint - toPos )).Normalise();
            
            //rightAngle *= 0.8f;
            rightAngle.SetLength(5.0f);

            glBegin( GL_QUADS );
                glTexCoord2i(0,0);      glVertex3dv( (fromPos - rightAngle).GetData() );
                glTexCoord2i(0,1);      glVertex3dv( (fromPos + rightAngle).GetData() );
                glTexCoord2i(1,1);      glVertex3dv( (toPos + rightAngle).GetData() );                
                glTexCoord2i(1,0);      glVertex3dv( (toPos - rightAngle).GetData() );                     

                glTexCoord2i(0,0);      glVertex3dv( (fromPos - rightAngle).GetData() );
                glTexCoord2i(0,1);      glVertex3dv( (fromPos + rightAngle).GetData() );
                glTexCoord2i(1,1);      glVertex3dv( (toPos + rightAngle).GetData() );                
                glTexCoord2i(1,0);      glVertex3dv( (toPos - rightAngle).GetData() );                     

                glTexCoord2i(0,0);      glVertex3dv( (fromPos - rightAngle).GetData() );
                glTexCoord2i(0,1);      glVertex3dv( (fromPos + rightAngle).GetData() );
                glTexCoord2i(1,1);      glVertex3dv( (toPos + rightAngle).GetData() );                
                glTexCoord2i(1,0);      glVertex3dv( (toPos - rightAngle).GetData() );                     
            glEnd();

            lastPos = historyPos;
        }
    }
}
void Nuke::Render( double _predictionTime )
{
    if( m_renderMarker )
    {
        RenderGroundMarker();
    }
    RenderSub( _predictionTime );
    if( m_exploded )
    {
        //RenderDeaths();
    }
    else
    {
        if( !m_launched ) return;

        Vector3 front = m_front;
        front.RotateAroundY( M_PI / 2.0f );
        Vector3 predictedPos = m_pos + m_vel * _predictionTime;;
        Vector3 entityUp = m_front;
        Vector3 entityRight (front ^ entityUp);

        Vector3 lengthVector = m_vel;
        lengthVector.SetLength( 10.0f );
        Vector3 fromPos = predictedPos;
        Vector3 toPos = predictedPos - lengthVector;

        Vector3 midPoint        = fromPos + (toPos - fromPos)/2.0f;
        Vector3 camToMidPoint   = g_app->m_camera->GetPos() - midPoint;
        float   camDistSqd      = camToMidPoint.MagSquared();
        Vector3 rightAngle      = (camToMidPoint ^ ( midPoint - toPos )).Normalise();

        entityRight = rightAngle;

        float size = 10.0f;  
        size *= (1.0f + 0.03f * (( m_id.GetIndex() * m_id.GetUniqueId() ) % 10));
        entityRight *= size;
        entityUp *= size * 2.0f;

        glDepthMask     ( false );
        glEnable        ( GL_BLEND );
        glBlendFunc     ( GL_SRC_ALPHA, GL_ONE );
        glEnable        ( GL_TEXTURE_2D );
        glBindTexture( GL_TEXTURE_2D, g_app->m_resource->GetTexture( "sprites/nuke.bmp" ) );

        RGBAColour colour = g_app->m_location->m_teams[m_id.GetTeamId()]->m_colour;
        if( m_id.GetTeamId() == g_app->m_location->GetMonsterTeamId() )
        {
            glBlendFunc     ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR );
            colour.Set( 255, 255, 255, 0 );
        }
        glColor4ubv(colour.GetData());

        glBegin(GL_QUADS);
            glTexCoord2i(0, 1);     glVertex3dv( (predictedPos - entityRight + entityUp).GetData() );
            glTexCoord2i(1, 1);     glVertex3dv( (predictedPos + entityRight + entityUp).GetData() );
            glTexCoord2i(1, 0);     glVertex3dv( (predictedPos + entityRight).GetData() );
            glTexCoord2i(0, 0);     glVertex3dv( (predictedPos - entityRight).GetData() );
        glEnd();

        RenderHistory( _predictionTime );

        glShadeModel    ( GL_FLAT );
        glDisable       ( GL_TEXTURE_2D );
        glDepthMask     ( true );
    }
}