예제 #1
0
        private void SetRandomColor()
        {
            int index = Random.Range(0, 4);

            while (_color == (Colors.Color)index)
            {
                index = Random.Range(0, 4);
            }

            _color = (Colors.Color)index;

            switch (_color)
            {
            case Colors.Color.Cyan:
                _sr.color = colorCyan;
                break;

            case Colors.Color.Yellow:
                _sr.color = colorYellow;
                break;

            case Colors.Color.Magenta:
                _sr.color = colorMagenta;
                break;

            case Colors.Color.Pink:
                _sr.color = colorPink;
                break;
            }
        }
예제 #2
0
        public void OldColorStruct()
        {
            var TestArray = new Colors.Color[10000];

            for (int x = 0; x < TestArray.Length; ++x)
            {
                TestArray[x] *= 3;
            }
        }
예제 #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 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);
 }
예제 #5
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);
        }
예제 #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.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));
 }
예제 #8
0
 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);
예제 #9
0
 public abstract void drawSimpleText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Colors.Color color);