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


C# LevelEditorCore.ViewControl类代码示例

本文整理汇总了C#中LevelEditorCore.ViewControl的典型用法代码示例。如果您正苦于以下问题:C# ViewControl类的具体用法?C# ViewControl怎么用?C# ViewControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1:

        void IManipulator.Render(ViewControl vc)
        {
            TerrainGob terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain;
            TerrainBrush brush = m_terrainEditor.TerrainEditorControl.SelectedBrush;
            TerrainMap terrainMap = m_terrainEditor.TerrainEditorControl.SelectedTerrainMap;
            if (brush == null || (!brush.CanApplyTo(terrain) && !brush.CanApplyTo(terrainMap))) return;
            
            Vec2F drawscale = new Vec2F(1.0f,1.0f);
            if (brush.CanApplyTo(terrainMap))
            {
                ImageData mapImg = terrainMap.GetSurface();
                ImageData hmImg = terrain.GetSurface();
                drawscale.X = (float)hmImg.Width / (float)mapImg.Width;
                drawscale.Y = (float)hmImg.Height / (float)mapImg.Height;
            }

            Point scrPt = vc.PointToClient(Control.MousePosition);
            if (!vc.ClientRectangle.Contains(scrPt)) return;                       
            Ray3F rayw = vc.GetWorldRay(scrPt);            
            TerrainGob.RayPickRetVal retval;
            if (terrain.RayPick(rayw, out retval))
            {
                terrain.DrawBrush(brush, drawscale, retval.hitpos);
            }           
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:25,代码来源:TerrainManipulator.cs

示例2: Pick

        public bool Pick(ViewControl vc, Point scrPt) 
        {
            m_highlightMaterialGUID = ~0ul;
            m_highlight.Clear();

            var ray = vc.GetWorldRay(scrPt);
            var endPt = ray.Origin + vc.Camera.FarZ * ray.Direction;

            var nativeVC = vc as GUILayer.IViewContext;
            if (nativeVC == null) return false;

            // do an intersection test here, and find the material under the cursor
            var pick = XLEBridgeUtils.Picking.RayPick(
                nativeVC, ray, XLEBridgeUtils.Picking.Flags.Objects);

            if (pick != null && pick.Length > 0)
            {
                m_highlightMaterialGUID = pick[0].materialGuid;
                m_highlight.Add(pick[0].documentId, pick[0].instanceId);

                using (var placements = nativeVC.SceneManager.GetPlacementsEditor())
                {
                    m_highlight.DoFixup(placements);
                }
            }

            return true;
        }
开发者ID:coreafive,项目名称:XLE,代码行数:28,代码来源:PickMaterialManipulator.cs

示例3: Render

 public override void Render(ViewControl vc)
 {                                                
     Matrix4F normWorld = GetManipulatorMatrix();
     if (normWorld == null) return;
     float s;
     Util.CalcAxisLengths(vc.Camera, normWorld.Translation, out s);
     m_translatorControl.Render(normWorld, s);        
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:8,代码来源:TranslateManipulator.cs

示例4: Pick

 public virtual bool Pick(ViewControl vc, Point scrPt)
 {
     Matrix4F normWorld = GetManipulatorMatrix();
     if (normWorld == null) return false;
     HitRayV = vc.GetRay(scrPt, vc.Camera.ProjectionMatrix);            
     HitMatrix.Set(normWorld);            
     return true;
 }
开发者ID:arsaccol,项目名称:LevelEditor,代码行数:8,代码来源:Manipulator.cs

示例5: Pick

        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            Camera camera = vc.Camera;
            float rad;
            Util.CalcAxisLengths(camera, HitMatrix.Translation, out rad);
            float tolerance = rad / 10.0f;

            // compute ray in object space  space.
            Matrix4F vp = camera.ViewMatrix * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;            
            Ray3F rayL = vc.GetRay(scrPt, wvp);

            Plane3F xplane = new Plane3F(Vec3F.XAxis, Vec3F.ZeroVector);
            Plane3F yplane = new Plane3F(Vec3F.YAxis,Vec3F.ZeroVector);
            Plane3F zplane = new Plane3F(Vec3F.ZAxis,Vec3F.ZeroVector);

            Vec3F pt;
            float xdelta = float.MaxValue;            
            float ydelta = float.MaxValue;
            float zdelta = float.MaxValue;
            if(rayL.IntersectPlane(xplane,out pt))
            {
                xdelta = Math.Abs(pt.Length - rad); 
            }

            if (rayL.IntersectPlane(yplane, out pt))
            {
                ydelta = Math.Abs(pt.Length - rad);              
            }

            if (rayL.IntersectPlane(zplane, out pt))
            {
                zdelta = Math.Abs(pt.Length - rad);
            }

            if(xdelta < tolerance && xdelta < ydelta && xdelta < zdelta)
            {
                m_hitRegion = HitRegion.XAxis;                
            }
            else if(ydelta < tolerance && ydelta < zdelta)
            {
                m_hitRegion = HitRegion.YAxis;
            }
            else if(zdelta < tolerance)
            {
                m_hitRegion = HitRegion.ZAxis;
            }

            return m_hitRegion != HitRegion.None;
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:54,代码来源:RotateManipulator.cs

示例6: OnDragging

        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || !CanManipulate(m_node))
                return;

            Matrix4F proj = vc.Camera.ProjectionMatrix;
            // create ray in view space.
            Ray3F rayV = vc.GetRay(scrPt, proj);

            Vec3F translate = m_translatorControl.OnDragging(rayV);

            Vec3F localTranslation;
            m_worldToLocal.TransformVector(translate, out localTranslation);
            m_node.Pivot = m_originalPivot + localTranslation;
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:15,代码来源:TranslatePivotManipulator.cs

示例7: Pick

        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            m_node = GetManipulatorNode(TransformationTypes.Pivot);

            Camera camera = vc.Camera;            
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp = view * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;

            Ray3F rayL = vc.GetRay(scrPt, wvp);
            m_hitRegion = m_translatorControl.Pick(vc, HitMatrix, view, rayL, HitRayV);
            bool picked = m_hitRegion != HitRegion.None;
            return picked;
        }
开发者ID:arsaccol,项目名称:LevelEditor,代码行数:18,代码来源:TranslatePivotManipulator.cs

示例8: Render

        public override void Render(object opaqueContext, ViewControl vc)
        {                                                
            Matrix4F normWorld = GetManipulatorMatrix();
            if (normWorld == null) return;

            var context = opaqueContext as GUILayer.SimpleRenderingContext;
            if (context == null) return;

            Vec3F pos = normWorld.Translation;
            float s = Util.CalcAxisScale(vc.Camera, pos, AxisLength, vc.Height);

            bool highlight = m_hitRegion == HitRegion.XYSquare;
            Color centerCubeColor = highlight ? Color.Gold : Color.White;

            Vec3F sv = new Vec3F(s, s, s);
            Vec3F centerCubeScale = sv * CenterCubeSize;
            Matrix4F scale = new Matrix4F(); 
            scale.Scale(centerCubeScale);
            Matrix4F centerCubeXform = scale * normWorld;
            Util3D.DrawCube(context, centerCubeXform, centerCubeColor);

            Matrix4F arrowScale = new Matrix4F();
            arrowScale.Scale(0.75f);

            Util3D.DrawArrowCap(
                context,
                arrowScale * Matrix4F.CreateTranslation(new Vec3F(1.0f, 0.0f, -0.5f)) * centerCubeXform,
                highlight ? Color.Gold : Color.Red);

            Util3D.DrawArrowCap(
                context,
                arrowScale * Matrix4F.RotAxisRH(Vec3F.ZAxis, Math.PI) * Matrix4F.CreateTranslation(new Vec3F(-1.0f, 0.0f, -0.5f)) * centerCubeXform,
                highlight ? Color.Gold : Color.Red);

            Util3D.DrawArrowCap(
                context,
                arrowScale * Matrix4F.RotAxisRH(Vec3F.ZAxis, .5 * Math.PI) * Matrix4F.CreateTranslation(new Vec3F(0.0f, 1.0f, -0.5f)) * centerCubeXform,
                highlight ? Color.Gold : Color.Green);

            Util3D.DrawArrowCap(
                context,
                arrowScale * Matrix4F.RotAxisRH(Vec3F.ZAxis, 1.5f * Math.PI) * Matrix4F.CreateTranslation(new Vec3F(0.0f, -1.0f, -0.5f)) * centerCubeXform,
                highlight ? Color.Gold : Color.Green);
        }
开发者ID:coreafive,项目名称:XLE,代码行数:44,代码来源:MoveAcrossTerrainManipulator.cs

示例9: OnEndDrag

        public void OnEndDrag(ViewControl vc, Point scrPt) 
        {
            var ray = vc.GetWorldRay(scrPt);
            var endPt = ray.Origin + vc.Camera.FarZ * ray.Direction;

            // do an intersection test here, and find the material under the cursor
            var pick = XLEBridgeUtils.Picking.RayPick(
                vc as GUILayer.IViewContext, ray, XLEBridgeUtils.Picking.Flags.Objects);

            if (pick != null && pick.Length > 0)
            {
                Context.PreviewModelName = pick[0].modelName;
                Context.PreviewModelBinding = pick[0].materialGuid; 
                Context.MaterialName = pick[0].materialName;
            }

            m_highlightMaterialGUID = ~0ul;
            m_highlight.Clear();
        }
开发者ID:coreafive,项目名称:XLE,代码行数:19,代码来源:PickMaterialManipulator.cs

示例10: Pick

        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            Camera camera = vc.Camera;
            float s;
            Util.CalcAxisLengths(camera, HitMatrix.Translation, out s);
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp = view  * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;
            
            Ray3F rayL = vc.GetRay(scrPt,wvp);

            m_hitRegion = m_translatorControl.Pick(HitMatrix, view, rayL, HitRayV, s);
            
            bool picked = m_hitRegion != HitRegion.None;                      
            return picked;
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:20,代码来源:TranslateManipulator.cs

示例11: Render

        public override void Render(ViewControl vc)
        {
            Matrix4F normWorld = GetManipulatorMatrix();
            if (normWorld == null) return;

            Camera camera = vc.Camera;
            float s;
            Util.CalcAxisLengths(camera, normWorld.Translation, out s);
            m_translatorControl.Render(normWorld, s);        
            
            Matrix4F sc = new Matrix4F();
            Vec3F pos = normWorld.Translation;            
            s /= 12.0f;
            sc.Scale(s);

            Matrix4F bl = new Matrix4F();
            Util.CreateBillboard(bl, pos, camera.WorldEye, camera.Up, camera.LookAt);

            Matrix4F recXform = new Matrix4F();
            Matrix4F.Multiply(sc, bl, recXform);

            Util3D.DrawPivot(recXform, Color.Yellow);
        }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:23,代码来源:TranslatePivotManipulator.cs

示例12: OnEndDrag

        public override void OnEndDrag(ViewControl vc, Point scrPt)
        {
            if (CanManipulate(m_node))
            {
                var transactionContext = DesignView.Context.As<ITransactionContext>();
                try
                {
                    if (transactionContext.InTransaction)
                        transactionContext.End();
                }
                catch (InvalidTransactionException ex)
                {
                    if (transactionContext.InTransaction)
                        transactionContext.Cancel();

                    if (ex.ReportError)
                        Outputs.WriteLine(OutputMessageType.Error, ex.Message);
                }
            }

            m_hitRegion = HitRegion.None;
            m_node = null;
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:23,代码来源:TranslatePivotManipulator.cs

示例13: Pick

        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            Camera camera = vc.Camera;
            
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp = view  * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;
            
            Ray3F rayL = vc.GetRay(scrPt,wvp);

            float s = Util.CalcAxisScale(vc.Camera, HitMatrix.Translation, AxisLength, vc.Height);

                // There's only one hot-spot for this manipulator:
                //      a square at the manipulator origin.
            Vec3F min = new Vec3F(-0.5f, -0.5f, -0.5f);
            Vec3F max = new Vec3F(0.5f, 0.5f, 0.5f);
            AABB box = new AABB(min, max);

            float centerCubeScale = s * CenterCubeSize;
            Matrix4F centerCubeXform = new Matrix4F();
            centerCubeXform.Scale(centerCubeScale);
            centerCubeXform.Invert(centerCubeXform);
            Ray3F ray = rayL;
            ray.Transform(centerCubeXform);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.XYSquare;
                return true;
            }

            m_hitRegion = HitRegion.None;
            return false;
        }
开发者ID:coreafive,项目名称:XLE,代码行数:37,代码来源:MoveAcrossTerrainManipulator.cs

示例14: Pick

 public bool Pick(ViewControl vc, Point scrPt)
 {
     m_hasHoverPt = HitTest(out m_hoverPt, scrPt, vc);
     return m_hasHoverPt;
 }
开发者ID:coreafive,项目名称:XLE,代码行数:5,代码来源:ScatterPlaceManipulator.cs

示例15: OnMouseWheel

 public override void OnMouseWheel(ViewControl vc, Point scrPt, int delta) { }
开发者ID:coreafive,项目名称:XLE,代码行数:1,代码来源:RotateManipulator.cs


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