Ejemplo n.º 1
0
        public void Render(Matrix4 view)
        {
            if (b == null) return;

            Matrix4 mat = b.transform;
            Vector3 center = Vector3.Transform(Vector3.Zero, mat);
            Vector3 point;

            hit = false;
            bool _hiX = false;
            bool _hiY = false;
            bool _hiZ = false;
            if (RenderTools.CheckSphereHit(center, 2, VBNViewport.p1, VBNViewport.p2, out point))
            {
                hit = true;

                VBNViewport.LineSphereIntersect(VBNViewport.p1, VBNViewport.p2, center, 2, out point);

                Vector3 angle = Angles(Vector3.Transform(point, b.invert)) * new Vector3(180f / (float)Math.PI);
                angle.X = Math.Abs(angle.X);
                angle.Y = Math.Abs(angle.Y);
                angle.Z = Math.Abs(angle.Z);
                //Console.WriteLine(angle.ToString());

                float _axisSnapRange = 7f;
                if (Math.Abs(angle.Y - 90.0f) <= _axisSnapRange)
                    _hiX = true;
                else if (angle.X >= (180.0f - _axisSnapRange) || angle.X <= _axisSnapRange)
                    _hiY = true;
                else if (angle.Y >= (180.0f - _axisSnapRange) || angle.Y <= _axisSnapRange)
                    _hiZ = true;
            }
        
            GL.PushMatrix();
            GL.MultMatrix(ref mat);
            
            GL.Color3(_hiX ? Color.Yellow : Color.Green);
            GL.LineWidth(2);
            RenderTools.drawCircleOutline(Vector3.Zero, 2, 25);

            GL.Rotate(90.0f, 0.0f, 1.0f, 0.0f);

            GL.Color3(_hiY ? Color.Yellow : Color.Red);
            RenderTools.drawCircleOutline(Vector3.Zero, 2, 25);

            GL.Rotate(90.0f, 1.0f, 0.0f, 0.0f);

            GL.Color3(_hiZ ? Color.Yellow : Color.Blue);
            RenderTools.drawCircleOutline(Vector3.Zero, 2, 25);
            
            GL.PopMatrix();
        }
Ejemplo n.º 2
0
 public bool TrySphereHit(Vector3 sphere, float rad, out Vector3 closest)
 {
     return(RenderTools.CheckSphereHit(sphere, rad, p1, p2, out closest));
 }