示例#1
0
        // RenderAFrame is called once a frame
        public override void RenderAFrame()
        {
            Console.WriteLine("hallo");
            Diagnostics.Log(TimeSinceStart);

            // Clear the backbuffer
            RC.Clear(ClearFlags.Color | ClearFlags.Depth);

            // Animate the camera angle
            //_camAngle = _camAngle + 90.0f * M.Pi/180.0f * DeltaTime ;

            // Animate the cube 1
            _cubeTransform.Translation = new float3(0, 6 * M.Sin(2 * TimeSinceStart) + 10, 0);
            _cubeTransform.Rotation    = _cubeTransform.Rotation + new float3(0.05f * Time.DeltaTime, 0, 0);
            /* muss mit Time.DeltaTime multipiziert werden, damit auf jedem System die Animation gleich schnell abgespielt wird*/
            _cubeTransform.Scale = new float3(1 * M.Sin(1 * TimeSinceStart), 1, 1 * M.Sin(4 * TimeSinceStart));
            // Animation Quader 2
            _quaderTransform.Translation = new float3(6 * M.Cos(10 * TimeSinceStart), -10, 0);
            _quaderTransform.Rotation    = _quaderTransform.Rotation + new float3(0, 0.7f * Time.DeltaTime, 0.7f * Time.DeltaTime);

            //Animation Cube 3

            _wuerfelDreiTransform.Translation = new float3(15, 2 * M.Sin(6 * TimeSinceStart), 15 * M.Sin(1 * TimeSinceStart));
            _wuerfelDreiShader.Effect         = SimpleMeshes.MakeShaderEffect(new float3(1, M.Sin(3 * TimeSinceStart), 0), new float3(1, 1, 1), 4);

            // Setup the camera
            RC.View = float4x4.CreateTranslation(0, 0, 50) * float4x4.CreateRotationY(_camAngle);


            // Render the scene on the current render context
            _sceneRenderer.Render(RC);

            // Swap buffers: Show the contents of the backbuffer (containing the currently rendered farame) on the front buffer.
            Present();
        }
示例#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)
            };

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

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

                            // MESH COMPONENT
                            SimpleMeshes.CreateCylinder(5, 10, 24)
                        }
                    },
                }
            });
        }
示例#3
0
        // RenderAFrame is called once a frame
        public override void RenderAFrame()
        {
            // Clear the backbuffer
            RC.Clear(ClearFlags.Color | ClearFlags.Depth);

            // Animate the camera angle
            _camAngle = _camAngle + 20.0f * M.Pi / 180.0f * DeltaTime;   //Drehung von 90° pro Sekunde (bei 90*M.Pi/180), egal wie mit vielen Frames die Animation läuft

            // Setup the camera
            RC.View = float4x4.CreateTranslation(0, 0, 50) * float4x4.CreateRotationY(_camAngle);

            // Animate the cube
            _cube1Transform.Translation = new float3(0, 2 * M.Sin(1.75f * TimeSinceStart), 0);
            _cube2Transform.Scale       = new float3(0.5f * M.Sin(4 * TimeSinceStart) + 1, 1, 1);
            _cube3Transform.Translation = new float3(-20, 5, 5 * M.Sin(1.5f * TimeSinceStart));
            _cube3Transform.Rotation    = new float3(0, 0, (-M.Pi / 4 * TimeSinceStart));
            cube3Shader.Effect          = SimpleMeshes.MakeShaderEffect(new float3(0.5f * M.Sin(2 * TimeSinceStart) + 0.5f, 0.09f, 0.3f), new float3(1, 1, 1), 4);

            // Render the scene on the current render context
            _sceneRenderer.Render(RC);

            Diagnostics.Log(Time.DeltaTime);
            // Swap buffers: Show the contents of the backbuffer (containing the currently rendered farame) on the front buffer.
            Present();
        }
示例#4
0
        // 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 SceneRenderer(_scene);
        }
示例#5
0
        // 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.5f, 0.5f, 0.5f, 1.0f);

            //Create a scene with a cube
            // The three components: one XFrom, one Shade 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, 1, 1), new float3(1, 1, 1), 4)
            };
            var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));


            var cubeNode = new SceneNodeContainer();

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

            //cube 2

            _cubeTransform2 = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, -20)
            };
            cubeShader2 = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0.4f), new float3(1, 1, 1), 4)
            };
            var cubeMesh2 = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            var cubeNode2 = new SceneNodeContainer();

            cubeNode2.Components = new List <SceneComponentContainer>();
            cubeNode2.Components.Add(_cubeTransform2);
            cubeNode2.Components.Add(cubeShader2);
            cubeNode2.Components.Add(cubeMesh);


            //scene load
            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();
            _scene.Children.Add(cubeNode);
            _scene.Children.Add(cubeNode2);

            _sceneRenderer = new SceneRenderer(_scene);
        }
        // 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.1f, 0.1f, 0.1f, 1);

            float cubeSpace = (float)1 / _count * 50;                                              //cube width with space between
            float cubeSize  = cubeSpace * 0.75f;                                                   //cube width
            Mesh  cubeMesh  = SimpleMeshes.CreateCuboid(new float3(cubeSize, cubeSize, cubeSize)); //cube mesh

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

            // Create a scene with a cube
            // The three components: one XForm, one Shader and the Mesh
            float center = -(cubeSpace * _count) / 2 + cubeSpace / 2; //leftmost x-value to display cubes in center

            Diagnostics.Log("center " + center);
            for (int i = 0; i < _count; i++)
            {
                _cubeTransform[i] = new TransformComponent //Transformation
                {
                    Scale       = new float3(1, 1, 1),
                    Translation = new float3(center + i * cubeSpace, 0, 0),
                    Rotation    = new float3(0, 0, 0)
                };
                Diagnostics.Log(i + " " + _cubeTransform[i].Translation.x);

                float color = (float)(i + 1) / _count;     //color of cubes, gray levels between ]black,white]

                _cubeShader[i] = new ShaderEffectComponent //Shader
                {
                    Effect = SimpleMeshes.MakeShaderEffect(new float3(color, color, color), new float3(1, 1, 1), 4)
                };

                // Assemble the cube node containing the three components
                var cubeNode = new SceneNodeContainer();
                cubeNode.Components = new List <SceneComponentContainer>();
                cubeNode.Components.Add(_cubeTransform[i]);
                cubeNode.Components.Add(_cubeShader[i]);
                cubeNode.Components.Add(cubeMesh);
                _scene.Children.Add(cubeNode);
            }

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
        }
示例#7
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(0.7f, 1.0f, 0.5f, 1.0f);

            // Create five cubes
            _cubes = new SceneNodeContainer[5];

            for (int i = 0; i < 5; i++)
            {
                var cubeTransform = new TransformComponent {
                    Scale = new float3(1, 1, 1), Translation = new float3((i - 3) * 10, 0, 0)
                };
                var cubeShader = new ShaderEffectComponent
                {
                    Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 1, 1), new float3(1, 1, 1), i)
                };
                var cubeMesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

                var cubeNode = new SceneNodeContainer();
                cubeNode.Components = new List <SceneComponentContainer>();
                cubeNode.Components.Add(cubeTransform);
                cubeNode.Components.Add(cubeShader);
                cubeNode.Components.Add(cubeMesh);

                _cubes[i] = cubeNode;
            }

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

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
        }
示例#8
0
        public void addCube(int amount)
        {
            for (int i = 0; i < amount; i++)
            {
                _cubeTransform = new TransformComponent {
                    Scale = new float3(1, 1, 1), Translation = new float3((float)random.Next(-50, 50), (float)random.Next(-50, 50), (float)random.Next(-50, 50))
                };
                var cubeShader = new ShaderEffectComponent {
                    Effect = SimpleMeshes.MakeShaderEffect(new float3((float)1 / (i + 1), (float)1 / (i + 1), (float)1 / (i + 1)), new float3(1, 1, 1), 4)
                };

                var cubeMesh = SimpleMeshes.CreateCuboid(new float3(random.Next(5, 20), random.Next(5, 20), random.Next(5, 20)));

                //assemble cube node
                var cubeNode = new SceneNodeContainer();
                cubeNode.Components = new List <SceneComponentContainer>();
                cubeNode.Components.Add(_cubeTransform);
                cubeNode.Components.Add(cubeShader);
                cubeNode.Components.Add(cubeMesh);

                _scene.Children.Add(cubeNode);
            }
        }
示例#9
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(ColorUint.Tofloat3(ColorUint.DeepPink), new float3(1, 1, 1), 5)
                            },

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 10, 10))

                            SimpleMeshes.CreateCylinder(5, 10, 8)
                        }
                    },
                }
            });
示例#10
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, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

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

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

            _handTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(1, 9, 0)
            };

            _hand2Transform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-1, 9, 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.0f, 0.1f, 0.1f), new float3(0.7f, 0.7f, 0.7f), 5)
                            },
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            // green upper 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.1f, 1.0f, 0.1f), new float3(0.7f, 0.7f, 0.7f), 5)
                                            },
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },

                                    // blue arm
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _foreArmTransform
                                        },
                                        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.1f, 0.1f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                    },
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            },

                                            // hand
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _handTransform
                                                },
                                                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, 1.5f, 0)
                                                            },
                                                            new ShaderEffectComponent
                                                            {
                                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1.0f, 1.0f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(0.5f, 3, 2))
                                                        }
                                                    }
                                                }
                                            },
                                            // hand2
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _hand2Transform
                                                },
                                                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, 1.5f, 0)
                                                            },
                                                            new ShaderEffectComponent
                                                            {
                                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1.0f, 1.0f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(0.5f, 3, 2))
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
示例#11
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)
            };
            _greifHandBase = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 5.5f, -0.5f)
            };
            _greifFingerLinks = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2.5f, -0.5f, 1.0f)
            };
            _greifFingerRechts = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2.5f, -0.5f, 1.0f)
            };


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

                            // MATERIAL COMPONENT
                            new MaterialComponent
                            {
                                Diffuse = new MatChannelContainer {
                                    Color = new float3(0.7f, 0.7f, 0.7f)
                                },
                                Specular = new SpecularChannelContainer {
                                    Color = new float3(1, 1, 1), Shininess = 5
                                }
                            },


                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    // RED BODY
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            _bodyTransform,
                            new MaterialComponent
                            {
                                Diffuse = new MatChannelContainer {
                                    Color = new float3(1, 0, 0)
                                },
                                Specular = new SpecularChannelContainer {
                                    Color = new float3(1, 1, 1), Shininess = 5
                                }
                            },
                            new ShaderEffectComponent
                            {
                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0), new float3(1, 0, 0), 5)
                            },
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            // GREEN UPPER 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 MaterialComponent
                                            {
                                                Diffuse = new MatChannelContainer {
                                                    Color = new float3(0, 1, 0)
                                                },
                                                Specular = new SpecularChannelContainer {
                                                    Color = new float3(1, 1, 1), Shininess = 5
                                                }
                                            },
                                            new ShaderEffectComponent
                                            {
                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 1, 0), new float3(0, 1, 0), 5)
                                            },
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },
                                    // BLUE FOREARM
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _foreArmTransform,
                                        },
                                        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 MaterialComponent
                                                    {
                                                        Diffuse = new MatChannelContainer {
                                                            Color = new float3(0, 0, 1)
                                                        },
                                                        Specular = new SpecularChannelContainer {
                                                            Color = new float3(1, 1, 1), Shininess = 5
                                                        }
                                                    },
                                                    new ShaderEffectComponent
                                                    {
                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(0, 0, 1), 5)
                                                    },
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    //GreifHand
                                                    new SceneNodeContainer
                                                    {
                                                        Components = new List <SceneComponentContainer>
                                                        {
                                                            _greifHandBase
                                                        },
                                                        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, 0, 0)
                                                                    },
                                                                    new MaterialComponent
                                                                    {
                                                                        Diffuse = new MatChannelContainer {
                                                                            Color = new float3(0, 0, 1)
                                                                        },
                                                                        Specular = new SpecularChannelContainer {
                                                                            Color = new float3(1, 1, 1), Shininess = 5
                                                                        }
                                                                    },
                                                                    new ShaderEffectComponent
                                                                    {
                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0.5f, 0.5f, 0.5f), new float3(1, 1, 1), 5)
                                                                    },
                                                                    SimpleMeshes.CreateCuboid(new float3(6, 1, 1))
                                                                },
                                                                Children = new List <SceneNodeContainer>
                                                                {
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            _greifFingerRechts
                                                                        },
                                                                        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, 2, 0)
                                                                                    },
                                                                                    new MaterialComponent
                                                                                    {
                                                                                        Diffuse = new MatChannelContainer {
                                                                                            Color = new float3(0, 0, 1)
                                                                                        },
                                                                                        Specular = new SpecularChannelContainer {
                                                                                            Color = new float3(1, 1, 1), Shininess = 5
                                                                                        }
                                                                                    },
                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 0), new float3(1, 1, 1), 5)
                                                                                    },
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4.3f, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            _greifFingerLinks
                                                                        },
                                                                        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, 2, 0)
                                                                                    },
                                                                                    new MaterialComponent
                                                                                    {
                                                                                        Diffuse = new MatChannelContainer {
                                                                                            Color = new float3(0, 0, 1)
                                                                                        },
                                                                                        Specular = new SpecularChannelContainer {
                                                                                            Color = new float3(1, 1, 1), Shininess = 5
                                                                                        }
                                                                                    },
                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 0), new float3(1, 1, 1), 5)
                                                                                    },
                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 4.3f, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
示例#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, 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
示例#13
0
        // Init is called on startup.
        public override void Init()
        {
            RC.ClearColor = new float4(0.3f, 0.2f, 0.8f, 1.0f);

            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();

            var cubeNode = new SceneNodeContainer();

            _scene.Children.Add(cubeNode);

            var cube2Node = new SceneNodeContainer();

            _scene.Children.Add(cube2Node);

            var cube3Node = new SceneNodeContainer();

            _scene.Children.Add(cube3Node);


            //The three components: one XForm, one Shader and the Mesh
            _cubeTransform = new TransformComponent {
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 10),
                Rotation    = new float3(0, 0, 0)
            };

            var cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 1, 0), new float3(1, 1, 1), 4)
            };

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

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



            _cube2Transform = new TransformComponent {
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0),
                Rotation    = new float3(0, 0, 0)
            };

            var cube2Shader = new ShaderEffectComponent {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(1, 1, 1), 4)
            };

            var cube2Mesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));

            cube2Node.Components = new List <SceneComponentContainer>();
            cube2Node.Components.Add(_cube2Transform);
            cube2Node.Components.Add(cube2Shader);
            cube2Node.Components.Add(cube2Mesh);



            _cube3Transform = new TransformComponent {
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0),
                Rotation    = new float3(0, 0, 0)
            };

            var cube3Shader = new ShaderEffectComponent {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0), new float3(1, 1, 1), 4)
            };

            var cube3Mesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 5));

            cube3Node.Components = new List <SceneComponentContainer>();
            cube3Node.Components.Add(_cube3Transform);
            cube3Node.Components.Add(cube3Shader);
            cube3Node.Components.Add(cube3Mesh);



            _sceneRenderer = new SceneRenderer(_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, 0, 0)
            };

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

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

            _foreArmTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };
            _RightHandTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0.5f, 4.5f, 0)
            };
            _LeftHandTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-0.5f, 4.5f, 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)
                                         //Diffuse = new MatChannelContainer {Color = new float3(0.7f,0.7f,0.7f)},
                                         //Specular = new SpecularChannelContainer {Color = new float3(0,0,0), Shininess = 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(1f, 0f, 0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                         // Diffuse = new MatChannelContainer {Color = new float3(1,0,0)},
                                         // Specular = new SpecularChannelContainer {Color = new float3(1,1,1), Shininess = 5}
                            },
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            //Green Upperarm
                            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(0.7f, 0.7f, 0.7f), 5)
                                            },
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        },
                                        Children = new List <SceneNodeContainer>
                                        {
                                            //Blue Forearm
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _foreArmTransform
                                                },
                                                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(0.7f, 0.7f, 0.7f), 5)
                                                            },
                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        },
                                                        Children = new List <SceneNodeContainer>
                                                        {
                                                            //RightHand
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    _RightHandTransform
                                                                },

                                                                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, 2.5f, 0)
                                                                            },

                                                                            new ShaderEffectComponent
                                                                            {
                                                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 1, 0), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                            },
                                                                            SimpleMeshes.CreateCuboid(new float3(1, 5, 2))
                                                                        }
                                                                    }
                                                                }
                                                            },
                                                            //LeftHand
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    _LeftHandTransform
                                                                },
                                                                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, 2.5f, 0)
                                                                            },

                                                                            new ShaderEffectComponent
                                                                            {
                                                                                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 1, 0), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                            },
                                                                            SimpleMeshes.CreateCuboid(new float3(1, 5, 2))
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
示例#15
0
        // 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.2f, 0.2f, 0.2f, 1); // Hintergrundfarbe (r,g,b, Durchsichtigkeit)

            // 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),       // Skalierung
                Translation = new float3(0, 0, 0),       // Position des Objektes (x,y,z)
                Rotation    = new float3(0, -0.5f, 0.2f) // Drehung an den Achsen; in Gradmaß angeben
            };
            var cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0, 1), new float3(1, 1, 1), 4)
                                                                           /* Erster float Wert Farbe des Würfels; Zweiter float Wert Farbe des Glanzlichtes  */
            };
            var cubeMesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 5)); // Größe des Quaders

            // 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);



            // Eigenschaften des Quaders

            _quaderTransform = new TransformComponent {
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 20),
                Rotation    = new float3(0, 0, 0)
            };
            var quaderShader = new ShaderEffectComponent {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 1, 1), new float3(1, 1, 1), 4)
            };
            var quaderMesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 20));



            var quader = new SceneNodeContainer();

            quader.Components = new List <SceneComponentContainer>();
            quader.Components.Add(_quaderTransform);
            quader.Components.Add(quaderShader);
            quader.Components.Add(quaderMesh);



            // Eigenschaften 3. Würfel

            _wuerfelDreiTransform = new TransformComponent {
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 20),
                Rotation    = new float3(0, 0, 0)
            };
            _wuerfelDreiShader = new ShaderEffectComponent {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.9f, 0.2f, 0.4f), new float3(1, 1, 1), 4)
            };
            var wuerfelDreiMesh = SimpleMeshes.CreateCuboid(new float3(5, 5, 20));



            var wuerfelDrei = new SceneNodeContainer();

            wuerfelDrei.Components = new List <SceneComponentContainer>();
            wuerfelDrei.Components.Add(_wuerfelDreiTransform);
            wuerfelDrei.Components.Add(_wuerfelDreiShader);
            wuerfelDrei.Components.Add(wuerfelDreiMesh);



            // Create the scene containing the cube as the only object
            // Hier werden alle Objekte der Szene Hinzugefügt
            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();
            _scene.Children.Add(cubeNode);
            _scene.Children.Add(quader);
            _scene.Children.Add(wuerfelDrei);



            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
        }
        SceneContainer CreateScene()
        {
            // Initialize Transform Components that need to be changed inside "RenderAFrame"
            _baseTransform = new TransformComponent
            {
                Rotation    = new float3(0, M.Pi / 2, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            _bodyTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            _upperArmJointTransform = new TransformComponent
            {
                Rotation    = new float3(M.Pi / 4, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            _upperArmTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 4, 0)
            };
            _foreArmJointTransform = new TransformComponent
            {
                Rotation    = new float3(M.Pi / 4, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };
            _foreArmTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 4, 0)
            };
            _prehensileRailTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 5.5f, 0)
            };
            _prehensileClawLeftTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2.5f, 3, 0)
            };
            _prehensileClawRightTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2.5f, 3, 0)
            };

            // Shader Effect Components
            var baseShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.7f, 0.7f, 0.7f), new float3(0.7f, 0.7f, 0.7f), 5)
            };
            var bodyShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.8f, 0.2f, 0.2f), new float3(0.7f, 0.7f, 0.7f), 5)
            };
            var upperArmShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.2f, 0.8f, 0.2f), new float3(0.7f, 0.7f, 0.7f), 5)
            };
            var foreArmShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.2f, 0.2f, 0.8f), new float3(0.7f, 0.7f, 0.7f), 5)
            };
            var prehensileRailShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.8f, 0.8f, 0.8f), new float3(0.7f, 0.7f, 0.7f), 5)
            };
            var prehensileClawShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.6f, 0.6f, 0.6f), new float3(0.7f, 0.7f, 0.7f), 5)
            };

            // Mesh components
            var baseMesh = SimpleMeshes.CreateCuboid(new float3(10, 2, 10));
            var armMesh  = SimpleMeshes.CreateCuboid(new float3(2, 10, 2));
            var railMesh = SimpleMeshes.CreateCuboid(new float3(6, 1, 2));
            var clawMesh = SimpleMeshes.CreateCuboid(new float3(1, 5, 2));

            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNodeContainer>
                {
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            _baseTransform,
                            baseShader,
                            baseMesh
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            new SceneNodeContainer
                            {
                                Components = new List <SceneComponentContainer>
                                {
                                    _bodyTransform,
                                    bodyShader,
                                    armMesh
                                },
                                Children = new List <SceneNodeContainer>
                                {
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _upperArmJointTransform
                                        },
                                        Children = new List <SceneNodeContainer>
                                        {
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _upperArmTransform,
                                                    upperArmShader,
                                                    armMesh
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    new SceneNodeContainer
                                                    {
                                                        Components = new List <SceneComponentContainer>
                                                        {
                                                            _foreArmJointTransform
                                                        },
                                                        Children = new List <SceneNodeContainer>
                                                        {
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    _foreArmTransform,
                                                                    foreArmShader,
                                                                    armMesh
                                                                },
                                                                Children = new List <SceneNodeContainer>
                                                                {
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            _prehensileRailTransform,
                                                                            prehensileRailShader,
                                                                            railMesh
                                                                        },
                                                                        Children = new List <SceneNodeContainer>
                                                                        {
                                                                            new SceneNodeContainer
                                                                            {
                                                                                Components = new List <SceneComponentContainer>
                                                                                {
                                                                                    _prehensileClawLeftTransform,
                                                                                    prehensileClawShader,
                                                                                    clawMesh
                                                                                }
                                                                            },
                                                                            new SceneNodeContainer
                                                                            {
                                                                                Components = new List <SceneComponentContainer>
                                                                                {
                                                                                    _prehensileClawRightTransform,
                                                                                    prehensileClawShader,
                                                                                    clawMesh
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
示例#17
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, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };

            _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)
            };

            _leftFingerTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-0.5f, 4.5f, 0)
            };

            _rechterfingertrans = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0.5f, 4.5f, 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))
                        }
                    },
                    // RED BODY
                    new SceneNodeContainer
                    {
                        Components = new List <SceneComponentContainer>
                        {
                            // TRANSFROM COMPONENT
                            _bodyTransform,

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

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            // PIVOT GREEN UPPER ARM
                            new SceneNodeContainer
                            {
                                Components = new List <SceneComponentContainer>
                                {
                                    // TRANSFROM COMPONENT
                                    _upperArmTransform
                                },
                                Children = new List <SceneNodeContainer>
                                {
                                    // GREEN UPPER ARM
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            // TRANSFROM COMPONENT
                                            new TransformComponent
                                            {
                                                Rotation = new float3(0, 0, 0),
                                                Scale = new float3(1, 1, 1),
                                                Translation = new float3(0, 4, 0)
                                            },

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

                                            // MESH COMPONENT
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        },
                                        Children = new List <SceneNodeContainer>
                                        {
                                            // PIVOT BLUE LOWER ARM
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    // TRANSFROM COMPONENT
                                                    _lowerArmTransform
                                                },
                                                Children = new List <SceneNodeContainer>
                                                {
                                                    // BLUE LOWER ARM
                                                    new SceneNodeContainer
                                                    {
                                                        Components = new List <SceneComponentContainer>
                                                        {
                                                            // TRANSFROM COMPONENT
                                                            new TransformComponent
                                                            {
                                                                Rotation = new float3(0, 0, 0),
                                                                Scale = new float3(1, 1, 1),
                                                                Translation = new float3(0, 4, 0)
                                                            },

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

                                                            // MESH COMPONENT
                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        },
                                                        Children = new List <SceneNodeContainer>
                                                        {
                                                            //  left finger
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    // TRANSFROM COMPONENT
                                                                    _leftFingerTransform
                                                                },
                                                                Children = new List <SceneNodeContainer>
                                                                {
                                                                    // left finger
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            // TRANSFROM COMPONENT
                                                                            new TransformComponent
                                                                            {
                                                                                Rotation = new float3(0, 0, 0),
                                                                                Scale = new float3(1, 1, 1),
                                                                                Translation = new float3(0, 2.5f, 0)
                                                                            },

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

                                                                            // MESH COMPONENT
                                                                            SimpleMeshes.CreateCuboid(new float3(1, 5, 1))
                                                                        }
                                                                    }
                                                                }
                                                            },
                                                            // PIVOT RIGHT FINGER
                                                            new SceneNodeContainer
                                                            {
                                                                Components = new List <SceneComponentContainer>
                                                                {
                                                                    // TRANSFROM COMPONENT
                                                                    _rechterfingertrans
                                                                },
                                                                Children = new List <SceneNodeContainer>
                                                                {
                                                                    // RIGHT FINGER
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            // TRANSFROM COMPONENT
                                                                            new TransformComponent
                                                                            {
                                                                                Rotation = new float3(0, 0, 0),
                                                                                Scale = new float3(1, 1, 1),
                                                                                Translation = new float3(0, 2.5f, 0)
                                                                            },

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

                                                                            // MESH COMPONENT
                                                                            SimpleMeshes.CreateCuboid(new float3(1, 5, 1))
                                                                        } //end components
                                                                    }     //end node container
                                                                }         // end node container
                                                            }             //end node container
                                                        }                 //end list
                                                    }                     //end node container
                                                }                         //end scene node container
                                            }                             //end node container
                                        }                                 //end blue node container
                                    }                                     //end red node container
                                }                                         //end children node container
                            }                                             //end new node container
                        }                                                 //end node container
                    }                                                     //node red body
                }
            });
        }
示例#18
0
        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(2f, 2f, 2.7f, 5);

            // Create scene with cubes
            // The three components: one XForm, one Shader and the Mesh
            _cubeTransform = new TransformComponent {
                Scale = new float3(1, 0.1f, 1), Translation = new float3(2, 0.7f, 0)
            };
            var cubeShader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 4, 2), new float3(6, 4, 2), 3)
            };
            var cubeMesh  = SimpleMeshes.CreateCuboid(new float3(4, 5, 7));
            var cubeMesh1 = SimpleMeshes.CreateCuboid(new float3(3, 1, 15));
            var cubeMesh2 = SimpleMeshes.CreateCuboid(new float3(5, 7, 9));

            _cubeTransform1 = new TransformComponent {
                Scale = new float3(1.2f, 2.7f, 0.1f), Translation = new float3(10, 5, 5)
            };
            var cubeShader1 = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.2f, 0.4f, 0.6f), new float3(1, 1, 1), 4)
            };

            _cubeTransform2 = new TransformComponent {
                Scale = new float3(0.5f, 0.5f, 0.5f), Translation = new float3(30, 14, 19)
            };
            var cubeShader2 = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(2, 1, 20), new float3(1, 1, 1), 5)
            };

            // Assemble the cubes
            var cubeNode = new SceneNodeContainer();

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

            var cubeNode1 = new SceneNodeContainer();

            cubeNode1.Components = new List <SceneComponentContainer>();
            cubeNode1.Components.Add(_cubeTransform1);
            cubeNode1.Components.Add(cubeShader1);
            cubeNode1.Components.Add(cubeMesh1);

            var cubeNode2 = new SceneNodeContainer();

            cubeNode2.Components = new List <SceneComponentContainer>();
            cubeNode2.Components.Add(_cubeTransform2);
            cubeNode2.Components.Add(cubeShader2);
            cubeNode2.Components.Add(cubeMesh2);


            _scene          = new SceneContainer();
            _scene.Children = new List <SceneNodeContainer>();
            _scene.Children.Add(cubeNode);
            _scene.Children.Add(cubeNode1);
            _scene.Children.Add(cubeNode2);


            _sceneRenderer = new SceneRenderer(_scene);
        }
示例#19
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
        }
示例#20
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);
        }
示例#21
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to custom color (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0.58f, 0, 0.7f, 1);

            // Create a scene with 3 cubes
            // The three components: one XForm, one Shader and the Mesh

            //Würfel Nr.1
            _cube1Transform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0)
            };                                                                                                         //Translation = Position im Raum
            var cube1Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.3f, 0.88f, 1), new float3(1, 1, 1), 4)
            };
            var cube1Mesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

            //Würfel Nr.2
            _cube2Transform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(20, 0, 0)
            };
            var cube2Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(1, 0, 0.67f), new float3(1, 1, 1), 4)
            };
            var cube2Mesh = SimpleMeshes.CreateCuboid(new float3(12, 12, 12));

            //Würfel Nr.3
            _cube3Transform = new TransformComponent {
                Scale = new float3(1, 1, 1), Translation = new float3(-20, 5, 0)
            };
            cube3Shader = new ShaderEffectComponent
            {
                Effect = SimpleMeshes.MakeShaderEffect(new float3(0.8f, 0, 0.13f), new float3(1, 1, 1), 4)
            };
            var cube3Mesh = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

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

            cube1Node.Components = new List <SceneComponentContainer>();
            cube1Node.Components.Add(_cube1Transform);
            cube1Node.Components.Add(cube1Shader);
            cube1Node.Components.Add(cube1Mesh);

            var cube2Node = new SceneNodeContainer();

            cube2Node.Components = new List <SceneComponentContainer>();
            cube2Node.Components.Add(_cube2Transform);
            cube2Node.Components.Add(cube2Shader);
            cube2Node.Components.Add(cube2Mesh);

            var cube3Node = new SceneNodeContainer();

            cube3Node.Components = new List <SceneComponentContainer>();
            cube3Node.Components.Add(_cube3Transform);
            cube3Node.Components.Add(cube3Shader);
            cube3Node.Components.Add(cube3Mesh);

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

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
        }
示例#22
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, -45 * M.Pi / 180, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            _upperArmTransform = new TransformComponent
            {
                Rotation    = new float3(38 * M.Pi / 180, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            _foreArmTransform = new TransformComponent
            {
                Rotation    = new float3(90 * M.Pi / 180, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 4, 0)
            };
            _greifLeftTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 45 * M.Pi / 180),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-1, 5, 0)
            };
            _greifRightTransform = new TransformComponent
            {
                Rotation    = new float3(0, 0, -45 * M.Pi / 180),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(1, 5, 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))
                        },

                        Children = new List <SceneNodeContainer>
                        {
                            //roter Arm/ roter Body
                            new SceneNodeContainer
                            {
                                Components = new List <SceneComponentContainer>
                                {
                                    _bodyTransform,

                                    new ShaderEffectComponent
                                    {
                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0.83f, 0.13f, 0.18f), new float3(0.7f, 0.7f, 0.7f), 5)
                                    },

                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                },

                                Children = new List <SceneNodeContainer>
                                {
                                    //grüner Arm
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _upperArmTransform //extra Koordinatensystem für Rotation um bestimmten Punkt eingefügt als extra Child
                                        },

                                        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.23f, 0.64f, 0.34f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                    },

                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                },

                                                Children = new List <SceneNodeContainer>
                                                {
                                                    //blauer Arm
                                                    new SceneNodeContainer
                                                    {
                                                        Components = new List <SceneComponentContainer>
                                                        {
                                                            _foreArmTransform //extra Koordinatensystem für Rotation um bestimmten Punkt eingefügt als extra Child
                                                        },

                                                        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.13f, 0.21f, 0.61f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                    },

                                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                                },

                                                                //Greifarme
                                                                Children = new List <SceneNodeContainer>
                                                                {
                                                                    //Linker Arm
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            _greifLeftTransform
                                                                        },

                                                                        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, 1.25f, 0)
                                                                                    },

                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0.84f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                                    },

                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 2.5f, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    },

                                                                    //Rechter Arm
                                                                    new SceneNodeContainer
                                                                    {
                                                                        Components = new List <SceneComponentContainer>
                                                                        {
                                                                            _greifRightTransform
                                                                        },

                                                                        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, 1.25f, 0)
                                                                                    },

                                                                                    new ShaderEffectComponent
                                                                                    {
                                                                                        Effect = SimpleMeshes.MakeShaderEffect(new float3(0, 0.84f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                                                    },

                                                                                    SimpleMeshes.CreateCuboid(new float3(1, 2.5f, 1))
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
示例#23
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)
            };
            _GreifArm1Transform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(0.3f, 0.4f, 0.6f),
                Translation = new float3(0.1f, 9, 0)
            };
            _GreifArm2Transform = new TransformComponent
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(0.3f, 0.4f, 0.6f),
                Translation = new float3(-0.75f, 9, 0)
            };



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

                            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.0f, 0.0f, 0.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                            },

                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new List <SceneNodeContainer>
                        {
                            // GREEN UPPER 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.0f, 1.0f, 0.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                            },


                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },
                                    // BLUE FOREARM
                                    new SceneNodeContainer
                                    {
                                        Components = new List <SceneComponentContainer>
                                        {
                                            _foreArmTransform,
                                        },
                                        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.0f, 0.0f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                    },


                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            },
                                            // GreifArm1
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _GreifArm1Transform,
                                                },
                                                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.2f, 0.2f, 0.2f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                            },


                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        }
                                                    }
                                                }
                                            },

                                            // GreifArm2
                                            new SceneNodeContainer
                                            {
                                                Components = new List <SceneComponentContainer>
                                                {
                                                    _GreifArm2Transform,
                                                },
                                                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(1.0f, 0.2f, 1.0f), new float3(0.7f, 0.7f, 0.7f), 5)
                                                            },


                                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                        }
                    }
                }
            });
        }