Esempio n. 1
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            SimpleMeshes.MakeMaterial((float4)ColorUint.LightGrey),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 10, 10))
                        }
                    },
                }
            });
        }
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0.8f, 1, 0.4f, 1);

            // Create a scene with a cube
            // The three components: one XForm, one Material and the Mesh
            _cubeTransform = new Transform {
                Translation = new float3(0, 0, 0)
            };
            var cubeShader = ShaderCodeBuilder.MakeShaderEffect(new float4(0, 0, 1, 1));
            var cubeMesh   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            // Assemble the cube node containing the three components
            var cubeNode = new SceneNode();

            cubeNode.Components.Add(_cubeTransform);
            cubeNode.Components.Add(cubeShader);
            cubeNode.Components.Add(cubeMesh);

            // Create the scene containing the cube as the only object
            _scene = new SceneContainer();
            _scene.Children.Add(cubeNode);

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Esempio n. 3
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to "greenery" ;-) (https://store.pantone.com/de/de/color-of-the-year-2017/).
            RC.ClearColor = new float4(136f / 255f, 176f / 255f, 75f / 255f, 1);

            // Create a scene with a cube
            // The three components: one Transform, one ShaderEffect (blue material) and the Mesh
            _cubeTransform = new Transform {
                Translation = new float3(0, 0, 0)
            };
            _cubeEffect = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero);
            var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            // Assemble the cube node containing the three components
            var cubeNode = new SceneNode();

            cubeNode.Components.Add(_cubeTransform);
            cubeNode.Components.Add(_cubeEffect);
            cubeNode.Components.Add(cubeMesh);

            // Create the scene containing the cube as the only object
            _scene = new SceneContainer();
            _scene.Children.Add(cubeNode);

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);

            _camAngle = 0;
        }
Esempio n. 4
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNodeContainer>
                {
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            // TRANSFROM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.7f, 0.7f, 0.7f), new float3(0.7f, 0.7f, 0.7f), 5)
                            },

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    }
                }
            });
        }
Esempio n. 5
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            //Git Test
            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            ShaderCodeBuilder.MakeShaderEffect(new float4(0.7f, 0.7f, 0.7f, 1)),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 10, 10))
                        }
                    },
                }
            });
        }
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to light green (intensities in R, G, B, A).
            RC.ClearColor = new float4(0.7f, 1.0f, 0.5f, 1.0f);


            // Create a scene with a cube
            // The three components: one XForm, one Material and the Mesh
            _cubeTransform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0)
            };
            var cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(1, 1, 1), 4)
            };
            var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            // Assemble the cube node containing the three components
            var cubeNode = new SceneNodeContainer();

            cubeNode.Components = new List <SceneComponentContainer>();
            cubeNode.Components.Add(_cubeTransform);
            cubeNode.Components.Add(cubeShader);
            cubeNode.Components.Add(cubeMesh);

            // Create the scene containing the cube as the only object
            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();
            _scene.Children.Add(cubeNode);

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Esempio n. 7
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(136f / 255f, 176f / 255f, 75f / 255f, 1);


            // Create a scene with a cube
            // The three components: one Transform, one ShaderEffect (blue material) and the Mesh
            _cubeTransform = new Transform {
                Translation = new float3(0, 0, 50), Rotation = new float3(0, 0.4f, 0)
            };
            var cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero);
            var cubeMesh   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            // Assemble the cube node containing the three components
            var cubeNode = new SceneNode();

            cubeNode.Components.Add(_cubeTransform);
            cubeNode.Components.Add(cubeShader);
            cubeNode.Components.Add(cubeMesh);

            // Create the scene containing the cube as the only object
            _scene = new SceneContainer();
            _scene.Children.Add(cubeNode);

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);

            _camAngle = 0;
        }
Esempio n. 8
0
        // Init is called on startup.
        public override void Init()
        {
            randomIntBack = new Random();
            float RndIntColorBackOne   = randomIntBack.Next(255);
            float RndIntColorBackTwo   = randomIntBack.Next(255);
            float RndIntColorBackThree = randomIntBack.Next(255);

            // Set the clear color for the backbuffer to "greenery" ;-) (https://store.pantone.com/de/de/color-of-the-year-2017/).
            RC.ClearColor = new float4(RndIntColorBackOne / 255f, RndIntColorBackTwo / 255f, RndIntColorBackThree / 255f, 1);

            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNode>();
            _cubeAnimation  = new List <Transform>();


            // The three components: one XForm, one Material and the Mesh
            randomInt = new Random();
            // Animate the camera angle
            _camAngle = _camAngle + 0.01f;


            for (int i = 0; i <= randomInt.Next(3500); i++)
            {
                int   RndIntX          = randomInt.Next(-75, 75);
                int   RndIntY          = randomInt.Next(-75, 75);
                int   RndIntZ          = randomInt.Next(-25, 25);
                float RndIntColorOne   = randomInt.Next(255);
                float RndIntColorTwo   = randomInt.Next(255);
                float RndIntColorThree = randomInt.Next(255);
                float RndIntRotationX  = randomInt.Next(360);
                float RndIntRotationY  = randomInt.Next(360);
                float RndIntRotationZ  = randomInt.Next(360);
                float ScaleX           = randomInt.Next(1, 7);
                float ScaleY           = randomInt.Next(1, 5);
                float ScaleZ           = randomInt.Next(1, 3);


                var _cubeTransform = new Transform {
                    Scale = new float3(ScaleX, ScaleY, ScaleZ), Translation = new float3(RndIntX * 3, RndIntY * 2, RndIntZ * 52), Rotation = new float3(RndIntRotationX, RndIntRotationY, RndIntRotationZ)
                };
                var _cubeShader = ShaderCodeBuilder.MakeShaderEffect(new float4(RndIntColorOne / 255f, RndIntColorTwo / 255f, RndIntColorThree / 255f, 1));
                var _cubeMesh   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

                SceneNode cubeNode = new SceneNode();
                _scene.Children.Add(cubeNode);

                // Assemble the cube node containing the three components
                cubeNode.Components.Add(_cubeTransform);
                cubeNode.Components.Add(_cubeShader);
                cubeNode.Components.Add(_cubeMesh);
                _cubeAnimation.Add(_cubeTransform);
            }

            _sceneRenderer = new SceneRendererForward(_scene);
        }
Esempio n. 9
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0f, 0, 0f, 1);

            // Create a scene with a cube
            // The three components: one XForm, one Shader and the Mesh
            _cubeTransform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0)
            };

            int l = 10;

            SceneNodeContainer[] cubes = new SceneNodeContainer[l];

            for (int i = 1; i <= l; i++)
            {
                var tempCube = new SceneNodeContainer();
                tempCube.Components = new List <SceneComponentContainer>();
                tempCube.Components.Add(new TransformComponent {
                    Scale = new float3(2, 2, 2), Translation = new float3((1 + 2 * i) - (l), (1 + 2 * i) - (l), (1 + 2 * i) - (l))
                });
                tempCube.Components.Add(new ShaderEffectComponent {
                    Effect = SimpleMeshes.MakeShaderEffect(new float3(200, 1, 1), new float3(1, 1, 2), 4)
                });
                tempCube.Components.Add(SimpleMeshes.CreateCuboid(new float3(1, 1, 1)));
                cubes[i - 1] = tempCube;
            }

            /*
             * var cubeNode2 = new SceneNodeContainer();
             * cubeNode2.Components = new List<SceneComponentContainer>();
             * cubeNode2.Components.Add(new TransformComponent {Scale = new float3(2, 2, 1), Translation = new float3(0, 0, 10)});
             * cubeNode2.Components.Add(new ShaderEffectComponent{ Effect = SimpleMeshes.MakeShaderEffect(new float3 (0, 0, 1), new float3 (1, 1, 1),  4)});
             * cubeNode2.Components.Add(SimpleMeshes.CreateCuboid(new float3(10, 10, 10)));
             */

            // Create the scene containing the cube as the only object
            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();
            foreach (SceneNodeContainer c in cubes)
            {
                _scene.Children.Add(c);
            }

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Esempio n. 10
0
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Create a shader effect and set it on the render context
            var shaderEffect = SimpleMeshes.MakeShaderEffect(new float3(0.4f, 1.0f, 0.2f), float3.One, 4);

            RC.SetShaderEffect(shaderEffect);

            // Create a mesh representing a cube
            _mesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));


            // Set the camera 30 units along the _negative_ z-axis.
            // (The View matrix holds the inversion of the camera transformation,
            // thus we apply a positive 30 Z translation).
            RC.View = float4x4.CreateTranslation(0, 0, 30);
        }
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            var cubeNodes = new List <SceneNode>();

            // Create a scene with a cube
            // The three components: one Transform, one ShaderEffect (blue material) and the Mesh
            for (int i = 0; i < maxIndex; i++)
            {
                cTransform.Add(new Transform {
                    Translation = new float3(i * 15, (i + 1) * 5, 0)
                });

                var cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero);

                var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

                // Assemble the cube node containing the three components
                var cubeNode = new SceneNode();
                cubeNode.Components.Add(cTransform[i]);
                cubeNode.Components.Add(cubeShader);
                cubeNode.Components.Add(cubeMesh);
                cubeNodes.Add(cubeNode);
            }

            // Create the scene containing the cube as the only object
            _scene = new SceneContainer();

            foreach (var cNode in cubeNodes)
            {
                _scene.Children.Add(cNode);
            }

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Esempio n. 12
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            _bodyTransform = new TransformComponent
            {
                Rotation    = new float3(0, 1.2f, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            _upperArmTransform = new TransformComponent
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            _foreArmTransform = new TransformComponent
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 8, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNodeContainer>
                {
                    // GREY BASE
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            // TRANSFROM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.7f, 0.7f, 0.7f), new float3(0.7f, 0.7f, 0.7f), 5)
                            },

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    // RED BODY
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            _bodyTransform,
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0), new float3(1, 1, 1), 5)
                            },
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new ChildList
                        {
                            // GREEN UPPER ARM
                            new SceneNodeContainer
                            {
                                Components = new List <SceneComponentContainer>
                                {
                                    _upperArmTransform,
                                },
                                Children = new ChildList
                                {
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            new TransformComponent
                                            {
                                                Rotation = new float3(0, 0, 0),
                                                Scale = new float3(1, 1, 1),
                                                Translation = new float3(0, 4, 0)
                                            },
                                            new ShaderEffectComponent
                                            {
                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 1, 0), new float3(1, 1, 1), 5)
                                            },
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },
                                    // BLUE FOREARM
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _foreArmTransform,
                                        },
                                        Children = new ChildList
                                        {
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    new TransformComponent
                                                    {
                                                        Rotation = new float3(0, 0, 0),
                                                        Scale = new float3(1, 1, 1),
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    new ShaderEffectComponent
                                                    {
                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(1, 1, 1), 5)
                                                    },
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                        }
                    }
                }
            });
        }
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            _bodyTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

            _upperArmTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };

            _foreArmTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };

            _bindingHandTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

            _firstHandTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            _secondHandTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Grey Base
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        },
                        Children =
                        {
                            //red Body
                            new SceneNode
                            {
                                Components =
                                {
                                    _bodyTransform,
                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red,float4.Zero),
                                    SimpleMeshes.CreateCuboid(new float3(2,                         10, 2))
                                },
                                Children =
                                {
                                    //green UpperArm
                                    new SceneNode
                                    {
                                        Components =
                                        {
                                            _upperArmTransform,
                                        },
                                        Children =
                                        {
                                            new SceneNode
                                            {
                                                Components =
                                                {
                                                    new Transform                                                 {
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero),
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                },
                                                Children =
                                                {
                                                    //blue ForeArm
                                                    new SceneNode
                                                    {
                                                        Components =
                                                        {
                                                            _foreArmTransform,
                                                        },
                                                        Children =
                                                        {
                                                            new SceneNode
                                                            {
                                                                Components =
                                                                {
                                                                    new Transform                                 {
                                                                        Translation = new float3(0, 4, 0)
                                                                    },
                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                                },
                                                                Children =
                                                                {
                                                                    //bindingPiece
                                                                    new SceneNode
                                                                    {
                                                                        Components =
                                                                        {
                                                                            _bindingHandTransform,
                                                                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Aquamarine,float4.Zero),
                                                                            SimpleMeshes.CreateCuboid(new float3(3,                                 2, 3))
                                                                        },
                                                                        Children =
                                                                        {
                                                                            //Greifhand firsthand
                                                                            new SceneNode
                                                                            {
                                                                                Components =
                                                                                {
                                                                                    _firstHandTransform,
                                                                                },
                                                                                Children =
                                                                                {
                                                                                    new SceneNode
                                                                                    {
                                                                                        Components =
                                                                                        {
                                                                                            new Transform         {
                                                                                                Translation = new float3(0, 2, -1)
                                                                                            },
                                                                                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Turquoise, float4.Zero),
                                                                                            SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                        }
                                                                                    },
                                                                                    // Greifhand secondHand
                                                                                    new SceneNode
                                                                                    {
                                                                                        Components =
                                                                                        {
                                                                                            _secondHandTransform,
                                                                                        },
                                                                                        Children =
                                                                                        {
                                                                                            new SceneNode
                                                                                            {
                                                                                                Components =
                                                                                                {
                                                                                                    new Transform {
                                                                                                        Translation = new float3(0, 2, 1)
                                                                                                    },
                                                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Turquoise, float4.Zero),
                                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };


            _bodyTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

            _upperarmTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };

            _forearmTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 8, 0)
            };


            _fingerLeftTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 1, 0)
            };

            _fingerRightTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 1, 0)
            };

            _fingerUpTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 1, 2)
            };


            _fingerBottomTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 1, -2)
            };



            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    // grey Base
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Black, float4.Zero),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        },
                        Children =
                        {
                            // red body
                            new SceneNode
                            {
                                Components =
                                {
                                    _bodyTransform,
                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red,float4.Zero),
                                    SimpleMeshes.CreateCuboid(new float3(2,                         10, 2))
                                },

                                Children =
                                {
                                    new SceneNode
                                    {
                                        Components =
                                        {
                                            _upperarmTransform,
                                        },
                                        Children =
                                        {
                                            new SceneNode
                                            {
                                                Components =
                                                {
                                                    new Transform                                 {
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero),
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            },// forearm
                                            new SceneNode
                                            {
                                                Components =
                                                {
                                                    _forearmTransform,
                                                },

                                                Children =
                                                {
                                                    new SceneNode
                                                    {
                                                        Components =
                                                        {
                                                            new Transform                         {
                                                                Translation = new float3(-2, 4, 0)
                                                            },
                                                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        },

                                                        Children =
                                                        {
                                                            // base of the hand
                                                            new SceneNode
                                                            {
                                                                Components =
                                                                {
                                                                    new Transform                 {
                                                                        Translation = new float3(0, 5, 0)
                                                                    },
                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                                    SimpleMeshes.CreateCuboid(new float3(5, 1, 5))
                                                                },

                                                                Children =
                                                                {
                                                                    new SceneNode
                                                                    {
                                                                        Components =
                                                                        {
                                                                            _fingerUpTransform,
                                                                        },
                                                                        Children =
                                                                        {
                                                                            new SceneNode
                                                                            {
                                                                                Components =
                                                                                {
                                                                                    new Transform {
                                                                                        Translation = new float3(0, 1.5f, 0)
                                                                                    },
                                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero),
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    new SceneNode
                                                                    {
                                                                        Components =
                                                                        {
                                                                            _fingerLeftTransform
                                                                        },
                                                                        Children =
                                                                        {
                                                                            new SceneNode
                                                                            {
                                                                                Components =
                                                                                {
                                                                                    new Transform {
                                                                                        Translation = new float3(0, 1.5f, 0)
                                                                                    },
                                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero),
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    new SceneNode
                                                                    {
                                                                        Components =
                                                                        {
                                                                            _fingerRightTransform,
                                                                        },
                                                                        Children =
                                                                        {
                                                                            new SceneNode
                                                                            {
                                                                                Components =
                                                                                {
                                                                                    new Transform {
                                                                                        Translation = new float3(0, 1.5f, 0)
                                                                                    },
                                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero),
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    new SceneNode
                                                                    {
                                                                        Components =
                                                                        {
                                                                            _fingerBottomTransform,
                                                                        },

                                                                        Children =
                                                                        {
                                                                            new SceneNode
                                                                            {
                                                                                Components =
                                                                                {
                                                                                    new Transform {
                                                                                        Translation = new float3(0, 1.5f, 0)
                                                                                    },
                                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.White, float4.Zero),
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        },
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio n. 15
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            _bodyTransform = new Transform
            {
                Rotation    = new float3(0, 1.2f, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            _upperArmTransform = new Transform
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            _foreArmTransform = new Transform
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 8, 0)
            };

            _baseHandTransform = new Transform
            {
                Rotation    = new float3((float)Math.PI, 0, (float)Math.PI / 2),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(4, 10, 0)
            };
            _leftHandTransform = new Transform
            {
                Rotation    = new float3((float)Math.PI / 2, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 8, 2)
            };
            _rightHandTransform = new Transform
            {
                Rotation    = new float3((float)Math.PI / 2, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 0, 2)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    // GREY BASE
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFROM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    // RED BODY
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            _bodyTransform,
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Red, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new ChildList
                        {
                            // GREEN UPPER ARM
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    _upperArmTransform,
                                },
                                Children = new ChildList
                                {
                                    new SceneNode
                                    {
                                        Components = new List <SceneComponent>
                                        {
                                            new Transform
                                            {
                                                Rotation = new float3(0, 0, 0),
                                                Scale = new float3(1, 1, 1),
                                                Translation = new float3(0, 4, 0)
                                            },
                                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Green, float4.Zero),
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },
                                    // BLUE FOREARM
                                    new SceneNode
                                    {
                                        Components = new List <SceneComponent>
                                        {
                                            _foreArmTransform,
                                        },
                                        Children = new ChildList
                                        {
                                            new SceneNode
                                            {
                                                Components = new List <SceneComponent>
                                                {
                                                    new Transform
                                                    {
                                                        Rotation = new float3(0, 0, 0),
                                                        Scale = new float3(1, 1, 1),
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            },
                                            // HandBase
                                            new SceneNode
                                            {
                                                Components = new List <SceneComponent>
                                                {
                                                    _baseHandTransform,
                                                },
                                                Children = new ChildList
                                                {
                                                    new SceneNode
                                                    {
                                                        Components = new List <SceneComponent>
                                                        {
                                                            new Transform
                                                            {
                                                                Rotation = new float3(0, 0, 0),
                                                                Scale = new float3(1, 1, 1),
                                                                Translation = new float3(0, 4, 0)
                                                            },
                                                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.LightGrey, float4.Zero),
                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        }
                                                    },
                                                    // HandLeft
                                                    new SceneNode
                                                    {
                                                        Components = new List <SceneComponent>
                                                        {
                                                            _leftHandTransform,
                                                        },
                                                        Children = new ChildList
                                                        {
                                                            new SceneNode
                                                            {
                                                                Components = new List <SceneComponent>
                                                                {
                                                                    new Transform
                                                                    {
                                                                        Rotation = new float3(0, 0, 0),
                                                                        Scale = new float3(1, 1, 1),
                                                                        Translation = new float3(0, 0, 0)
                                                                    },
                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                                    SimpleMeshes.CreateCuboid(new float3(2, 6, 2))
                                                                }
                                                            }
                                                        }
                                                    },
                                                    // HandRight
                                                    new SceneNode
                                                    {
                                                        Components = new List <SceneComponent>
                                                        {
                                                            _rightHandTransform,
                                                        },
                                                        Children = new ChildList
                                                        {
                                                            new SceneNode
                                                            {
                                                                Components = new List <SceneComponent>
                                                                {
                                                                    new Transform
                                                                    {
                                                                        Rotation = new float3(0, 0, 0),
                                                                        Scale = new float3(1, 1, 1),
                                                                        Translation = new float3(0, 0, 0)
                                                                    },
                                                                    MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                                                                    SimpleMeshes.CreateCuboid(new float3(2, 6, 2))
                                                                }
                                                            },
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                        }
                    }
                }
            });
        }
        public override void Init()
        {
            // Set the clear color for the backbuffer to "greenery"
            RC.ClearColor = (float4)ColorUint.Greenery;

            _cubeTransform = new Transform
            {
                Translation = new float3(0, 0, 50),
                Rotation    = new float3(0, 0, 2.3f),
            };
            _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero);
            _scene      = new SceneContainer
            {
                Children =
                {
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,
                            _cubeShader,
                            SimpleMeshes.CreateCuboid(new float3(4, 4, 4))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,                                              new Transform{
                                Translation = new float3(12,                          5, 15),
                                Rotation    = new float3(20.8f,                                                           55.3f, 6.9f),
                            },
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.BlueViolet, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(4, 4, 4))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,                                         new Transform{
                                Translation = new float3(12,                       -15, 17),
                                Rotation    = new float3(34f,                                                      0.03f * Time.DeltaTime, 0)
                            },
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Wheat, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(6, 6, 6))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,                                        new Transform{
                                Translation = new float3(0,                     15, -15),
                                Rotation    = new float3(6.9f,                                                     0.3f * Time.DeltaTime, 0)
                            },
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(3, 3, 3))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,                                          new Transform{
                                Translation = new float3(-25,                          -10, 8),
                                Rotation    = new float3(0,                                                       6.9f, 67.2f)
                            },
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Yellow, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(2, 2, 2))
                        }
                    }
                }
            };

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
        public override void Init()
        {
            // Set the clear color for the backbuffer to "greenery"
            RC.ClearColor = (float4)(ColorUint.Black);
            // Create a scene with a cube
            // The three components: one Transform, one ShaderEffect (blue material) and the Mesh

            /* _cubeTransform1 = new Transform {
             *   Translation = new float3(-10, 0, 40),
             *   Rotation = new float3(0,0.3f,0),
             *   };
             * _cubeshader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero);
             * var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));
             *
             *
             * _cubeTransform2 = new Transform{
             *   Translation = new float3(10,0,40),
             *   Rotation = new float3(0,0.3f,0),
             * };
             *
             *
             * // Assemble the cube node containing the three components
             *
             * var Cubenode2 = new SceneNode();
             * Cubenode2.Components.Add(_cubeTransform2);
             * Cubenode2.Components.Add(_cubeshader);
             * Cubenode2.Components.Add(cubeMesh);
             *
             * var cubeNode = new SceneNode(); //Hauptnode
             * cubeNode.Components.Add(_cubeTransform1);// kinderKomponenten werden gesetzt
             * cubeNode.Components.Add(_cubeshader);
             * cubeNode.Components.Add(cubeMesh);
             *
             * // Create the scene containing the cube as the only object
             * _scene = new SceneContainer();
             * _scene.Children.Add(cubeNode);
             * _scene.Children.Add(Cubenode2);                                // in childrenliste der szene einreihen
             */
            // Create a scene renderer holding the scene above


            _cubeTransform1 = new Transform {
                Translation = new float3(-10, 0, 70),
                Rotation    = new float3(0, 0.3f, 0),
            };
            _cubeshader  = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero);
            _cubeshader2 = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Cyan, float4.Zero);

            _cubeTransform2 = new Transform {
                Translation = new float3(10, 0, 70),
                Rotation    = new float3(0, 0.3f, 0),
            };

            _cubeTransform3 = new Transform {
                Translation = new float3(0, 0, 70),
                Rotation    = new float3(0, 0.3f, 0),
            };

            _cubeTransform4 = new Transform {
                Translation = new float3(0, 0, 70),
                Rotation    = new float3(0, 0.3f, 0),
            };

            _cubeMesh = SimpleMeshes.CreateCuboid(new float3(6, 6, 6));


            node = new SceneNode {
                Components =
                {
                    _cubeTransform4,
                    _cubeshader2,
                    _cubeMesh,
                }
            };

            _scene = new SceneContainer
            {
                Children =
                {
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform1,
                            _cubeshader,
                            SimpleMeshes.CreateCuboid(new float3(3, 3, 3))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform2,
                            _cubeshader,
                            SimpleMeshes.CreateCuboid(new float3(3, 3, 3))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform3,
                            _cubeshader,
                            SimpleMeshes.CreateCuboid(new float3(3, 3, 3))
                        }
                    },
                    node
                }
            };


            _sceneRenderer = new SceneRendererForward(_scene);//renderer der einzelne pixel einfärben kann
        }
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

            _bodyTransform = new Transform {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

            _upperArmTransform = new Transform {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };

            _foreArmTransform = new Transform {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };

            _kralleoben = new Transform {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(1, 5, 0)
            };

            _kralleunten = new Transform {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-1, 5, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    // Graue Basis
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

                            // SHADER EFFECT COMPONENT
                            ShaderCodeBuilder.MakeShaderEffect(new float4(0.8f, 0.8f, 0.8f, 1)),

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    //Roter Körper
                    new SceneNode {
                        Components = new List <SceneComponent>
                        {
                            _bodyTransform,

                            ShaderCodeBuilder.MakeShaderEffect(new float4(1, 0, 0, 1)),

                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new ChildList {
                            //grün Oberarm
                            new SceneNode {
                                Components = new List <SceneComponent> {
                                    _upperArmTransform,
                                },
                                Children = new ChildList {
                                    new SceneNode {
                                        Components = new List <SceneComponent> {
                                            new Transform {
                                                Rotation = new float3(0, 0, 0),
                                                Scale = new float3(1, 1, 1),
                                                Translation = new float3(0, 4, 0)
                                            },
                                            ShaderCodeBuilder.MakeShaderEffect(new float4(0, 1, 0, 1)),
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        },
                                        Children = new ChildList {
                                            // blauer Unterarm
                                            new SceneNode {
                                                Components = new List <SceneComponent> {
                                                    _foreArmTransform,

                                                    new Transform {
                                                        Rotation = new float3(0, 0, 0),
                                                        Scale = new float3(1, 1, 1),
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    ShaderCodeBuilder.MakeShaderEffect(new float4(0, 0, 1, 1)),
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                },
                                                //Hand oben
                                                Children = new ChildList {
                                                    new SceneNode {
                                                        Components = new List <SceneComponent> {
                                                            _kralleoben,
                                                        },
                                                        Children = new ChildList {
                                                            new SceneNode {
                                                                Components = new List <SceneComponent> {
                                                                    new Transform {
                                                                        Rotation = new float3(0, 0, 0),
                                                                        Scale = new float3(1, 1, 1),
                                                                        Translation = new float3(0, 1, 0)
                                                                    },
                                                                    ShaderCodeBuilder.MakeShaderEffect(new float4(0, 1, 1, 1)),
                                                                    SimpleMeshes.CreateCuboid(new float3(1, 2, 1))
                                                                }
                                                            }
                                                        }
                                                    },
                                                    // Hand unten
                                                    new SceneNode {
                                                        Components = new List <SceneComponent> {
                                                            _kralleunten,
                                                        },

                                                        Children = new ChildList {
                                                            new SceneNode {
                                                                Components = new List <SceneComponent> {
                                                                    new Transform {
                                                                        Rotation = new float3(0, 0, 0),
                                                                        Scale = new float3(1, 1, 1),
                                                                        Translation = new float3(0, 1, 0)
                                                                    },

                                                                    ShaderCodeBuilder.MakeShaderEffect(new float4(0, 1, 1, 1)),
                                                                    SimpleMeshes.CreateCuboid(new float3(1, 2, 1))
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio n. 19
0
        public override void Init()//Farbe wird definiert
        {
            // Set the clear color for the backbuffer to "greenery"
            RC.ClearColor = (float4)ColorUint.Greenery;

            // Create a scene with a cube
            // The three components: one Transform, one ShaderEffect (blue material) and the Mesh

            //Umständliche Schreibweise

            /*_cubeTransform = new Transform
             * {
             *  Translation = new float3(0, 0, 20), //Position wird festgelegt (3D), x,y,z
             *  Rotation = new float3(0, 0.3f, 0),
             * };
             * _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero); //hier wird die Farbe festgelegt; Grundfarbe
             * var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));// Größe des Würfels
             *
             * // Assemble the cube node containing the three components
             * var cubeNode = new SceneNode();
             * cubeNode.Components.Add(_cubeTransform); //fügt die Transform-Kompenente an
             * cubeNode.Components.Add(_cubeShader); // fügt den Shader
             * cubeNode.Components.Add(cubeMesh);// fügt den Mesh
             *
             * // Create the scene containing the cube as the only object
             * _scene = new SceneContainer(); // Container, der alles enthält
             * _scene.Children.Add(cubeNode);// Node zu den Kinder-Komponenten hinzufügen
             */

            //Alternative (einfache) Schreibweise
            _cubeTransform = new Transform {
                Translation = new float3(0, 0, 20),
                Rotation    = new float3(0, 0.3f, 0),
            };
            _cubeShader = MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero);

            _scene = new SceneContainer
            {
                Children =
                {
                    new SceneNode
                    {
                        Components =
                        {
                            _cubeTransform,
                            _cubeShader,
                            SimpleMeshes.CreateCuboid(new float3(10, 10, 10))
                        }
                    },
                    new SceneNode
                    {
                        Components =
                        {
                            new Transform {
                                Translation = new float3(0, 0, 10), Rotation = new float3(0, 0.3f, 0)
                            },
                            MakeEffect.FromDiffuseSpecular((float4)ColorUint.Blue, float4.Zero),
                            SimpleMeshes.CreateCuboid(new float3(5, 10, 5))
                        }
                    }
                }
            };

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene); //
        }
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            baseTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, -6, 0)
            };

            bodyTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            //Arms
            upperArmTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            lowerArmTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };

            //Grabbers
            grabber1Transform = new TransformComponent
            {
                Rotation    = new float3(grabber1Limit, (float)Math.PI / 2, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-.4f, 3.8f, 0)
            };
            grabber2Transform = new TransformComponent
            {
                Rotation    = new float3(grabber2Limit, (float)Math.PI / 2, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(.4f, 3.8f, 0)
            };

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNodeContainer>
                {
                    new SceneNodeContainer
                    {
                        Name = "Base",
                        Components = new List <SceneComponentContainer>
                        {
                            // TRANSFROM COMPONENT
                            baseTransform,

                            // SHADER EFFECT COMPONENT
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.7f, 0.7f, 0.7f), new float3(0.7f, 0.7f, 0.7f), 5)
                            },

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        },
                        Children = new ChildList
                        {
                            new SceneNodeContainer
                            {
                                Name = "Body",
                                Components = new List <SceneComponentContainer>
                                {
                                    // TRANSFROM COMPONENT
                                    bodyTransform,

                                    // SHADER EFFECT COMPONENT
                                    new ShaderEffectComponent
                                    {
                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0), new float3(0.7f, 0.7f, 0.7f), 5)
                                    },

                                    // MESH COMPONENT
                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                },
                                Children = new ChildList
                                {
                                    new SceneNodeContainer
                                    {
                                        Name = "UpperArm",
                                        Components = new List <SceneComponentContainer>
                                        {
                                            upperArmTransform
                                        },
                                        Children = new ChildList
                                        {
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    new TransformComponent
                                                    {
                                                        Rotation = new float3(0, 0, 0),
                                                        Scale = new float3(1, 1, 1),
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    new ShaderEffectComponent
                                                    {
                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 1, 0), new float3(0.7f, 0.7f, 0.7f), 5)
                                                    },
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                },
                                                Children = new ChildList {
                                                    new SceneNodeContainer
                                                    {
                                                        Name = "LowerArm",
                                                        Components = new List <SceneComponentContainer>
                                                        {
                                                            lowerArmTransform
                                                        },
                                                        Children = new ChildList
                                                        {
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    new TransformComponent
                                                                    {
                                                                        Rotation = new float3(0, 0, 0),
                                                                        Scale = new float3(1, 1, 1),
                                                                        Translation = new float3(0, 4, 0)
                                                                    },
                                                                    new ShaderEffectComponent
                                                                    {
                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                    },
                                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                                },
                                                                Children = new ChildList
                                                                {
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Name = "Grabber1",
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            grabber1Transform
                                                                        },
                                                                        Children = new ChildList
                                                                        {
                                                                            new SceneNodeContainer
                                                                            {
                                                                                Components = new List <SceneComponentContainer>
                                                                                {
                                                                                    new TransformComponent
                                                                                    {
                                                                                        Rotation = new float3(0, 0, 0),
                                                                                        Scale = new float3(1, 1, 1),
                                                                                        Translation = new float3(0, 4, 0)
                                                                                    },
                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(grabberColor, new float3(0.7f, 0.7f, 0.7f), 5)
                                                                                    },
                                                                                    SimpleMeshes.CreateCuboid(grabberCuboidSize)
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Name = "Grabber2",
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            grabber2Transform
                                                                        },
                                                                        Children = new ChildList
                                                                        {
                                                                            new SceneNodeContainer
                                                                            {
                                                                                Components = new List <SceneComponentContainer>
                                                                                {
                                                                                    new TransformComponent
                                                                                    {
                                                                                        Rotation = new float3(0, 0, 0),
                                                                                        Scale = new float3(1, 1, 1),
                                                                                        Translation = new float3(0, 4, 0)
                                                                                    },
                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(grabberColor, new float3(0.7f, 0.7f, 0.7f), 5)
                                                                                    },
                                                                                    SimpleMeshes.CreateCuboid(grabberCuboidSize)
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio n. 21
0
        public override void Init()
        {
            // Create a scene with a cube
            // The three components: one XForm, one Material and the Mesh
            _cubeTransform = new Transform {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0), Rotation = new float3(0, 0, 0)
            };
            var cubeShader = ShaderCodeBuilder.MakeShaderEffect(new float4(50 / 255f, 100 / 255f, 180 / 255f, 1));
            var cubeMesh   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            _cubeTransform2 = new Transform {
                Scale = new float3(2, 2, 2), Translation = new float3(50, 0, 0), Rotation = new float3(10, 10, 10)
            };
            var cubeShader2 = ShaderCodeBuilder.MakeShaderEffect(new float4(1f, 0f, 0f, 1));
            var cubeMesh2   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            _cubeTransform3 = new Transform {
                Scale = new float3(3, 1, 3), Translation = new float3(0, -20, 0), Rotation = new float3(0, 0, 0)
            };
            var cubeShader3 = ShaderCodeBuilder.MakeShaderEffect(new float4(80 / 255f, 170 / 255f, 0 / 255f, 1));
            var cubeMesh3   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            _cubeTransform4 = new Transform {
                Scale = new float3(2, 1, 1), Translation = new float3(-50, 0, 0), Rotation = new float3(0, 0, 0)
            };
            var cubeShader4 = ShaderCodeBuilder.MakeShaderEffect(new float4(255 / 255f, 216 / 255f, 0 / 255f, 1));
            var cubeMesh4   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            _cubeTransform5 = new Transform {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 18, 0), Rotation = new float3(0, 0, 0)
            };
            var cubeShader5 = ShaderCodeBuilder.MakeShaderEffect(new float4(128 / 255f, 128 / 255f, 128 / 255f, 1));
            var cubeMesh5   = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));

            // Assemble the cube node containing the three components
            var cubeNode = new SceneNode();

            cubeNode.Components.Add(_cubeTransform);
            cubeNode.Components.Add(cubeShader);
            cubeNode.Components.Add(cubeMesh);

            var cubeNode2 = new SceneNode();

            cubeNode2.Components.Add(_cubeTransform2);
            cubeNode2.Components.Add(cubeShader2);
            cubeNode2.Components.Add(cubeMesh2);

            var cubeNode3 = new SceneNode();

            cubeNode3.Components.Add(_cubeTransform3);
            cubeNode3.Components.Add(cubeShader3);
            cubeNode3.Components.Add(cubeMesh3);

            var cubeNode4 = new SceneNode();

            cubeNode4.Components.Add(_cubeTransform4);
            cubeNode4.Components.Add(cubeShader4);
            cubeNode4.Components.Add(cubeMesh4);

            var cubeNode5 = new SceneNode();

            cubeNode5.Components.Add(_cubeTransform5);
            cubeNode5.Components.Add(cubeShader5);
            cubeNode5.Components.Add(cubeMesh5);
            // Create the scene containing the cube as the only object
            _scene = new SceneContainer();
            _scene.Children.Add(cubeNode);
            _scene.Children.Add(cubeNode2);
            _scene.Children.Add(cubeNode3);
            _scene.Children.Add(cubeNode4);
            _scene.Children.Add(cubeNode5);

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }