Ejemplo n.º 1
0
        public override void GCode_GenerateCode(ref string strDefinitionSegment, ref string strSegment, int nLayer, CodeGenerateSystem.Base.LinkPinControl element, CodeGenerateSystem.Base.GenerateCodeContext_Method context)
        {
            var strValueIdt = "float4 " + GetVarName() + " = float4(0,0,0,0);\r\n";

            if (!strDefinitionSegment.Contains(strValueIdt))
            {
                strDefinitionSegment += "    " + strValueIdt;
            }

            var strTab = GCode_GetTabString(nLayer);

            string uvName = "input.vUV";

            if (UVLink.HasLink)
            {
                UVLink.GetLinkedObject(0, true).GCode_GenerateCode(ref strDefinitionSegment, ref strSegment, nLayer, element, context);
                uvName = UVLink.GetLinkedObject(0, true).GCode_GetValueName(UVLink.GetLinkedPinControl(0, true), context);
            }

            if (TextureLink.HasLink)
            {
                TextureLink.GetLinkedObject(0, true).GCode_GenerateCode(ref strDefinitionSegment, ref strSegment, nLayer, element, context);
                var    ctrl        = TextureLink.GetLinkedObject(0, true);
                string texSampName = "";
                string texName     = "";
                if (ctrl is TextureControl)
                {
                    texSampName = ((TextureControl)ctrl).GetTextureSampName();
                    texName     = ((TextureControl)ctrl).GetTextureName();
                }
                else if (ctrl is ShaderAutoData)
                {
                    texSampName = ((ShaderAutoData)ctrl).GCode_GetValueName(null, context);
                    texName     = texSampName;
                }
                var assignStr = strTab + GetVarName() + " = vise_tex2D(" + texName + ", " + texSampName + ", " + uvName + ");\r\n";
                // 这里先不做判断,连线中有if的情况下会导致问题
                //if (!strSegment.Contains(assignStr))
                if (!Program.IsSegmentContainString(strSegment.Length - 1, strSegment, assignStr))
                {
                    strSegment += assignStr;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a texture for the specified description.
        /// </summary>
        /// <param name="description">The description.</param>
        /// <returns>A texture</returns>
        public Texture GetTemporaryTexture(TextureDescription description)
        {
            // For a specific description, get allocated textures
            List <TextureLink> textureLinks = null;

            if (!textureCache.TryGetValue(description, out textureLinks))
            {
                textureLinks = new List <TextureLink>();
                textureCache.Add(description, textureLinks);
            }

            // Find a texture available
            foreach (var textureLink in textureLinks)
            {
                if (textureLink.RefCount == 0)
                {
                    textureLink.RefCount = 1;
                    return(textureLink.Texture);
                }
            }

            // If no texture available, then creates a new one
            var newTexture = CreateTexture(description);

            if (newTexture.Name == null)
            {
                newTexture.Name = string.Format("PostEffect{0}-{1}", Name == null ? string.Empty : string.Format("-{0}", Name), textureLinks.Count);
            }

            // Add the texture to the allocated textures
            // Start RefCount == 1, because we don't want this texture to be available if a post FxProcessor is calling
            // several times this GetTemporaryTexture method.
            var newTextureLink = new TextureLink(newTexture)
            {
                RefCount = 1
            };

            textureLinks.Add(newTextureLink);

            return(newTexture);
        }
 protected override void RefillTextureLinks()
 {
     base.RefillTextureLinks();
     if (UseTextureArray)
     {
         List <Utils.RenderSet.Set> RenderSets = RenderSet.Sets;
         List <TextureLink>         Links      = new List <TextureLink> ();
         for (int i = 0; i < RenderSets.Count; i++)
         {
             if (TextureKeys.Length <= i || !Management.GameManager.I.Modular.TextureDataDictionary.ContainsKey(TextureKeys [i]))
             {
                 continue;
             }
             ModularTextureData Texture = Management.GameManager.I.Modular.TextureDataDictionary [TextureKeys [i]];
             TextureLink        Link    = new TextureLink(Texture, TextureArrays [i].TextureArray, this, RenderSet, i);
             Link.ApplyTextureData(RenderSets[i].Renderer, Texture);
             Links.Add(Link);
         }
         Textures = Links;
     }
 }
Ejemplo n.º 4
0
        private void Button_SetTexturePath_Click(object sender, RoutedEventArgs e)
        {
            var data = EditorCommon.PluginAssist.PropertyGridAssist.GetSelectedObjectData("Texture");

            if (data == null)
            {
                return;
            }

            if (data.Length <= 0)
            {
                return;
            }

            TexturePath = data[0] as EngineNS.RName;

            // 向连接到本节点的其他节点发送贴图设置的信息以便其他节点更新显示贴图
            var linkObj = TextureLink.GetLinkedObject(0, false);

            if (linkObj is Texture.Tex2D)
            {
                ((Texture.Tex2D)linkObj).TexturePath = TexturePath;
            }
        }
Ejemplo n.º 5
0
 public TextureGroup(TextureLink link, ModularTextureArray TextureArray)
 {
     this._Texture      = link._Texture;
     this._TextureArray = TextureArray;
     this.Links.Add(link);
 }
Ejemplo n.º 6
0
 public void AddTextureLink(TextureLink Link)
 {
     AddRenderTuple(Link.Tuples);
 }
Ejemplo n.º 7
0
 public void AddLink(TextureLink Link)
 {
     Links.Add(Link);
 }