/// <summary> /// Initializes the additional information in the texture. /// </summary> public void Initialize() { _name = null; _file = null; _mask = false; _render = true; _shift = new Vector2(0f, 0f); _scale = new Vector2(1f, 1f); _operation = D3D.TextureOperation.SelectArg1; _operationText = null; }
/// <summary> /// Creates a copy of a Texture object. /// </summary> /// <param name="tex">Texture object to copy.</param> public Texture(Texture tex) { if (tex != null) { _texture = tex.DXTexture; _name = tex._name; _file = tex._file; _mask = tex._mask; _render = tex._render; _shift = new Vector2(tex._shift.X, tex._shift.Y); _scale = new Vector2(tex._scale.X, tex._scale.Y); _operation = tex._operation; _operationText = tex._operationText; } else { _texture = null; Initialize(); } }
/// <summary> /// Creates a copy of a Texture object. /// </summary> /// <param name="tex">Texture object to copy.</param> public Texture( Texture tex ) { if ( tex != null ) { _texture = tex.DXTexture; _name = tex._name; _file = tex._file; _mask = tex._mask; _render = tex._render; _shift = new Vector2( tex._shift.X, tex._shift.Y ); _scale = new Vector2( tex._scale.X, tex._scale.Y ); _operation = tex._operation; _operationText = tex._operationText; } else { _texture = null; Initialize(); } }
/// <summary> /// Sets the texture drawing operation for the specified texture state in the DirectX device. /// </summary> /// <param name="texture">Texture state to update.</param> private void SetTextureOperation(int texture) { DataCore.Texture tex = (DataCore.Texture)_page.TerrainPatch.Textures[texture]; D3D.TextureOperation operation = tex.Operation; switch (operation) { case D3D.TextureOperation.Add: case D3D.TextureOperation.AddSigned: case D3D.TextureOperation.AddSmooth: case D3D.TextureOperation.BlendTextureAlpha: case D3D.TextureOperation.DotProduct3: case D3D.TextureOperation.Modulate: case D3D.TextureOperation.Modulate2X: case D3D.TextureOperation.Subtract: _viewport.Device.TextureState[texture].ColorArgument1 = D3D.TextureArgument.Current; _viewport.Device.TextureState[texture].ColorArgument2 = D3D.TextureArgument.TextureColor; _viewport.Device.TextureState[texture].ColorOperation = operation; break; case D3D.TextureOperation.BlendFactorAlpha: _viewport.Device.RenderState.BlendOperation = D3D.BlendOperation.Subtract; _viewport.Device.RenderState.SourceBlend = D3D.Blend.SourceAlpha; _viewport.Device.RenderState.DestinationBlend = D3D.Blend.DestinationAlpha; _viewport.Device.RenderState.AlphaBlendEnable = true; _viewport.Device.RenderState.BlendFactor = Color.FromArgb(50, Color.Black); _viewport.Device.TextureState[texture].ColorArgument1 = D3D.TextureArgument.Current; _viewport.Device.TextureState[texture].ColorArgument2 = D3D.TextureArgument.TextureColor; _viewport.Device.TextureState[texture].ColorOperation = operation; break; case D3D.TextureOperation.SelectArg1: default: _viewport.Device.TextureState[texture].ColorArgument1 = D3D.TextureArgument.TextureColor; _viewport.Device.TextureState[texture].ColorOperation = D3D.TextureOperation.SelectArg1; break; } }
/// <summary> /// Static method for converting LayerBlendOperationEx enum values to the Direct3D /// TextureOperation enum. /// </summary> /// <param name="blendop"></param> /// <returns></returns> public static D3D.TextureOperation ConvertEnum(LayerBlendOperationEx blendop, D3D.Caps devCaps) { D3D.TextureOperation d3dTexOp = 0; // figure out what is what switch (blendop) { case LayerBlendOperationEx.Source1: d3dTexOp = D3D.TextureOperation.SelectArg1; break; case LayerBlendOperationEx.Source2: d3dTexOp = D3D.TextureOperation.SelectArg2; break; case LayerBlendOperationEx.Modulate: d3dTexOp = D3D.TextureOperation.Modulate; break; case LayerBlendOperationEx.ModulateX2: d3dTexOp = D3D.TextureOperation.Modulate2X; break; case LayerBlendOperationEx.ModulateX4: d3dTexOp = D3D.TextureOperation.Modulate4X; break; case LayerBlendOperationEx.Add: d3dTexOp = D3D.TextureOperation.Add; break; case LayerBlendOperationEx.AddSigned: d3dTexOp = D3D.TextureOperation.AddSigned; break; case LayerBlendOperationEx.AddSmooth: d3dTexOp = D3D.TextureOperation.AddSmooth; break; case LayerBlendOperationEx.Subtract: d3dTexOp = D3D.TextureOperation.Subtract; break; case LayerBlendOperationEx.BlendDiffuseAlpha: d3dTexOp = D3D.TextureOperation.BlendDiffuseAlpha; break; case LayerBlendOperationEx.BlendTextureAlpha: d3dTexOp = D3D.TextureOperation.BlendTextureAlpha; break; case LayerBlendOperationEx.BlendCurrentAlpha: d3dTexOp = D3D.TextureOperation.BlendCurrentAlpha; break; case LayerBlendOperationEx.BlendManual: d3dTexOp = D3D.TextureOperation.BlendFactorAlpha; break; case LayerBlendOperationEx.DotProduct: if (Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.Dot3)) { d3dTexOp = D3D.TextureOperation.DotProduct3; } else { d3dTexOp = D3D.TextureOperation.Modulate; } break; case LayerBlendOperationEx.BlendDiffuseColor: if (devCaps.TextureOperationCaps.SupportsLerp) { d3dTexOp = D3D.TextureOperation.Lerp; } else { d3dTexOp = D3D.TextureOperation.Modulate; } break; } // end switch return(d3dTexOp); }
/// <summary> /// Initializes the additional information in the texture. /// </summary> public void Initialize() { _name = null; _file = null; _mask = false; _render = true; _shift = new Vector2( 0f, 0f ); _scale = new Vector2( 1f, 1f ); _operation = D3D.TextureOperation.SelectArg1; _operationText = null; }