Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.48 KB | None | 0 0
  1.         void SceneBuilder()
  2.         {
  3.             Stopwatch CPUtick = new Stopwatch();
  4.             CPUtick.Start();
  5.  
  6.             while (true)
  7.             {
  8.                 for (UInt64 Voxel = OBJ_HEADER; Voxel <= (UInt64)VoxCube[OBJ_SIZE] * 4; Voxel += BPP)
  9.                 {
  10.                     double a, b;
  11.  
  12.                     VoxCube[Voxel + _z]++;
  13.  
  14.                     if (VoxCube[Voxel + _z] != 0)
  15.                     {
  16.                         a = (VoxCube[Voxel + _x] * 500) / -VoxCube[Voxel + _z];
  17.                         b = (VoxCube[Voxel + _y] * 500) / -VoxCube[Voxel + _z];
  18.                     }
  19.                     else
  20.                     {
  21.                         a = (VoxCube[Voxel + _x] * 500);
  22.                         b = (VoxCube[Voxel + _y] * 500);
  23.                     }
  24.  
  25.                     if ((a <= ((double)Resolution.X / 2) - 0 && a >= -((double)Resolution.X / 2)) &&
  26.                         (b <= ((double)Resolution.Y / 2) - 0 && b >= -((double)Resolution.Y / 2)) && VoxCube[Voxel + _z] >= 0)
  27.                     {
  28.                         Int64 Repere = ((Int64)Resolution.X / 2 + (Int64)Resolution.X * (Int64)Resolution.Y / 2) * 4;
  29.                         Int64 OffsetPixel = Repere - (((Int64)Resolution.X * (Int64)b) + (Int64)a) * 4;
  30.  
  31.                         if (OffsetPixel >= 0 && OffsetPixel < ((Int64)Resolution.X * (Int64)Resolution.Y * (Int64)BPP))
  32.                         {
  33.                             UInt64 byteA = ((UInt64)VoxCube[Voxel + _color] << 24) >> 24;
  34.                             UInt64 byteR = ((UInt64)VoxCube[Voxel + _color] << 16) >> 24;
  35.                             UInt64 byteG = ((UInt64)VoxCube[Voxel + _color] << 08) >> 24;
  36.                             UInt64 byteB = ((UInt64)VoxCube[Voxel + _color] << 00) >> 24;
  37.  
  38.                             Viewport[150 + OffsetPixel] = (byte)byteR;
  39.                             Viewport[151 + OffsetPixel] = (byte)byteG;
  40.                             Viewport[152 + OffsetPixel] = (byte)byteB;
  41.                             Viewport[153 + OffsetPixel] = (byte)byteA;
  42.                         }
  43.                     }
  44.                 }
  45.  
  46.                 //UploadScreen();
  47.  
  48.                 // Show FPS
  49.                 FPS[0]++;
  50.  
  51.                 if (CPUtick.ElapsedMilliseconds > FPS[1] + 1000)
  52.                 {
  53.                     textBox8.Text = FPS[0].ToString();
  54.  
  55.                     FPS[0] = 0;
  56.                     FPS[1] = CPUtick.ElapsedMilliseconds;
  57.                 }
  58.             }
  59.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement