Exemplo n.º 1
0
        private static void ApplyMaterial(DualTextureEffect effect, Material material)
        {
            effect.DiffuseColor = material.DiffuseColor;

            if (material.Texture.IsNotNull() && effect.Texture.IsNull())
                effect.Texture = material.Texture;
        }
Exemplo n.º 2
0
 protected DualTextureEffect(DualTextureEffect cloneSource)
     : base((Effect)cloneSource)
 {
     this.CacheEffectParameters();
     this.fogEnabled         = cloneSource.fogEnabled;
     this.vertexColorEnabled = cloneSource.vertexColorEnabled;
     this.world        = cloneSource.world;
     this.view         = cloneSource.view;
     this.projection   = cloneSource.projection;
     this.diffuseColor = cloneSource.diffuseColor;
     this.alpha        = cloneSource.alpha;
     this.fogStart     = cloneSource.fogStart;
     this.fogEnd       = cloneSource.fogEnd;
 }
Exemplo n.º 3
0
        public override void LoadContent()
        {
            base.LoadContent();

            if (!_secondTextureLoaded && _secondTextureName != String.Empty)
            {
                _secondTexture = YnG.Content.Load<Texture2D>(_secondTextureName);
                _secondTextureLoaded = true;
            }

            if (!_effectLoaded)
            {
                _effect = new DualTextureEffect(YnG.GraphicsDevice);
				_effectLoaded = true;
            }
        }
 public MultipassDualTextureEffectRenderer_DualChannel(GraphicsDevice device)
 {
     _device = device;
     _basicEffect = new BasicEffect(_device)
     {
         LightingEnabled = false,
         VertexColorEnabled = true,
         TextureEnabled = true
     };
     _alphaTestEffect = new AlphaTestEffect(_device)
     {
         VertexColorEnabled = true
     };
     _dualTextureEffect = new DualTextureEffect(_device)
     {
         VertexColorEnabled = true,
     };
 }
        /// <summary>
        /// Creates a new DualTextureEffect by cloning parameter settings from an existing instance.
        /// </summary>
        protected DualTextureEffect(DualTextureEffect cloneSource)
            : base(cloneSource)
        {
            CacheEffectParameters();

            fogEnabled         = cloneSource.fogEnabled;
            vertexColorEnabled = cloneSource.vertexColorEnabled;

            world      = cloneSource.world;
            view       = cloneSource.view;
            projection = cloneSource.projection;

            diffuseColor = cloneSource.diffuseColor;

            alpha = cloneSource.alpha;

            fogStart = cloneSource.fogStart;
            fogEnd   = cloneSource.fogEnd;
        }
Exemplo n.º 6
0
 protected DualTextureEffect(DualTextureEffect cloneSource)
   : base((Effect) cloneSource)
 {
   this.CacheEffectParameters();
   this.fogEnabled = cloneSource.fogEnabled;
   this.vertexColorEnabled = cloneSource.vertexColorEnabled;
   this.world = cloneSource.world;
   this.view = cloneSource.view;
   this.projection = cloneSource.projection;
   this.diffuseColor = cloneSource.diffuseColor;
   this.alpha = cloneSource.alpha;
   this.fogStart = cloneSource.fogStart;
   this.fogEnd = cloneSource.fogEnd;
 }
        /// <summary>
        /// Prepare a BasicEffect for rendering
        /// </summary>
        /// <param name="effect"></param>
        protected void PrepareEffect(DualTextureEffect effect)
        {
            if (effect.Texture != ObjectTexture) effect.Texture = ObjectTexture;
            if (effect.Texture2 != ObjectTexture2) effect.Texture2 = ObjectTexture2;

            // Set the color and alpha
            effect.DiffuseColor = ObjectColor.ToVector3();
            effect.Alpha = (float)ObjectColor.A / 255.0f;

            // Apply the transformation matrix
            effect.World = Transformation;

            // Now the effect is ready for the derived class to actually draw the object
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new DualTextureEffect by cloning parameter settings from an existing instance.
        /// </summary>
        protected DualTextureEffect(DualTextureEffect cloneSource)
            : base(cloneSource)
        {
            CacheEffectParameters();

            fogEnabled = cloneSource.fogEnabled;
            vertexColorEnabled = cloneSource.vertexColorEnabled;

            world = cloneSource.world;
            view = cloneSource.view;
            projection = cloneSource.projection;

            diffuseColor = cloneSource.diffuseColor;

            alpha = cloneSource.alpha;

            fogStart = cloneSource.fogStart;
            fogEnd = cloneSource.fogEnd;
        }
 private void DrawModel(Model m, Matrix world, DualTextureEffect be)
 {
     foreach (ModelMesh mm in m.Meshes)
       {
     foreach (ModelMeshPart mmp in mm.MeshParts)
     {
       be.World = world;
       GraphicsDevice.SetVertexBuffer(mmp.VertexBuffer, mmp.VertexOffset);
       GraphicsDevice.Indices = mmp.IndexBuffer;
       be.CurrentTechnique.Passes[0].Apply();
       GraphicsDevice.DrawIndexedPrimitives(
       PrimitiveType.TriangleList, 0, 0,
       mmp.NumVertices, mmp.StartIndex, mmp.PrimitiveCount);
     }
       }
 }
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 /// <param name="ginfo"></param>
 /// <param name="factory"></param>
 /// <param name="obj"></param>
 public override void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj)
 {
     effect = factory.GetDualTextureEffect();            
     base.Initialize(ginfo,factory,obj);            
 }
Exemplo n.º 11
0
        private DefaultShaderType DetermineEffect( bool createNewEffect, Effect effectToTest )
        {
            #region Determine precendence between effects
            float skinningPrecedence = mPrecedenceTable["SkinnedEffect"];
            float dualTexturePrecedence = mPrecedenceTable["DualTextureEffect"];
            float environmentMappingPrecedence = mPrecedenceTable["EnvironmentMapEffect"];
            float basicEffectPrecedence = mPrecedenceTable["BasicEffect"];
            #endregion

            #region Determining the possible types of Effect

            #region Check for key information for determining possible effect types
            Texture2D tex = Texture2;
            Matrix[] transforms = BoneTransforms;
#if !MONOGAME
            TextureCube cube = CubeMap;
#endif
            if (tex == null)
            {
                dualTexturePrecedence = float.MinValue;
            }

#if !MONOGAME
            if (cube == null)
            {
                environmentMappingPrecedence = float.MinValue;
            }
#endif

            if (transforms == null)
            {
                skinningPrecedence = float.MinValue;
            }
            #endregion
                

            // Three possible outcomes. If its a lower precedence than any
            // of it's competitors, it will lose out.
            // If it's greater than the others, it will win,
            // If it's equal to one another, well in technical terms, we guess.
            // ...
            // WELCOME TO IF STATEMENT HELL
#if !MONOGAME
            #region Skinning Shader determination... Don't look. Ever.
            //... I said don't look. Sigh
            if( skinningPrecedence >= environmentMappingPrecedence )
            {
                if( skinningPrecedence >= dualTexturePrecedence )
                {
                    if( skinningPrecedence > basicEffectPrecedence )
                    {
                        if( createNewEffect )
                        {
                            // Create a skinning shader
                            mSkinnedEffect = new SkinnedEffect( FlatRedBallServices.GraphicsDevice );
                            SetSkinningEffectParameters();
                        }

                        return DefaultShaderType.Skinned;
                    }
                }
            }
            #endregion

            #region Environment Mapping Determination
            if( environmentMappingPrecedence >= dualTexturePrecedence )
            {
                if( environmentMappingPrecedence >= basicEffectPrecedence )
                {
                    if( createNewEffect )
                    {
                        // Create Environment map
                        mEnvironmentMapEffect = new EnvironmentMapEffect(FlatRedBallServices.GraphicsDevice);
                        SetEnvironmentMapEffectParameters();
                    }
                    return DefaultShaderType.EnvironmentMapped;
                }
            }
            #endregion

            #region Dual Texture determination
            if( dualTexturePrecedence >= basicEffectPrecedence )
            {
                // Create Dual Texture
                if( createNewEffect )
                {
                    mDualTextureEffect = new DualTextureEffect( FlatRedBallServices.GraphicsDevice );
                    SetDualTextureEffectParameters();
                }
                return DefaultShaderType.DualTexture;
            }
            #endregion
#endif

            #region Basic Shader determination
             // Create a basic Shader
            if( createNewEffect )
            {
                mBasicEffect = new BasicEffect(FlatRedBallServices.GraphicsDevice);
                SetBasicEffectParameters();
            }

            return DefaultShaderType.Basic;

            #endregion
        #endregion
        }
Exemplo n.º 12
0
        public GenericEffect( Effect effectToAssimilate )
            :this()
        {
            /*
            DefaultShaderType type = DetermineEffect( false, effectToAssimilate );
            if( type == DefaultShaderType.Basic )
            {
                mBasicEffect = (BasicEffect)effectToAssimilate;
            }
            else if( type == DefaultShaderType.DualTexture )
            {
                mDualTextureEffect = (DualTextureEffect)effectToAssimilate;
            }
            else if( type == DefaultShaderType.EnvironmentMapped )
            {
                mEnvironmentMapEffect = (EnvironmentMapEffect)effectToAssimilate;
            }
            else if( type == DefaultShaderType.Skinned )
            {
                mSkinnedEffect = (SkinnedEffect)effectToAssimilate;
            }
            */
            if ( effectToAssimilate is BasicEffect )
            {
                mBasicEffect = effectToAssimilate as BasicEffect;
            }
            else if (effectToAssimilate is AlphaTestEffect)
            {
                mAlphaTestEffect = effectToAssimilate as AlphaTestEffect;
            }
#if !MONOGAME

            else if (effectToAssimilate is DualTextureEffect)
            {
                mDualTextureEffect = effectToAssimilate as DualTextureEffect;
            }
            else if (effectToAssimilate is EnvironmentMapEffect)
            {
                mEnvironmentMapEffect = effectToAssimilate as EnvironmentMapEffect;
            }
            else if (effectToAssimilate is SkinnedEffect)
            {
                mSkinnedEffect = effectToAssimilate as SkinnedEffect;
            }
#endif
        }
Exemplo n.º 13
0
        public GenericEffect( DefaultShaderType type )
            :this()
        {
            if( type != DefaultShaderType.Determine )
            {
                if( type == DefaultShaderType.Basic )
                {
                    mBasicEffect = new BasicEffect( FlatRedBallServices.GraphicsDevice );
                }

                else if (type == DefaultShaderType.AlphaTest)
                {
                    mAlphaTestEffect = new AlphaTestEffect(FlatRedBallServices.GraphicsDevice);
                }

                else if (type == DefaultShaderType.DualTexture)
                {
#if MONOGAME
                    throw new NotImplementedException();
#else
                    mDualTextureEffect = new DualTextureEffect(FlatRedBallServices.GraphicsDevice);
#endif
                }

                else if (type == DefaultShaderType.EnvironmentMapped)
                {
#if MONOGAME
                    throw new NotImplementedException();
#else
                    mEnvironmentMapEffect = new EnvironmentMapEffect(FlatRedBallServices.GraphicsDevice);
#endif
                }

                else if (type == DefaultShaderType.Skinned)
                {
#if MONOGAME
                    throw new NotImplementedException();
#else
                    mSkinnedEffect = new SkinnedEffect(FlatRedBallServices.GraphicsDevice);
#endif
                }
            }
        }