コード例 #1
0
        protected override void OnDraw(ref Matrix4 world)
        {
            var cam = ScopedObject.Find <Camera> ();

            if (cam == null)
            {
                throw new InvalidOperationException("There is no active camera.");
            }

            var mat = ScopedObject.Find <Material>();

            if (mat == null)
            {
                using (_material.Begin()) {
                    cam.Apply(ref world);
                    using (_vbuffer.Begin()) {
                        _ibuffer.Draw(_ioffset, _icount);
                    }
                }
            }
            else
            {
                cam.Apply(ref world);
                using (_vbuffer.Begin()) {
                    _ibuffer.Draw(_ioffset, _icount);
                }
            }
        }
コード例 #2
0
ファイル: Batch.cs プロジェクト: Milstein/GameStack
        protected override void OnEnd()
        {
            var cam = ScopedObject.Find <Camera>();

            if (cam == null)
            {
                throw new InvalidOperationException("There is no active camera.");
            }

            if (_vbuffer == null || _ibuffer == null)
            {
                return;
            }
            _vbuffer.Commit();
            _ibuffer.Commit();

            using (_material.Begin()) {
                cam.Apply(ref Matrix4.Identity);
                using (_vbuffer.Begin()) {
                    _ibuffer.Draw(0, _iidx);
                }
            }
        }
コード例 #3
0
ファイル: Mesh.cs プロジェクト: Milstein/GameStack
        public void Draw(ref Matrix4 world)
        {
            var cam = ScopedObject.Find <Camera>();

            if (cam == null)
            {
                throw new InvalidOperationException("There is no active camera.");
            }
            var lights = ScopedObject.Find <Lighting>();

            if (_bones != null)
            {
                if (_boneSet == null)
                {
                    _boneSet = new HashSet <Node>(_bones.Select(b => b.Node));
                }
                var identity = Matrix4.Identity;
                foreach (var node in _node.Parent.Children)
                {
                    if (node != _node)
                    {
                        this.PrepareBoneTransforms(node, ref identity);
                    }
                }
                if (_node.Children != null)
                {
                    foreach (var child in _node.Children)
                    {
                        this.PrepareBoneTransforms(child, ref identity);
                    }
                }
            }

            var mat = ScopedObject.Find <Material>();

            if (mat == null)
            {
                using (_material.Begin()) {
                    cam.Apply(ref world);
                    if (lights != null)
                    {
                        lights.Apply(ref world);
                    }
                    if (_bones != null && _bones.Length > 0)
                    {
                        _material.Shader.Uniform("Bones[0]", _boneTransforms);
                    }
                    using (_vbuffer.Begin()) {
                        _ibuffer.Draw();
                    }
                }
            }
            else
            {
                cam.Apply(ref world);
                if (lights != null)
                {
                    lights.Apply(ref world);
                }
                if (_bones != null && _bones.Length > 0)
                {
                    mat.Shader.Uniform("Bones[0]", _boneTransforms);
                }
                using (_vbuffer.Begin()) {
                    _ibuffer.Draw();
                }
            }
        }