Exemplo n.º 1
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,

                            // ShaderEffect
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.Yellow), new float3(1, 1, 1), 5)
                            },

                            // MESH COMPONENT
                            // SimpleMeshes.CreateCuboid(new float3(10, 10, 10))
                            SimpleMeshes.CreateCylinder(5, 10, 8)
                        }
                    },
                }
            });
        }
Exemplo n.º 2
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, 0.9f, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)    //hier wird die Position festgelegt, um 6 in Y-Richtung transaliert, da man die Position des Pivot Point festlegt, und der Arm 10 lang ist
            };

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

            _lowerArmTransform = new TransformComponent
            {
                Rotation    = new float3(-1.5f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 8, 0)
            };

            _grabMiddleTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 5.25f, 0)
            };

            _grabLeftTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-0.75f, 6.0f, 0)
            };

            _grabRightTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0.75f, 6.0f, 0)
            };


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

                            // Shader Effect
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.7f, 0.7f, 0.7f), new float3(1, 1, 1), 5)
                            },

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    //roter Arm
                    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 List <SceneNodeContainer>
                        {
                            //grüner Arm
                            new SceneNodeContainer
                            {
                                Components = new List <SceneComponentContainer>
                                {
                                    _upperArmTransform,
                                },
                                Children = new List <SceneNodeContainer>
                                {
                                    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))
                                        }
                                    },
                                    //blauer Arm
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _lowerArmTransform,
                                        },
                                        Children = new List <SceneNodeContainer>
                                        {
                                            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))
                                                }
                                            },
                                            //middleGrap
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _grabMiddleTransform,
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    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(ColorUint.Tofloat3(ColorUint.Silver), new float3(1, 1, 1), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(1, 0.5f, 0.5f))
                                                        }
                                                    }
                                                }
                                            },
                                            //leftGrap
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _grabLeftTransform,
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    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(ColorUint.Tofloat3(ColorUint.Silver), new float3(1, 1, 1), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(0.5f, 2, 0.5f))
                                                        }
                                                    }
                                                }
                                            },
                                            //RightGrap
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _grabRightTransform,
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    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(ColorUint.Tofloat3(ColorUint.Silver), new float3(1, 1, 1), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(0.5f, 2, 0.5f))
                                                        }
                                                    }
                                                }
                                            },
                                        }
                                    },
                                }
                            },//grünerARm
                        } //Children roterArm
                    }
                }
            }); //SceneContainer
        } //SceneNodeContainer
Exemplo n.º 3
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 = ColorUint.Tofloat4(ColorUint.PaleGreen);

            // 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), Rotation = new float3(0.1f, 0, 0.3f)
            };
            _cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.Crimson), 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);
// Würfel 2
            _cube2Transform = new TransformComponent {
                Scale = new float3(5, 1, 1), Translation = new float3(30, 0, 30), Rotation = new float3(0.6f, 0.6f, 0)
            };
            _cube2Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.Navy), new float3(1, 1, 1), 4)
            };
            var cubeMesh2 = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));

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

            cubeNode2.Components = new List <SceneComponentContainer>();
            cubeNode2.Components.Add(_cube2Transform);
            cubeNode2.Components.Add(_cube2Shader);
            cubeNode2.Components.Add(cubeMesh2);
//würfel 3
            _cube3Transform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(18, 0, -30)
            };
            _cube3Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.Lime), new float3(1, 2, 1), 4)
            };
            var cubeMesh3 = SimpleMeshes.CreateCuboid(new float3(1, 1, 1));

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

            cubeNode3.Components = new List <SceneComponentContainer>();
            cubeNode3.Components.Add(_cube3Transform);
            cubeNode3.Components.Add(_cube3Shader);
            cubeNode3.Components.Add(cubeMesh3);

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

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

            // RenderAFrame is called once a frame
        }
Exemplo n.º 4
0
        public override void Init()
        {
            // Set the clear color for the backbuffer to light green (intensities in R, G, B, A).
            RC.ClearColor  = new float4(0f, 1f, 2f, 1f);
            _cubeTransform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0)
            };

            var cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.Beige), 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);

//CUBE2_________________________________________________________________________

            _cube2Transform = new TransformComponent {
                Scale = new float3(3, 3, 1), Translation = new float3(30, 0, 30), Rotation = new float3(0.1f, 0.5f, 0)
            };
            _cube2Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.DarkRed), new float3(1, 1, 1), 4)
            };
            var cubeMesh2 = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));

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

            cubeNode2.Components = new List <SceneComponentContainer>();
            cubeNode2.Components.Add(_cube2Transform);
            cubeNode2.Components.Add(_cube2Shader);
            cubeNode2.Components.Add(cubeMesh2);



//CUBE3_______________________________________________________________________________
            _cube3Transform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(15, 0, -10), Rotation = new float3(-0.1f, -0.5f, 0)
            };
            _cube3Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(ColorUint.Tofloat3(ColorUint.MediumSeaGreen), new float3(1, 2, 1), 4)
            };
            var cubeMesh3 = SimpleMeshes.CreateCuboid(new float3(2, 3, 1));

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

            cubeNode3.Components = new List <SceneComponentContainer>();
            cubeNode3.Components.Add(_cube3Transform);
            cubeNode3.Components.Add(_cube3Shader);
            cubeNode3.Components.Add(cubeMesh3);

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



            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
        }
Exemplo n.º 5
0
 private SceneContainer CreateScene()
 {
     return(new SceneContainer
     {
         Header =
         {
             CreationDate = "May 2017",
             CreatedBy    = "mch",
             Generator    = "Handcoded with pride",
             Version      =                     42,
         },
         Children = new List <SceneNodeContainer>
         {
             new SceneNodeContainer
             {
                 Name = "Parent",
                 Components = new List <SceneComponentContainer>
                 {
                     new RectTransformComponent
                     {
                         Anchors = { Min = { x = 0, y = 0 }, Max = { x = 0, y = 0 } },
                         Offsets = { Min = { x = -1, y = -1 }, Max = { x = 1, y = 1 } }
                     },
                     // new TransformComponent {Scale = new float3(1, 1.5f, 1)},
                     new MaterialComponent
                     {
                         Diffuse = new MatChannelContainer {
                             Color = ColorUint.Tofloat3(ColorUint.Green)
                         },
                         Specular = new SpecularChannelContainer
                         {
                             Color = ColorUint.Tofloat3(ColorUint.White),
                             Intensity = 1.0f,
                             Shininess = 4.0f
                         }
                     },
                     SimpleMeshes.CreateCuboid(new float3(2, 2, 0.7f))
                 },
                 Children = new List <SceneNodeContainer>
                 {
                     new SceneNodeContainer
                     {
                         Name = "Child",
                         Components = new List <SceneComponentContainer>
                         {
                             new RectTransformComponent
                             {
                                 Anchors = { Min = { x = 0, y = 0 }, Max = { x = 1, y = 1 } },
                                 Offsets = { Min = { x = -0, y = 0 }, Max = { x = 0, y = 0 } }
                             },
                             // new TransformComponent {Translation = new float3(1, 1, 0), Scale = new float3(1, 1, 1)},
                             new MaterialComponent
                             {
                                 Diffuse = new MatChannelContainer {
                                     Color = ColorUint.Tofloat3(ColorUint.Red)
                                 },
                                 Specular = new SpecularChannelContainer
                                 {
                                     Color = ColorUint.Tofloat3(ColorUint.White),
                                     Intensity = 1.0f,
                                     Shininess = 4.0f
                                 }
                             },
                             SimpleMeshes.CreateCuboid(new float3(2, 2, 1))
                         },
                     }
                 },
             }
         },
     });
 }