Пример #1
0
 public Texture2DSampler(Texture texture)
 {
     Texture = texture;
 }
Пример #2
0
        private ColorSampler ReadColorSampler(XElement profileElement, XElement effectElement, string xpath)
        {
            XElement shaiderElement = effectElement.XPathSelectElement(xpath, _nsMgr);

            if (shaiderElement.Name.LocalName == "color")
            {
                return new PlaneColorSampler(shaiderElement == null ? Vector3.Zero : shaiderElement.Value.ToVec3());
            }
            else if (shaiderElement.Name.LocalName == "texture")
            {
                string textureSamplerID = shaiderElement.Attribute("texture").Value;
                string textureSurfcaeID = profileElement.XPathSelectElement(string.Format("c:newparam[@sid='{0}']/c:sampler2D/c:source", textureSamplerID), _nsMgr).Value;
                string textureImageID = profileElement.XPathSelectElement(string.Format("c:newparam[@sid='{0}']/c:surface/c:init_from", textureSurfcaeID), _nsMgr).Value;
                string texturePath = _document.XPathSelectElement(string.Format("//c:library_images/c:image[@id='{0}']/c:init_from", textureImageID), _nsMgr).Value.Trim('/');

                Texture texture = new Texture(texturePath);
                _scene.Textures.Add(texture);

                return new Texture2DSampler(texture);
            }

            throw new Exception("Unknown surface shader");
        }