Ejemplo n.º 1
0
        /// <summary>
        /// Render propeller in modern opengl.
        /// </summary>
        /// <returns></returns>
        public static LightPostionNode Create()
        {
            var vs       = new VertexShader(vertexCode, inPosition);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, CubeModel.strPosition);
            var builder = new RenderMethodBuilder(provider, map, new PolygonModeState(PolygonMode.Line));
            var node    = new LightPostionNode(new CubeModel(), CubeModel.strPosition, builder);

            node.Initialize();

            return(node);
        }
Ejemplo n.º 2
0
        private SceneNodeBase GetRootElement()
        {
            var group         = new GroupNode();
            var lightPosition = new vec3(0, 3, 5) * 2;
            var localLight    = new SpotLight(lightPosition, new vec3(0, 0, 0), 60, 1, 500)
            {
                Color = new vec3(1, 1, 1),
            };

            {
                var lightContainer = new LightContainerNode(localLight);
                {
                    var model = new Teapot();
                    var node  = ShadowMappingNode.Create(model, Teapot.strPosition, Teapot.strNormal, model.GetModelSize());
                    node.Diffuse     = Color.Gold.ToVec3();
                    node.RotateSpeed = 1;
                    lightContainer.Children.Add(node);
                }
                {
                    var model = new GroundModel();
                    var node  = ShadowMappingNode.Create(model, GroundModel.strPosition, GroundModel.strNormal, model.ModelSize);
                    node.Diffuse       = Color.AliceBlue.ToVec3();
                    node.Scale        *= 30;
                    node.WorldPosition = new vec3(0, -3, 0);
                    lightContainer.Children.Add(node);
                }
                group.Children.Add(lightContainer);
            }
            {
                var rectangle = RectangleNode.Create();
                rectangle.TextureSource = localLight;
                rectangle.RotationAngle = 45;
                rectangle.WorldPosition = new vec3(5, 1, 5) * 3;
                rectangle.Scale        *= 4;

                group.Children.Add(rectangle);
            }
            {
                var cube = LightPostionNode.Create();
                cube.WorldPosition = lightPosition;
                cube.SetLight(localLight);
                group.Children.Add(cube);
            }
            return(group);
        }