//============================================================ // <T>加载配置信息。</T> // // @param xconfig 配置信息 //============================================================ public void LoadModelConfig(FXmlNode xconfig) { foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Geometry")) { string geometryName = xnode.Get("name"); // 查找几何体 FDrGeometry geometry = _geometryDictionary.Find(geometryName); if (geometry == null) { RMoCore.TrackConsole.Write(this, "LoadConfig", "Geomery is not exists in model. (model={0}, geometry={1}", _model.Name, geometryName); // 加载模型信息 geometry = new FDrGeometry(_model); geometry.LoadModelConfig(xnode); _geometryDictionary.Set(geometryName, geometry); } else { // 加载模型信息 geometry.LoadModelConfig(xnode); } } } }
//============================================================ // <T>生成设计颜色。</T> // // @param color 颜色 // @return 颜色 //============================================================ public FUiColor BuildDesignColor(Color color) { string code = color.ToArgb().ToString(); FUiColor result = _designColors.Find(code); if (result == null) { result = new FUiColor(); result.Set(color.R, color.G, color.B, color.A); result.brush = _context.Device.CreateSolidBrush(result); _designColors.Set(code, result); } return(result); }
//============================================================ public void Unserialize(IInput input) { _name = input.ReadString(); //............................................................ // 读取材质列表 int materialCount = input.ReadInt16(); for (int n = 0; n < materialCount; n++) { FDxRsTemplateMaterial material = new FDxRsTemplateMaterial(); material.Template = this; material.Unserialize(input); _materials.Set(material.Code, material); } //............................................................ // 读取材质列表 int renderableCount = input.ReadInt16(); for (int n = 0; n < renderableCount; n++) { FDxRsTemplateRenderable renderable = new FDxRsTemplateRenderable(); renderable.Template = this; renderable.Unserialize(input); //_logger.Debug(this, "LoadFile", "Load renderable. (loop={0}/{1}, model={2}({3}, material={4})", // n, renderableCount, renderable.ModelCode, renderable.GeometryName, renderable.MaterialCode); _renderables.Push(renderable); } }
//============================================================ public void LoadResource(FDxRsTemplate resource) { //............................................................ // 加载材质列表 int materialCount = resource.Materials.Count; for (int n = 0; n < materialCount; n++) { // 创建几何体 FDxRsTemplateMaterial rsMaterial = resource.Materials[n]; FDxSpatialMaterial material = new FDxSpatialMaterial(); material.Device = _device; material.LoadResource(rsMaterial); // 增加渲染对象 _materials.Set(material.Name, material); } //............................................................ // 加载渲染列表 int renderableCount = resource.Renderables.Count; for (int n = 0; n < renderableCount; n++) { // 创建几何体 FDxRsTemplateRenderable rsRenderable = resource.Renderables[n]; FDxGeometry geometry = RDxCore.GeometryConsole.Create(_device, rsRenderable.ModelCode, rsRenderable.GeometryName); geometry.Display = this; geometry.LoadRenderable(rsRenderable); _geometries.Push(geometry); // 设置材质 FDxSpatialMaterial material = _materials.Get(rsRenderable.MaterialCode); geometry.ModelMaterial = material; // 增加渲染对象 _renderables.Push(geometry); } }
//============================================================ // <T>打开处理。</T> //============================================================ public void Open() { if (!RDirectory.Exists(_configDirectory)) { return; } if (_opened) { return; } // 打开文件 foreach (string fileName in RDirectory.ListFiles(_configDirectory)) { // 检查类型 if (!fileName.EndsWith(".xml")) { continue; } // 创建主题 FTplTheme theme = new FTplTheme(); theme.FileName = fileName; using (FXmlDocument xdocument = new FXmlDocument(fileName)) { theme.LoadConfig(xdocument.Root); } _themes.Set(theme.Name, theme); // 设置默认主题 if (_activeTheme == null) { _activeTheme = theme; } } _opened = true; }
static void FilterProject(string projectName, string path) { // 获得项目文件集合 FDictionary <SFileInfo> infos = new FDictionary <SFileInfo>(); foreach (string fileName in RDirectory.ListFiles(path)) { if (fileName.EndsWith(".h") || fileName.EndsWith(".cpp")) { string formatName = fileName.Replace('\\', '/'); string name = RString.Right(formatName, "/"); SFileInfo info = new SFileInfo(); info.fileName = formatName; info.include = false; infos.Set(name, info); } } // 查找使用中的文件集合 string configFileName = path + "/vcproject/" + projectName + ".vcxproj"; FXmlDocument document = new FXmlDocument(configFileName); foreach (FXmlNode xnode in document.Root.Nodes) { if (xnode.IsName("ItemGroup")) { foreach (FXmlNode xfile in xnode.Nodes) { if (xfile.IsName("ClInclude") || xfile.IsName("ClCompile")) { string include = xfile.Get("Include"); string name = RString.Right(include, "\\"); SFileInfo info = infos.Find(name); if (info != null) { info.include = true; } } } } } // 查找删除集合 foreach (SFileInfo info in infos.Values) { if (!info.include) { RLogger.Find(typeof(SFileInfo)).Debug(null, "FilterProject", info.fileName); File.Delete(info.fileName); } } // 查找没用目录 RDirectory.Delete(path + "/build"); RDirectory.Delete(path + "/dist"); RDirectory.Delete(path + "/nbproject/private"); RDirectory.Delete(path + "/maproject/libs"); RDirectory.Delete(path + "/maproject/obj"); RDirectory.Delete(path + "/vcproject/Debug"); RDirectory.Delete(path + "/vcproject/Release"); RDirectory.Delete(path + "/vcproject/x64"); File.Delete(path + "/vcproject/" + projectName + ".vcxproj.user"); }
//============================================================ // <T>同步属性编辑器</T> // // @param typeName 类型 // @return 属性编辑器 //============================================================ public QUiProperty SyncProperty(string typeName, FRcObject resource, bool type) { QUiProperty property = _properties.Find(typeName); if (property == null) { property = new QUiProperty(); property.Dock = DockStyle.Top; IUiPropertyEditor editor = CreateProperty(typeName); editor.Setup(); editor.PropertyChanged += OnPropertyChanged; UserControl control = editor as UserControl; property.LinkPanel(control); _properties.Set(typeName, property); } if (type) { property.LoadResource(resource); property.Visible = true; } else { property.Visible = false; } return(property); }
//============================================================ // <T>扫描资源控制台。</T> // // @author TYFNG 20120409 //============================================================ public void Scan() { // 检查文件存在性 if (!RDirectory.Exists(_directory)) { return; } // 扫描文件 FStrings fileNames = RDirectory.ListFiles(_directory); foreach (string fileName in fileNames) { // 检查后缀 if (!fileName.EndsWith(".xml")) { continue; } // 解析资源 string name = fileName.Substring(fileName.LastIndexOf("\\") + 1); string code = name.Substring(0, name.Length - 4); FRsDataset dataset = new FRsDataset(); dataset.Code = code; dataset.FileName = fileName; _datasets.Set(code, dataset); } }
//============================================================ // <T>扫描所有节点。</T> // // @param folder 文件夹 // @param path 路径 //============================================================ private void ScanNodes(FDrFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FDrFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = path + "\\" + items[1]; if (type == "fd") { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if (type == "mt") { subfloder.Type = "material"; FDrMaterialGroup materialGroup = new FDrMaterialGroup(); subfloder.Label = items[1] + " [" + items[2] + "]"; materialGroup.Name = dotPath; materialGroup.Label = items[2]; materialGroup.Directory = subfloder.Directory; materialGroup.DirectoryExprot = _exportDirectory; materialGroup.Scan(); // 存储对照表 if (materialGroup.OptionValid) { subfloder.Tag = materialGroup; _materials.Set(materialGroup.Code, materialGroup); _folders.Push(subfloder); } } ScanNodes(subfloder, dotPath); } } }
//============================================================ public void Unserialize(IInput input) { int count = input.ReadInt16(); for (int n = 0; n < count; n++) { FDxRsGeometry geometry = new FDxRsGeometry(); geometry.Unserialize(input); _geometries.Set(geometry.Name, geometry); } }
//============================================================ // <T>根据指定颜色生成默认色刷。</T> // // @param color 颜色 // @return 色刷 //============================================================ public FDxSolidBrush BuildSoldBrush(int color) { string code = color.ToString(); FDxSolidBrush brush = _designColors.Find(code); if (brush == null) { brush = _device.CreateSolidBrush(Color.FromArgb(color)); _designColors.Set(code, brush); } return(brush); }
//============================================================ public override void Serialize(IOutput output) { base.Serialize(output); // 存储属性 output.WriteInt8((sbyte)_optionLoaded); output.WriteInt8((sbyte)_optionSelect); output.WriteInt8((sbyte)_optionGround); output.WriteInt8((sbyte)_optionMergeVertex); output.WriteInt8((sbyte)_optionMergeMaterial); output.WriteInt8((sbyte)_optionLightMap); //............................................................ // 统计材质次数 FDictionary <int> materialsCount = new FDictionary <int>(); foreach (FDrTemplateRenderable renderable in _renderables) { int materialCount = 0; if (materialsCount.Contains(renderable.MaterialCode)) { materialCount = materialsCount.Get(renderable.MaterialCode); } materialCount++; materialsCount.Set(renderable.MaterialCode, materialCount); } //............................................................ // 存储渲染列表 int count = _renderables.Count; output.WriteInt16((short)count); for (int n = 0; n < count; n++) { FDrTemplateRenderable renderable = _renderables[n]; int materialCount = materialsCount.Get(renderable.MaterialCode); if (1 == materialCount) { renderable.OptionMerge = EDrFlag.No; } renderable.Id = n + 1; renderable.Serialize(output); } //............................................................ // 存储动画列表 if (_animation.IsEmpty) { output.WriteBool(false); } else { output.WriteBool(true); _animation.Serialize(output); } }
//============================================================ // <T>根据名称打开界面。</T> // // @param name 名称 // @return 界面 //============================================================ public FUiFrame OpenFrame(string name) { FUiFrame frame = _frames.Find(name); if (frame == null) { FRcFrame resource = RContent2dManager.FrameConsole.OpenFrame(name); frame = CreateComponent(resource.TypeName) as FUiFrame; frame.LoadResource(resource); _frames.Set(name, frame); } return(frame); }
//============================================================ public FDxRsTexturePack Get(string code) { FDxRsTexturePack texture = _textures.Find(code); if (null == texture) { texture = new FDxRsTexturePack(); string fileName = MakeFileName(code); texture.LoadFile(fileName); _textures.Set(code, texture); } return(texture); }
//============================================================ public FDxRsTemplate Get(string code) { FDxRsTemplate template = _templates.Find(code); if (null == template) { template = new FDxRsTemplate(); string fileName = MakeFileName(code); template.LoadFile(fileName); _templates.Set(code, template); } return(template); }
//============================================================ public FDxRsModel Get(string code) { FDxRsModel model = _models.Find(code); if (null == model) { model = new FDxRsModel(); string fileName = MakeFileName(code); model.LoadFile(fileName); _models.Set(code, model); } return(model); }
//============================================================s public FDxTechnique Get(FDxDevice3D device, string type) { FDxTechnique technique = _techniques.Find(type); if (null == technique) { technique = Create(type); technique.Device = device; technique.Setup(); _techniques.Set(type, technique); } return(technique); }
//============================================================ // <T>根据类型名称创建界面组件。</T> // // @param typeName 类型名称 //============================================================ public QUiDesignForm OpenDesignForm(string name) { // 弹出画面 QUiDesignForm form = _frameForms.Find(name); if (form == null) { FUiFrame frame = OpenFrame(name); form = new QUiDesignForm(); form.LoadFrame(frame); _frameForms.Set(name, form); } return(form); }
//============================================================s public FDxEffect Get(FDxDevice3D device, string type) { FDxEffect effect = _effects.Find(type); if (null == effect) { effect = Create(type); effect.Device = device; effect.LoadFile(_path + "\\" + type + ".fx"); effect.Setup(); _effects.Set(type, effect); } return(effect); }
//============================================================ // <T>加载设置节点。</T> // // @param xconfig 配置节点 //============================================================ public void LoadConfig(FXmlNode xconfig) { _name = xconfig.Get("name"); // 加载属性集合 foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Property")) { FTplThemeStyleProperty property = new FTplThemeStyleProperty(); property.LoadConfig(xnode); _properties.Set(property.Name, property); } } }
//============================================================ // <T>加载设置节点。</T> // // @param xconfig 配置节点 //============================================================ public void LoadConfig(FXmlNode xconfig) { _name = xconfig.Get("name"); // 加载样式集合 foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Style")) { FTplThemeStyle style = new FTplThemeStyle(); style.LoadConfig(xnode); _styles.Set(style.Name, style); } } }
//============================================================ public void LoadResource(FDxRsModel resource) { int count = resource.Mesh.Geometries.Count; for (int n = 0; n < count; n++) { // 创建几何体 FDxModelGeometry geometry = new FDxModelGeometry(); geometry.Device = _device; // 加载资源 FDxRsGeometry geometryResource = resource.Mesh.Geometries[n]; geometry.LoadResource(geometryResource); // 存储对象 _geometries.Set(geometry.Name, geometry); _renderables.Push(geometry); } }
//============================================================ public FDxModel Get(FDxDevice3D device, string code) { FDxModel model = _models.Find(code); if (null == model) { // 创建模型 model = new FDxModel(); model.Device = device; // 加载模型资源 FDxRsModel rsModel = RDxCore.ModelResourceConsole.Get(code); model.LoadResource(rsModel); // 存储模型 _models.Set(code, model); } return(model); }
//============================================================ public FDxModelTexture Get(FDxDevice3D device, string code, int typeCd) { string name = code + "|" + typeCd; FDxModelTexture texture = _textures.Find(name); if (null == texture) { // 创建模型 texture = new FDxModelTexture(); texture.Device = device; // 加载模型资源 FDxRsTexturePack rsTexture = RDxCore.TextureResourceConsole.Get(code); FDxRsTextureBitmapPack rsPack = rsTexture.Packs[typeCd]; texture.LoadResource(rsPack); // 存储模型 _textures.Set(name, texture); } return(texture); }
//============================================================ public void LoadModelConfig(FXmlNode xconfig) { foreach (FXmlNode xnode in xconfig.Nodes) { if (xnode.IsName("Material")) { // 读取材质信息 FDrModelMaterial material = new FDrModelMaterial(); material.LoadModelConfig(xnode); _dataNames.Set(material.DataName, material); // 读取子材质 foreach (FXmlNode xsubnode in xnode.Nodes) { if (xsubnode.IsName("Material")) { LoadModelConfig(xsubnode); } } } } }
//============================================================ // <T>扫描所有节点。</T> // // @param folder 文件夹 // @param path 路径 //============================================================ protected void ScanNodes(FDrFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FDrFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = path + "\\" + items[1]; if ("fd" == type) { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if ("tp" == type) { subfloder.Type = "template"; FDrTemplate template = new FDrTemplate(); subfloder.Label = items[1] + " [" + items[2] + "]"; template.Name = dotPath; template.Label = items[2]; template.Directory = subfloder.Directory; // template.ExportPath = _exportDirectory; template.Scan(); subfloder.Tag = template; // 存储对照表 _templates.Set(template.Code, template); _folders.Push(subfloder); } ScanNodes(subfloder, dotPath); } } }
//============================================================ // <T>扫描所有节点。</T> // // @param folder 文件夹 // @param path 路径 //============================================================ private void ScanNodes(FDrFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FDrFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = path + "\\" + items[1]; if ("fd" == type) { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if ("md" == type) { subfloder.Type = "material"; FDrModel model = new FDrModel(); subfloder.Label = items[1] + " [" + items[2] + "]"; model.Name = dotPath; model.Label = items[2]; model.Directory = subfloder.Directory; model.DirectoryExprot = _exportDirectory; model.Scan(); subfloder.Tag = model; // 存储对照表 _models.Set(model.Code, model); _folders.Push(subfloder); } ScanNodes(subfloder, dotPath); } } }
//============================================================ // <T>扫描所有节点。</T> // // @param folder 文件夹 // @param path 路径 //============================================================ protected void ScanNodes(FDrFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FDrFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = path + "\\" + items[1]; if ("fd" == type) { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if ("sc" == type) { subfloder.Type = "scene"; FDrSceneGroup group = new FDrSceneGroup(); subfloder.Label = items[1] + " [" + items[2] + "]"; group.Name = dotPath; group.Label = items[2]; group.Directory = subfloder.Directory; group.DirectoryExprot = _exportDirectory; group.Scan(); subfloder.Tag = group; // 存储对照表 _sceneGroups.Set(group.Code, group); _folders.Push(subfloder); } ScanNodes(subfloder, dotPath); } } }
//============================================================ // <T>扫描所有节点。</T> // // @param folder 文件夹 // @param path 路径 //============================================================ protected void ScanNodes(FDrFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FDrFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = path + "\\" + items[1]; if ("fd" == type) { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if ("tp" == type) { subfloder.Type = "camera"; FDrCamera camera = new FDrCamera(); subfloder.Label = items[1] + " [" + items[2] + "]"; camera.Name = dotPath; camera.Label = items[2]; camera.Directory = subfloder.Directory; camera.Scan(); subfloder.Tag = camera; // 存储对照表 _cameras.Set(camera.Code, camera); _folders.Push(subfloder); } ScanNodes(subfloder, dotPath); } } }
//============================================================ // <T>加载。</T> //============================================================ private void ScanNodes(FCfgFolder folder, string path) { string fileTag = string.Empty; // 文件夹排序 folder.Folders.Sort(); // 循环取得每个文件 foreach (FCfgFolder subfloder in folder.Folders) { // 获得经过处理的名称 string[] items = subfloder.Name.Split('-'); if (items.Length >= 3) { string type = items[0]; string dotPath = RString.IsEmpty(path) ? items[1] : path + "." + items[1]; if ("fd" == type) { subfloder.Type = "folder"; subfloder.Label = items[1] + " [" + items[2] + "]"; } else if ("mp" == type) { subfloder.Type = "map"; FDrMap map = new FDrMap(); subfloder.Label = items[1] + " [" + items[2] + "]"; map.Name = dotPath; map.Label = items[2]; map.Path = subfloder.Directory; map.ExprotPath = _exportDirectory; subfloder.Tag = map; // 存储对照表 _mapDictionary.Set(dotPath, map); subfloder.Folders.Clear(); } ScanNodes(subfloder, dotPath); } } }