Ejemplo n.º 1
0
 public override void Draw(Rendering.View.Camera cam)
 {
     foreach (Polygon quad in _quads)
     {
         quad.Draw(cam);
     }
 }
Ejemplo n.º 2
0
 internal void Execute(Rendering.View.Camera cam)
 {
     if ((_transform != null))
     {
         _transform.Execute();
     }
     GL.CallList(_dlID);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// If you call compile, the display list will be regenerated.
 /// </summary>
 internal void Compile(Rendering.View.Camera cam)
 {
     this.Reset();
     // clear old list
     this.NullifyChildrenTransforms();
     _dlID = GL.GenLists(1);
     GL.NewList(_dlID, ListMode.Compile);
     this.DrawComponents(cam);
     GL.EndList();
 }
Ejemplo n.º 4
0
 public override void Draw(Rendering.View.Camera cam)
 {
     if ((_transform != null))
     {
         _transform.Execute();
     }
     GL.PointSize(_width);
     GL.Begin(BeginMode.Points);
     GL.Color4(_rgb.r, _rgb.g, _rgb.b, _rgb.a);
     GL.Vertex3(_xyz.x, _xyz.y, _xyz.z);
     GL.End();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Delegate rendering iteratively to all Drawable of this composite.
 /// </summary>
 public override void Draw(Rendering.View.Camera cam)
 {
     lock (_components) {
         foreach (AbstractDrawable s in _components)
         {
             if ((s != null))
             {
                 s.Draw(cam);
             }
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Reset the object if required, compile the object if it is not compiled,
 /// and execute actual rendering.
 /// </summary>
 /// <param name="cam">Camera to draw for.</param>
 public override void Draw(Rendering.View.Camera cam)
 {
     if (_resetDL)
     {
         this.Reset();
     }
     if (_dlID == -1)
     {
         this.Compile(cam);
     }
     this.Execute(cam);
 }
Ejemplo n.º 7
0
 public override void Draw(Rendering.View.Camera cam)
 {
     if ((_transform != null))
     {
         _transform.Execute();
     }
     if (_facestatus)
     {
         ApplyPolygonModeFill();
         if (_wfstatus & _polygonOffsetFillEnable)
         {
             EnablePolygonOffsetFill();
         }
         GL.Begin(BeginMode.Polygon);
         foreach (Point p in _points)
         {
             if ((_mapper != null))
             {
                 p.Color = _mapper.Color(p.xyz);
             }
             GL.Color4(p.Color.r, p.Color.g, p.Color.b, p.Color.a);
             GL.Vertex3(p.xyz.x, p.xyz.y, p.xyz.z);
         }
         GL.End();
         if (_wfstatus & _polygonOffsetFillEnable)
         {
             DisablePolygonOffsetFill();
         }
     }
     if (_wfstatus)
     {
         ApplyPolygonModeLine();
         if (_polygonOffsetFillEnable)
         {
             EnablePolygonOffsetFill();
         }
         GL.Color4(_wfcolor.r, _wfcolor.g, _wfcolor.b, _wfcolor.a);
         GL.LineWidth(_wfwidth);
         GL.Begin(BeginMode.Polygon);
         foreach (Point p in _points)
         {
             GL.Vertex3(p.xyz.x, p.xyz.y, p.xyz.z);
         }
         GL.End();
         if (_polygonOffsetFillEnable)
         {
             DisablePolygonOffsetFill();
         }
     }
 }
Ejemplo n.º 8
0
        public override double getLongestDistance(Rendering.View.Camera camera)
        {
            double max  = 0;
            double dist = 0;

            foreach (Point p in _points)
            {
                dist = p.getDistance(camera);
                if (dist > max)
                {
                    max = dist;
                }
            }
            return(max);
        }
Ejemplo n.º 9
0
        public override double getShortestDistance(Rendering.View.Camera camera)
        {
            double min  = double.MaxValue;
            double dist = 0;

            foreach (Point p in _points)
            {
                dist = p.getDistance(camera);
                if (dist < min)
                {
                    min = dist;
                }
            }
            dist = Barycentre.distance(camera.Eye);
            if (dist < min)
            {
                min = dist;
            }
            return(min);
        }
Ejemplo n.º 10
0
 public void Draw(Rendering.View.Camera camera)
 {
     GL.LoadIdentity();
     GL.Scale(_scale.x, _scale.y, _scale.y);
     GL.LineWidth(2);
     GL.Begin(BeginMode.Lines);
     GL.Color3(1, 0, 0);
     // R
     GL.Vertex3(_bbox.xmin, _bbox.ymin, _bbox.zmin);
     GL.Vertex3(_bbox.xmax, 0, 0);
     GL.Color3(0, 1, 0);
     // G
     GL.Vertex3(_bbox.xmin, _bbox.ymin, _bbox.zmin);
     GL.Vertex3(0, _bbox.ymax, 0);
     GL.Color3(0, 0, 1);
     // B
     GL.Vertex3(_bbox.xmin, _bbox.ymin, _bbox.zmin);
     GL.Vertex3(0, 0, _bbox.zmax);
     GL.End();
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 public abstract void drawSimpleText(Rendering.View.Camera cam, string s, Maths.Coord3d position, Colors.Color color);
Ejemplo n.º 13
0
        public void Draw(Rendering.View.Camera camera)
        {
            // Set scaling
            GL.LoadIdentity();
            GL.Scale(_scale.x, _scale.y, _scale.z);
            // Set culling
            GL.Enable(EnableCap.CullFace);
            GL.FrontFace(FrontFaceDirection.Ccw);
            GL.CullFace(CullFaceMode.Front);
            // Draw cube in feedback buffer for computing hidden quads
            _quadIsHidden = getHiddenQuads(camera);
            // Plain part of quad making the surrounding box
            if (_layout.FaceDisplayed)
            {
                Color quadcolor = _layout.QuadColor;
                GL.PolygonMode(MaterialFace.Back, PolygonMode.Fill);
                GL.Color4(quadcolor.r, quadcolor.g, quadcolor.b, quadcolor.a);
                GL.LineWidth(1);
                GL.Enable(EnableCap.PolygonOffsetFill);
                GL.PolygonOffset(1, 1);
                // handle stippling
                drawCube(OpenTK.Graphics.RenderingMode.Render);
                GL.Disable(EnableCap.PolygonOffsetFill);
            }
            // Edge part of quads making the surrounding box
            Color gridcolor = _layout.GridColor;

            GL.PolygonMode(MaterialFace.Back, PolygonMode.Line);
            GL.Color4(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a);
            GL.LineWidth(1);
            drawCube(OpenTK.Graphics.RenderingMode.Render);
            // Draw grids on non hidden quads
            GL.PolygonMode(MaterialFace.Back, PolygonMode.Line);
            GL.Color4(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a);
            GL.LineWidth(1);
            GL.LineStipple(1, 0xaaaa);
            GL.Enable(EnableCap.LineStipple);
            for (int quad = 0; quad <= 5; quad++)
            {
                if ((!_quadIsHidden[quad]))
                {
                    drawGridOnQuad(quad);
                }
            }
            GL.Disable(EnableCap.LineStipple);
            // Draw ticks on the closest axes
            _wholeBounds.reset();
            _wholeBounds.Add(_boxBounds);
            //gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
            // Display x axis ticks
            if ((_xrange > 0 & _layout.XTickLabelDisplayed))
            {
                // If we are on top, we make direct axe placement
                if ((((_view != null) && _view.ViewMode == nzy3D.Plot3D.Rendering.View.Modes.ViewPositionMode.TOP)))
                {
                    BoundingBox3d bbox = drawTicks(camera, 1, AxeDirection.AxeX, _layout.XTickColor, Halign.LEFT, Valign.TOP);
                    // setup tick labels for X on the bottom
                    _wholeBounds.Add(bbox);
                }
                else
                {
                    // otherwise computed placement
                    int xselect = findClosestXaxe(camera);
                    if ((xselect >= 0))
                    {
                        BoundingBox3d bbox = drawTicks(camera, xselect, AxeDirection.AxeX, _layout.XTickColor);
                        _wholeBounds.Add(bbox);
                    }
                    else
                    {
                        //System.err.println("no x axe selected: " + Arrays.toString(quadIsHidden));
                        // HACK: handles "on top" view, when all face of cube are drawn, which forbid to select an axe automatically
                        BoundingBox3d bbox = drawTicks(camera, 2, AxeDirection.AxeX, _layout.XTickColor, Halign.CENTER, Valign.TOP);
                        _wholeBounds.Add(bbox);
                    }
                }
            }
            // Display y axis ticks
            if ((_yrange > 0 & _layout.YTickLabelDisplayed))
            {
                if ((((_view != null)) && _view.ViewMode == nzy3D.Plot3D.Rendering.View.Modes.ViewPositionMode.TOP))
                {
                    BoundingBox3d bbox = drawTicks(camera, 2, AxeDirection.AxeY, _layout.YTickColor, Halign.LEFT, Valign.GROUND);
                    // setup tick labels for Y on the left
                    _wholeBounds.Add(bbox);
                }
                else
                {
                    int yselect = findClosestYaxe(camera);
                    if ((yselect >= 0))
                    {
                        BoundingBox3d bbox = drawTicks(camera, yselect, AxeDirection.AxeY, _layout.YTickColor);
                        _wholeBounds.Add(bbox);
                    }
                    else
                    {
                        //System.err.println("no y axe selected: " + Arrays.toString(quadIsHidden));
                        // HACK: handles "on top" view, when all face of cube are drawn, which forbid to select an axe automatically
                        BoundingBox3d bbox = drawTicks(camera, 1, AxeDirection.AxeY, _layout.YTickColor, Halign.RIGHT, Valign.GROUND);
                        _wholeBounds.Add(bbox);
                    }
                }
            }
            // Display z axis ticks
            if ((_zrange > 0 & _layout.ZTickLabelDisplayed))
            {
                if ((((_view != null)) && _view.ViewMode == nzy3D.Plot3D.Rendering.View.Modes.ViewPositionMode.TOP))
                {
                }
                else
                {
                    int zselect = findClosestZaxe(camera);
                    if ((zselect >= 0))
                    {
                        BoundingBox3d bbox = drawTicks(camera, zselect, AxeDirection.AxeZ, _layout.ZTickColor);
                        _wholeBounds.Add(bbox);
                    }
                }
            }
            // Unset culling
            GL.Disable(EnableCap.CullFace);
        }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
0
 public override double getShortestDistance(Rendering.View.Camera camera)
 {
     return(getDistance(camera));
 }
Ejemplo n.º 16
0
 public virtual double getDistance(Rendering.View.Camera camera)
 {
     return(Barycentre.distance(camera.Eye));
 }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
 public override double getDistance(Rendering.View.Camera camera)
 {
     return(_xyz.distance(camera.Eye));
 }
Ejemplo n.º 19
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);
 }
Ejemplo n.º 20
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));
 }
Ejemplo n.º 21
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);
Ejemplo n.º 22
0
 public virtual double getShortestDistance(Rendering.View.Camera camera)
 {
     return(getDistance(camera));
 }
Ejemplo n.º 23
0
 public abstract void Draw(Rendering.View.Camera cam);