Exemple #1
0
        private void OpenProject(string project)
        {
            RenderMethods.OpenProject(project);
            m_ProjectLocation = Path.GetDirectoryName(project);

            m_ProjectView.UpdateProject(project, selectedNode =>
            {
                if (m_PropertiesView.UpdateProjectProperties(selectedNode))
                {
                    int selectAcotrId = m_ProjectView.GetSelectActorId();
                    if (selectAcotrId > 2)
                    {
                        RenderMethods.SetPickedActor((uint)selectAcotrId);
                    }
                    else
                    {
                        RenderMethods.SetPickedActor(0);
                    }
                }
                else
                {
                    RenderMethods.SetPickedActor(0);
                }
            });

            string assetFile = m_ProjectLocation + @"\" + Path.GetFileNameWithoutExtension(project) + ".asset";

            m_AssetsView.UpdateAssets(assetFile, m_PropertiesView.UpdateAssetProperties, m_outputView.UpdateCompileInfo,
                                      effectNode =>
            {
                panelAllView.ActiveDocumentPane.ActiveContent = m_EditorView;
                m_EditorView.ShowEffectDoc(effectNode, m_ProjectLocation);
            },
                                      m_MaterialView);

            m_PropertiesView.ProjectLocation = m_ProjectLocation;
            m_PropertiesView.SetMoveActorDelegate(
                (string component, string attribute, Inspector.Vector3 value) =>
            {
                int actorId = m_ProjectView.GetSelectActorId();

                XmlDocument xmlDoc  = new XmlDocument();
                XmlElement xmlActor = xmlDoc.CreateElement("Actor");

                xmlActor.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "id", (actorId > 2 ? actorId : 0).ToString()));

                XmlElement transformComponent = xmlDoc.CreateElement(component);;
                XmlElement transformType      = xmlDoc.CreateElement(attribute);
                transformComponent.AppendChild(transformType);
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "x", value.X.ToString()));
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "y", value.Y.ToString()));
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "z", value.Z.ToString()));
                xmlActor.AppendChild(transformComponent);

                RenderMethods.ModifyActor(xmlActor.OuterXml);
            },
                (string name, string value) =>
            {
                m_AssetsView.ModifyMaterial(name, value);
            }
                );

            m_RenderView.SetChangeMaterialDelegate((name, actorId, mesh) =>
            {
                m_ProjectView.SelectActorNode(actorId);
                XmlNode actorNode = m_ProjectView.GetSelectActorXml();

                XmlDocument xmlDoc  = new XmlDocument();
                XmlElement xmlActor = xmlDoc.CreateElement("Actor");

                xmlActor.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "id", actorId.ToString()));

                XmlElement material = xmlDoc.CreateElement("Material");
                material.InnerText  = @"Materials\" + Path.GetFileName(name);

                XmlElement renderComponent = null;
                string nodeType            = actorNode.Attributes["type"].Value;
                if (nodeType == "Model")
                {
                    renderComponent = xmlDoc.CreateElement("ModelRenderComponent");
                    material.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "index", mesh.ToString()));
                    XmlElement materials = xmlDoc.CreateElement("Materials");
                    materials.AppendChild(material);
                    renderComponent.AppendChild(materials);
                }
                else if (nodeType == "Plane")
                {
                    renderComponent = xmlDoc.CreateElement("PlaneRenderComponent");
                    renderComponent.AppendChild(material);
                }
                else if (nodeType == "Sphere")
                {
                    renderComponent = xmlDoc.CreateElement("SphereRenderComponent");
                    renderComponent.AppendChild(material);
                }
                else if (nodeType == "Torus")
                {
                    renderComponent = xmlDoc.CreateElement("TorusRenderComponent");
                    renderComponent.AppendChild(material);
                }
                else if (nodeType == "Teapot")
                {
                    renderComponent = xmlDoc.CreateElement("TeapotRenderComponent");
                    renderComponent.AppendChild(material);
                }

                xmlActor.AppendChild(renderComponent);

                RenderMethods.ModifyActor(xmlActor.OuterXml);
                m_ProjectView.ModifyMaterialXml((int)actorId, mesh, material.InnerText);
            });

            RenderMethods.SetMoveDelegate(m_DllMoveDelegate);

            EnableControlView(true);
        }
Exemple #2
0
        private void OpenProject(string project)
        {
            RenderMethods.OpenProject(project);
            m_ProjectLocation = Path.GetDirectoryName(project);

            m_ProjectView.UpdateProject(project, selectedNode =>
            {
                if (m_PropertiesView.UpdateProjectProperties(selectedNode))
                {
                    int selectAcotrId = m_ProjectView.GetSelectActorId();
                    if (selectAcotrId > 2)
                    {
                        RenderMethods.SetPickedActor((uint)selectAcotrId);
                    }
                    else
                    {
                        RenderMethods.SetPickedActor(0);
                    }
                }
                else
                {
                    RenderMethods.SetPickedActor(0);
                }
            });

            string assetFile = m_ProjectLocation + @"\" + Path.GetFileNameWithoutExtension(project) + ".asset";

            m_AssetsView.UpdateAssets(assetFile, m_PropertiesView.UpdateAssetProperties, m_outputView.UpdateCompileInfo);

            m_PropertiesView.SetMoveActorDelegate((string component, string attribute, Inspector.Vector3 value) =>
            {
                int actorId = m_ProjectView.GetSelectActorId();

                XmlDocument xmlDoc  = new XmlDocument();
                XmlElement xmlActor = xmlDoc.CreateElement("Actor");

                xmlActor.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "id", (actorId > 2 ? actorId : 0).ToString()));

                XmlElement transformComponent = xmlDoc.CreateElement(component);;
                XmlElement transformType      = xmlDoc.CreateElement(attribute);
                transformComponent.AppendChild(transformType);
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "x", value.X.ToString()));
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "y", value.Y.ToString()));
                transformType.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "z", value.Z.ToString()));
                xmlActor.AppendChild(transformComponent);

                RenderMethods.ModifyActor(xmlActor.OuterXml);
            });

            m_RenderView.SetChangeEffectDelegate((effectNode, actorId) =>
            {
                m_ProjectView.SelectActorNode(actorId);
                XmlNode actorNode = m_ProjectView.GetSelectActorXml();

                XmlDocument xmlDoc  = new XmlDocument();
                XmlElement xmlActor = xmlDoc.CreateElement("Actor");

                xmlActor.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "id", actorId.ToString()));

                XmlElement renderComponent = null;
                string nodeType            = actorNode.Attributes["type"].Value;
                if (nodeType == "Model")
                {
                    renderComponent = xmlDoc.CreateElement("ModelRenderComponent");
                }
                else if (nodeType == "Cube")
                {
                    renderComponent = xmlDoc.CreateElement("CubeRenderComponent");
                }
                else if (nodeType == "Sphere")
                {
                    renderComponent = xmlDoc.CreateElement("SphereRenderComponent");
                }
                else if (nodeType == "Cylinder")
                {
                    renderComponent = xmlDoc.CreateElement("CylinderRenderComponent");
                }
                else if (nodeType == "Teapot")
                {
                    renderComponent = xmlDoc.CreateElement("TeapotRenderComponent");
                }

                XmlElement effect = xmlDoc.CreateElement("Effect");
                renderComponent.AppendChild(effect);
                effect.InnerText = effectNode.Attributes["object"].Value;
                effect.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "technique", "main11"));
                effect.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "pass", "p0"));
                xmlActor.AppendChild(renderComponent);

                RenderMethods.ModifyActor(xmlActor.OuterXml);
            });

            RenderMethods.SetMoveDelegate(m_DllMoveDelegate);

            EnableControlView(true);
        }