コード例 #1
0
ファイル: Scene.cs プロジェクト: RonOHara-GG/WebGLRenderer
        public Viewport GetViewport(string name, string src)
        {
            for (var i = 0; i < viewports.Count; i++)
            {
                if( viewports[i].name == name )
                    return viewports[i];
            }

            // Doesnt exist, load it now
            Viewport viewport = new Viewport(this, name, src);
            viewports.Add(viewport);
            return viewport;
        }
コード例 #2
0
        public RenderPass(Scene scene, string name, string src)
            : base(scene, name, src)
        {
            // Load the source
            try
            {
                XmlDocument rpXML = new XmlDocument();
                rpXML.Load(src);

                // Get the attribute properties
                foreach( XmlAttribute attrib in rpXML.DocumentElement.Attributes )
                {
                    switch( attrib.Name )
                    {
                        case "sortMode":
                            sortMode = attrib.Value;
                            break;
                        case "clearMode":
                            string clearMode = attrib.Value;
                            clearColor = (clearMode.IndexOf("color") >= 0);
                            clearDepth = (clearMode.IndexOf("depth") >= 0);
                            clearStencil = (clearMode.IndexOf("stencil") >= 0);
                            break;
                        case "clearDepth":
                            clearDepthValue = Convert.ToSingle(attrib.Value);
                            break;
                        case "clearStencil":
                            clearStencilValue = Convert.ToSingle(attrib.Value);
                            break;
                        case "clearColor":
                            string[] clearColors = attrib.Value.Split(',');
                            clearColorRed = Convert.ToSingle(clearColors[0]) / 255.0f;
                            clearColorGreen = Convert.ToSingle(clearColors[1]) / 255.0f;
                            clearColorBlue = Convert.ToSingle(clearColors[2]) / 255.0f;
                            break;
                        default:
                            break;
                    }
                }

                foreach( XmlNode child in rpXML.DocumentElement.ChildNodes )
                {
                    if (child.NodeType == XmlNodeType.Element)
                    {
                        string objName = child.Attributes.GetNamedItem("name").Value;
                        string objSrc = child.Attributes.GetNamedItem("src").Value;
                        if (child.Name == "viewport")
                        {
                            viewport = scene.GetViewport(objName, objSrc);
                        }
                        else if (child.Name == "camera")
                        {
                            camera = scene.GetCamera(objName, objSrc);
                        }
                        else if (child.Name == "frameBuffer")
                        {
                            frameBuffer = scene.GetFrameBuffer(objName, objSrc);
                        }
                        else if (child.Name == "overrideShader")
                        {
                            overrideShader = scene.GetShader(objName, objSrc);
                        }
                    }
                }
            }
            catch(Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Failed to load render pass: "******"\r\n" + e.Message);
            }
        }