Advertisement
Krythic

Wireframe Builder

Aug 3rd, 2020
1,457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. using SharpDX;
  2. using SharpDX.Direct3D11;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using VoidwalkerEngine.Framework.Maths;
  9.  
  10. namespace VoidwalkerEngine.Framework.DirectX.Rendering
  11. {
  12.     public static class Wireframe
  13.     {
  14.         public static ModelMesh GenerateWireframeSphere(Device device, Vector3 location, float radius)
  15.         {
  16.             float pi = (float)Math.PI;
  17.             List<Vertex> vertices = new List<Vertex>();
  18.             for (float angle = 0f; angle <= 2 * pi; angle += 0.01f)
  19.             {
  20.                 float x = radius * (float)Math.Sin(angle);
  21.                 float y = radius * (float)Math.Cos(angle);
  22.                 float z = 0;
  23.                 vertices.Add(new Vertex(location.X + x, location.Y + y, location.Z + z));
  24.             }
  25.             for (float angle = 0f; angle <= 2 * pi; angle += 0.01f)
  26.             {
  27.                 float x = radius * (float)Math.Sin(angle);
  28.                 float y = 0;
  29.                 float z = radius * (float)Math.Cos(angle);
  30.                 vertices.Add(new Vertex(location.X + x, location.Y + y, location.Z + z));
  31.             }
  32.  
  33.             for (float angle = 0f; angle <= 2 * pi; angle += 0.01f)
  34.             {
  35.                 float x = 0;
  36.                 float y = radius * (float)Math.Sin(angle);
  37.                 float z = radius * (float)Math.Cos(angle);
  38.                 vertices.Add(new Vertex(location.X + x, location.Y + y, location.Z + z));
  39.             }
  40.             ModelMesh mesh = new ModelMesh(device, vertices.ToArray());
  41.             return mesh;
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement