Пример #1
0
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (!loaded)
            {
                return;
            }
            HitResult dist;
            Vector3   mousepos = new Vector3(e.X, e.Y, 0);
            Viewport  viewport = d3ddevice.Viewport;
            Matrix    proj = d3ddevice.Transform.Projection;
            Matrix    view = d3ddevice.Transform.View;
            Vector3   Near, Far;

            Near   = mousepos;
            Near.Z = 0;
            Far    = Near;
            Far.Z  = -1;
            dist   = model.CheckHit(Near, Far, viewport, proj, view, new MatrixStack(), meshes);
            if (dist.IsHit)
            {
                selectedObject = dist.Model;
                SelectedItemChanged();
            }
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(panel1, e.Location);
            }
        }
Пример #2
0
 public override void Init(IniLevelData data, byte act, byte timeofday)
 {
     model1 = ObjectHelper.LoadModel("boss_chaos6/common/objmodels/ecsc_s_sora.nja.sa1mdl");
     model2 = ObjectHelper.LoadModel("boss_chaos6/common/objmodels/ecsc_s_sitakumo.nja.sa1mdl");
     mesh1  = ObjectHelper.GetMeshes(model1);
     mesh2  = ObjectHelper.GetMeshes(model2);
 }
Пример #3
0
 public override void Init(ObjectData data, string name)
 {
     whale     = ObjectHelper.LoadModel("stg01_beach/common/models/seaobj_oruka.nja.sa1mdl");
     whalemsh  = ObjectHelper.GetMeshes(whale);
     sphere    = ObjectHelper.LoadModel("nondisp/sphere01.nja.sa1mdl");
     spheremsh = ObjectHelper.GetMeshes(sphere);
 }
Пример #4
0
 public override void Init(ObjectData data, string name)
 {
     model  = ObjectHelper.LoadModel("Objects/Enemies/SPINA.sa1mdl");
     meshes = ObjectHelper.GetMeshes(model);
     cylmdl = ObjectHelper.LoadModel("Objects/Collision/C CYLINDER.sa1mdl");
     cylmsh = ObjectHelper.GetMeshes(cylmdl);
 }
Пример #5
0
 public override void Init(ObjectData data, string name)
 {
     modelA  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/Raft01.sa1mdl");
     meshesA = ObjectHelper.GetMeshes(modelA);
     modelB  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/Raft02.sa1mdl");
     meshesB = ObjectHelper.GetMeshes(modelB);
 }
Пример #6
0
 public override void Init(ObjectData data, string name, Device dev)
 {
     modelA  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/O_VCROK_A.sa1mdl");
     meshesA = ObjectHelper.GetMeshes(modelA, dev);
     modelB  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/O_VCROK_B.sa1mdl");
     meshesB = ObjectHelper.GetMeshes(modelB, dev);
 }
Пример #7
0
 public override void Init(ObjectData data, string name)
 {
     plane     = ObjectHelper.LoadModel("Objects/Levels/Emerald Coast/O BZ.sa1mdl");
     planemsh  = ObjectHelper.GetMeshes(plane);
     sphere    = ObjectHelper.LoadModel("Objects/Collision/C SPHERE.sa1mdl");
     spheremsh = ObjectHelper.GetMeshes(sphere);
 }
Пример #8
0
 public override void Init(ObjectData data, string name)
 {
     modelA  = ObjectHelper.LoadModel("stg02_windy/common/models/col_bridgeshort.sa1mdl");
     meshesA = ObjectHelper.GetMeshes(modelA);
     modelB  = ObjectHelper.LoadModel("stg02_windy/common/models/col_bridgelong.sa1mdl");
     meshesB = ObjectHelper.GetMeshes(modelB);
 }
Пример #9
0
        private static string GetModel(byte[] fc, int address, uint key, string fn, List <string> nodenames, Dictionary <string, KeyValuePair <string, NJS_OBJECT> > modelfiles)
        {
            string name = null;
            int    ptr3 = fc.GetPointer(address, key);

            if (ptr3 != 0)
            {
                name = $"object_{ptr3:X8}";
                if (!nodenames.Contains(name))
                {
                    NJS_OBJECT obj = new NJS_OBJECT(fc, ptr3, key, ModelFormat.Chunk);
                    name = obj.Name;
                    List <string> names = new List <string>(obj.GetObjects().Select((o) => o.Name));
                    foreach (string s in names)
                    {
                        if (modelfiles.ContainsKey(s))
                        {
                            modelfiles.Remove(s);
                        }
                    }
                    nodenames.AddRange(names);
                    modelfiles.Add(obj.Name, new KeyValuePair <string, NJS_OBJECT>(fn, obj));
                }
            }

            return(name);
        }
Пример #10
0
        private static void ConvertSETItem(List <COL> newcollist, SETItem item, bool solid, int ind)
        {
            NJS_OBJECT obj = new NJS_OBJECT()
            {
                Scale = new Vertex(1, 1, 1), Name = item.InternalName + " " + ind
            };
            BasicAttach attach = new BasicAttach();

            obj.Attach = attach;
            foreach (ModelTransform mt in item.GetObjectDefinition().GetModels(item, new MatrixStack()))
            {
                MatrixStack transform = new MatrixStack();
                transform.LoadMatrix(mt.Transform);
                ProcessModel(mt.Model.Clone(), transform, attach);
            }
            attach.ProcessVertexData();
            attach.CalculateBounds();
            COL col = new COL()
            {
                Model = obj, SurfaceFlags = SurfaceFlags.Visible
            };

            if (solid)
            {
                col.SurfaceFlags |= SurfaceFlags.Solid | SurfaceFlags.Unclimbable;
            }
            col.CalculateBounds();
            ConvertCOL(newcollist, new Dictionary <string, Attach>(), col);
        }
Пример #11
0
        private void DrawSelectedObject(NJS_OBJECT obj, MatrixStack transform)
        {
            int modelnum  = -1;
            int animindex = -1;

            DrawSelectedObject(obj, transform, ref modelnum, ref animindex);
        }
Пример #12
0
 public void InitModels()
 {
     whale     = ObjectHelper.LoadModel("stg01_beach/common/models/seaobj_oruka.nja.sa1mdl");
     sphere    = ObjectHelper.LoadModel("nondisp/sphere01.nja.sa1mdl");
     whalemsh  = ObjectHelper.GetMeshes(whale);
     spheremsh = ObjectHelper.GetMeshes(sphere);
 }
Пример #13
0
 public override void Init(ObjectData data, string name)
 {
     plane     = ObjectHelper.LoadModel("stg01_beach/common/models/zangai_toru.nja.sa1mdl");
     planemsh  = ObjectHelper.GetMeshes(plane);
     sphere    = ObjectHelper.LoadModel("nondisp/sphere01.nja.sa1mdl");
     spheremsh = ObjectHelper.GetMeshes(sphere);
 }
Пример #14
0
        public StartPosItem(NJS_OBJECT model, string textures, float offset, Vertex position, int yrot, Device dev, EditorItemSelection selectionManager, bool Weight = false)
            : base(selectionManager)
        {
            Model     = model;
            hasWeight = Weight;

            model.ProcessVertexData();

            if (hasWeight)
            {
                Meshes = model.ProcessWeightedModel().ToArray();
            }
            else
            {
                NJS_OBJECT[] models = model.GetObjects();
                Meshes = new Mesh[models.Length];
                for (int i = 0; i < models.Length; i++)
                {
                    if (models[i].Attach != null)
                    {
                        Meshes[i] = models[i].Attach.CreateD3DMesh();
                    }
                }
            }

            texture     = textures;
            this.offset = offset;
            Position    = position;
            YRotation   = yrot;
        }
Пример #15
0
        public void ImportModel(string filePath, bool legacyImport = false)
        {
            NJS_OBJECT newmodel;

            // Old OBJ import (with vcolor face) for NodeTable and legacy import
            if (legacyImport)
            {
                newmodel = new NJS_OBJECT
                {
                    Attach = SAModel.Direct3D.Extensions.obj2nj(filePath, LevelData.TextureBitmaps != null ? LevelData.TextureBitmaps[LevelData.leveltexs].Select(a => a.Name).ToArray() : null),
                };
                COL.Model.Attach = newmodel.Attach;
                COL.Model.ProcessVertexData();
                Visible = true;
                Solid   = true;
                mesh    = COL.Model.Attach.CreateD3DMesh();
                return;
            }
            Assimp.AssimpContext context = new Assimp.AssimpContext();
            context.SetConfig(new Assimp.Configs.FBXPreservePivotsConfig(false));
            Assimp.Scene scene = context.ImportFile(filePath, Assimp.PostProcessSteps.Triangulate | Assimp.PostProcessSteps.JoinIdenticalVertices | Assimp.PostProcessSteps.FlipUVs);
            newmodel         = SAEditorCommon.Import.AssimpStuff.AssimpImport(scene, scene.RootNode, ModelFormat.BasicDX, LevelData.TextureBitmaps[LevelData.leveltexs].Select(a => a.Name).ToArray(), true);
            COL.Model.Attach = newmodel.Attach;
            COL.Model.ProcessVertexData();
            Visible = true;
            Solid   = true;
            mesh    = COL.Model.Attach.CreateD3DMesh();
        }
Пример #16
0
        internal static List <Item> ImportFromHierarchy(NJS_OBJECT objm, EditorItemSelection selectionManager, OnScreenDisplay osd, bool multiple = false)
        {
            List <Item> createdItems = new List <Item>();

            if (objm.Attach != null)
            {
                objm.Attach.ProcessVertexData();
                LevelItem lvlitem = new LevelItem(objm.Attach, new Vertex(objm.Position.X, objm.Position.Y, objm.Position.Z), objm.Rotation, levelItems.Count, selectionManager)
                {
                    Visible = true
                };
                createdItems.Add(lvlitem);
            }
            if (multiple)
            {
                if (objm.Children != null && objm.Children.Count > 0)
                {
                    foreach (NJS_OBJECT child in objm.Children)
                    {
                        createdItems.AddRange(ImportFromHierarchy(child, selectionManager, osd, true));
                    }
                }
            }
            return(createdItems);
        }
Пример #17
0
        public override void Init(IniLevelData data, byte act, byte timeofday)
        {
            Act = act;
            SkyboxScale[] skyboxdata = SkyboxScaleList.Load("adv03_past/bg/bgScale.ini");
            if (skyboxdata.Length > act)
            {
                Skybox_Scale = skyboxdata[act].Far.ToVector3();
            }
            switch (act)
            {
            case 0:
                model = ObjectHelper.LoadModel("adv03_past/bg/mrc_bf_s_skyhiru.nja.sa1mdl");
                break;

            case 1:
                model = ObjectHelper.LoadModel("adv03_past/bg/mra_s_sora_hare.nja.sa1mdl");
                break;

            case 2:
                model = ObjectHelper.LoadModel("adv03_past/bg/mra_s_sora_yoru.nja.sa1mdl");
                break;
            }
            meshes = ObjectHelper.GetMeshes(model);
            SetOceanData();
        }
Пример #18
0
 public override void Init(ObjectData data, string name)
 {
     model        = ObjectHelper.LoadModel("object/jumppanel_base.nja.sa1mdl");
     meshes       = ObjectHelper.GetMeshes(model);
     numbermodel  = ObjectHelper.LoadModel("object/no_unite/jumppanel_numbers.nja.sa1mdl");
     numbermeshes = ObjectHelper.GetMeshes(numbermodel);
 }
Пример #19
0
 public override void Init(ObjectData data, string name)
 {
     modelA  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/SBridg_ShortCol.sa1mdl");
     meshesA = ObjectHelper.GetMeshes(modelA);
     modelB  = ObjectHelper.LoadModel("Objects/Levels/Windy Valley/SBridg_LongCol.sa1mdl");
     meshesB = ObjectHelper.GetMeshes(modelB);
 }
Пример #20
0
 public override void Init(ObjectData data, string name)
 {
     modelA  = ObjectHelper.LoadModel("stg02_windy/common/models/wvobj_raft1.sa1mdl");
     meshesA = ObjectHelper.GetMeshes(modelA);
     modelB  = ObjectHelper.LoadModel("stg02_windy/common/models/wvobj_raft2.sa1mdl");
     meshesB = ObjectHelper.GetMeshes(modelB);
 }
Пример #21
0
        public override void Init(IniLevelData data, byte act, byte timeofday)
        {
            Act       = act;
            TimeOfDay = timeofday;
            SkyboxScale[] skyboxdata = SkyboxScaleList.Load("adv00_stationsquare/bg/bgScale.ini");
            if (skyboxdata.Length > act)
            {
                Skybox_Scale = skyboxdata[act].Far.ToVector3();
            }
            switch (timeofday)
            {
            case 0:
            default:
                model = ObjectHelper.LoadModel("adv00_stationsquare/object/no_unite/bg/ss_haikei_sky_d.nja.sa1mdl");
                break;

            case 1:
                model = ObjectHelper.LoadModel("adv00_stationsquare/object/no_unite/bg/ss_haikei_sky_e.nja.sa1mdl");
                break;

            case 2:
                model = ObjectHelper.LoadModel("adv00_stationsquare/object/no_unite/bg/ss_haikei_sky_n.nja.sa1mdl");
                break;
            }
            meshes = ObjectHelper.GetMeshes(model);
            SetOceanData();
        }
Пример #22
0
        public void ImportModel()
        {
            OpenFileDialog dlg = new OpenFileDialog()
            {
                DefaultExt = "sa1mdl", Filter = "Model Files|*.sa1mdl;*.obj;*.objf", RestoreDirectory = true
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                switch (Path.GetExtension(dlg.FileName).ToLowerInvariant())
                {
                case ".obj":
                case ".fbx":
                case ".dae":
                case ".objf":
                    Assimp.AssimpContext context = new Assimp.AssimpContext();
                    context.SetConfig(new Assimp.Configs.FBXPreservePivotsConfig(false));
                    Assimp.Scene scene    = context.ImportFile(dlg.FileName, Assimp.PostProcessSteps.Triangulate | Assimp.PostProcessSteps.JoinIdenticalVertices | Assimp.PostProcessSteps.FlipUVs);
                    NJS_OBJECT   newmodel = SAEditorCommon.Import.AssimpStuff.AssimpImport(scene, scene.RootNode, ModelFormat.BasicDX, LevelData.TextureBitmaps[LevelData.leveltexs].Select(a => a.Name).ToArray(), true);
                    Model.Attach = newmodel.Attach;
                    Model.ProcessVertexData();
                    Mesh = Model.Attach.CreateD3DMesh();
                    break;

                case ".sa1mdl":
                    ModelFile mf = new ModelFile(dlg.FileName);
                    Model.Attach = mf.Model.Attach;
                    Model.ProcessVertexData();
                    Mesh = Model.Attach.CreateD3DMesh();
                    break;
                }
            }
        }
Пример #23
0
        public override void Init(ObjectData data, string name)
        {
            this.name = data.Name ?? name;
            if (!string.IsNullOrEmpty(data.Model))
            {
                model  = ObjectHelper.LoadModel(data.Model);
                meshes = ObjectHelper.GetMeshes(model);
            }

            texture = data.Texture;
            xpos    = data.XPos;
            ypos    = data.YPos;
            zpos    = data.ZPos;
            xrot    = data.XRot;
            yrot    = data.YRot;
            zrot    = data.ZRot;
            xscl    = data.XScl;
            yscl    = data.YScl;
            zscl    = data.ZScl;
            defxrot = data.DefXRot;
            defyrot = data.DefYRot;
            defzrot = data.DefZRot;
            defxscl = data.DefXScl;
            defyscl = data.DefYScl;
            defzscl = data.DefZScl;
            gnddst  = data.GndDst;
        }
Пример #24
0
 public override void Init(ObjectData data, string name)
 {
     model1  = ObjectHelper.LoadModel("Objects/Levels/Emerald Coast/O BIGROCK_A.sa1mdl");
     meshes1 = ObjectHelper.GetMeshes(model1);
     model2  = ObjectHelper.LoadModel("Objects/Levels/Emerald Coast/O BIGROCK_B.sa1mdl");
     meshes2 = ObjectHelper.GetMeshes(model2);
 }
Пример #25
0
 public DeathZoneItem(Device device, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.device = device;
     Model       = new NJS_OBJECT();
     ImportModel();
     Paste();
 }
Пример #26
0
 public DeathZoneItem(Device device, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     this.device = device;
     Model = new NJS_OBJECT();
     ImportModel();
     Paste();
 }
Пример #27
0
 public DeathZoneItem(NJS_OBJECT model, SA1CharacterFlags flags, Device device, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Model = model;
     model.ProcessVertexData();
     Flags = flags;
     Mesh = Model.Attach.CreateD3DMesh(device);
     this.device = device;
 }
Пример #28
0
 public static Mesh[] GetMeshes(NJS_OBJECT model, Device dev)
 {
     model.ProcessVertexData();
     NJS_OBJECT[] models = model.GetObjects();
     Mesh[] Meshes = new Mesh[models.Length];
     for (int i = 0; i < models.Length; i++)
         if (models[i].Attach != null)
             Meshes[i] = models[i].Attach.CreateD3DMesh(dev);
     return Meshes;
 }
Пример #29
0
 public StartPosItem(NJS_OBJECT model, string textures, float offset, Vertex position, int yrot, Device dev, EditorItemSelection selectionManager)
     : base(selectionManager)
 {
     Model = model;
     model.ProcessVertexData();
     NJS_OBJECT[] models = model.GetObjects();
     Meshes = new Mesh[models.Length];
     for (int i = 0; i < models.Length; i++)
         if (models[i].Attach != null)
             Meshes[i] = models[i].Attach.CreateD3DMesh(dev);
     texture = textures;
     this.offset = offset;
     Position = position;
     YRotation = yrot;
 }
Пример #30
0
        /// <summary>
        /// Returns a bounding sphere for the supplied SET Item.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public virtual BoundingSphere GetBounds(SETItem item, NJS_OBJECT model=null)
        {
            BoundingSphere result = new BoundingSphere();

            if (model != null)
            {
                // build bounding spheres for all children using BoundingSphere.CreateMerged
                if (model.Attach != null)
                {
                    result = model.Attach.Bounds;
                }

                ProcessModel(model, ref result);
            }

            return new BoundingSphere(item.Position, result.Radius);
        }
        public override void Init(ObjectData data, string name, Device dev)
        {
            this.name = data.Name ?? name;
            if (!string.IsNullOrEmpty(data.Model))
            {
                model = ObjectHelper.LoadModel(data.Model);
                meshes = ObjectHelper.GetMeshes(model, dev);
            }

            texture = data.Texture;
            xpos = data.XPos;
            ypos = data.YPos;
            zpos = data.ZPos;
            xrot = data.XRot;
            yrot = data.YRot;
            zrot = data.ZRot;
            xscl = data.XScl;
            yscl = data.YScl;
            zscl = data.ZScl;
        }
Пример #32
0
 private void AddTreeNode(NJS_OBJECT model, TreeNodeCollection nodes)
 {
     TreeNode node = nodes.Add(model.Name);
     node.Tag = model;
     nodeDict[model] = node;
     foreach (NJS_OBJECT child in model.Children)
         AddTreeNode(child, node.Nodes);
 }
Пример #33
0
 private bool DrawSelectedObject(NJS_OBJECT obj, MatrixStack transform, ref int modelindex, ref int animindex)
 {
     transform.Push();
     modelindex++;
     if (obj.Animate) animindex++;
     if (animation != null && animation.Models.ContainsKey(animindex))
         obj.ProcessTransforms(animation.Models[animindex], animframe, transform);
     else
         obj.ProcessTransforms(transform);
     if (obj == selectedObject)
     {
         if (obj.Attach != null)
             for (int j = 0; j < obj.Attach.MeshInfo.Length; j++)
             {
                 Color col = obj.Attach.MeshInfo[j].Material == null ? Color.White : obj.Attach.MeshInfo[j].Material.DiffuseColor;
                 col = Color.FromArgb(255 - col.R, 255 - col.G, 255 - col.B);
                 NJS_MATERIAL mat = new NJS_MATERIAL
                 {
                     DiffuseColor = col,
                     IgnoreLighting = true,
                     UseAlpha = false
                 };
                 new RenderInfo(meshes[modelindex], j, transform.Top, mat, null, FillMode.WireFrame, obj.Attach.CalculateBounds(j, transform.Top)).Draw(d3ddevice);
             }
         transform.Pop();
         return true;
     }
     foreach (NJS_OBJECT child in obj.Children)
         if (DrawSelectedObject(child, transform, ref modelindex, ref animindex))
         {
             transform.Pop();
             return true;
         }
     transform.Pop();
     return false;
 }
Пример #34
0
 private void findToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (FindDialog dlg = new FindDialog())
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             NJS_OBJECT obj = model.GetObjects().SingleOrDefault(o => o.Name == dlg.SearchText || (o.Attach != null && o.Attach.Name == dlg.SearchText));
             if (obj != null)
             {
                 selectedObject = obj;
                 SelectedItemChanged();
             }
             else
                 MessageBox.Show(this, "Not found.", "SAMDL");
         }
 }
Пример #35
0
 private void LoadFile(string filename)
 {
     loaded = false;
     Environment.CurrentDirectory = Path.GetDirectoryName(filename);
     timer1.Stop();
     modelFile = null;
     animation = null;
     animations = null;
     animnum = -1;
     animframe = 0;
     if (ModelFile.CheckModelFile(filename))
     {
         modelFile = new ModelFile(filename);
         outfmt = modelFile.Format;
         model = modelFile.Model;
         animations = new Animation[modelFile.Animations.Count];
         modelFile.Animations.CopyTo(animations, 0);
     }
     else
     {
         using (FileTypeDialog ftd = new FileTypeDialog())
         {
             if (ftd.ShowDialog(this) != DialogResult.OK)
                 return;
             byte[] file = File.ReadAllBytes(filename);
             if (Path.GetExtension(filename).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                 file = FraGag.Compression.Prs.Decompress(file);
             if (ftd.typBinary.Checked)
             {
                 modelinfo.ShowDialog(this);
                 if (modelinfo.checkBox1.Checked)
                     animations = new Animation[] { Animation.ReadHeader(file, (int)modelinfo.numericUpDown3.Value, (uint)modelinfo.numericUpDown2.Value, (ModelFormat)modelinfo.comboBox2.SelectedIndex) };
                 model = new NJS_OBJECT(file, (int)modelinfo.NumericUpDown1.Value, (uint)modelinfo.numericUpDown2.Value, (ModelFormat)modelinfo.comboBox2.SelectedIndex);
                 switch ((ModelFormat)modelinfo.comboBox2.SelectedIndex)
                 {
                     case ModelFormat.Basic:
                     case ModelFormat.BasicDX:
                         outfmt = ModelFormat.Basic;
                         break;
                     case ModelFormat.Chunk:
                         outfmt = ModelFormat.Chunk;
                         break;
                 }
             }
             else if (ftd.typSA2MDL.Checked | ftd.typSA2BMDL.Checked)
             {
                 ModelFormat fmt = outfmt = ModelFormat.Chunk;
                 ByteConverter.BigEndian = ftd.typSA2BMDL.Checked;
                 using (SA2MDLDialog dlg = new SA2MDLDialog())
                 {
                     int address = 0;
                     SortedDictionary<int, NJS_OBJECT> sa2models = new SortedDictionary<int, NJS_OBJECT>();
                     int i = ByteConverter.ToInt32(file, address);
                     while (i != -1)
                     {
                         sa2models.Add(i, new NJS_OBJECT(file, ByteConverter.ToInt32(file, address + 4), 0, fmt));
                         address += 8;
                         i = ByteConverter.ToInt32(file, address);
                     }
                     foreach (KeyValuePair<int, NJS_OBJECT> item in sa2models)
                         dlg.modelChoice.Items.Add(item.Key + ": " + item.Value.Name);
                     dlg.ShowDialog(this);
                     i = 0;
                     foreach (KeyValuePair<int, NJS_OBJECT> item in sa2models)
                     {
                         if (i == dlg.modelChoice.SelectedIndex)
                         {
                             model = item.Value;
                             break;
                         }
                         i++;
                     }
                     if (dlg.checkBox1.Checked)
                     {
                         using (OpenFileDialog anidlg = new OpenFileDialog()
                         {
                             DefaultExt = "bin",
                             Filter = "Motion Files|*MTN.BIN;*MTN.PRS|All Files|*.*"
                         })
                         {
                             if (anidlg.ShowDialog(this) == DialogResult.OK)
                             {
                                 byte[] anifile = File.ReadAllBytes(anidlg.FileName);
                                 if (Path.GetExtension(anidlg.FileName).Equals(".prs", StringComparison.OrdinalIgnoreCase))
                                     anifile = FraGag.Compression.Prs.Decompress(anifile);
                                 address = 0;
                                 SortedDictionary<int, Animation> anis = new SortedDictionary<int, Animation>();
                                 i = ByteConverter.ToInt32(file, address);
                                 while (i != -1)
                                 {
                                     anis.Add(i, new Animation(file, ByteConverter.ToInt32(file, address + 4), 0, model.CountAnimated()));
                                     address += 8;
                                     i = ByteConverter.ToInt32(file, address);
                                 }
                                 animations = new List<Animation>(anis.Values).ToArray();
                             }
                         }
                     }
                 }
             }
         }
     }
     model.ProcessVertexData();
     NJS_OBJECT[] models = model.GetObjects();
     meshes = new Mesh[models.Length];
     for (int i = 0; i < models.Length; i++)
         if (models[i].Attach != null)
             try { meshes[i] = models[i].Attach.CreateD3DMesh(d3ddevice); }
             catch { }
     treeView1.Nodes.Clear();
     nodeDict = new Dictionary<NJS_OBJECT, TreeNode>();
     AddTreeNode(model, treeView1.Nodes);
     loaded = saveToolStripMenuItem.Enabled = exportToolStripMenuItem.Enabled = findToolStripMenuItem.Enabled = true;
     selectedObject = model;
     SelectedItemChanged();
 }
Пример #36
0
 private void panel1_MouseDown(object sender, MouseEventArgs e)
 {
     if (!loaded) return;
     HitResult dist;
     Vector3 mousepos = new Vector3(e.X, e.Y, 0);
     Viewport viewport = d3ddevice.Viewport;
     Matrix proj = d3ddevice.Transform.Projection;
     Matrix view = d3ddevice.Transform.View;
     Vector3 Near, Far;
     Near = mousepos;
     Near.Z = 0;
     Far = Near;
     Far.Z = -1;
     dist = model.CheckHit(Near, Far, viewport, proj, view, new MatrixStack(), meshes);
     if (dist.IsHit)
     {
         selectedObject = dist.Model;
         SelectedItemChanged();
     }
 }
Пример #37
0
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (suppressTreeEvent) return;
     selectedObject = (NJS_OBJECT)e.Node.Tag;
     SelectedItemChanged();
 }
Пример #38
0
        private void ProcessModel(NJS_OBJECT model, ref BoundingSphere bounds)
        {
            if (model.Attach != null) bounds = Direct3D.Extensions.Merge(bounds, model.Attach.Bounds);

            foreach (NJS_OBJECT child in model.Children) ProcessModel(child, ref bounds);
        }
Пример #39
0
 public HitResult(NJS_OBJECT model, float distance)
 {
     Model = model;
     Distance = distance;
     IsHit = true;
 }
Пример #40
0
 private void DrawSelectedObject(NJS_OBJECT obj, MatrixStack transform)
 {
     int modelnum = -1;
     int animindex = -1;
     DrawSelectedObject(obj, transform, ref modelnum, ref animindex);
 }
 public override BoundingSphere GetBounds(SETItem item, NJS_OBJECT model = null)
 {
     return base.GetBounds(item, this.model);
 }