コード例 #1
0
ファイル: Triple.cs プロジェクト: gitter-badger/blimey
        public static Triple Create(Vector3 a, Vector3 b, Vector3 c, Rgba32 colour)
        {
            var t = new Triple ();
            t.v = new [] {
                new VertexPositionTextureColour (a, new Vector2 (0, 0), colour),
                new VertexPositionTextureColour (b, new Vector2 (0, 1), colour),
                new VertexPositionTextureColour (c, new Vector2 (1, 0), colour),
            };
            t.blend = BlendMode.Default;
            t.tex = null;

            return t;
        }
コード例 #2
0
ファイル: Scene_Particles.cs プロジェクト: dreamsxin/engine-1
        public override void Start()
        {
            //var meshAsset = Engine.Assets.Load <MeshAsset> ();

            //var vb = Platform.Graphics.CreateVertexBuffer (meshAsset.VertexDeclaration, meshAsset.VertexCount);
            //vb.SetData <REFLECTION> ()

            var ta = Engine.Assets.Load <TextureAsset> ("assets/cvan01.bba");
            tex1 = Platform.Graphics.CreateTexture (ta);
            var tb = Engine.Assets.Load <TextureAsset> ("assets/bg2.bba");
            tex2 = Platform.Graphics.CreateTexture (tb);

            q = new Triple ();
            q.blend = BlendMode.Default;
            q.tex = tex1;
            q.v [0].Colour = Rgba32.Blue;
            q.v [0].Position.X = 0.0f;
            q.v [0].Position.Y = 0.0f;
            q.v [0].UV = new Vector2 (0, 0);
            q.v [1].Colour = Rgba32.Green;
            q.v [1].Position.X = 0.5f;
            q.v [1].Position.Y = 0.5f;
            q.v [1].UV = new Vector2 (1f, 1f);
            q.v [2].Colour = Rgba32.Red;
            q.v [2].Position.X = 0f;
            q.v [2].Position.Y = 0.5f;
            q.v [2].UV = new Vector2 (0, 1f);
            returnScene = this;

            s = new SpritePrimitive (this.Engine.PrimitiveRenderer, tex2, 64, 64, 256, 256);
            s.SetBlendMode (BlendMode.Default);

            var psi = new PrimitiveParticleSystemInfo ();
            psi.sprite = s;
            psi.fLifetime = 3f;
            psi.colColourStart = Rgba32.Red;
            psi.colColourEnd = Rgba32.Yellow;
            psi.nEmission = 10;
            psi.fSpinStart = 0.3f;
            psi.fRadialAccel = 0.1f;
            psi.fSpeed = 3f;
            psi.fSizeVar = 0.1f;

            ps = new PrimitiveParticleSystem (psi);
        }
コード例 #3
0
        public void AddTriple(String pass, Triple zTriple)
        {
            if (!passState.ContainsKey (pass))
                passState [pass] = new RenderPassState ();

            if (passState[pass].currentPrimitiveType != Type.PRIM_TRIPLES
                || passState[pass].nPrimsInBuffer >= VERT_BUFFER_SIZE / (uint)Type.PRIM_TRIPLES
                || passState[pass].currentTexture != zTriple.tex
                || passState[pass].currentBlendMode != zTriple.blend)
            {
                if (passState[pass].nPrimsInBuffer > 0)
                    _enqueue_batch (pass);

                passState[pass].currentPrimitiveType = Type.PRIM_TRIPLES;
                passState[pass].currentBlendMode = zTriple.blend;
                passState[pass].currentTexture = zTriple.tex;
            }

            uint offset = passState[pass].nPrimsInBuffer * (uint)Type.PRIM_TRIPLES;

            for (uint i = 0; i < 3; ++i)
            {
                passState[pass].vertBuffer[i + offset].Position.X = zTriple.v[i].Position.X;
                passState[pass].vertBuffer[i + offset].Position.Y = zTriple.v[i].Position.Y;
                passState[pass].vertBuffer[i + offset].Position.Z = zTriple.v[i].Position.Z;
                passState[pass].vertBuffer[i + offset].Colour = zTriple.v[i].Colour;
                passState[pass].vertBuffer[i + offset].UV.X = zTriple.v[i].UV.X;
                passState[pass].vertBuffer[i + offset].UV.Y = zTriple.v[i].UV.Y;
            }
            passState[pass].nPrimsInBuffer++;
        }
コード例 #4
0
        public override void Start()
        {
            var ta = Engine.Assets.Load <TextureAsset> ("assets/blimey_fnt_tex.bba");
            tex = Platform.Graphics.CreateTexture (ta);
            q = new Triple ();
            q.blend = BlendMode.Default;
            q.tex = tex;
            q.v [0].Colour = Rgba32.Blue;
            q.v [0].Position.X = -0.5f;
            q.v [0].Position.Y = 0f;
            q.v [0].UV = new Vector2 (0, 1);
            q.v [1].Colour = Rgba32.Green;
            q.v [1].Position.X = 0f;
            q.v [1].Position.Y = 0.5f;
            q.v [1].UV = new Vector2 (1, 0);
            q.v [2].Colour = Rgba32.Red;
            q.v [2].Position.X = -0.5f;
            q.v [2].Position.Y = 0.5f;
            q.v [2].UV = new Vector2 (0, 0);

            _returnScene = this;

            CommonDemoResources.Create (Platform, Engine);

            this.Configuration.BackgroundColour = _startCol;
            var teaPotModel = new TeapotPrimitive(this.Platform.Graphics);

            var so1 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so2 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so3 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so4 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so5 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so6 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so7 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);
            var so8 = RandomObjectHelper.CreateShapeGO(this, "Gui", teaPotModel.Mesh, 1);

            so1.Transform.LocalPosition = new Vector3(-0.35f, 0f, 0f);
            so2.Transform.LocalPosition = new Vector3(-0.25f, 0f, 0f);
            so3.Transform.LocalPosition = new Vector3(-0.15f, 0f, 0f);
            so4.Transform.LocalPosition = new Vector3(-0.05f, 0f, 0f);
            so5.Transform.LocalPosition = new Vector3(+0.05f, 0f, 0f);
            so6.Transform.LocalPosition = new Vector3(+0.15f, 0f, 0f);
            so7.Transform.LocalPosition = new Vector3(+0.25f, 0f, 0f);
            so8.Transform.LocalPosition = new Vector3(+0.35f, 0f, 0f);

            _menuItemMaterials.Add(so1.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so2.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so3.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so4.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so5.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so6.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so7.GetTrait<MeshRendererTrait>().Material);
            _menuItemMaterials.Add(so8.GetTrait<MeshRendererTrait>().Material);

            _menuSceneObjects.Add(so1);
            _menuSceneObjects.Add(so2);
            _menuSceneObjects.Add(so3);
            _menuSceneObjects.Add(so4);
            _menuSceneObjects.Add(so5);
            _menuSceneObjects.Add(so6);
            _menuSceneObjects.Add(so7);
            _menuSceneObjects.Add(so8);

            this.Engine.InputEventSystem.Tap += this.OnTap;
            this.Engine.InputEventSystem.Flick += this.OnFlick;
        }