lixiaojun
2024-11-11 00bcee19c5dff21a9848c16b45419efb74bf07e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
using SharpGL;
using SharpGL.SceneGraph.Assets;
using SharpGL.SceneGraph.Effects;
using SharpGL.SceneGraph.Lighting;
using SharpGL.SceneGraph.Primitives;
using SharpGL.SceneGraph.Quadrics;
 
 
namespace Yw.WinFrmUI.HydroL3d
{
    public partial class NetworkScenePanel : DevExpress.XtraEditors.XtraUserControl
    {
        public NetworkScenePanel()
        {
            InitializeComponent();
 
        }
 
        private void sceneControl1_OpenGLDraw(object sender, RenderEventArgs args)
        {
            //// 获取 OpenGL 对象
            //var gl = sceneControl.OpenGL;
 
            //// 清除颜色和深度缓冲区
            //gl.ClearColor(0.2f, 0.3f, 0.3f, 1.0f);
            //gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
 
            SharpGL.SceneGraph.Quadrics.Sphere sphere = new SharpGL.SceneGraph.Quadrics.Sphere();
            sphere.Transformation.TranslateX = 2;
            sphere.Transformation.TranslateY = 2;
 
            //  Create a cone.
            SharpGL.SceneGraph.Quadrics.Cylinder cone = new SharpGL.SceneGraph.Quadrics.Cylinder() { Name = "Cone" };
            cone.BaseRadius = 1.5;
            cone.TopRadius = 0;
            cone.Height = 2;
            cone.Transformation.TranslateX = -2;
            cone.Transformation.TranslateY = -2;
 
            //  Create a cylinder.
            SharpGL.SceneGraph.Quadrics.Cylinder cylinder = new SharpGL.SceneGraph.Quadrics.Cylinder() { Name = "Cylinder" };
            cylinder.BaseRadius = 1.5;
            cylinder.TopRadius = 1.5;
            cylinder.Height = 2;
            cylinder.Transformation.TranslateX = -2;
            cylinder.Transformation.TranslateY = 2;
 
            //  Create a cube.
            Cube cube = new Cube();
            cube.Transformation.TranslateX = 2;
            cube.Transformation.TranslateY = -2;
            cube.Transformation.RotateZ = 45f;
 
            //  Add them.
            sceneControl.Scene.SceneContainer.AddChild(sphere);
            sceneControl.Scene.SceneContainer.AddChild(cube);
            sceneControl.Scene.SceneContainer.AddChild(cone);
            sceneControl.Scene.SceneContainer.AddChild(cylinder);
 
            this.sceneControl.Invalidate();
        }
 
        private void sceneControl1_Resized(object sender, EventArgs e)
        {
 
        }
 
        private void sceneControl1_Load(object sender, EventArgs e)
        {
            //  Create a sphere.
 
        }
 
    }
}