コード例 #1
0
        public void RemoveFigure(Figure3D Fig)
        {
            int Ind = Figs.IndexOf(Fig);

            if (Ind >= 0)
            {
                if (Selected == Fig)
                {
                    Selected = null;
                }
                int Id = Fig.ID;
                Figs.RemoveAt(Ind);
                Figs.ForEach(delegate(Figure3D F)
                {
                    if (F.ParrentID == Id)
                    {
                        F.ParrentID = -1;
                        F.ApplyTransform(this);
                        F.BuildVBO(false);
                    }
                });
                if (Parrent != null)
                {
                    Parrent.ChangesUnsaved = true;
                }
            }
            else
            {
                throw new Exception("The scene does not contains the figure you want to remove from it.");
            }
        }
コード例 #2
0
ファイル: Figure3D.cs プロジェクト: tirinox/Rays
        public void ApplyTransform(Scene3D s)
        {
            TransformedFaces.Clear();
            MyAABB = new AABB();

            Matrix TrfM = TransformToMatrix();

            Figure3D ParrentF = s.Figs.Find(f => f.ID == this.ParrentID);
            Matrix   ParrentM = ParrentF != null?ParrentF.GetTrasnformRecursive(s, 0) : null;

            foreach (Plane3D F in Faces)
            {
                Plane3D newF = new Plane3D(F);
                for (int i = 0; i < 3; ++i)
                {
                    if (ParrentF != null)
                    {
                        newF.Vertex[i] = newF.Vertex[i].MultMatrix(ParrentM);
                    }
                    newF.Vertex[i] = newF.Vertex[i].MultMatrix(TrfM);
                    MyAABB.Extend(newF.Vertex[i]);
                }
                newF.ID = ID;
                newF.CalcNormal();
                TransformedFaces.Add(newF);
            }
        }
コード例 #3
0
 public void BeginFigure()
 {
     if (CurrentFigure != null)
     {
         throw new Exception("Call EndFigure first!");
     }
     CurrentFigure = new Figure3D(this);
 }
コード例 #4
0
 public void EndFigure()
 {
     if (CurrentFigure == null)
     {
         throw new Exception("Call BeginFigure first!");
     }
     Figs.Add(CurrentFigure);
     CurrentFigure = null;
 }
コード例 #5
0
 public void SelectFigure(Figure3D Fig)
 {
     if (Selected != null)
     {
         Selected.BuildVBO(false);
     }
     Selected = Figs.Contains(Fig) ? Fig : null;
     if (Selected != null)
     {
         Selected.BuildVBO(true);
     }
 }
コード例 #6
0
ファイル: Figure3D.cs プロジェクト: tirinox/Rays
        public Matrix GetTrasnformRecursive(Scene3D s, int Call = 0)
        {
            if (Call > 10)
            {
                return(new Matrix(Matrix.Identity(4)));
            }

            Figure3D ParrentF = s.Figs.Find(f => f.ID == this.ParrentID);

            if (ParrentF == null)
            {
                return(TransformToMatrix());
            }
            else
            {
                return(TransformToMatrix() * ParrentF.GetTrasnformRecursive(s, Call + 1));
            }
        }
コード例 #7
0
        public void Open(string fName = "")
        {
            try
            {
                if (Asm != null)
                {
                    Asm.Dispose();
                    Asm = null;
                }
                Selected    = null;
                RaysVisible = false;
                AllRays.Clear();
                InitialRays.Clear();
                Figs.Clear();

                if (fName == "")
                {
                    fName = FileName;
                }
                else
                {
                    FileName = fName;
                }

                DateTime Begin = DateTime.Now;

                Log("[i] Начинается загрузка файла \"" + fName + "\".");

                Assembly aS = CSScript.Load(fName, null, true);
                Asm = new AsmHelper(aS);


                Log("[i] Загрузка файла завершена \"" + fName + "\".");
                Log("[i] Выполнение скрипта вызовом Script.Load(this).");

                Asm.Invoke("Script.Load", this);
                LoadedFromScript = true;

                Log("[i] Вызов метода Script.Load(this) завершен.");

                TransformFiguresAndMergeFaces();

                Log("[i] Загрузка выполнена за " + (DateTime.Now - Begin).TotalSeconds + " сек.");
            }
            catch (csscript.CompilerException ce)
            {
                CompilerErrorCollection errors = (CompilerErrorCollection)ce.Data["Errors"];

                foreach (CompilerError err in errors)
                {
                    Log(@"/!\ Loader ERROR (C#) " + string.Format("{0}({1},{2}): {3} {4}: {5}",
                                                                  err.FileName,
                                                                  err.Line,
                                                                  err.Column,
                                                                  err.IsWarning ? "warning" : "error",
                                                                  err.ErrorNumber,
                                                                  err.ErrorText));
                }
            }
            catch (ArgumentException ce)
            {
                Log(@"/!\ Loader ERROR (ArgumentExpection) " + ce.Message);
            }
            catch (ApplicationException ce)
            {
                Log(@"/!\ Loader ERROR (ApplicationExpection) " + ce.Message);
            }
            catch (Exception ce)
            {
                Log(@"/!\ Loader ERROR (Expection) " + ce.Message);
            }
        }