ForceBaseTexture
by David Everhart · in Torque X 2D · 12/05/2007 (12:56 pm) · 0 replies
I have been trying to use the following code below:
The newTexture is a valid Texture2D. I based the code off of a .txscene xml block such as:
Now, I checked out what BindBackBufferTexture does,and it calls ForceBaseTexture below:
Here is the issue:
The _baseTextParameter is only setup when init is called, and creating a defaultEffect in code doesnt seem to set it up. Since it is null , it never sets that value, and my material is useless at that point. Is this by design or is there something I am missing? This is part of my runtime animation generation sequence (very similar to Diablo IIs token based itemization technique). Any ideas or feedback is appreciated.
DefaultEffect newEffect = new DefaultEffect();
newEffect.Name = "testEffect";
newEffect.BaseTex = "MergedImages";
newEffect.BindBackBufferTexture(newTexture);
newEffect.Translucent = true;
newEffect.SpecularColor = new Vector4(1);
newEffect.SpecularPower = 0f;
newEffect.EnableLighting = false;
newEffect.Additive = false;The newTexture is a valid Texture2D. I based the code off of a .txscene xml block such as:
<DefaultEffect name="SwordWalkMaterial">
<BaseTex>data/images/SwordWalk.png</BaseTex>
<Translucent>true</Translucent>
<SpecularPower>0.000</SpecularPower>
<SpecularColor>
<X>1</X>
<Y>1</Y>
<Z>1</Z>
<W>1</W>
</SpecularColor>
<EnableLighting>false</EnableLighting>
<Additive>false</Additive>
</DefaultEffect>Now, I checked out what BindBackBufferTexture does,and it calls ForceBaseTexture below:
/// <summary>
/// Used to replace the base texture with an existing texture without
/// requiring a filename (commonly used for rendering dynamically generated textures).
/// </summary>
/// <param name="tex"></param>
public void ForceBaseTexture(Texture2D tex)
{
if ((_baseTexParameter == null) || (tex == null))
return;
_baseTexParameter.SetValue(tex);
}Here is the issue:
The _baseTextParameter is only setup when init is called, and creating a defaultEffect in code doesnt seem to set it up. Since it is null , it never sets that value, and my material is useless at that point. Is this by design or is there something I am missing? This is part of my runtime animation generation sequence (very similar to Diablo IIs token based itemization technique). Any ideas or feedback is appreciated.