Ejemplo n.º 1
0
        internal override void VRender(Cv_Renderer renderer)
        {
            if (renderer.DebugDrawClickAreas)
            {
                var clickableComponent = (Cv_ClickableComponent)Component;
                var scene = CaravelApp.Instance.Scene;

                var pos   = scene.Transform.Position;
                var rot   = scene.Transform.Rotation;
                var scale = scene.Transform.Scale;

                var offsetX = clickableComponent.AnchorPoint.X;
                var offsetY = clickableComponent.AnchorPoint.Y;

                var rotMatrixZ = Matrix.CreateRotationZ(rot);

                Vector2        point1;
                Vector2        point2;
                List <Vector2> points = new List <Vector2>();
                var            width  = clickableComponent.Width * scale.X;
                var            height = clickableComponent.Height * scale.Y;
                points.Add(new Vector2(0, 0));
                points.Add(new Vector2(width, 0));
                points.Add(new Vector2(width, height));
                points.Add(new Vector2(0, height));
                for (int i = 0, j = 1; i < points.Count; i++, j++)
                {
                    if (j >= points.Count)
                    {
                        j = 0;
                    }

                    point1 = new Vector2(points[i].X, points[i].Y);
                    point2 = new Vector2(points[j].X, points[j].Y);

                    point1 -= new Vector2(scene.Transform.Origin.X * width, scene.Transform.Origin.Y * height);
                    point2 -= new Vector2(scene.Transform.Origin.X * width, scene.Transform.Origin.Y * height);
                    point1 -= new Vector2(offsetX * scale.X, offsetY * scale.Y);
                    point2 -= new Vector2(offsetX * scale.X, offsetY * scale.Y);
                    point1  = Vector2.Transform(point1, rotMatrixZ);
                    point2  = Vector2.Transform(point2, rotMatrixZ);
                    point1 += new Vector2(pos.X, pos.Y);
                    point2 += new Vector2(pos.X, pos.Y);

                    var thickness = (int)Math.Ceiling(3 / scene.Camera.Zoom);
                    if (thickness <= 0)
                    {
                        thickness = 1;
                    }

                    Cv_DrawUtils.DrawLine(renderer,
                                          point1,
                                          point2,
                                          thickness,
                                          Cv_Renderer.MaxLayers - 1,
                                          Color.White);
                }
            }
        }
Ejemplo n.º 2
0
        internal override void VRender(Cv_Renderer renderer)
        {
            var scene = CaravelApp.Instance.Scene;

            if (renderer.DebugDrawCameras)
            {
                var zoom       = ((Cv_CameraComponent)Component).Zoom;
                var rot        = scene.Transform.Rotation;
                var pos        = scene.Transform.Position;
                var rotMatrixZ = Matrix.CreateRotationZ(rot);

                Vector2        point1;
                Vector2        point2;
                List <Vector2> points = new List <Vector2>();
                points.Add(new Vector2(0, 0));
                points.Add(new Vector2((renderer.VirtualWidth / zoom), 0));
                points.Add(new Vector2((renderer.VirtualWidth / zoom), (renderer.VirtualHeight / zoom)));
                points.Add(new Vector2(0, (renderer.VirtualHeight / zoom)));
                for (int i = 0, j = 1; i < points.Count; i++, j++)
                {
                    if (j >= points.Count)
                    {
                        j = 0;
                    }

                    point1  = new Vector2(points[i].X, points[i].Y);
                    point2  = new Vector2(points[j].X, points[j].Y);
                    point1 -= new Vector2((renderer.VirtualWidth / zoom) * 0.5f, (renderer.VirtualHeight / zoom) * 0.5f);
                    point2 -= new Vector2((renderer.VirtualWidth / zoom) * 0.5f, (renderer.VirtualHeight / zoom) * 0.5f);
                    point1  = Vector2.Transform(point1, rotMatrixZ);
                    point2  = Vector2.Transform(point2, rotMatrixZ);
                    point1 += new Vector2(pos.X, pos.Y);
                    point2 += new Vector2(pos.X, pos.Y);

                    var thickness = (int)Math.Ceiling(3 / scene.Camera.Zoom);
                    if (thickness <= 0)
                    {
                        thickness = 1;
                    }

                    Cv_DrawUtils.DrawLine(renderer,
                                          point1,
                                          point2,
                                          thickness,
                                          Cv_Renderer.MaxLayers - 2,
                                          Color.Purple);
                }

                if (scene.EditorSelectedEntity == Properties.EntityID)
                {
                    for (int i = 0, j = 1; i < points.Count; i++, j++)
                    {
                        if (j >= points.Count)
                        {
                            j = 0;
                        }

                        point1  = new Vector2(points[i].X, points[i].Y);
                        point2  = new Vector2(points[j].X, points[j].Y);
                        point1  = Vector2.Transform(point1, rotMatrixZ);
                        point2  = Vector2.Transform(point2, rotMatrixZ);
                        point1 += new Vector2(pos.X, pos.Y);
                        point2 += new Vector2(pos.X, pos.Y);
                        point1 -= new Vector2((renderer.VirtualWidth / zoom) * 0.5f, (renderer.VirtualHeight / zoom) * 0.5f);
                        point2 -= new Vector2((renderer.VirtualWidth / zoom) * 0.5f, (renderer.VirtualHeight / zoom) * 0.5f);

                        var thickness = (int)Math.Ceiling(3 / scene.Camera.Zoom);
                        if (thickness <= 0)
                        {
                            thickness = 1;
                        }

                        Cv_DrawUtils.DrawLine(renderer,
                                              point1,
                                              point2,
                                              thickness,
                                              Cv_Renderer.MaxLayers - 1,
                                              Color.Yellow);
                    }
                }
            }
        }