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


C# Camera.GetCameraToViewportRay方法代码示例

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


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

示例1: RenderEntityOverCursor

        void RenderEntityOverCursor( Camera camera )
        {
            Vec2 mouse = renderTargetUserControl1.GetFloatMousePosition();

            Ray ray = camera.GetCameraToViewportRay( mouse );

            MapObject mapObject = null;

            Map.Instance.GetObjects( ray, delegate( MapObject obj, float scale )
            {
                if( obj is StaticMesh )
                    return true;
                mapObject = obj;
                return false;
            } );

            if( mapObject != null )
            {
                camera.DebugGeometry.Color = new ColorValue( 1, 1, 0 );
                camera.DebugGeometry.AddBounds( mapObject.MapBounds );
            }
        }
开发者ID:whztt07,项目名称:SDK,代码行数:22,代码来源:MainWindow.xaml.cs

示例2: RenderEntityOverCursor

        void RenderEntityOverCursor(Camera camera)
        {
            Vec2 mouse = renderTarget.GetFloatMousePosition();
            _mouseOver = null;

            if (mouse.X < 0 || mouse.X > 1 || mouse.Y < 0 || mouse.Y > 1)
                _worldViewModel.ClearMouseOverEntity();
            else
            {
                // Find entity under cursor of mouse
                Ray ray = camera.GetCameraToViewportRay(mouse);
                Map.Instance.GetObjects(ray, delegate(MapObject obj, float scale)
                {
                    if (obj.UserData == null || !(obj.UserData is EntityModel))
                        return true;
                    _mouseOver = obj;
                    return false;
                });

                if (_mouseOver != null)
                {
                    // Put a yellow box around it and a tooltip
                    camera.DebugGeometry.Color = new ColorValue(1, 1, 0);
                    camera.DebugGeometry.AddBounds(_mouseOver.MapBounds);
                    _worldViewModel.SetMouseOverEntity(((EntityModel)_mouseOver.UserData).Id);
                }
                else
                    _worldViewModel.ClearMouseOverEntity();

                RayCastResult result = PhysicsWorld.Instance.RayCast(ray, (int)ContactGroup.CastOnlyCollision);
                _mouseIntersection = result.Position;
                if (result.Shape != null)
                {
                    camera.DebugGeometry.Color = new ColorValue(1, 0, 0);
                    camera.DebugGeometry.AddSphere(new Sphere(result.Position, 0.2f));
                }
            }
            SetToolTipString();

            // Show all selected entities with a blue box around them
            // except MouseOver as it will be yellow
            camera.DebugGeometry.Color = new ColorValue(0.5f, 0.5f, 1);
            foreach (MapObject mo in _worldViewModel.SelectedEntities
                .Select(evm => Entities.Instance.GetByName(evm.Entity.Id.ToString()))
                .OfType<MapObject>()
                .Where(mo => mo != _mouseOver))
                camera.DebugGeometry.AddBounds(mo.MapBounds);
        }
开发者ID:628426,项目名称:Strive.NET,代码行数:48,代码来源:PerspectiveView.xaml.cs


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