示例#1
0
void Arrow3d::Render(ScreenBase const & screen, int zoomLevel, ref_ptr<dp::GpuProgramManager> mng)
{
    // Unbind current VAO, because glVertexAttributePointer and glEnableVertexAttribute can affect it.
    if (dp::GLExtensionsList::Instance().IsSupported(dp::GLExtensionsList::VertexArrayObject))
        GLFunctions::glBindVertexArray(0);

    if (!m_isInitialized)
    {
        Build();
        m_isInitialized = true;
    }

    // Render shadow.
    if (screen.isPerspective())
    {
        ref_ptr<dp::GpuProgram> shadowProgram = mng->GetProgram(gpu::ARROW_3D_SHADOW_PROGRAM);
        RenderArrow(screen, shadowProgram, dp::Color(60, 60, 60, 60), 0.05f, false /* hasNormals */);
    }

    // Render arrow.
    ref_ptr<dp::GpuProgram> arrowProgram = mng->GetProgram(gpu::ARROW_3D_PROGRAM);
    dp::Color const color = df::GetColorConstant(GetStyleReader().GetCurrentStyle(),
                            m_obsoletePosition ? df::Arrow3DObsolete : df::Arrow3D);
    RenderArrow(screen, arrowProgram, color, 0.0f, true /* hasNormals */);

    arrowProgram->Unbind();
    GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
}
void LocationEditor::RenderModeCameraMount()
{
	RGBAColour bright(255,255,0);
	RGBAColour dim(90,90,0);

	LList <CameraAnimation*> *list = &g_app->m_location->m_levelFile->m_cameraAnimations;
	for (int i = 0; i < list->Size(); ++i)
	{
		CameraAnimation *anim = list->GetData(i);
		CamAnimNode *lastNode = anim->m_nodes.GetData(0);
		for (int j = 1; j < anim->m_nodes.Size(); ++j)
		{
			CamAnimNode *node = anim->m_nodes.GetData(j);
			if (stricmp(node->m_mountName, MAGIC_MOUNT_NAME_START_POS) == 0 ||
				stricmp(lastNode->m_mountName, MAGIC_MOUNT_NAME_START_POS) == 0)
			{
				continue;
			}

			CameraMount *mount1 = g_app->m_location->m_levelFile->GetCameraMount(lastNode->m_mountName);
			CameraMount *mount2 = g_app->m_location->m_levelFile->GetCameraMount(node->m_mountName);
			if (i == m_selectionId)
			{
				RenderArrow(mount1->m_pos, mount2->m_pos, 1.0, bright);
			}
			else
			{
				RenderArrow(mount1->m_pos, mount2->m_pos, 1.0, dim);
			}

			lastNode = node;
		}
	}
}
示例#3
0
/// render the whole snake
void cRubikSnake::Render()
{
    TSRGlobalConstants.PushMatrix();
    TSRGlobalConstants.Translate( m_vPanTranslation.x, m_vPanTranslation.y, m_vPanTranslation.z );
    TSRGlobalConstants.MultMatrix( m_ArcBall.m_Transform.d );
    TSRGlobalConstants.Translate( -m_Center.x, -m_Center.y, -m_Center.z );

    TSRGlobalConstants.PushMatrix();
	for ( unsigned int i = 0; i < m_Angles.size(); i++ )
	{
        m_ColorModifier.m_Color = ( i % 2 ) ? m_EvenColor : m_OddColor;
		if ( m_SelectedIndex > -1 && ( ( int ) i ) > m_SelectedIndex )
        {
            m_ColorModifier.m_Color = m_SelectionColor;
        }
        TSRGlobalConstants.MultMatrix( m_Transform.d );
		m_pSnakeEntity->Render();
		TSRGlobalConstants.Translate( -0.5f, 0.5f, 0.0f );
		TSRGlobalConstants.Rotate( m_Angles[ i ], 1.0f, 0.0f, 0.0f );
	}
	TSRGlobalConstants.PopMatrix();

	RenderArrow();

    TSRGlobalConstants.PopMatrix();
}
示例#4
0
void GameRender(void)
{
	u_int uColor = (dbg_collided && tcoll < 0.0f)? 0x80FF8080 : 0x8080FF80;
	int y = 1;

	PolyColl::Render(m_xPosition[0], m_fAngle[0], uColor, 0xFFFFFFFF, m_pxVertices[0], m_iNumVertices[0]);
	PolyColl::Render(m_xPosition[1], m_fAngle[1], uColor, 0xFF000000, m_pxVertices[1], m_iNumVertices[1]);

	PrintString(m_xPosition[0].x, m_xPosition[0].y, true, 0xFFFFFFFF, "Poly A");
	PrintString(m_xPosition[1].x, m_xPosition[1].y, true, 0xFFFFFFFF, "Poly B");

	// render the collision stuff
	RenderArrow(m_xPosition[0], m_xDisplacement[0].Direction(), m_xDisplacement[0].Length(), 0xFFFFFFFF);

	if (tcoll > 0.0f)
	{
		u_int uColor = (dbg_collided)? 0x40FF8080 : 0x4080FF80;
	
		Vector Pcoll = m_xPosition[0] + m_xDisplacement[0] * tcoll;
		PolyColl::Render(Pcoll, m_fAngle[0], uColor, 0x40FFFFFF, m_pxVertices[0], m_iNumVertices[0]);
	}

	if (dbg_collided)
	{
		float length = (tcoll < 0.0f)? fabs(tcoll) : dbg_world_size * 0.1f;

		// render the collision stuff
		RenderArrow((m_xPosition[0] + m_xPosition[1]) * 0.5f, Ncoll, length, 0xFFFFFFFF);
		
		if (tcoll < 0.0f)
		{
			PrintString(1, y++, false, 0xFFFFFFFF, "Press 'RETURN' to separate the objects");
		}
	}
	PrintString(1, y++, false, 0xFFFFFFFF, "Press mnouse button 1 to launch poly A towards mouse cursor");
	PrintString(1, y++, false, 0xFFFFFFFF, "Press 'P' to pause");
	PrintString(1, y++, false, 0xFFFFFFFF, "Press 'A' to enable-disable rotations");
}
示例#5
0
void GameRender(void)
{
	for(int i = 0; i < m_iNumBodies; i ++)
	{
		if (!m_pxBodies[i])	continue;

		m_pxBodies[i]->Render();
	}

	if (m_pxPlayer)
	{
		PrintString(m_pxPlayer->GetPosition().x, m_pxPlayer->GetPosition().y, true, 0xFFFFFFFF, "player");
		RenderArrow(m_pxPlayer->GetPosition(), m_pxPlayer->GetDisplacement().Direction(), m_pxPlayer->GetDisplacement().Length() + 10.0f, 0xFFFFFFFF);
	}
	GameRenderStats();
}
void PylonStart::RenderAlphas( float _predictionTime )
{
    PowerBuilding::RenderAlphas( _predictionTime );

#ifdef DEBUG_RENDER_ENABLED
    if( g_app->m_editing )
    {
        Building *req = g_app->m_location->GetBuilding( m_reqBuildingId );
        if( req )
        {
            RenderArrow( m_pos+Vector3(0,50,0),
                         req->m_pos+Vector3(0,50,0),
                         2.0f, RGBAColour(255,0,0) );
        }
    }
#endif
}
void Building::RenderLink()
{
#ifdef DEBUG_RENDER_ENABLED
    int buildingId = GetBuildingLink();
    if( buildingId != -1 )
    {
        Building *linkBuilding = g_app->m_location->GetBuilding( buildingId );
        if( linkBuilding )
        {
			Vector3 start = m_pos;
			start.y += 10.0f;
			Vector3 end = linkBuilding->m_pos;
			end.y += 10.0f;
			RenderArrow(start, end, 6.0f, RGBAColour(255,0,255));
        }
    }
#endif
}
示例#8
0
void GameRender(void)
{
	u_int uColor = (dbg_collided)? 0x80FF8080 : 0x8080FF80;

	PolyColl::Render(m_xPosition[0], uColor, 0xFFFFFFFF, m_pxVertices[0], m_iNumVertices[0]);
	PolyColl::Render(m_xPosition[1], uColor, 0xFF000000, m_pxVertices[1], m_iNumVertices[1]);

	PrintString(m_xPosition[0].x, m_xPosition[0].y, true, 0xFFFFFFFF, "Poly A");
	PrintString(m_xPosition[1].x, m_xPosition[1].y, true, 0xFFFFFFFF, "Poly B");

	if (dbg_collided)
	{
		// render the collision stuff
		RenderArrow((m_xPosition[0] + m_xPosition[1]) * 0.5f, Ncoll, fabs(dcoll), 0xFFFFFFFF);

		PrintString(1, 1, false, 0xFFFFFFFF, "Press 'RETURN' to separate the objects");
	}
}
void Building::Render( float predictionTime )
{
#ifdef DEBUG_RENDER_ENABLED
	if (g_app->m_editing)
	{
		Vector3 pos(m_pos);
		pos.y += 5.0f;
		RenderArrow(pos, pos + m_front * 20.0f, 4.0f);
	}
#endif

	if (m_shape)
	{
		Matrix34 mat(m_front, m_up, m_pos);
		m_shape->Render(predictionTime, mat);

        //m_shape->RenderMarkers(mat);
	}
}
void LocationEditor::Render()
{
    //
    // Render our buildings
	
	g_app->m_renderer->SetObjectLighting();
    LevelFile *levelFile = g_app->m_location->m_levelFile;
    for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
    {
        if( levelFile->m_buildings.ValidIndex(i) )
        {
            Building *b = levelFile->m_buildings.GetData(i);
            b->Render(0.0);
        }
    } 
    g_app->m_renderer->UnsetObjectLighting();
	if (m_mode == ModeBuilding)
	{
		for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
		{
			if( levelFile->m_buildings.ValidIndex(i) )
			{
				Building *b = levelFile->m_buildings.GetData(i);
				b->RenderAlphas(0.0);
				b->RenderLink();
			}
		}
	}


	// 
	// Render camera mounts

	{
		g_app->m_renderer->SetObjectLighting();
		Shape *camShape = g_app->m_resource->GetShape("camera.shp");
		Matrix34 mat;
		
		for (int i = 0; i < g_app->m_location->m_levelFile->m_cameraMounts.Size(); ++i)
		{
			CameraMount *mount = g_app->m_location->m_levelFile->m_cameraMounts[i];
			Vector3 camToMount = g_app->m_camera->GetPos() - mount->m_pos;
			if (camToMount.Mag() < 20.0) continue;
			mat.OrientFU(mount->m_front, mount->m_up);
			mat.pos = mount->m_pos;
			camShape->Render(0.0, mat);
		}
	    g_app->m_renderer->UnsetObjectLighting();
	}


    g_app->m_renderer->UnsetObjectLighting();


	// 
	// Render our instant units
	
	for (int i = 0; i < levelFile->m_instantUnits.Size(); ++i)
	{
		InstantUnit *iu = levelFile->m_instantUnits.GetData(i);
		RenderUnit(iu);
	}

	switch (m_mode)
	{
		case ModeLandTile:			RenderModeLandTile();				break;
		case ModeLandFlat:			RenderModeLandFlat();				break;
		case ModeBuilding:			RenderModeBuilding();				break;
		case ModeLight:													break;
		case ModeInstantUnit:		RenderModeInstantUnit();			break;
		case ModeCameraMount:		RenderModeCameraMount();			break;
	}

	
	//
	// Render axes

	float sizeX = g_app->m_location->m_landscape.GetWorldSizeX() / 2;
	float sizeZ = g_app->m_location->m_landscape.GetWorldSizeZ() / 2;
	RenderArrow(Vector3(10, 200, 0), Vector3(sizeX, 200, 0), 4.0);
	glBegin(GL_LINES);
		glVertex3f(sizeX,      250, 0);
		glVertex3f(sizeX + 90, 150, 0);
		glVertex3f(sizeX,      150, 0);
		glVertex3f(sizeX + 90, 250, 0);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);

	RenderArrow(Vector3(0, 200, 10), Vector3(0, 200, sizeZ), 4.0);
	glBegin(GL_LINES);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 250, sizeZ + 90);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
		glVertex3f(0, 150, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);


    //
    // Render targetting crosshair

    g_app->m_renderer->SetupMatricesFor2D();
	glColor3ub(255,255,255);
    glLineWidth( 1.0 );
    glBegin( GL_LINES );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 - 30 );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 + 30 );

        glVertex2i( g_app->m_renderer->ScreenW()/2 - 30, g_app->m_renderer->ScreenH()/2 );
        glVertex2i( g_app->m_renderer->ScreenW()/2 + 30, g_app->m_renderer->ScreenH()/2 );
    glEnd();
    g_app->m_renderer->SetupMatricesFor3D();
    

	CHECK_OPENGL_STATE();
}
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
    }
}