示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParticleSystem"/> class.
        /// </summary>
        public ParticleSystem()
        {
            //  Create the effect for the system.
            OpenGLAttributesEffect attributesEffect = new OpenGLAttributesEffect();
            attributesEffect.LightingAttributes.Enable = false;

            //  Add the effects.
            AddEffect(attributesEffect);
        }
示例#2
0
        public void draw_sphere(OpenGL gl, double agent)
        {
            Sphere sphere = new SharpGL.SceneGraph.Quadrics.Sphere();
            sphere.Radius = agent;
            GLColor glClr = new GLColor(0.0f, 0.0f, 1.0f, 0.5f);
            OpenGLAttributesEffect glEffect = new OpenGLAttributesEffect();
            glEffect.ColorBufferAttributes.ColorModeClearColor = glClr;
            glEffect.ColorBufferAttributes.ColorModeWriteMask = glClr;

            sphere.NormalGeneration = SharpGL.SceneGraph.Quadrics.Normals.Smooth;
            sphere.NormalOrientation = SharpGL.SceneGraph.Quadrics.Orientation.Outside;
            sphere.QuadricDrawStyle = SharpGL.SceneGraph.Quadrics.DrawStyle.Fill;
            sphere.AddEffect(glEffect);

            sphere.CreateInContext(gl);

            sphere.Slices = 100;
            sphere.Stacks = 100;
            sphere.TextureCoords = false;

            sphere.PushObjectSpace(gl);
            sphere.Render(gl, SharpGL.SceneGraph.Core.RenderMode.Render);
            sphere.PopObjectSpace(gl);
        }
示例#3
0
文件: Scene.cs 项目: chances/Animatum
        /// <summary>
        /// Construct a new scene, optionally enableing post-processing, if available.
        /// </summary>
        /// <param name="postprocessingEnabled">Whether or not to enable post-processing; defaults to false</param>
        public Scene(OpenGL gl, Size viewportSize)
        {
            this.gl = gl;
            this.viewportSize = viewportSize;

            model = null;

            postprocessingEnabled = false;

            ClearColor = Color.Black;
            camera = new MovingLookAtCamera()
            {
                Position = new Vertex(10f, 0f, 0f),
                Target = new Vertex(0f, 0f, 0f),
                UpVector = new Vertex(0f, 0f, 1f),
                Near = 0,
                Far = 250,
                HorizontalTheta = 0.785f,
                VerticalTheta = -0.785f
            };
            RenderGrid = true;
            RenderAxies = true;
            grid = new Grid();
            grid.Size = 150;
            axies = new Axies();
            axies.Size = 150;
            //Set attributes
            attrs = new OpenGLAttributesEffect();
            attrs.EnableAttributes.EnableDepthTest = true;
            attrs.EnableAttributes.EnableNormalize = true;
            attrs.EnableAttributes.EnableLighting = true;
            attrs.EnableAttributes.EnableTexture2D = true;
            attrs.LightingAttributes.TwoSided = false;

            Color col = Color.FromArgb(40, 40, 40);

            // Nice soft-ish lighting
            Light light = new Light(OpenGL.GL_LIGHT0)
            {
                Position = new Vertex(-9, -9, 11),
                Ambient = Color.Black,
                Diffuse = col,
                Specular = col
            };
            this.Children.Add(light);
            light = new Light(OpenGL.GL_LIGHT1)
            {
                Position = new Vertex(9, -9, 11),
                Ambient = Color.Black,
                Diffuse = col,
                Specular = col
            };
            this.Children.Add(light);
            light = new Light(OpenGL.GL_LIGHT2)
            {
                Position = new Vertex(0, 15, 15),
                Ambient = Color.Black,
                Diffuse = col,
                Specular = col
            };
            this.Children.Add(light);
        }
示例#4
0
        /// <summary>
        /// Initialises a modeling scene. A modeling scene has:
        ///  - A 'Look At' camera targetting the centre of the scene
        ///  - Three gentle omnidirectional lights
        ///  - A design time grid and axis.
        /// </summary>
        /// <param name="scene">The scene.</param>
        public static void InitialiseModelingScene(Scene scene)
        {
            //  Create the 'Look At' camera
            var lookAtCamera = new LookAtCamera()
            {
                Position = new Vertex(-10f, -10f, 10f),
                Target = new Vertex(0f, 0f, 0f),
                UpVector = new Vertex(0f, 0f, 1f)
            };

            //  Set the look at camera as the current camera.
            scene.CurrentCamera = lookAtCamera;

            //  Add some design-time primitives.
            var folder = new Folder() { Name = "Design Primitives" };
            folder.AddChild(new Grid());
            folder.AddChild(new Axies());
            scene.SceneContainer.AddChild(folder);

            //  Create some lights.
            Light light1 = new Light()
            {
                Name="Light 1",
                On = true,
                Position = new Vertex(-9, -9, 11),
                GLCode = OpenGL.GL_LIGHT0
            };
            Light light2 = new Light()
            {
                Name = "Light 2",
                On = true,
                Position = new Vertex(9, -9, 11),
                GLCode = OpenGL.GL_LIGHT1
            };
            Light light3 = new Light()
            {
                Name = "Light 3",
                On = true,
                Position = new Vertex(0, 15, 15),
                GLCode = OpenGL.GL_LIGHT2
            };
            //  Add the lights.
            folder = new Folder() { Name = "Lights" };
            folder.AddChild(light1);
            folder.AddChild(light2);
            folder.AddChild(light3);
            scene.SceneContainer.AddChild(folder);

            //  Create a set of scene attributes.
            OpenGLAttributesEffect sceneAttributes = new OpenGLAttributesEffect()
            {
                Name = "Scene Attributes"
            };

            //  Specify the scene attributes.
            sceneAttributes.EnableAttributes.EnableDepthTest = true;
            sceneAttributes.EnableAttributes.EnableNormalize = true;
            sceneAttributes.EnableAttributes.EnableLighting = true;
            sceneAttributes.EnableAttributes.EnableTexture2D = true;
            sceneAttributes.EnableAttributes.EnableBlend = true;
            sceneAttributes.ColorBufferAttributes.BlendingSourceFactor = BlendingSourceFactor.SourceAlpha;
            sceneAttributes.ColorBufferAttributes.BlendingDestinationFactor = BlendingDestinationFactor.OneMinusSourceAlpha;
            sceneAttributes.LightingAttributes.TwoSided = true;
            scene.SceneContainer.AddEffect(sceneAttributes);
        }