Inheritance: GraphicsResource
Example #1
0
 public void InitWithTextureBlock(Texture.TexturePacket.TextureBlock tb)
 {
     block = tb;
     seedsize.X = (float)tb.parent.texture.Width * tb.uv.Width;
     seedsize.Y = (float)tb.parent.texture.Height * tb.uv.Height;
     seedorient = new Vector2(0, 0);
 }
Example #2
0
 public RenderTargetBinding(RenderTarget2D renderTarget)
 {
   if (renderTarget == null)
     throw new ArgumentNullException("renderTarget");
   this._renderTarget = (Texture) renderTarget;
   this.isTargetCube = false;
 }
Example #3
0
 public static int GetIdFromCharacterWorldTexture(Texture tex)
 {
     if (tex == MCGirlWorld) return 1;
     if (tex == MCBoyWorld) return 2;
     if (tex == ChristmanWorld) return 3;
     return 0;
 }
        }         // Reload()

        #endregion

        #region Reset parameters
        /// <summary>
        /// Reset parameters
        /// </summary>
        protected virtual void ResetParameters()
        {
            lastUsedInverseViewMatrix = Matrix.Identity;
            lastUsedScale             = 0.0f;
            lastUsedAmbientColor      = ColorHelper.Empty;
            lastUsedDiffuseTexture    = null;
        }         // ResetParameters()
Example #5
0
 public override void Draw(GameTime gameTime)
 {
   if (this.RtHandle != null && this.TargetRenderer.IsHooked(this.RtHandle.Target))
   {
     this.TargetRenderer.Resolve(this.RtHandle.Target, false);
     this.capturedScreen = (Texture) this.RtHandle.Target;
     if (this.ScreenCaptured != null)
       this.ScreenCaptured();
   }
   GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Always, StencilMask.None);
   if (this.capturedScreen != null)
   {
     SettingsManager.SetupViewport(this.GraphicsDevice, false);
     this.TargetRenderer.DrawFullscreen(this.capturedScreen);
   }
   this.Elapsed += gameTime.ElapsedGameTime;
   float num = (float) this.Elapsed.TotalSeconds / this.Duration;
   float amount = FezMath.Saturate(this.EaseOut ? Easing.EaseOut((double) num, this.EasingType) : Easing.EaseIn((double) num, this.EasingType));
   if ((double) amount == 1.0 && (this.WaitUntil == null || this.WaitUntil()))
   {
     if (this.Faded != null)
     {
       this.Faded();
       this.Faded = (Action) null;
     }
     this.WaitUntil = (Func<bool>) null;
     ServiceHelper.RemoveComponent<ScreenFade>(this);
   }
   this.TargetRenderer.DrawFullscreen(Color.Lerp(this.FromColor, this.ToColor, amount));
 }
Example #6
0
 public RenderTargetBinding(RenderTarget2D renderTarget)
 {
   if (renderTarget == null)
     throw new ArgumentNullException("renderTarget");
   this._renderTarget = (Texture) renderTarget;
   this._cubeMapFace = CubeMapFace.PositiveX;
 }
Example #7
0
        public Player( GamerEntity owner, string entityName, Vector3 position, float orientation)
            : base("characters", entityName, position, orientation, Color.White, 0)
        {
            this.owner = owner;

            entityState = tEntityState.Active;
            setCollisions();

            // life stuff
            initializeLifeStuff();

            // actions stuff
            fastShotCooldownTime = 0.0f;
            dashCooldownTime = 0.0f;
            dashVelocity = Vector2.Zero;
            dashParticleTimer = 0.0f;
            bigShotChargeTimer = 0.0f;
            bigShotCharging = false;
            bigShotCooldownTime = 0.0f;

            mode = tMode.Arcade;

            if (bigShotBall == null) bigShotBall = TextureManager.Instance.getTexture("projectiles/bigShotPlayer");
            if (starXP == null) starXP = TextureManager.Instance.getTexture("GUI/menu/starXP");
            if (garlicGunTexture == null) garlicGunTexture = TextureManager.Instance.getTexture("characters/garlicGun");
            if (garlicGunBandTexture == null) garlicGunBandTexture = TextureManager.Instance.getTexture("characters/garlicGunBand");
            if (wishLife == null) wishLife = TextureManager.Instance.getTexture("GUI/ingame/wishLife");
            if (wishLifePortion == null) wishLifePortion = TextureManager.Instance.getTexture("GUI/ingame/wishLifePortion");
            if (wishLifePortionEmpty == null) wishLifePortionEmpty = TextureManager.Instance.getTexture("GUI/ingame/wishLifePortionEmpty");
        }
Example #8
0
 public Munitions(Rectangle position, Texture2D texture, Direction direction, int spriteWidth, int spriteHeigth)
     : base(PlayerType.Munition, spriteWidth, spriteHeigth)
 {
     this.Hitbox = position;
     this.texture = texture;
     this.Direction = direction;
 }
 public GUIElement(Vector2 min, Vector2 max, Texture image, Vector4 color)
 {
     Color = color;
     ScaleOffset = Vector4.Zero;
     Image = image;
     SetDimensions(min, max);
 }
Example #10
0
 public void InitWithSeed(Seed seed, Texture.TextureMgr tmgr)
 {
     var block = tmgr.GetTexture(seed.texname);
     tex = block.parent.texture;
     srcuv = block.uv;
     seedsize = seed.size;
     seedorient = seed.orient;
 }
Example #11
0
 public void LoadContent()
 {
     if (!String.IsNullOrEmpty(_fileName))
     {
         _baseTexture = EngineManager.Game.Content.Load<Texture>(_fileName);
         _readyToRender = true;
     }
 }
 public GUIElement(Vector2 min, Vector2 max, Texture image, Vector3 color)
 {
     Color = new Vector4(color,1.0f);
     ScaleOffset = Vector4.Zero;
     Image = image;
     UseAlphaOnly = false;
     SetDimensions(min, max);
 }
 public GUIElementTC(Vector2 min, Vector2 max, Texture image, Vector2 minTC, Vector2 maxTC)
 {
     Color = Vector4.One;
     ScaleOffset = Vector4.Zero;
     TCMinMax = new Vector4(minTC.X, minTC.Y, maxTC.X, maxTC.Y);
     Image = image;
     SetDimensions(min, max);
 }
 public GUIElement(Vector2 min, Vector2 max, Texture image, Vector4 color, bool useAlphaOnly)
 {
     Color = color;
     ScaleOffset = Vector4.Zero;
     Image = image;
     UseAlphaOnly = useAlphaOnly;
     SetDimensions(min, max);
 }
Example #15
0
 public static void Init()
 {
     Color[] colors = new Color[1];
     colors[0] = new Color(255, 255, 255, 255);
     Texture2D tempTexture = new Texture2D(Stator.device, 1, 1, false, SurfaceFormat.Color);
     tempTexture.SetData(colors);
     particleTexture = new Graphics.Texture("#ParticleTexture", tempTexture);
 }
		public RenderTargetBinding (RenderTarget2D renderTarget)
			{
			if (renderTarget == null) {
				throw new ArgumentNullException ("renderTarget");
			}
			_renderTarget = renderTarget;
			isTargetCube = false;
		}
Example #17
0
		public RenderTargetBinding(RenderTarget2D renderTarget)
		{
			if (renderTarget == null) 
				throw new ArgumentNullException("renderTarget");

			_renderTarget = renderTarget;
            _arraySlice = (int)CubeMapFace.PositiveX;
		}
 public GUIElement(Vector2 min, Vector2 max, Texture image)
 {
     Color = Vector4.One;
     ScaleOffset = Vector4.Zero;
     Image = image;
     UseAlphaOnly = false;
     SetDimensions(min, max);
 }
 public BillboardRenderComponent(Actor owner)
     : base(owner)
 {
     Effect = null;
     mDepthOnlyEffect = null;
     mTexture = null;
     mGeometry = null;
     mCurrentTime = 0.0f;
 }
Example #20
0
 public RenderTargetBinding(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
 {
   if (renderTarget == null)
     throw new ArgumentNullException("renderTarget");
   if (cubeMapFace < CubeMapFace.PositiveX || cubeMapFace > CubeMapFace.NegativeZ)
     throw new ArgumentOutOfRangeException("cubeMapFace");
   this._renderTarget = (Texture) renderTarget;
   this._cubeMapFace = cubeMapFace;
 }
Example #21
0
        public RenderTargetBinding(RenderTarget2D renderTarget)
        {
            if (renderTarget == null)
            {
                throw new ArgumentNullException("renderTarget");
            }

            this.renderTarget = renderTarget;
            cubeMapFace = CubeMapFace.PositiveX;
        }
Example #22
0
        public RenderTargetBinding(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
        {
            if (renderTarget == null)
                throw new ArgumentNullException("renderTarget");
            if (cubeMapFace < CubeMapFace.PositiveX || cubeMapFace > CubeMapFace.NegativeZ)
                throw new ArgumentOutOfRangeException("cubeMapFace");

            _renderTarget = renderTarget;
            _arraySlice = (int)cubeMapFace;
        }
Example #23
0
 /// <summary>
 /// Set value helper to set an effect parameter.
 /// </summary>
 /// <param name="param">Param</param>
 /// <param name="lastUsedValue">Last used value</param>
 /// <param name="newValue">New value</param>
 private static void SetValue(EffectParameter param,
                              ref XnaTexture lastUsedValue, XnaTexture newValue)
 {
     if (param != null &&
         lastUsedValue != newValue)
     {
         lastUsedValue = newValue;
         param.SetValue(newValue);
     }
 }
Example #24
0
 protected override void Dispose(bool disposing)
 {
   base.Dispose(disposing);
   if (this.RtHandle != null)
   {
     this.TargetRenderer.ReturnTarget(this.RtHandle);
     this.RtHandle = (RenderTargetHandle) null;
   }
   this.Faded = (Action) null;
   this.ScreenCaptured = (Action) null;
   this.WaitUntil = (Func<bool>) null;
   this.capturedScreen = (Texture) null;
   this.IsDisposed = true;
 }
Example #25
0
        public void Initialize(Player player, Texture2D textura, Texture texturaFrameProyectil, float daño, Vector2 pos, Vector2 incremento, Colision colision)
        {
            _player = player;
            _textura = textura;
            _daño = (int)daño;
            _pos = pos;
            _colision = colision;
            _incremento = incremento;

            //Datos de color de la textura
            _texturaFrame = textura;
            textureData = new Color[_texturaFrame.Width * _texturaFrame.Height];
            _texturaFrame.GetData(textureData);
        }
Example #26
0
 public override void DrawVertices(VerticesMode mode, VertexPositionColorTextured[] vertices)
 {
     CheckCreatePositionColorTextureBuffer();
     positionColorUvVertexBuffer.SetData(vertices, 0, vertices.Length, SetDataOptions.Discard);
     BindVertexBuffer(positionColorUvVertexBuffer);
     if (lastTexture != device.NativeDevice.Textures[0])
     {
         ApplyEffect(true);
         lastTexture = device.NativeDevice.Textures[0];
     }
     if (lastIndicesCount == -1)
         DoDraw(mode, vertices.Length);
     else
         DoDrawIndexed(mode, vertices.Length, lastIndicesCount);
 }
Example #27
0
 public override void Draw(GameTime gameTime)
 {
     if (this.effect == null)
     {
         this.effect = this.Game.Content.Load<Effect>("Shaders/LightSourceMask");
         this.lishsourceTexture = this.Game.Content.Load<Texture2D>(this.lightSourceasset);
     }
     this.effect.Parameters["screenRes"].SetValue(new Vector2(16f, 9f));
     this.effect.Parameters["halfPixel"].SetValue(this.HalfPixel);
     this.effect.CurrentTechnique = this.effect.Techniques["LightSourceMask"];
     this.effect.Parameters["flare"].SetValue(this.lishsourceTexture);
     this.effect.Parameters["SunSize"].SetValue(this.lightSize);
     this.effect.Parameters["lightScreenPosition"].SetValue(this.lighScreenSourcePos);
     base.Draw(gameTime);
 }
        public override void Initialize(ContentManager contentLoader, ComponentManifest manifest)
        {
            Effect genericEffect = contentLoader.Load<Effect>("shaders\\PhongShadow");

            // If we have several of these objects, the content manager will return
            // a single shared effect instance to them all. But we want to preconfigure
            // the effect with parameters that are specific to this particular
            // object. By cloning the effect, we prevent one
            // from stomping over the parameter settings of another.

            Effect = genericEffect.Clone();
            mTexture = contentLoader.Load<Texture>((string)(manifest.Properties[ManifestKeys.TEXTURE]));

            base.Initialize(contentLoader, manifest);
        }
Example #29
0
        public XnaHardwarePixelBuffer(BufferUsage usage)
            : base(0, 0, 0, PixelFormat.Unknown, usage, false, false)
        {
            device      = null;
            surface     = null;
            tempSurface = null;
#if !SILVERLIGHT
            volume     = null;
            tempVolume = null;
#endif
            doMipmapGen = false;
            HWMipmaps   = false;
            mipTex      = null;
            sliceTRT    = new List <RenderTexture>();
        }
        /// <summary>
        /// This is called after the scene has been rendered to actually perform the post processing effect.
        /// The base implementation simply calls SceneRenderer.RenderManager.RenderQuad, passing it the
        /// material, position, and size to use for rendering.
        /// </summary>
        /// <param name="texture">The texture containing the rendered scene.</param>
        /// <param name="position">The position on the screen to render at.</param>
        /// <param name="size">The size of the quad to render.</param>
        public virtual void Run(Texture texture, Vector2 position, Vector2 size)
        {
            if (_material == null)
            {
                TorqueConsole.Warn("\nPostProcessor.Run - Cannot perform post processing. No material.");
                return;
            }

            GFXDevice.Instance.Device.RenderState.AlphaBlendEnable = false;

            _material.Texture = texture;
            SceneRenderer.RenderManager.RenderQuad(_material, position, size);

            GFXDevice.Instance.Device.RenderState.AlphaBlendEnable = true;
        }
Example #31
0
        public QuadTree(Game game, Vector3 position, Matrix view, Matrix projection)
        {
            this.graphicsDevice = game.GraphicsDevice;
            this.position = position;
            effect = game.Content.Load<Effect>("Multitexture");
            sand = game.Content.Load<Texture>("Dirt cracked 00 seamless");
            grass = game.Content.Load<Texture>("grass0026_1_l2");
            rock = game.Content.Load<Texture>("Tileable stone texture (2)");
            snow = game.Content.Load<Texture>("snow");

            View = view;
            Projection = projection;

            InitializeEffect();
        }
Example #32
0
        public void DrawSprite(Matrix trans, Texture tex, Vector2 ll, Vector2 ur)
        {
            VertexPositionTexture[] drawBox = MakeBox(ll, ur);

            effect.CurrentTechnique = techniqueBasicTexturedRender;
            paramViewMatrix.SetValue(trans * ortho);
            paramBoundTexture.SetValue(tex);
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes) {
                pass.Begin();
                graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaration(graphics.GraphicsDevice, VertexPositionTexture.VertexElements);
                graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleFan, drawBox, 0, 2);
                pass.End();
            }
            effect.End();
        }
        public void ThreadPoolCallback(Object threadContext)
        {
            if (this.texture.IsDisposed == false)
            {
                try
                {
                    Global.RemoveTexture(this.texture);
                    this.texture.Dispose();
                }
                catch(Exception e)
                {
                    Trace.WriteLine("Exception caught disposing of texture: " + e.ToString(), "TextureUse");
                }
            }

            this.texture = null;
        }
        }         // SetParameters()

        /// <summary>
        /// Set parameters, this overload sets all material parameters too.
        /// </summary>
        public virtual void SetParametersOptimizedGeneral()
        {
            if (worldViewProj != null)
            {
                worldViewProj.SetValue(BaseGame.WorldViewProjectionMatrix);
            }
            if (viewProj != null)
            {
                viewProj.SetValue(BaseGame.ViewProjectionMatrix);
            }
            if (world != null)
            {
                world.SetValue(BaseGame.WorldMatrix);
            }
            if (viewInverse != null)
            {
                viewInverse.SetValue(BaseGame.InverseViewMatrix);
            }
            if (lightDir != null)
            {
                lightDir.SetValue(BaseGame.LightDirection);
            }

            // Set the reflection cube texture only once
            if (lastUsedReflectionCubeTexture == null &&
                reflectionCubeTexture != null)
            {
                ReflectionCubeTexture = BaseGame.skyCube.SkyCubeMapTexture;
            }             // if (lastUsedReflectionCubeTexture)

            // This shader is used for MeshRenderManager and we want all
            // materials to be opacque, else hotels will look wrong.
            //obs: AlphaFactor = 1.0f;

            // lastUsed parameters for colors and textures are not used,
            // but we overwrite the values in SetParametersOptimized.
            // We fix this by clearing all lastUsed values we will use later.
            lastUsedAmbientColor   = ColorHelper.Empty;
            lastUsedDiffuseColor   = ColorHelper.Empty;
            lastUsedSpecularColor  = ColorHelper.Empty;
            lastUsedDiffuseTexture = null;
            lastUsedNormalTexture  = null;
        }         // SetParametersOptimizedGeneral()
Example #35
0
        /// <summary>
        /// Set parameters, this overload sets all material parameters too.
        /// </summary>
        public virtual void SetParametersOptimizedGeneral()
        {
            if (worldViewProj != null)
            {
                worldViewProj.SetValue(BaseGame.WorldViewProjectionMatrix);
            }
            if (viewProj != null)
            {
                viewProj.SetValue(BaseGame.ViewProjectionMatrix);
            }
            if (world != null)
            {
                world.SetValue(BaseGame.WorldMatrix);
            }
            if (viewInverse != null)
            {
                viewInverse.SetValue(BaseGame.InverseViewMatrix.Translation);
            }
            if (lightDir != null)
            {
                lightDir.SetValue(BaseGame.LightDirection);
            }

            // Set the reflection cube texture only once
            if (lastUsedReflectionCubeTexture == null &&
                reflectionCubeTexture != null)
            {
                ReflectionCubeTexture = BaseGame.UI.SkyCubeMapTexture;
            }

            // lastUsed parameters for colors and textures are not used,
            // but we overwrite the values in SetParametersOptimized.
            // We fix this by clearing all lastUsed values we will use later.
            lastUsedAmbientColor   = ColorHelper.Empty;
            lastUsedDiffuseColor   = ColorHelper.Empty;
            lastUsedSpecularColor  = ColorHelper.Empty;
            lastUsedDiffuseTexture = null;
            lastUsedNormalTexture  = null;
        }
Example #36
0
 internal void SetMipmapping(bool doMipmapGen, bool MipmapsHardwareGenerated, Texture texture)
 {
     this.doMipmapGen = doMipmapGen;
     HWMipmaps        = MipmapsHardwareGenerated;
     mipTex           = texture;
 }