Guest User

Untitled

a guest
Sep 25th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.23 KB | None | 0 0
  1. public:
  2.     __declspec(dllexport) static bool RenderFrame(Camera camera) {
  3.  
  4.         for (size_t y = 0; y < ScreenClass::SizeY; y++)
  5.         {
  6.             for (size_t x = 0; x < ScreenClass::SizeX; x++)
  7.             {
  8.                 bool IsDraw = false;//Костыль
  9.  
  10.                 Vector2 currentPos;
  11.                 currentPos.x = x;
  12.                 currentPos.y = y;
  13.  
  14.                 ConsoleInfo::SetCursorPosition({ static_cast<SHORT>(currentPos.x), static_cast<SHORT>(currentPos.y) });
  15.  
  16.                 for (size_t z = 0; z < SpriteObject::AllSpriteObjects.size(); z++)
  17.                 {
  18.                     vector<Vector2> triangles = SpriteObject::AllSpriteObjects[z]->Mesh.Triangles;
  19.  
  20.                     for (size_t t = 0; t < triangles.size(); t += 3)
  21.                     {
  22.                         float x1 = ((triangles[t].x + SpriteObject::AllSpriteObjects[z]->Position->x) - currentPos.x) * ((triangles[t + 1].y + SpriteObject::AllSpriteObjects[z]->Position->y) - (triangles[t].y + SpriteObject::AllSpriteObjects[z]->Position->y)) - ((triangles[t + 1].x + SpriteObject::AllSpriteObjects[z]->Position->x) - (triangles[t].x + SpriteObject::AllSpriteObjects[z]->Position->x)) * ((triangles[t].y + SpriteObject::AllSpriteObjects[z]->Position->y) - currentPos.y);
  23.                         float x2 = ((triangles[t + 1].x + SpriteObject::AllSpriteObjects[z]->Position->x) - currentPos.x) * ((triangles[t + 2].y + SpriteObject::AllSpriteObjects[z]->Position->y) - (triangles[t + 1].y + SpriteObject::AllSpriteObjects[z]->Position->y)) - ((triangles[t + 2].x + SpriteObject::AllSpriteObjects[z]->Position->x) - (triangles[t + 1].x + SpriteObject::AllSpriteObjects[z]->Position->x)) * ((triangles[t + 1].y + SpriteObject::AllSpriteObjects[z]->Position->y) - currentPos.y);
  24.                         float x3 = ((triangles[t + 2].x + SpriteObject::AllSpriteObjects[z]->Position->x) - currentPos.x) * ((triangles[t].y + SpriteObject::AllSpriteObjects[z]->Position->y) - (triangles[t + 2].y + SpriteObject::AllSpriteObjects[z]->Position->y)) - ((triangles[t].x + SpriteObject::AllSpriteObjects[z]->Position->x) - (triangles[t + 2].x + SpriteObject::AllSpriteObjects[z]->Position->x)) * ((triangles[t + 2].y + SpriteObject::AllSpriteObjects[z]->Position->y) - currentPos.y);
  25.  
  26.                         if (x1 >= 0 && x2 >= 0 && x3 >= 0)
  27.                         {      
  28.                             ConsoleInfo::SetConsoleColour(SpriteObject::AllSpriteObjects[z]->Color);
  29.                             IsDraw = true;//Костыль
  30.                             printf(&SpriteObject::AllSpriteObjects[z]->Texture);
  31.                             break;
  32.                         }
  33.                         else if (x1 <= 0 && x2 <= 0 && x3 <= 0)
  34.                         {
  35.                             ConsoleInfo::SetConsoleColour(SpriteObject::AllSpriteObjects[z]->Color);
  36.                             IsDraw = true;//Костыль
  37.                             printf(&SpriteObject::AllSpriteObjects[z]->Texture);
  38.                             break;
  39.                         }
  40.                     }
  41.                 }
  42.                 if (IsDraw == false)
  43.                 {
  44.                     printf(" ");
  45.                 }
  46.             }
  47.         }
  48.         return true;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment