예제 #1
0
파일: Model.cs 프로젝트: sarath263/openvice
            /// <summary>
            /// Creating branch for existing model<para/>
            /// Создание ветки для существующей модели
            /// </summary>
            /// <param name="model">Parent model<para/>Модель-родитель</param>
            /// <param name="parent">Parent branch<para/>Родительский бранч</param>
            /// <param name="branchIndex">Branch index in ModelFile<para/>Индекс в файле модели</param>
            public Branch(Model model, Branch parent, int branchIndex)
            {
                // Setting up special data
                // Установка спецданных
                ModelFile.Frame f = model.File.Frames[branchIndex];
                Position = new Vector3(f.Position[0], f.Position[2], f.Position[1]);
                Quaternion q = Quaternion.FromMatrix(
                    new Matrix3(
                        f.Rotation[0], f.Rotation[1], f.Rotation[2],
                        f.Rotation[3], f.Rotation[4], f.Rotation[5],
                        f.Rotation[6], f.Rotation[7], f.Rotation[8]
                        )
                    );

                Angles      = new Quaternion(-q.X, -q.Z, -q.Y, -q.W);
                Scale       = 1f;
                ParentModel = model;
                Parent      = parent;
                Name        = f.Name;

                // Hack to rebuild matrix
                // Хак для перестройки матрицы
                needNewMatrix = true;
                mat           = Matrix;

                // Analyze model's geometries for data
                // Анализируем геометрию модели для создание сурфейсов
                List <SubMesh> lm = new List <SubMesh>();

                foreach (ModelFile.Geometry g in model.File.Surfaces)
                {
                    if (g.Frame == branchIndex)
                    {
                        lm.Add(new SubMesh(this, model, g)
                        {
                        });
                    }
                }
                SubMeshes = lm.ToArray();

                // Analyze sub-branches
                // Выборка дочерних веток
                List <Branch> ch = new List <Branch>();

                for (int i = 0; i < model.File.Frames.Length; i++)
                {
                    ModelFile.Frame fr = model.File.Frames[i];
                    if (fr.Parent == branchIndex)
                    {
                        ch.Add(new Branch(model, this, i)
                        {
                        });
                    }
                }
                Children = ch.ToArray();
            }
예제 #2
0
파일: Model.cs 프로젝트: sarath263/openvice
        /// <summary>
        /// Generate submesh temporary data<para/>
        /// Генерация временных GL-данных
        /// </summary>
        public void BuildSubMeshes()
        {
            // Analyze sub-branches
            // Выборка дочерних веток
            List <Branch> ch = new List <Branch>();

            for (int i = 0; i < File.Frames.Length; i++)
            {
                ModelFile.Frame fr = File.Frames[i];
                if (fr.Parent == -1)
                {
                    ch.Add(new Branch(this, null, i));
                }
            }
            Children = ch.ToArray();
            foreach (Branch b in Children)
            {
                RecursiveProcessBranch(b, false);
            }
            State = ReadyState.NotSent;
        }