Exemplo n.º 1
0
        public void Add(Attach model)
        {
            bool foundMatch = false;

            foundMatch = modelList.Exists(item => item.Value.Name == model.Name);             // change this to something more robust when proper hashing of objects is implemented

            if (!foundMatch)
            {
                modelList.Add(new KeyValuePair <int, Attach>(model.GetHashCode(), model));
                attachListRenders.Add(new KeyValuePair <int, Bitmap>(model.GetHashCode(), renderFailureBitmap));
                meshes.Add(model.CreateD3DMesh());

                if (Visible)
                {
                    RenderModel(modelList.Count - 1, true);                          // todo: I think these Add calls are getting called while a separate thread is open, and thus causing locking issues
                }
                // perhaps we could find a way to defer all of this until after the file load operation is complete

                if (!suppressingListUpateEvents)
                {
                    if (Visible)
                    {
                        PopulateListView();
                    }
                }
                else
                {
                    listChangedWhileSuppressed = true;
                }
            }
        }
Exemplo n.º 2
0
 private void importOBJToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog()
     {
         DefaultExt = "obj",
         Filter = "OBJ Files|*.obj"
     })
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             Attach newattach = Direct3D.Extensions.obj2nj(dlg.FileName, TextureInfo?.Select(a => a.Name).ToArray());
             if (selectedObject.Attach != null)
             {
                 newattach.Name = selectedObject.Attach.Name;
             }
             meshes[Array.IndexOf(model.GetObjects(), selectedObject)] = newattach.CreateD3DMesh(d3ddevice);
             selectedObject.Attach = newattach;
             DrawLevel();
         }
 }
Exemplo n.º 3
0
        private void pasteModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Attach attach = (Attach)Clipboard.GetData(GetAttachType().AssemblyQualifiedName);

            if (selectedObject.Attach != null)
            {
                attach.Name = selectedObject.Attach.Name;
            }
            if (attach is BasicAttach)
            {
                BasicAttach batt = (BasicAttach)attach;
                batt.VertexName   = "vertex_" + Extensions.GenerateIdentifier();
                batt.NormalName   = "normal_" + Extensions.GenerateIdentifier();
                batt.MaterialName = "material_" + Extensions.GenerateIdentifier();
                batt.MeshName     = "mesh_" + Extensions.GenerateIdentifier();
                foreach (NJS_MESHSET m in batt.Mesh)
                {
                    m.PolyName       = "poly_" + Extensions.GenerateIdentifier();
                    m.PolyNormalName = "polynormal_" + Extensions.GenerateIdentifier();
                    m.UVName         = "uv_" + Extensions.GenerateIdentifier();
                    m.VColorName     = "vcolor_" + Extensions.GenerateIdentifier();
                }
            }
            else if (attach is ChunkAttach)
            {
                ChunkAttach catt = (ChunkAttach)attach;
                catt.VertexName = "vertex_" + Extensions.GenerateIdentifier();
                catt.PolyName   = "poly_" + Extensions.GenerateIdentifier();
            }
            selectedObject.Attach = attach;
            attach.ProcessVertexData();
            NJS_OBJECT[] models = model.GetObjects();
            try { meshes[Array.IndexOf(models, selectedObject)] = attach.CreateD3DMesh(d3ddevice); }
            catch { }
            DrawLevel();
        }