当前位置: 首页>>代码示例>>C#>>正文


C# Camera.UpdateEffect方法代码示例

本文整理汇总了C#中Camera.UpdateEffect方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.UpdateEffect方法的具体用法?C# Camera.UpdateEffect怎么用?C# Camera.UpdateEffect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera的用法示例。


在下文中一共展示了Camera.UpdateEffect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: draw

 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.World = World;
     Thing.Draw(Effect);
     return true;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:7,代码来源:VDrawableInstance.cs

示例2: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            base.draw(camera, drawingReason, shadowMap);

            if (drawingReason != DrawingReason.Normal)
                return true;

            camera.UpdateEffect(_signTextEffect);
            var world = World*Matrix.Translation(0, TextDistanceAboveGround - 2, 0);
            _signTextEffect.DiffuseColor = Color.WhiteSmoke.ToVector4();

            foreach (var vc in _vclasses)
            {
                var pos = Vector3.TransformCoordinate(vc.Position, world);
                var viewDirection = Vector3.Normalize(pos - camera.Position);

                if (Vector3.DistanceSquared(pos, camera.Position) > 200000 || Vector3.Dot(viewDirection, camera.Front) < 0)
                    continue;

                var text = vc.VClass.Name;
                _signTextEffect.World = createConstrainedBillboard(pos - viewDirection*0.2f, viewDirection, Vector3.Down);
                _spriteBatch.Begin(SpriteSortMode.Deferred, null, null, Effect.GraphicsDevice.DepthStencilStates.DepthRead, null, _signTextEffect.Effect);
                _spriteBatch.DrawString(_spriteFont, text, Vector2.Zero, Color.Black, 0, _spriteFont.MeasureString(text)/2, TextSize, 0, 0);
                _spriteBatch.End();
            }

            Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
            Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Opaque);

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:31,代码来源:Signs.cs

示例3: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            if (_vertexBuffer == null)
                return false;

            camera.UpdateEffect(Effect);
            Effect.World = _world;
            Effect.Texture = _texture;

            Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
            Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);

            Effect.Parameters["WindTime"].SetValue(_time);
            Effect.Parameters["BillboardWidth"].SetValue(_billboardWidth);
            Effect.Parameters["BillboardHeight"].SetValue(_billboardHeight);

            //pass one
            Effect.Parameters["AlphaTestDirection"].SetValue(1f);
            Effect.Effect.CurrentTechnique.Passes[0].Apply();
            Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);

            if (drawingReason == DrawingReason.Normal)
            {
                //pass two
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.DepthRead);
                Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.NonPremultiplied);
                Effect.Parameters["AlphaTestDirection"].SetValue(-1f);
                Effect.Effect.CurrentTechnique.Passes[0].Apply();
                Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.Default);
                Effect.GraphicsDevice.SetBlendState(Effect.GraphicsDevice.BlendStates.Default);
            }

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:35,代码来源:CxBillboard.cs

示例4: draw

 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     if (drawingReason == DrawingReason.ShadowDepthMap)
         return false;
     camera.UpdateEffect(Effect);
     Effect.World = Matrix.Scaling(1, 0.5f, 1)*Matrix.Translation(camera.Position);
     _sphere.Draw(Effect);
     return true;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:9,代码来源:SkySphere.cs

示例5: draw

 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.DiffuseColor = new Vector4(0.6f, 0.6f, 0.6f, 1);
     Effect.Texture = _texture;
     _caveModel.Draw(Effect.GraphicsDevice, CaveWorld, camera.View, camera.Projection, Effect.Effect);
     Effect.Texture = _gratingTexture;
     _gratingModel.Draw(Effect.GraphicsDevice, GratingWorld, camera.View, camera.Projection, Effect.Effect);
     return true;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:10,代码来源:CaveModel.cs

示例6: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);

            if (drawingReason != DrawingReason.ShadowDepthMap)
                Effect.Texture = _texture;
            _model.Draw(Effect.GraphicsDevice, World, camera.View, camera.Projection, Effect.Effect);

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:10,代码来源:Windmill.cs

示例7: draw

 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     Effect.World = World;
     if (drawingReason != DrawingReason.ShadowDepthMap)
     {
         Effect.Texture = _texture;
     //TODO                Effect.Parameters["BumpMap"].SetResource(_bumpMap);
     }
     _cube.Draw(Effect);
     return true;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:12,代码来源:DrawableBox.cs

示例8: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            var testSphere = new BoundingSphere(Vector3.TransformCoordinate(_boundingSphere.Center, World), _boundingSphere.Radius);
            if (camera.BoundingFrustum.Contains(testSphere) == ContainmentType.Disjoint)
                return false;

            camera.UpdateEffect(Effect);
            Effect.Texture = _texture;

            var world = Matrix.RotationZ((float) _bob1.Value)*Matrix.RotationX((float) _bob2.Value)*World;
            _model.Draw(Effect.GraphicsDevice, world, camera.View, camera.Projection, Effect.Effect);

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:14,代码来源:ShipModel.cs

示例9: Draw

        public void Draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            _serpents.Draw(camera, drawingReason, shadowMap);

            camera.UpdateEffect(_signEffect);

            var sb = _serpents.LContent.SpriteBatch;
            var font = _serpents.LContent.Font;
            var text = string.Format("Entering scene {0}", 1 + _scene);
            _signEffect.World = Matrix.BillboardRH(_signPosition + Vector3.Left * 0.1f, _signPosition + Vector3.Left, -camera.Up, Vector3.Right);
            _signEffect.DiffuseColor = new Vector4(0.5f, 0.4f, 0.3f, 1);
            sb.Begin(SpriteSortMode.Deferred, _signEffect.GraphicsDevice.BlendStates.NonPremultiplied, null, _signEffect.GraphicsDevice.DepthStencilStates.DepthRead, null, _signEffect.Effect);
            sb.DrawString(font, text, Vector2.Zero, Color.Black, 0, font.MeasureString(text) / 2, 0.010f, 0, 0);
            sb.End();
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:15,代码来源:GotoBoardState.cs

示例10: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);

            if (drawingReason != DrawingReason.ShadowDepthMap)
                Effect.Texture = _texture;

            foreach (var mesh in _model.Meshes)
            {
                Effect.World = _bones[mesh.ParentBone.Index]*World;
                //Effect.Apply();
                mesh.Draw(Effect.GraphicsDevice, null, Effect.Effect);
            }

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:16,代码来源:Windmill.cs

示例11: draw

 protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
 {
     camera.UpdateEffect(Effect);
     if (drawingReason == DrawingReason.ShadowDepthMap)
         Effect.CameraPosition = shadowMap.RealCamera.Position;
     Effect.World = World;
     Effect.Parameters["WindTime"].SetValue(Time);
     Effect.Parameters["BillboardWidth"].SetValue(Width);
     Effect.Parameters["BillboardHeight"].SetValue(Height);
     Effect.Texture = _treeTexture;
     Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);
     Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
     Effect.Effect.CurrentTechnique.Passes[0].Apply();
     Effect.GraphicsDevice.Draw(PrimitiveType.TriangleList, _vertexBuffer.ElementCount);
     return true;
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:16,代码来源:SimpleBillboards.cs

示例12: Draw

        public void Draw(Camera camera, Matrix world, DrawingReason drawingReason)
        {
            camera.UpdateEffect(Effect);
            Effect.World = world;

            var distance = Vector3.Distance(camera.Position, world.TranslationVector);
            var lod = 3;
            if (distance < 1800)
                lod = 2;
            if (distance < 600)
                lod = 1;
            if (distance < 300)
                lod = 0;
            if (drawingReason != DrawingReason.Normal)
                lod++;
            _loPlane.Draw(Effect, lod);
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:17,代码来源:TerrainPlane.cs

示例13: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            try
            {
                camera.UpdateEffect(Effect);
                Effect.Parameters["Time"].SetValue(_time);
                Effect.Apply();

                Effect.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
                Effect.GraphicsDevice.SetVertexInputLayout(_vertexInputLayout);
                Effect.GraphicsDevice.SetDepthStencilState(Effect.GraphicsDevice.DepthStencilStates.DepthRead);

                if (Archipelag.SelectedClass != null)
                    drawArchsFromClass(Archipelag.SelectedClass, 2);
                else
                    Effect.GraphicsDevice.Draw(PrimitiveType.LineList, _vertexBuffer.ElementCount);
            }
            catch (Exception)
            {
            }
            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:22,代码来源:Arcs.cs

示例14: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            camera.UpdateEffect(Effect);

            Effect.Texture = _texture;
            Effect.DiffuseColor = Vector4.One;
            Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position1);
            _sphere.Draw(Effect);

            Effect.DiffuseColor = Vector4.Zero;
            Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position2);
            _sphere.Draw(Effect);
            Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position3);
            _sphere.Draw(Effect);
            Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position4);
            _sphere.Draw(Effect);
            Effect.World = Matrix.Scaling(0.1f) * Matrix.Translation(_position5);
            _sphere.Draw(Effect);

            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:21,代码来源:TerrainWalker.cs

示例15: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            var p = Position;

            var slinger = p.X + p.Z;
            p += wormTwist(ref slinger);

            camera.UpdateEffect(Effect);

            var worlds = new List<Matrix>
            {
                _headRotation[HeadDirection]*
                Matrix.Scaling(HeadSize)*
                Matrix.Translation(p.X, HeadSize + p.Y + _ascendToHeaven, p.Z)
            };

            // p is the the loc of the last segement - which is the head on the first round
            var segment = _tail;
            while (true)
            {
                var p2 = segment.Position + wormTwist(ref slinger);
                worlds.Add(
                    Matrix.Scaling(SegmentSize)*
                    Matrix.Translation(
                        (p.X + p2.X)/2,
                        SegmentSize + (p.Y + p2.Y)/2 + _ascendToHeaven,
                        (p.Z + p2.Z)/2));
                worlds.Add(
                    Matrix.Scaling(SegmentSize)*
                    Matrix.Translation(
                        p2.X,
                        SegmentSize + p2.Y + _ascendToHeaven,
                        p2.Z));
                p = p2;
                if (segment.Next == null)
                    break;
                segment = segment.Next;
            }

            if (_pendingEatenSegments <= SegmentEatTreshold/2)
                worlds.RemoveAt(worlds.Count - 1);

            if (_layingEgg > 0 && worlds.Count >= 3)
            {
                Effect.Texture = _eggSkin;
                _eggWorld = worlds.Last();
                Egg.Draw(_textureEffect, _eggSkin, TintColor(), _sphere, _eggWorld, segment.Whereabouts.Direction);

                //move the last two spheres so that they slowly dissolves into the serpent
                var factor = MathUtil.Clamp(_layingEgg/TimeForLayingEggProcess - 0.5f, 0, 1);
                var world1 = worlds.Last();
                worlds.RemoveAt(worlds.Count - 1);
                var world2 = worlds.Last();
                worlds.RemoveAt(worlds.Count - 1);
                var world3 = worlds.Last();
                world2.TranslationVector = Vector3.Lerp(world2.TranslationVector, world3.TranslationVector, factor);
                world1.TranslationVector = Vector3.Lerp(world1.TranslationVector, world2.TranslationVector, factor);
                worlds.Add(world2);
                worlds.Add(world1);
            }

            Effect.Parameters["BumpMap"].SetResource(_serpentBump);
            Effect.DiffuseColor = TintColor();

            Effect.Texture = _serpentHeadSkin;
            Effect.World = worlds.First();
            _sphere.Draw(Effect);

            Effect.Texture = _serpentSkin;
            foreach (var world in worlds.Skip(1))
            {
                Effect.World = world;
                _sphere.Draw(Effect);
            }

            Effect.DiffuseColor = Vector4.One;
            return true;
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:78,代码来源:BaseSerpent.cs


注:本文中的Camera.UpdateEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。