Esempio n. 1
0
        public void Initialize(Entity entity)
        {
            _triggerFlag = entity as TriggerFlag;
            SimpleMaterial material = new SimpleMaterial();
            material.IsTranslucent = true;
            material.IsColorBlended = true;

            switch (_team)
            {
                case GameManager.GameManager.Teams.Blue:
                    Name = "Flag0";
                    material.TextureFilename = @"data\images\MindCrafters\blueFlag";
                    Material = material;
                    break;
                case GameManager.GameManager.Teams.Red:
                    Name = "Flag1";
                    material.TextureFilename = @"data\images\MindCrafters\redFlag";
                    Material = material;
                    break;
                case GameManager.GameManager.Teams.Green:
                    Name = "Flag2";
                    material.TextureFilename = @"data\images\MindCrafters\greenFlag";
                    Material = material;
                    break;
                case GameManager.GameManager.Teams.Yellow:
                    Name = "Flag3";
                    material.TextureFilename = @"data\images\MindCrafters\yellowFlag";
                    Material = material;
                    break;
            }
            //set the size of the model in the scene
            Layer = 30;
            Size = new Vector2(16, 16);
        }
        public T2DPolygon()
        {
            // by default, we'll have physics and collision
            CreateWithCollision = true;
            CreateWithPhysics = true;

            GarageGames.Torque.Materials.SimpleMaterial seffect = new GarageGames.Torque.Materials.SimpleMaterial();
            _material = seffect;
        }
        public override void Dispose()
        {
            if (_copyMaterial != null)
            {
                _copyMaterial.Dispose();
                _copyMaterial = null;
            }

            #if DEBUG
            _renderProfileBlock = null;
            #endif
            _refractionTexture = null;
            _zPassMaterial = null;

            base.Dispose();
        }
Esempio n. 4
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _wall = entity as Wall;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\crate";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 30;
            IsTemplate = false;
            Size = new Vector2(8, 8);
        }
Esempio n. 5
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _graveMarker = entity as GraveMarker;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\gravestoneRIP";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 30;
            IsTemplate = false;
            Size = new Vector2(32, 32)*2;
        }
Esempio n. 6
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _projectilePellet = entity as ProjectilePellet;

            //Material =
            //   TorqueObjectDatabase.Instance.FindObject("bulletMaterial")
            //   as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename = @"data\images\GarageGames\bullet";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 0;
            IsTemplate = false;
            Size = new Vector2(4, 4);
        }
Esempio n. 7
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _triggerHealthGiver = entity as TriggerHealthGiver;

            //Material =
            //    TorqueObjectDatabase.Instance.FindObject("healthKitMaterial")
            //    as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\GarageGames\healthKit";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 30;
            IsTemplate = false;
            Size = new Vector2(16, 16);
        }
Esempio n. 8
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _triggerWeaponGiver = entity as TriggerWeaponGiver;

            //Material =
            //   TorqueObjectDatabase.Instance.FindObject("remingtonMaterial")
            //   as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\remington";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 30;
            IsTemplate = false;
            Size = new Vector2(32, 32);
        }
Esempio n. 9
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _projectileSlug = entity as ProjectileSlug;

            //Material =
            //   TorqueObjectDatabase.Instance.FindObject("RedBallMaterial")
            //   as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\RedBall";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 0;
            IsTemplate = false;
            Size = new Vector2(8, 8);
        }
Esempio n. 10
0
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _door = entity as Door;

            //Material =
            //   TorqueObjectDatabase.Instance.FindObject("corrodedMetalMaterial")
            //   as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\corrodedMetal";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;

            Layer = 30;
            IsTemplate = false;
            Size = new Vector2(16, 16);
        }
        public override void RenderTranslucentPass(SceneRenderState srs)
        {
            // Make sure we have something to render.
            if (_elementList.Count == 0 ||
                    srs.IsReflectPass ||
                    GFXDevice.Instance.ShaderProfile < ShaderProfile.PS_1_4)
                return;

            // Get the current render target which contains the state
            // of the scene rendered so far.
            RenderTarget2D sceneTarget = GFXDevice.Instance.Device.GetRenderTarget(0) as RenderTarget2D;
            if (sceneTarget == null)
                return;

            #if DEBUG
            Profiler.Instance.StartBlock(_renderProfileBlock);
            #endif

            // So here we're making a copy of the current state of the
            // active scene render target for use in the refraction effect.

            // Prepare the copy material if we don't have one.
            if (_copyMaterial == null)
            {
                _copyMaterial = new SimpleMaterial();
                _copyMaterial.IsCopyPass = true;
            }

            // Copy the content of the current scene render target to
            // the refraction texture.
            GFXDevice.Instance.Device.SetRenderTarget(0, null);
            _refractionTexture = sceneTarget.GetTexture();

            // Now set back the scene render target.
            //
            // At this point the act of switching render targets has
            // forced the content to be lost.  To fix that we do a
            // copy to get the original content back.
            //
            _copyMaterial.SetTexture(_refractionTexture);
            TorqueEngineComponent.Instance.ReapplyMainRenderTarget();
            SceneRenderer.RenderManager.RenderQuad(_copyMaterial, Vector2.Zero, new Vector2(sceneTarget.Width, sceneTarget.Height));

            // Now render all the refraction meshes.
            base.RenderOpaquePass(srs);

            #if DEBUG
            Profiler.Instance.EndBlock(_renderProfileBlock);
            #endif
        }
        void _RenderTileBounds(SceneRenderState srs, ref Matrix objToWorld, T2DTileObject tile)
        {
            int numVerts = tile.TileType.CollisionPolyBasis.Length + 1;
            if (tile.TileType._collisionPolyVB.IsNull)
            {
                int sizeInBytes = numVerts * GFXVertexFormat.VertexSize;
                tile.TileType._collisionPolyVB = ResourceManager.Instance.CreateDynamicVertexBuffer(ResourceProfiles.ManualStaticVBProfile, sizeInBytes);

                // fill in vertex array
                GFXVertexFormat.PCTTBN[] pVertices = TorqueUtil.GetScratchArray<GFXVertexFormat.PCTTBN>(numVerts);
                for (int k = 0; k < numVerts - 1; ++k)
                {
                    pVertices[k] = new GFXVertexFormat.PCTTBN();
                    pVertices[k].Position = new Vector3(tile.TileType.CollisionPolyBasis[k].X, tile.TileType.CollisionPolyBasis[k].Y, 0.0f);
                    pVertices[k].Color = Color.Green;
                }
                pVertices[numVerts - 1] = pVertices[0];

                tile.TileType._collisionPolyVB.Instance.SetData<GFXVertexFormat.PCTTBN>(pVertices, 0, numVerts);
            }

            srs.World.Push();
            srs.World.MultiplyMatrixLocal(objToWorld);
            float flipx = tile.FlipX ? -1.0f : 1.0f;
            float flipy = tile.FlipY ? -1.0f : 1.0f;
            srs.World.MultiplyMatrixLocal(Matrix.CreateScale(new Vector3(flipx, flipy, 1.0f)));

            if (_effect == null)
            {
                _effect = new GarageGames.Torque.Materials.SimpleMaterial();
            }

            RenderInstance ri = SceneRenderer.RenderManager.AllocateInstance();
            ri.Type = RenderInstance.RenderInstanceType.Mesh2D;
            ri.ObjectTransform = srs.World.Top;
            ri.VertexBuffer = tile.TileType._collisionPolyVB.Instance;
            ri.PrimitiveType = PrimitiveType.LineStrip;
            ri.VertexSize = GFXVertexFormat.VertexSize;
            ri.VertexDeclaration = GFXVertexFormat.GetVertexDeclaration(srs.Gfx.Device);
            ri.VertexCount = numVerts;
            ri.BaseVertex = 0;
            ri.PrimitiveCount = numVerts - 1;

            ri.UTextureAddressMode = TextureAddressMode.Clamp;
            ri.VTextureAddressMode = TextureAddressMode.Clamp;

            ri.Material = _effect;
            SceneRenderer.RenderManager.AddInstance(ri);

            srs.World.Pop();
        }
Esempio n. 13
0
        ///<summary>
        ///Change material to represent door trigger in closed state
        ///</summary>
        public void SetClosed()
        {
            //Material =
            //    TorqueObjectDatabase.Instance.FindObject("RedSquareMaterial")
            //    as SimpleMaterial;

            SimpleMaterial simpleMaterial = new SimpleMaterial();
            simpleMaterial.TextureFilename =
                @"data\images\Mindcrafters\RedSquare";
            simpleMaterial.IsTranslucent = true;
            simpleMaterial.IsColorBlended = true;

            Material = simpleMaterial;
        }