當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。