Esempio n. 1
0
void ResultScreen::DrawStatImage(Rect rect)
{
	RenderHelper *helper = RenderHelper::Instance();
	RenderManager *manager = RenderManager::Instance();

	for(uint32 i = 0; i < testData.GetItemCount(); ++i)
	{
		FpsStatItem item = testData.GetItem(i);
		Rect curRect = testData.TranslateRect(item.rect, rect);
		for(uint32 j = 0; j < SECTORS_COUNT; j++)
		{
			manager->SetColor(SettingsManager::Instance()->GetColorByFps(item.avFps[j]));
			Polygon2 curSector;
			curSector.AddPoint(curRect.GetCenter());
			curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f - 22.5f)));
			curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f)));
			curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f + 22.5f)));
			helper->FillPolygon(curSector);
			manager->SetColor(Color::Black());
			helper->DrawPolygon(curSector, true);
		}
	}
}
void NotPassableTerrain::HeihghtmapUpdated(const DAVA::Rect &forRect)
{
    EditorLandscape::HeihghtmapUpdated(forRect);
    
    AABBox3 boundingBox = nestedLandscape->GetBoundingBox();
    Vector3 landSize = boundingBox.max - boundingBox.min;

    float32 angleCellDistance = landSize.x / (float32)(heightmap->Size() - 1);
    float32 angleHeightDelta = landSize.z / (float32)(Heightmap::MAX_VALUE - 1);
    float32 tanCoef = angleHeightDelta / angleCellDistance;
 
    Texture *notPassableMap = notPassableMapSprite->GetTexture();
    float32 dx = (float32)notPassableMap->GetWidth() / (float32)(heightmap->Size() - 1);
    
    RenderManager::Instance()->LockNonMain();
    RenderManager::Instance()->SetRenderTarget(notPassableMapSprite);

    Rect drawRect(forRect.x * dx, forRect.y * dx, (forRect.dx - 1)* dx, (forRect.dy - 1) * dx);
    RenderManager::Instance()->ClipPush();
    RenderManager::Instance()->ClipRect(drawRect);

    DrawFullTiledTexture(notPassableMap, drawRect);
    
    int32 lastY = (int32)(forRect.y + forRect.dy);
    int32 lastX = (int32)(forRect.x + forRect.dx);
    for (int32 y = (int32)forRect.y; y < lastY; ++y)
    {
        int32 yOffset = y * heightmap->Size();
        for (int32 x = (int32)forRect.x; x < lastX; ++x)
        {
            uint16 currentPoint = heightmap->Data()[yOffset + x];
            uint16 rightPoint = heightmap->Data()[yOffset + x + 1];
            uint16 bottomPoint = heightmap->Data()[yOffset + x + heightmap->Size()];
            
            uint16 deltaRight = (uint16)abs((int32)currentPoint - (int32)rightPoint);
            uint16 deltaBottom = (uint16)abs((int32)currentPoint - (int32)bottomPoint);
            
            float32 tanRight = (float32)deltaRight * tanCoef;
            float32 tanBottom = (float32)deltaBottom * tanCoef;
            
            float32 ydx = y * dx;
            float32 xdx = x * dx;

            RenderManager* renderManager = RenderManager::Instance();
            RenderHelper* renderHelper = RenderHelper::Instance();
            
            Color color;

            if(PickColor(tanRight, color))
            {
                renderManager->SetColor(color);
                renderHelper->DrawLine(Vector2(xdx, ydx), Vector2((xdx + dx), ydx));
            }
            
            if(PickColor(tanBottom, color))
            {
                renderManager->SetColor(color);
                renderHelper->DrawLine(Vector2(xdx, ydx), Vector2(xdx, (ydx + dx)));
            }
            
        }
    }

    RenderManager::Instance()->ResetColor();
    
    RenderManager::Instance()->ClipPop();
    
    RenderManager::Instance()->RestoreRenderTarget();
    RenderManager::Instance()->UnlockNonMain();
}