Esempio n. 1
0
        /// <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 coll tempcoll)
        {
            for (int x = 0; x < tempcoll.Meshes.Count; x++)
            {
                if (tempcoll.Meshes[x].index2string == tempcoll.ConditionStrings[0])
                {
                    VertexBuffer vbx = new VertexBuffer(
                        typeof(CustomVertex.PositionColored),
                        tempcoll.Meshes[x].Vertices.Length,
                        device,
                        Usage.WriteOnly,
                        CustomVertex.PositionColored.Format,
                        Pool.Default);
                    CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vbx.Lock(0, 0);

                    // Lock the buffer (which will return our structs)
                    for (int i = 0; i < tempcoll.Meshes[x].Vertices.Length; i++)
                    {
                        verts[i].Position = new Vector3(
                            tempcoll.Meshes[x].Vertices[i].X,
                            tempcoll.Meshes[x].Vertices[i].Y,
                            tempcoll.Meshes[x].Vertices[i].Z);
                    }

                    vbx.Unlock();
                    vb.Add(vbx);
                    verticeCount.Add(tempcoll.Meshes[x].Vertices.Length);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectXCollision"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="tempcoll">The tempcoll.</param>
        /// <remarks></remarks>
        public DirectXCollision(ref Device device, ref coll tempcoll)
        {
            CreateVertexBuffers(ref device, ref tempcoll);
            CreateIndexBuffers(ref device, ref tempcoll);
            CreateSpheres(ref device, ref tempcoll);

            // verticeCount = tempcoll.Vertices.Length;

            // faceCount = tempcoll.Faces.Length;
        }
Esempio n. 3
0
        /// <summary>
        /// The create spheres.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="tempcoll">The tempcoll.</param>
        /// <remarks></remarks>
        private void CreateSpheres(ref Device device, ref coll tempcoll)
        {
            for (int x = 0; x < tempcoll.Spheres.Count; x++)
            {
                Mesh m = Mesh.Sphere(device, tempcoll.Spheres[x].radius, 10, 10);
                sphere.Add(m);
                Matrix mm = Matrix.Identity;

                mm.Multiply(Matrix.Translation(tempcoll.Spheres[x].position));
                spherematrix.Add(mm);
            }
        }
Esempio n. 4
0
 /// <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 coll tempcoll)
 {
     for (int x = 0; x < tempcoll.Meshes.Count; x++)
     {
         if (tempcoll.Meshes[x].index2string == tempcoll.ConditionStrings[0])
         {
             IndexBuffer tempib;
             tempib = new IndexBuffer(
                 typeof(short), tempcoll.Meshes[x].Faces.Length, device, Usage.WriteOnly, Pool.Default);
             tempib.SetData(tempcoll.Meshes[x].Faces, 0, LockFlags.None);
             tempib.Unlock();
             ib.Add(tempib);
             faceCount.Add(tempcoll.Meshes[x].Faces.Length);
         }
     }
 }
Esempio n. 5
0
        /// <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 coll tempcoll)
        {
            for (int x = 0; x < tempcoll.Meshes.Count; x++)
            {
                if (tempcoll.Meshes[x].index2string == tempcoll.ConditionStrings[0])
                {
                    VertexBuffer vbx = new VertexBuffer(
                        typeof(CustomVertex.PositionColored),
                        tempcoll.Meshes[x].Vertices.Length,
                        device,
                        Usage.WriteOnly,
                        CustomVertex.PositionColored.Format,
                        Pool.Default);
                    CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vbx.Lock(0, 0);

                    // Lock the buffer (which will return our structs)
                    for (int i = 0; i < tempcoll.Meshes[x].Vertices.Length; i++)
                    {
                        verts[i].Position = new Vector3(
                            tempcoll.Meshes[x].Vertices[i].X,
                            tempcoll.Meshes[x].Vertices[i].Y,
                            tempcoll.Meshes[x].Vertices[i].Z);
                    }

                    vbx.Unlock();
                    vb.Add(vbx);
                    verticeCount.Add(tempcoll.Meshes[x].Vertices.Length);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// The create spheres.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="tempcoll">The tempcoll.</param>
        /// <remarks></remarks>
        private void CreateSpheres(ref Device device, ref coll tempcoll)
        {
            for (int x = 0; x < tempcoll.Spheres.Count; x++)
            {
                Mesh m = Mesh.Sphere(device, tempcoll.Spheres[x].radius, 10, 10);
                sphere.Add(m);
                Matrix mm = Matrix.Identity;

                mm.Multiply(Matrix.Translation(tempcoll.Spheres[x].position));
                spherematrix.Add(mm);
            }
        }
Esempio n. 7
0
 /// <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 coll tempcoll)
 {
     for (int x = 0; x < tempcoll.Meshes.Count; x++)
     {
         if (tempcoll.Meshes[x].index2string == tempcoll.ConditionStrings[0])
         {
             IndexBuffer tempib;
             tempib = new IndexBuffer(
                 typeof(short), tempcoll.Meshes[x].Faces.Length, device, Usage.WriteOnly, Pool.Default);
             tempib.SetData(tempcoll.Meshes[x].Faces, 0, LockFlags.None);
             tempib.Unlock();
             ib.Add(tempib);
             faceCount.Add(tempcoll.Meshes[x].Faces.Length);
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DirectXCollision"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="tempcoll">The tempcoll.</param>
        /// <remarks></remarks>
        public DirectXCollision(ref Device device, ref coll tempcoll)
        {
            CreateVertexBuffers(ref device, ref tempcoll);
            CreateIndexBuffers(ref device, ref tempcoll);
            CreateSpheres(ref device, ref tempcoll);

            // verticeCount = tempcoll.Vertices.Length;

            // faceCount = tempcoll.Faces.Length;
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollisionViewer"/> class.
        /// </summary>
        /// <param name="tempcoll">The tempcoll.</param>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public CollisionViewer(coll tempcoll, Map map)
        {
            coll = tempcoll;
            this.map = map;

            // Set the initial size of our form
            this.ClientSize = new Size(800, 600);

            // And its caption
            this.Text = "Collision Viewer";
            this.MouseDown += BSPCollisionViewer_MouseDown;
            this.MouseMove += this.ModelViewer_MouseDown;

            keyboard = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);

            Main();
        }
Esempio n. 10
0
        /// <summary>
        /// The extract mesh to obj tool strip menu item_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void extractMeshToOBJToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveMetaDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            coll coll = new coll(ref map.SelectedMeta);
            coll.ExtractMeshes(saveMetaDialog.FileName);
        }
Esempio n. 11
0
 /// <summary>
 /// The collison viewer tool strip menu item_ click.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 /// <remarks></remarks>
 private void collisonViewerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     LoadMeta(map.SelectedMeta.TagIndex);
     coll coll = new coll(ref map.SelectedMeta);
     CollisionViewer cv = new CollisionViewer(coll, map);
 }