Example #1
0
        public Wall(Vertex[] vertex1, string name, OpenGL gl)
        {
            DepthBufferAttributes depthBufferAttributes = new DepthBufferAttributes();

            depthBufferAttributes.DepthFunction   = DepthFunction.LessThanOrEqual;
            depthBufferAttributes.EnableDepthTest = true;

            Name = name;

            // ==== Fill polygon ===
            PolygonAttributes polygonFillAttributes = new PolygonAttributes();

            polygonFillAttributes.PolygonMode    = PolygonMode.Filled;
            polygonFillAttributes.CullFaces      = FaceMode.Back;
            polygonFillAttributes.EnableCullFace = true;

            polygonFillAttributes.OffsetFactor     = 0f;
            polygonFillAttributes.OffsetBias       = 0;
            polygonFillAttributes.EnableOffsetFill = true;

            OpenGLAttributesEffect polyFillEffect = new OpenGLAttributesEffect();

            polyFillEffect.PolygonAttributes = polygonFillAttributes;
            //polyFillEffect.DepthBufferAttributes = depthBufferAttributes;

            SharpGL.SceneGraph.Primitives.Polygon polyFill = new Polygon(this.Name, vertex1);
            polyFill.Material = Materials.Pink(gl);
            polyFill.AddEffect(polyFillEffect);
            this.Children.Add(polyFill);

            // ==== Border polygon ===
            PolygonAttributes polygonBorderAttributes = new PolygonAttributes();

            polygonBorderAttributes.PolygonMode      = PolygonMode.Lines;
            polygonBorderAttributes.OffsetFactor     = -.5f;
            polygonBorderAttributes.OffsetBias       = -.5f;
            polygonBorderAttributes.EnableOffsetLine = true;
            polygonBorderAttributes.CullFaces        = FaceMode.Back;
            polygonBorderAttributes.EnableCullFace   = true;

            OpenGLAttributesEffect polyBorderEffect = new OpenGLAttributesEffect();

            polyBorderEffect.PolygonAttributes = polygonBorderAttributes;
            //polyBorderEffect.DepthBufferAttributes = depthBufferAttributes;

            SharpGL.SceneGraph.Primitives.Polygon polyBorder = new Polygon(this.Name, vertex1);
            polyBorder.Material = Materials.DarkGrey(gl);
            polyBorder.AddEffect(polyBorderEffect);
            this.Children.Add(polyBorder);

            this.polyFill = polyFill;
        }
Example #2
0
        public void AddSymbol(Circle circle, OpenGL gl)
        {
            DepthBufferAttributes depthBufferAttributes = new DepthBufferAttributes();

            depthBufferAttributes.DepthFunction   = DepthFunction.LessThanOrEqual;
            depthBufferAttributes.EnableDepthTest = true;

            PolygonAttributes polygonBorderAttributes = new PolygonAttributes();

            polygonBorderAttributes.PolygonMode = PolygonMode.Lines;

            polygonBorderAttributes.EnableOffsetLine = true;
            polygonBorderAttributes.OffsetFactor     = -3f;
            polygonBorderAttributes.OffsetBias       = -3f;

            OpenGLAttributesEffect polyBorderEffect = new OpenGLAttributesEffect();

            polyBorderEffect.PolygonAttributes     = polygonBorderAttributes;
            polyBorderEffect.DepthBufferAttributes = depthBufferAttributes;

            circle.Material = Materials.DarkGrey(gl);
            circle.AddEffect(polyBorderEffect);
            this.Children.Add(circle);
        }
Example #3
0
        public RoundColumn(OpenGL gl, string name, Circle circle, float bottomPoint, float topPoint) : base()
        {
            this.Name        = name;
            this.circle      = circle;
            this.bottomPoint = bottomPoint;
            this.topPoint    = topPoint;

            boundingVolumeHelper = new BoundingVolumeHelper();

            Vertex startPoint  = circle.StartPoint;
            Vertex secondPoint = circle.SecondPoint;
            Vertex endPoint    = circle.EndPoint;

            // ==== Create bottom circle of column ====
            startPoint.Z  = bottomPoint;
            secondPoint.Z = bottomPoint;
            endPoint.Z    = bottomPoint;


            DepthBufferAttributes depthBufferAttributes = new DepthBufferAttributes();

            depthBufferAttributes.DepthFunction   = DepthFunction.LessThanOrEqual;
            depthBufferAttributes.EnableDepthTest = true;

            PolygonAttributes polygonAttributes = new PolygonAttributes();

            polygonAttributes.PolygonMode = PolygonMode.Lines;

            polygonAttributes.EnableOffsetLine = true;
            polygonAttributes.OffsetFactor     = -.9f;
            polygonAttributes.OffsetBias       = -.9f;

            OpenGLAttributesEffect openGLAttributesEffect = new OpenGLAttributesEffect();

            openGLAttributesEffect.PolygonAttributes = polygonAttributes;
            //openGLAttributesEffect.DepthBufferAttributes = depthBufferAttributes;

            Circle bottomCircle = new Circle(new Vertex(startPoint), new Vertex(secondPoint), new Vertex(endPoint));

            bottomCircle.Material = Materials.DarkGrey(gl);
            bottomCircle.AddEffect(openGLAttributesEffect);
            AddChild(bottomCircle);

            // ==== Create top circle of column ====
            startPoint.Z  = topPoint;
            secondPoint.Z = topPoint;
            endPoint.Z    = topPoint;

            Circle topCircle = new Circle(new Vertex(startPoint), new Vertex(secondPoint), new Vertex(endPoint));

            topCircle.Material = Materials.DarkGrey(gl);
            topCircle.AddEffect(openGLAttributesEffect);
            AddChild(topCircle);

            // ==== Create column body ====
            // Create the display list.

            this.Material = Materials.Purple(gl);

            displayList = new DisplayList();

            // Generate the display list and
            displayList.Generate(gl);

            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);


            gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_FILL);
            gl.Begin(BeginMode.QuadStrip);
            double angle = 0;

            while (angle <= 2 * Math.PI * 1.01)
            {
                double xTmp = circle.Radius * Math.Cos(angle);
                double yTmp = circle.Radius * Math.Sin(angle);

                gl.Vertex(circle.Center.X + xTmp, circle.Center.Y + yTmp, bottomPoint);
                gl.Vertex(circle.Center.X + xTmp, circle.Center.Y + yTmp, topPoint);
                angle += 0.1;
            }
            gl.End();

            // End the display list.
            displayList.End(gl);
        }