示例#1
0
        public int Compare(Maths.Coord3d o1, Maths.Coord3d o2)
        {
            if ((_camera == null))
            {
                throw new Exception("No available camera for computing PointOrderingStrategy");
            }
            // Reflexivity
            if (o1.Equals(o2))
            {
                return(0);
            }
            double dist1 = _camera.Eye.distance(o1);
            double dist2 = _camera.Eye.distance(o2);

            if (dist1 == dist2)
            {
                return(0);
            }
            else if (dist1 < dist2)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
示例#2
0
 public void setScale(Maths.Coord3d scale)
 {
     _scale = scale;
 }
示例#3
0
        public override Maths.BoundingBox3d drawText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Align.Halign halign, Align.Valign valign, Colors.Color color, Maths.Coord2d screenOffset, Maths.Coord3d sceneOffset)
        {
            GL.Color3(color.r, color.g, color.b);
            GL.RasterPos3(position.x, position.y, position.z);
            BillBoardSize dims      = printString(s, halign, valign);
            Coord3d       posScreen = cam.ModelToScreen(position);
            Coord3d       botLeft   = new Coord3d();
            Coord3d       topRight  = new Coord3d();

            botLeft.x  = posScreen.x + dims.xoffset;
            botLeft.y  = posScreen.y + dims.yoffset;
            botLeft.z  = posScreen.z;
            topRight.x = botLeft.x + dims.xoffset;
            topRight.y = botLeft.y + dims.yoffset;
            topRight.z = botLeft.z;
            BoundingBox3d txtBounds = new BoundingBox3d();

            txtBounds.@add(cam.ScreenToModel(botLeft));
            txtBounds.@add(cam.ScreenToModel(topRight));
            return(txtBounds);
        }
示例#4
0
        public override Maths.BoundingBox3d drawText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Align.Halign halign, Align.Valign valign, Colors.Color color, Maths.Coord2d screenOffset, Maths.Coord3d sceneOffset)
        {
            GL.Color3(color.r, color.g, color.b);
            Coord3d posScreen = cam.ModelToScreen(position);
            float   strlen    = Glut.Glut.BitmapLength(_font, s);
            float   x         = 0;
            float   y         = 0;

            switch (halign)
            {
            case Align.Halign.RIGHT:
                x = (float)posScreen.x;
                break;

            case Align.Halign.CENTER:
                x = (float)(posScreen.x - strlen / 2);
                break;

            case Align.Halign.LEFT:
                x = (float)(posScreen.x - strlen);
                break;

            default:
                throw new Exception("Unsupported halign value");
            }
            switch (valign)
            {
            case Align.Valign.TOP:
                y = (float)(posScreen.y);
                break;

            case Align.Valign.GROUND:
                y = (float)(posScreen.y);
                break;

            case Align.Valign.CENTER:
                y = (float)(posScreen.y - _fontHeight / 2);
                break;

            case Align.Valign.BOTTOM:
                y = (float)(posScreen.y - _fontHeight);
                break;

            default:
                throw new Exception("Unsupported valign value");
            }
            Coord3d posScreenShifted = new Coord3d(x + screenOffset.x, y + screenOffset.y, posScreen.z);
            Coord3d posReal          = default(Coord3d);

            try {
                posReal = cam.ScreenToModel(posScreenShifted);
                // TODO: really solve this bug due to a Camera.PERSPECTIVE mode
            } catch (Exception ex) {
                Console.WriteLine("TextBitmap.drawText(): could not process text position: " + posScreen.ToString() + " " + posScreenShifted.ToString());
                return(new BoundingBox3d());
            }
            // Draw actual string
            GL.RasterPos3(posReal.x + sceneOffset.x, posReal.y + sceneOffset.y, posReal.z + sceneOffset.z);
            Glut.Glut.BitmapString(_font, s);
            // Compute bounds of text
            Coord3d botLeft  = new Coord3d();
            Coord3d topRight = new Coord3d();

            botLeft.x  = posScreenShifted.x;
            botLeft.y  = posScreenShifted.y;
            botLeft.z  = posScreenShifted.z;
            topRight.x = botLeft.x + strlen;
            topRight.y = botLeft.y + _fontHeight;
            topRight.z = botLeft.z;
            BoundingBox3d txtBounds = new BoundingBox3d();

            txtBounds.@add(cam.ScreenToModel(botLeft));
            txtBounds.@add(cam.ScreenToModel(topRight));
            return(txtBounds);
        }
示例#5
0
 public override void drawSimpleText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Colors.Color color)
 {
     GL.Color3(color.r, color.g, color.b);
     GL.RasterPos3(position.x, position.y, position.z);
     printString(s, Halign.RIGHT, Valign.GROUND);
 }
示例#6
0
 public override void drawSimpleText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Colors.Color color)
 {
     GL.Color3(color.r, color.g, color.b);
     GL.RasterPos3(position.x, position.y, position.z);
     Glut.Glut.BitmapString(_font, s);
 }
示例#7
0
 public Maths.Coord3d Compute(Maths.Coord3d input)
 {
     return(input.multiply(_scale));
 }
 public Maths.BoundingBox3d drawText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Align.Halign halign, Align.Valign valign, Colors.Color color, Maths.Coord3d sceneOffset)
 {
     return(drawText(cam, s, position, halign, valign, color, defScreenOffset, sceneOffset));
 }
 public abstract Maths.BoundingBox3d drawText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Align.Halign halign, Align.Valign valign, Colors.Color color, Maths.Coord2d screenOffset, Maths.Coord3d sceneOffset);
示例#10
0
 public abstract void drawSimpleText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Colors.Color color);