• Main Page
  • Packages
  • Classes
  • Files
  • File List

trunk/visLU/Effects/FlowShader.cs

Go to the documentation of this file.
00001 using System;
00002 using System.Collections.Generic;
00003 using System.Linq;
00004 using System.Text;
00005 using Microsoft.Xna.Framework;
00006 using Microsoft.Xna.Framework.Content;
00007 using Microsoft.Xna.Framework.Graphics;
00008 using Microsoft.Xna.Framework.Input;
00009 
00010 namespace visLU2.Effects
00011 {
00016     class FlowShader: Effect
00017     {
00018         Game game;
00019         GraphicsDevice device;
00020         Effect effect;
00021 
00022         private EffectParameter worldViewProjection;
00023         public EffectParameter world;
00024         public EffectParameter cameraPosition;
00025         private EffectParameter transferValues;
00026         private EffectParameter backBufferValues;
00027         private EffectParameter channel;
00028 
00029         private Texture2D backBuffer;
00030         private Texture2D transfer;
00031 
00038         public FlowShader(Game _game, GraphicsDevice _device, Effect _effect)
00039             : base(_device, _effect)
00040         {
00041             game = _game;
00042             device = _device;
00043             effect = _effect;
00044 
00045             // WorldViewProjection
00046             worldViewProjection = this.Parameters["myWorldViewProjectionMatrix"];
00047 
00048             // WorldProjection
00049             world = this.Parameters["myWorldMatrix"];
00050 
00051             // Position of Camera
00052             cameraPosition = this.Parameters["CameraPosition"];
00053 
00054             // Texture for Transferfunction
00055             transferValues = this.Parameters["Transfer"];
00056 
00057             //Texture2D representing already drawn channels
00058             backBufferValues = this.Parameters["BackBuffer"];
00059 
00060             //channel to draw
00061             channel = this.Parameters["Channel"];
00062         }
00063 
00064       
00068         public Texture2D TransferTexture
00069         {
00070             get { return transfer; }
00071             set { transfer = value; }
00072         }
00073 
00077         public Texture2D BackBuffer
00078         {
00079             get { return backBuffer; }
00080             set { backBuffer = value; }
00081         }
00082 
00083         #region SetEffectParameter
00084         
00085 
00091         public void SetEffectParameter(Matrix _worldViewProjection, Matrix _world, int channelNr)
00092         {
00093             this.worldViewProjection.SetValue(_worldViewProjection);
00094             this.world.SetValue(_world);
00095             this.transferValues.SetValue(transfer);
00096             this.channel.SetValue(channelNr);
00097             if (backBuffer != null)
00098             {
00099                 this.backBufferValues.SetValue(backBuffer);
00100             }
00101         }
00102 
00107         public void SetEffectParameter(Vector3 _cameraPosition)
00108         {
00109             this.cameraPosition.SetValue(_cameraPosition);
00110         }
00111 
00112 
00113         //set by the data itself
00123         /*public void SetEffectParameter(Texture3D _volumeTexture,
00124             Vector3 _stepSize,
00125             int _iterations,
00126             int _side,
00127             Vector4 _scaleFactor,
00128             float _slice)
00129         {
00130             this.volumeTexture.SetValue(_volumeTexture);
00131             this.stepSize.SetValue(_stepSize);
00132             this.iterations.SetValue(_iterations);
00133             this.side.SetValue(_side);
00134             this.scaleFactor.SetValue(_scaleFactor);
00135             this.frontToBack.SetValue(GameProperties.Instance.enableFrontToBackBlend);
00136             this.shading.SetValue(GameProperties.Instance.enableShading);
00137             this.useAlpha.SetValue(GameProperties.Instance.enableTransferAlphaValues);
00138             this.useTransferColors.SetValue(GameProperties.Instance.enableTransferFunction);
00139 
00140             if (front != null)
00141             {
00142                 this.frontFaces.SetValue(front);
00143             }
00144             if (back != null)
00145             {
00146                 this.backFaces.SetValue(back);
00147             }
00148             if (transfer != null)
00149             {
00150                 this.transferValues.SetValue(transfer);
00151             }
00152             if (alpha != null)
00153             {
00154                 this.transferValuesAlpha.SetValue(alpha);
00155             }
00156             this.slice.SetValue(_slice);
00157         }*/
00158         #endregion
00159     }
00160 }

Generated on Wed Jan 19 2011 21:59:17 for flowvis-2 by  doxygen 1.7.2