/// <summary> /// Initializes a new instance of the <see cref="DirectXBSPCollision"/> class. /// </summary> /// <param name="device">The device.</param> /// <param name="tempcoll">The tempcoll.</param> /// <remarks></remarks> public DirectXBSPCollision(ref Device device, ref BSPModel.BSPCollision tempcoll) { CreateVertexBuffers(ref device, ref tempcoll); CreateIndexBuffers(ref device, ref tempcoll); verticeCount = tempcoll.Vertices.Length; faceCount = tempcoll.Faces.Length; }
/// <summary> /// Initializes a new instance of the <see cref="BSPCollisionViewer"/> class. /// </summary> /// <param name="tempcoll">The tempcoll.</param> /// <param name="map">The map.</param> /// <remarks></remarks> public BSPCollisionViewer(BSPModel.BSPCollision tempcoll, Map map) { //InitializeComponent InitializeComponent(); this.map = map; coll = tempcoll; // Set the initial size of our form this.ClientSize = new Size(800, 600); // And its caption this.Text = "BSP Viewer"; // Load our points/edges & build polygons for surface detection / modifying LoadMeta(); Main(); }
/// <summary> /// The create vertex buffers. /// </summary> /// <param name="device">The device.</param> /// <param name="tempcoll">The tempcoll.</param> /// <remarks></remarks> private void CreateVertexBuffers(ref Device device, ref BSPModel.BSPCollision tempcoll) { vb = new VertexBuffer( typeof(CustomVertex.PositionColored), tempcoll.Vertices.Length, device, Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default); CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb.Lock(0, 0); // Lock the buffer (which will return our structs) for (int i = 0; i < tempcoll.Vertices.Length; i++) { verts[i].Position = new Vector3(tempcoll.Vertices[i].X, tempcoll.Vertices[i].Y, tempcoll.Vertices[i].Z); } // Unlock (and copy) the data vb.Unlock(); }
/// <summary> /// The create index buffers. /// </summary> /// <param name="device">The device.</param> /// <param name="tempcoll">The tempcoll.</param> /// <remarks></remarks> private void CreateIndexBuffers(ref Device device, ref BSPModel.BSPCollision tempcoll) { ib = new IndexBuffer(typeof(short), tempcoll.Faces.Length, device, Usage.WriteOnly, Pool.Default); ib.SetData(tempcoll.Faces, 0, LockFlags.None); ib.Unlock(); }