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; }
/****************************************************************** * treeView的右键菜单响应 完成度90% * *******************************************************************/ private void 多面体ToolStripMenuItem_Click(object sender, EventArgs e) { sceneControl1.Scene.OpenGL.NewQuadric(); Polygon 多面体 = new Polygon() { Name = "多面体" }; 多面体.Material = new Material(); 多面体.AddEffect(objectArcBallEffect); sceneControl1.Scene.SceneContainer.AddChild(多面体); treeView1.Nodes.Clear(); AddElementToTree(sceneControl1.Scene.SceneContainer, treeView1.Nodes); }