public void glutSolidSphere(double radius, int slices, int stacks) { Glu.QuadricDrawStyle(quadObj, QuadricDrawStyle.Fill); Glu.QuadricNormal(quadObj, QuadricNormal.Smooth); /* If we ever changed/used the texture or orientation state * of quadObj, we'd need to change it to the defaults here * with gluQuadricTexture and/or gluQuadricOrientation. */ Glu.Sphere(quadObj, radius, slices, stacks); }
public void Draw() { GL.Translate(pos); Glu.Sphere(quad, radius, slices, stacks); GL.Translate(-pos); }
//画多个内置立体件: private void DrawModels() { float width = 3; float height = 3; float length = 3; GL.LineWidth(4); GL.PointSize(8); var obj = Glu.NewQuadric(); //Glu.QuadricDrawStyle(obj, QuadricDrawStyle.Line); //Glu.QuadricDrawStyle(obj, QuadricDrawStyle.Silhouette); //Glu.QuadricDrawStyle(obj, QuadricDrawStyle.Point); //Glu.QuadricDrawStyle(obj, QuadricDrawStyle.Fill); Glu.QuadricDrawStyle(obj, QuadricDrawStyle.Line); ////画大正方形上可旋转各对象 Draw plane that the objects rest on //GL.PushMatrix(); //GL.Color4(0.5f,0.3f, 0.5f, 0.5f); // Blue //GL.Normal3(0.0f, 1.0f, 0.0f); //GL.Begin(BeginMode.Quads); //GL.Vertex3(-10.0f, -2.5f, -10.0f); //GL.Vertex3(-10.0f, -2.5f, 10.0f); //GL.Vertex3(10.0f, -2.5f, 10.0f); //GL.Vertex3(10.0f, -2.5f, -10.0f); //GL.End(); //GL.PopMatrix(); ////画网线空心球 //GL.PushMatrix(); //GL.Color3(0.6f, 0.6f, 0.8f); //GL.Translate(0.0f, -3.0f, 0.0f); //Glu.Sphere(obj, 2, 6, 4);//球体----------------- //GL.PopMatrix(); ////画立方体(6个正方形) Draw red cube //GL.PushMatrix(); //GL.Color3(0.5f, 0.75f, 0.5f); //GL.Translate(0.0f, 3.0f, 0.0f); //GL.Begin(BeginMode.Quads); //// //GL.Normal3(0.0f, 0.0f, -1.0f); //GL.Vertex3(-width, height, -length); //0 //GL.Vertex3(width, height, -length); //1 //GL.Vertex3(width, -height, -length);//2 //GL.Vertex3(-width, -height, -length); //3 //// //GL.Normal3(0.0f, 0.0f, 1.0f); //GL.Vertex3(-width, height, length); //4 //GL.Vertex3(-width, -height, length); //5 //GL.Vertex3(width, -height, length); //6 //GL.Vertex3(width, height, length); //7 //// //GL.Normal3(0.0f, 1.0f, 0.0f); //GL.Vertex3(-width, height, length); //8 (4) //GL.Vertex3(width, height, length); //9 (6) //GL.Vertex3(width, height, -length); //10 (0) //GL.Vertex3(-width, height, -length); //11 (1) //// //GL.Normal3(0.0f, -1.0f, 0.0f); //GL.Vertex3(-width, -height, length); //12 (5) //GL.Vertex3(-width, -height, -length);//13 (2) //GL.Vertex3(width, -height, -length); //14 (7) //GL.Vertex3(width, -height, length); //15 (3) //// //GL.Normal3(1.0f, 0.0f, 0.0f); //GL.Vertex3(width, height, -length); //16 (1) //GL.Vertex3(width, height, length); //17 (6) //GL.Vertex3(width, -height, length); //18 (3) //GL.Vertex3(width, -height, -length); //19 (7) //// //GL.Normal3(-1.0f, 0.0f, 0.0f); //GL.Vertex3(-width, height, -length); //20 (0) //GL.Vertex3(-width, -height, -length);//21 (2) //GL.Vertex3(-width, -height, length); //22 (4) //GL.Vertex3(-width, height, length); //23 (5) //// //GL.End(); //GL.PopMatrix(); //绿色球体 Draw green sphere GL.PushMatrix(); GL.Color3(0.0f, 1.0f, 0.0f); GL.Translate(-6.0f, 0.0f, 0.0f); Glu.Sphere(obj, 2.5f, 8, 12); GL.PopMatrix(); ////黄色锥体 Draw yellow cone //GL.PushMatrix(); //GL.Color3(1.0f, 1.0f, 0.0f); //GL.Rotate(-90.0f, 1.0f, 0.0f, 0.0f); //GL.Translate(6.0f, 0.0f, -2.4f); //Glu.Cylinder(obj, 2.5f, 1.0f, 5.0f, 8, 12); //GL.PopMatrix(); ////绘制实心圆环 Draw magenta torus //GL.PushMatrix(); //GL.Color3(1.0f, 0.0f, 1.0f); //GL.Translate(0.0f, 0.0f, 2.0f); //DrawTorus(5.0f, 1.0f, 20, 20);//绘制实心圆环 //GL.PopMatrix(); ////绘制八面体 Draw cyan octahedron //GL.PushMatrix(); //GL.Color3(0.0f, 1.0f, 1.0f); //GL.Translate(0.0f, -2.0f, 0f); //Glu.Sphere(obj, .5, 4, 2);//绘制八面体 //GL.PopMatrix(); }