DrawTriangleClass.cs
上传用户:lslight
上传日期:2022-01-10
资源大小:14248k
文件大小:2k
源码类别:

DirextX编程

开发平台:

C#

  1. ///////////////////////////////////////////////////////////////////////
  2. //      ■■■■     ■■■■■       ■■■■       ■       ■      //
  3. //    ■                 ■         ■               ■       ■      //
  4. //    ■                 ■         ■    ■■■     ■       ■      //
  5. //    ■                 ■         ■       ■      ■       ■      //
  6. //      ■■■■         ■           ■■■■         ■■■■       //
  7. // Copyright (c) 三峡大学水利与环境学院 肖泽云. All rights reserved.  //
  8. ////////////////////////////////////////////////////////////////////////
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Text;
  12. using System.Drawing;
  13. using Microsoft.DirectX;
  14. using Microsoft.DirectX.Direct3D;
  15. namespace 绘制基本几何体
  16. {
  17.     class DrawTriangleClass
  18.     {
  19.         public Device device;
  20.         public Vector3[] pointVectors;
  21.         public CustomVertex.PositionColored[] vertices;
  22.         public DrawTriangleClass(Device _device,Vector3[] _pointVectors)
  23.         {
  24.             device = _device;
  25.             pointVectors=_pointVectors;
  26.             vertices = new CustomVertex.PositionColored[3];
  27.             vertices[0].Position = pointVectors[0]; vertices[0].Color = Color.Yellow.ToArgb();
  28.             vertices[1].Position = pointVectors[1]; vertices[1].Color = Color.Red.ToArgb();
  29.             vertices[2].Position = pointVectors[2]; vertices[2].Color = Color.Green.ToArgb();
  30.         }
  31.         public void DrawTriangle()
  32.         {
  33.             device.BeginScene();
  34.             device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices);
  35.             device.EndScene();
  36.             device.Present();
  37.         }
  38.     }
  39. }