Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormSceneSample"/> class.
        /// </summary>
        public FormSceneSample()
        {
            InitializeComponent();

            sceneControl1.MouseDown += new MouseEventHandler(FormSceneSample_MouseDown);
            sceneControl1.MouseMove += new MouseEventHandler(FormSceneSample_MouseMove);
            sceneControl1.MouseUp += new MouseEventHandler(sceneControl1_MouseUp);

            //  Add some design-time primitives.
            sceneControl1.Scene.SceneContainer.AddChild(new
                SharpGL.SceneGraph.Primitives.Grid());
            sceneControl1.Scene.SceneContainer.AddChild(new 
                SharpGL.SceneGraph.Primitives.Axies());

            //  Create a light.
            Light light = new Light()
            {
                On = true,
                Position = new Vertex(3, 10, 3),
                GLCode = OpenGL.GL_LIGHT0
            };

            //  Add the light.
            sceneControl1.Scene.SceneContainer.AddChild(light);

            //  Create a sphere.
            Cube cube = new Cube();
            cube.AddEffect(arcBallEffect);
            
            //  Add it.
            sceneControl1.Scene.SceneContainer.AddChild(cube);

            //  Add the root element to the tree.
            AddElementToTree(sceneControl1.Scene.SceneContainer, treeView1.Nodes);
        }
Exemplo n.º 2
0
        public FormMain()
        {
            InitializeComponent();

            //  Create a light.
            Light light = new Light()
            {
                On = true,
                Position = new Vertex(30, 100, 30),
                GLCode = OpenGL.GL_LIGHT0
            };

            Cube cubeSmall = new Cube()
            {
                Position = new Vertex(0, 0, 1),
                Scale = new Vertex(1, 1, 1)
            };

            Cube cubeBig = new Cube
            {
                Position = new Vertex(-3, -3, 2),
                Scale = new Vertex(2, 2, 2)
            };

            //  Add some design-time primitives.
            sceneControl1.Scene.SceneContainer.AddChild(new Grid());
            sceneControl1.Scene.SceneContainer.AddChild(new Axies());
            //sceneControl1.Scene.CurrentCamera.Project();

            //  Add it.
            //  Add the light.
            sceneControl1.Scene.SceneContainer.AddChild(cubeSmall);
            sceneControl1.Scene.SceneContainer.AddChild(cubeBig);
            sceneControl1.Scene.SceneContainer.AddChild(light);

            Camera.Position = new Vertex(10, 10, 10);
            Camera.Target = new Vertex(0, 0, 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormHitTestSample"/> class.
        /// </summary>
        public FormHitTestSample()
        {
            InitializeComponent();

            //  Create a sphere.
            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.
            sceneControl1.Scene.SceneContainer.AddChild(sphere);
            sceneControl1.Scene.SceneContainer.AddChild(cube);
            sceneControl1.Scene.SceneContainer.AddChild(cone);
            sceneControl1.Scene.SceneContainer.AddChild(cylinder);
        }