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


C# Camera.GetPickingRay方法代码示例

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


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

示例1: draw

        protected override bool draw(Camera camera, DrawingReason drawingReason, ShadowMap shadowMap)
        {
            if (drawingReason != DrawingReason.Normal)
                return true;

            var ray = camera.GetPickingRay();

            foreach (var tpd in _tpds)
            {
                if (tpd.DistanceSquared < 5000 || tpd.DotProduct < 0)  // too close or facing away
                    continue;

                Effect.World = Matrix.BillboardRH(tpd.Pos, camera.Position, -camera.Up, camera.Front);
                Effect.DiffuseColor = tpd.BoundingBox.Intersects(ref ray)
                    ? Color.Yellow.ToVector4()
                    : Color.White.ToVector4();
                _spriteBatch.Begin(SpriteSortMode.Deferred, Effect.GraphicsDevice.BlendStates.NonPremultiplied, null, Effect.GraphicsDevice.DepthStencilStates.DepthRead, null, Effect.Effect);
                _spriteBatch.DrawString(_spriteFont, tpd.Text, Vector2.Zero, Color.Black, 0, _spriteFont.MeasureString(tpd.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,代码行数:26,代码来源:BannerSign.cs

示例2: Update

        public override void Update(Camera camera, GameTime gameTime)
        {
            if (camera.MouseState.LeftButton.Pressed)
            {
                var ray = camera.GetPickingRay();
                var islandsHit = CollisionHelpers.HitTest(ray, Children.Cast<CodeIsland>(), _ => _.BoundingSphere);
                var signsHit = CollisionHelpers.HitTest(ray, islandsHit.SelectMany(_ => _.Classes.Values), _ => _.SignClickBoundingSphere);
                if (signsHit.Any())
                    signsHit[0].CodeIsland.Archipelag.SelectedClass = signsHit[0];

                foreach (var island in islandsHit)
                {
                    Vector3 hit, normal;
                    if (! island.HitTest(ray, out hit, out normal))
                        continue;
                    System.Diagnostics.Debug.Print("{0}: {1},{2}", island.VAssembly.Name, hit.X, hit.Y);
                }
                //var q = hitTestGround(camera.GetPickingRay());
                //if(q!=null)
                //    q.CodeIsland
            }

            _bannerSign.Update(camera, gameTime);
            _arcs.Update(camera, gameTime);
            base.Update(camera, gameTime);
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:26,代码来源:Archipelag.cs


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