protected override void PostUnserial(XmlNode _node) { XmlNode materialNode = _node.SelectSingleNode("Material"); m_material = Mgr <CatProject> .Singleton.materialList1 .CreateMaterialInstanceByXml(materialNode); }
public CatModel(string _name, CatMaterial _material, Animation _animation = null) { m_name = _name; m_material = _material; m_animation = _animation; if (m_animation == null) { m_animation = new Animation(); } }
public void SetMaterialToTemplate(CatMaterialTemplate _materialTemplate) { if (m_material == null) { m_material = _materialTemplate.GetMaterialPrototype().Clone(); } else { m_material.ChangeMaterialTemplate(_materialTemplate); } }
public CatMaterial Clone() { CatMaterial newMaterial = new CatMaterial(m_materialTemplate); // parameters if (m_parameters != null) { foreach (KeyValuePair <string, IEffectParameter> keyValue in m_parameters) { newMaterial.AddParameter(keyValue.Key, keyValue.Value); } } return(newMaterial); }
/** * @brief Create materialTemplate from .material file * * @param _filepath filepath * * @result the materialTemplate * */ public static CatMaterialTemplate LoadMaterialTemplate(string _filepath) { // create material template CatMaterialTemplate newMaterialTemplate = new CatMaterialTemplate(); CatMaterial materialPrototype = newMaterialTemplate.GetMaterialPrototype(); // load .material file XmlDocument doc = new XmlDocument(); doc.Load(_filepath); XmlNode nodeMaterial = doc.SelectSingleNode("Material"); XmlElement eleMaterial = (XmlElement)nodeMaterial; string materialName = eleMaterial.GetAttribute("fxname"); // read material parameter if (nodeMaterial != null) { foreach (XmlNode node in nodeMaterial.ChildNodes) { XmlElement eleNode = (XmlElement)node; string parameterName = eleNode.GetAttribute("name"); string parameterType = eleNode.GetAttribute("type"); string parameterValue = eleNode.GetAttribute("value"); IEffectParameter variable = CatMaterial.CreateVariable(parameterType, parameterValue); if (variable != null) { materialPrototype.AddParameter(parameterName, variable); } // check if should show in editor, by checking whether note="NotInEditor" string parameterNote = eleNode.GetAttribute("note"); if (parameterNote != null && parameterNote.Contains("NotInEditor")) { newMaterialTemplate.m_maskedParameters.Add(parameterName, true); } } } // load effect newMaterialTemplate.m_effect = Mgr <CatProject> .Singleton.contentManger.Load <Effect>("effect\\" + materialName); return(newMaterialTemplate); }
private Dictionary <string, bool> m_maskedParameters; // attributes not shown in editor private CatMaterialTemplate() { m_effect = null; m_materialPrototype = new CatMaterial(this); m_maskedParameters = new Dictionary <string, bool>(); }
public CatModel() { m_name = "UntitledModel"; m_material = null; m_animation = null; }