Ejemplo n.º 1
0
 //============================================================
 // <T>加载配置信息。</T>
 //
 // @param config 配置信息
 //============================================================
 public void LoadWeightConfig(FXmlNode config)
 {
     // 读取权重信息
     foreach (FXmlNode node in config.Nodes)
     {
         if (node.IsName("Bone"))
         {
             FDrVertexWeight weight = new FDrVertexWeight();
             weight.LoadConfig(node);
             _weights.Push(weight);
         }
     }
     // 排序权重内容
     if (!_weights.IsEmpty)
     {
         _weights.Sort(FDrVertexWeight.Comparer);
         if (_weights.Count > _maxWeightCount)
         {
             float total = 0;
             for (int n = 0; n < _maxWeightCount; n++)
             {
                 total += _weights[n].Weight;
             }
             for (int n = 0; n < _maxWeightCount; n++)
             {
                 FDrVertexWeight weight = _weights[n];
                 weight.Weight = weight.Weight / total;
             }
         }
     }
 }
Ejemplo n.º 2
0
 //============================================================
 // <T>加载配置信息。</T>
 //
 // @param config 配置信息
 //============================================================
 public void LoadModelConfig(FXmlNode config)
 {
     // 获得属性内容
     _frameCount = config.GetInteger("frame_count");
     _frameTick  = config.GetInteger("frame_tick");
     _frameStart = config.GetInteger("frame_start");
     _frameEnd   = config.GetInteger("frame_end");
     // 获得跟踪列表
     foreach (FXmlNode node in config.Nodes)
     {
         if (node.IsName("Track"))
         {
             // 加载跟踪
             FDrTrack track = new FDrTrack(_model);
             track.LoadModelConfig(node);
             _tracks.Push(track);
             // 判断是否为关联器
             if (track.Bone.Name.StartsWith("jn_"))
             {
                 FDrJoiner joiner = new FDrJoiner(_model);
                 joiner.Name  = track.Bone.Name;
                 joiner.Track = track;
                 _joiners.Push(joiner);
             }
         }
     }
     // 根据内容排序
     _tracks.Sort(new FDrTrack(_model));
 }
Ejemplo n.º 3
0
        //============================================================
        // <T>加载配置信息。</T>
        //
        // @param config 配置信息
        //============================================================
        public void LoadConfig(FXmlNode xconfig)
        {
            _optionLoaded = xconfig.GetInteger("option_loaded", EDrFlag.Inherit);
            _optionSelect = xconfig.GetInteger("option_select", EDrFlag.Inherit);
            _optionGround = xconfig.GetInteger("option_ground", EDrFlag.Inherit);
            if (xconfig.Contains("option_merge"))
            {
                _optionMergeVertex = xconfig.GetInteger("option_merge");
            }
            if (xconfig.Contains("option_merge_vertex"))
            {
                _optionMergeVertex = xconfig.GetInteger("option_merge_vertex");
            }
            _optionMergeMaterial = xconfig.GetInteger("option_merge_material", EDrFlag.Inherit);
            _optionLightMap      = xconfig.GetInteger("option_light_map", EDrFlag.Inherit);
            //............................................................
            //............................................................
            // 加载引用列表
            FXmlNode xreferences = xconfig.Find("References");

            if (null != xreferences)
            {
                foreach (FXmlNode xreference in xreferences.Nodes)
                {
                    if (xreference.IsName("Reference"))
                    {
                        FDrTemplateReference reference = new FDrTemplateReference();
                        reference.LoadConfig(xreference);
                        _references.Push(reference);
                    }
                }
            }
            //............................................................
            // 加载动画列表
            FXmlNode xanimation = xconfig.Find("Animation");

            if (null != xanimation)
            {
                _animation.Model = _model;
                _animation.LoadConfig(xanimation);
            }
            //............................................................
            // 材质集合排序
            if (!_materials.IsEmpty)
            {
                _materials.Sort(_materials.First);
            }
        }
Ejemplo n.º 4
0
        //============================================================
        // <T>查找指定主题的材质。</T>
        //============================================================
        public FDrMaterial SyncMaterial(string themeName)
        {
            string themeCode = RDrUtil.FormatPathToCode(themeName);

            foreach (FDrMaterial material in _materials)
            {
                if (material.ThemeCode == themeCode)
                {
                    return(material);
                }
            }
            FDrMaterial createMaterial = new FDrMaterial();

            createMaterial.Group = this;
            createMaterial.Assign(_materials.First);
            createMaterial.ThemeName = themeName;
            _materials.Push(createMaterial);
            _materials.Sort(new FDrMaterial());
            return(createMaterial);
        }
Ejemplo n.º 5
0
 //============================================================
 // <T>打开数据内容。</T>
 //============================================================
 public override void Open()
 {
     if (!_opened)
     {
         base.Open();
         // 打开所有图片
         foreach (FDrTextureBitmap bitmap in _bitmaps)
         {
             bitmap.Open();
         }
         // 按照类型排序
         if (_sortAble && !_bitmaps.IsEmpty)
         {
             _bitmaps.Sort(_bitmaps.First);
         }
         int count = _bitmaps.Count;
         for (int n = 0; n < count; n++)
         {
             _bitmaps[n].Index = n;
         }
     }
 }
Ejemplo n.º 6
0
        //============================================================
        // <T>加载配置信息。</T>
        //
        // @param config 配置信息
        //============================================================
        public void LoadConfig(FXmlNode xconfig)
        {
            _optionLoaded = xconfig.GetInteger("option_loaded", EDrFlag.Inherit);
            _optionSelect = xconfig.GetInteger("option_select", EDrFlag.Inherit);
            _optionGround = xconfig.GetInteger("option_ground", EDrFlag.Inherit);
            if (xconfig.Contains("option_merge"))
            {
                _optionMergeVertex = xconfig.GetInteger("option_merge");
            }
            if (xconfig.Contains("option_merge_vertex"))
            {
                _optionMergeVertex = xconfig.GetInteger("option_merge_vertex");
            }
            _optionMergeMaterial = xconfig.GetInteger("option_merge_material", EDrFlag.Inherit);
            _optionLightMap      = xconfig.GetInteger("option_light_map", EDrFlag.Inherit);
            //............................................................
            // 加载渲染列表
            FXmlNode xrenderables = xconfig.Find("Renderables");

            if (null != xrenderables)
            {
                _outline.InitializeMin();
                foreach (FXmlNode xrenderable in xrenderables.Nodes)
                {
                    if (xrenderable.IsName("Renderable"))
                    {
                        // 建立渲染对象
                        FDrTemplateRenderable renderable = new FDrTemplateRenderable();
                        renderable.Template = this;
                        renderable.LoadConfig(xrenderable);
                        if (null == _model)
                        {
                            _model = renderable.Model;
                        }
                        _outline.InnerMax(renderable.Outline);
                        // 设置材质
                        FDrMaterialGroup material = renderable.Material;
                        if (null == material)
                        {
                            RMoCore.TrackConsole.Write(this, "LoadConfig", "Material is not exists. (template={0}, geometry={1}, material={2})",
                                                       _name, renderable.GeometryName, renderable.MaterialName);
                            return;
                        }
                        if (!_materials.Contains(material))
                        {
                            _materials.Push(material);
                        }
                        _renderables.Push(renderable);
                    }
                }
            }
            //............................................................
            // 加载引用列表
            FXmlNode xreferences = xconfig.Find("References");

            if (null != xreferences)
            {
                foreach (FXmlNode xreference in xreferences.Nodes)
                {
                    if (xreference.IsName("Reference"))
                    {
                        FDrTemplateReference reference = new FDrTemplateReference();
                        reference.LoadConfig(xreference);
                        _references.Push(reference);
                    }
                }
            }
            //............................................................
            // 加载动画列表
            FXmlNode xanimation = xconfig.Find("Animation");

            if (null != xanimation)
            {
                _animation.Model = _model;
                _animation.LoadConfig(xanimation);
            }
            //............................................................
            // 材质集合排序
            if (!_materials.IsEmpty)
            {
                _materials.Sort(_materials.First);
            }
        }