Exemplo n.º 1
0
        private void AddPlane()
        {
            var planeSo = new Node(Scene, "plane");

            planeSo.Transform.LocalPosition = new Vector3(0, 0.01f, 0);
            planeSo.Transform.LocalRotation = new Quaternion(Vector3.Left, MathF.PI / 2);
            var renderer = planeSo.AddComponent <MeshRenderable>();

            renderer.IsEnabled = true;

            var mesh = Plane.Create(2, 2);

            renderer.Mesh     = mesh;
            renderer.Material = new Material(MaterialType.DiffuseNormalTextureColor);
            renderer.Material.SetTexture("uniform_NormalTexture", new Texture2("Resources/Textures/1.png", true));
            renderer.Material.MainTexture = new Texture2("Resources/Textures/2.png", false);
        }
Exemplo n.º 2
0
        private void AddDeferredTest()
        {
            var planeSo = new Node(_scene, "plane");

            planeSo.AddComponent <MeshRenderable>().Mesh = Plane.Create(10, 10);
            planeSo.Transform.LocalRotation = new Quaternion(Vector3.Left, MathF.PI / 2);

            var sphereMesh     = Icosahedron.Create(0.01f, 2);
            var sphereMaterial = new Material(MaterialType.FlatColor);

            sphereMaterial.Color = Vector4.One;

            var lightsParent = new Node(_scene, "lights");

            lightsParent.AddComponent <Rotator>().Rotation = new Vector3(0.7, 0, 0);
            var lightCount = 50;

            for (int i = 0; i < lightCount; i++)
            {
                var so = new Node(_scene);
                so.Transform.Parent = lightsParent.Transform;
                var light = so.AddComponent <LightSource>();
                var color = new Vector3(RandomF.Float(), RandomF.Float(), RandomF.Float());
                color            /= MathF.Max(color.X, color.Y, color.Z);
                light.Diffuse     = color;
                light.Attenuation = new Vector3(0, 4f, 0);

                var position = Vector3.Zero;
                while (position.LengthSquared < 0.05f)
                {
                    position = RandomF.InsideUnitSphere();
                }
                so.Transform.LocalPosition = position * 5;

                var meshRenderer = so.AddComponent <MeshRenderable>();
                meshRenderer.Mesh     = sphereMesh;
                meshRenderer.Material = sphereMaterial;
            }
        }