Пример #1
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            //Git Test
            // Setup the scene graph
            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            // TRANSFORM COMPONENT
                            _baseTransform,

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

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

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

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

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

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

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Пример #3
0
        public void OnBtnCanvasExit(CodeComponent sender)
        {
            Debug.WriteLine("Canvas: Exit Btn!");
            var color = ShaderCodeBuilder.MakeShaderEffect(albedoColor: new float4(1, 0, 0, 1));
            var n     = _scene.Children.FindNodes(node => node.Name == "Canvas").First();

            n.GetComponent <ShaderEffect>().SetEffectParam(UniformNameDeclarations.AlbedoColor, new float4(1, 0, 0, 1));
        }
Пример #4
0
        private static SceneNodeContainer CreateCircle(float2 circleDim, MatColor color)
        {
            float4 col;

            string nameSuffix;

            switch (color)
            {
            default:
            case MatColor.WHITE:
                col        = White;
                nameSuffix = "white";
                break;

            case MatColor.GREEN:
                col        = Green;
                nameSuffix = "green";
                break;

            case MatColor.YELLOW:
                col        = Yellow;
                nameSuffix = "yellow";
                break;

            case MatColor.GRAY:
                col        = Gray;
                nameSuffix = "gray";
                break;
            }

            return(new SceneNodeContainer
            {
                Name = "Circle_" + nameSuffix,
                Components = new List <SceneComponentContainer>
                {
                    new RectTransformComponent
                    {
                        Name = "circle" + "_RectTransform",
                        Anchors = new MinMaxRect
                        {
                            Min = new float2(0.5f, 0.5f),
                            Max = new float2(0.5f, 0.5f)
                        },
                        Offsets = UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(0, 0), CanvasHeightInit, CanvasWidthInit, circleDim),
                    },
                    new XFormComponent
                    {
                        Name = "circle" + "_XForm",
                    },
                    new ShaderEffectComponent()
                    {
                        Effect = ShaderCodeBuilder.MakeShaderEffect(col, new float4(1, 1, 1, 1), 20, 0)
                    },
                    new Circle(false, 30, 100, _circleThickness)
                }
            });
        }
Пример #5
0
        // Init is called on startup.
        public override void Init()
        {
            randomIntBack = new Random();
            float RndIntColorBackOne   = randomIntBack.Next(255);
            float RndIntColorBackTwo   = randomIntBack.Next(255);
            float RndIntColorBackThree = randomIntBack.Next(255);

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

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


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


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


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

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

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

            _sceneRenderer = new SceneRendererForward(_scene);
        }
Пример #6
0
        private SceneContainer BuildScene()
        {
            var sphere = new Sphere(32, 24);

            var lineControlPoints = new List <float3>
            {
                new float3(-3f, 0, 0), new float3(-1.5f, -1.5f, 0), new float3(1f, 1.5f, 0)
            };
            var line = new Line(lineControlPoints, 0.2f);

            return(new SceneContainer()
            {
                Children = new List <SceneNodeContainer>()
                {
                    new SceneNodeContainer()
                    {
                        Components = new List <SceneComponentContainer>()
                        {
                            new TransformComponent()
                            {
                                Name = "SphereTransform",
                                Rotation = new float3(0, 0, 0),
                                Translation = new float3(0, 0, 0),
                                Scale = new float3(1, 1, 1)
                            },
                            new ShaderEffectComponent()
                            {
                                Effect = ShaderCodeBuilder.MakeShaderEffect(new float4(0.90980f, 0.35686f, 0.35686f, 1), new float4(1, 1, 1, 1), 20, "crumpled-paper-free.jpg", 0.5f)
                            },
                            //sphere
                        }
                    },
                    new SceneNodeContainer()
                    {
                        Components = new List <SceneComponentContainer>()
                        {
                            new TransformComponent()
                            {
                                Name = "LineTransform",
                                Rotation = new float3(0, 0, 0),
                                Translation = new float3(0, 0, 0),
                                Scale = new float3(1, 1, 1)
                            },
                            new ShaderEffectComponent()
                            {
                                Effect = ShaderCodeBuilder.MakeShaderEffect(new float4(0, 0, 1, 1), new float4(1, 1, 1, 1), 20)
                            },
                            line
                        }
                    }
                }
            });
        }
Пример #7
0
        public void OnBtnCanvasExit(CodeComponent sender)
        {
            Debug.WriteLine("Canvas: Exit Btn!");
            var color = ShaderCodeBuilder.MakeShaderEffectFromMatComp(new MaterialComponent
            {
                Diffuse = new MatChannelContainer {
                    Color = new float4(1, 0, 0, 1)
                },
            });

            _scene.Children.FindNodes(node => node.Name == "Canvas").First().GetComponent <ShaderEffectComponent>()
            .Effect = color;
        }
Пример #8
0
        private static SceneNodeContainer CreateLine(MatColor color)
        {
            float4 col;

            switch (color)
            {
            default:
            case MatColor.WHITE:
                col = White;
                break;

            case MatColor.GREEN:
                col = Green;
                break;

            case MatColor.YELLOW:
                col = Yellow;
                break;

            case MatColor.GRAY:
                col = Gray;
                break;
            }


            return(new SceneNodeContainer()
            {
                Name = "line",
                Components = new List <SceneComponentContainer>
                {
                    new RectTransformComponent
                    {
                        Name = "line" + "_RectTransform",
                        Anchors = new MinMaxRect
                        {
                            Min = new float2(0.5f, 0.5f),
                            Max = new float2(0.5f, 0.5f)
                        },
                        Offsets = UIElementPosition.CalcOffsets(AnchorPos.MIDDLE, new float2(0, 0), CanvasHeightInit, CanvasWidthInit, new float2(CanvasWidthInit, CanvasHeightInit)),
                    },
                    new XFormComponent
                    {
                        Name = "line" + "_XForm",
                    },
                    new ShaderEffectComponent()
                    {
                        Effect = ShaderCodeBuilder.MakeShaderEffect(col, new float4(1, 1, 1, 1), 20, 0)
                    }
                }
            });
        }
        public static ShaderEffect MakeShaderEffect(float3 diffuseColor, float3 specularColor, float shininess)
        {
            MaterialComponent temp = new MaterialComponent
            {
                Diffuse = new MatChannelContainer
                {
                    Color = diffuseColor
                },
                Specular = new SpecularChannelContainer
                {
                    Color     = specularColor,
                    Shininess = shininess
                }
            };

            return(ShaderCodeBuilder.MakeShaderEffectFromMatComp(temp));
        }
Пример #10
0
        public static ShaderEffect MakeShaderEffect(float3 diffuseColor, float3 specularColor, float shininess)
        {
            MaterialComponent temp = new MaterialComponent
            {
                Diffuse = new MatChannelContainer
                {
                    Color = diffuseColor
                },
                Specular = new SpecularChannelContainer
                {
                    Color     = specularColor,
                    Shininess = shininess
                }
            };

            var ret = ShaderCodeBuilder.MakeShaderEffectFromMatComp(temp);

            ret.SetEffectParam("allLights[0].intensities", new float3(1, 1, 1));

            return(ret);
        }
Пример #11
0
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };
            _bodyTransform = new Transform
            {
                Rotation    = new float3(0, 1.2f, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 6, 0)
            };
            _upperArmTransform = new Transform
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(2, 4, 0)
            };
            _foreArmTransform = new Transform
            {
                Rotation    = new float3(0.8f, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(-2, 8, 0)
            };

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

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

                            // MESH COMPONENT
                            SimpleMeshes.CreateCuboid(new float3(10, 2, 10))
                        }
                    },
                    // RED BODY
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            _bodyTransform,
                            ShaderCodeBuilder.MakeShaderEffect(new float4(1, 0, 0, 1)),
                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                        },
                        Children = new ChildList
                        {
                            // GREEN UPPER ARM
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    _upperArmTransform,
                                },
                                Children = new ChildList
                                {
                                    new SceneNode
                                    {
                                        Components = new List <SceneComponent>
                                        {
                                            new Transform
                                            {
                                                Rotation = new float3(0, 0, 0),
                                                Scale = new float3(1, 1, 1),
                                                Translation = new float3(0, 4, 0)
                                            },
                                            ShaderCodeBuilder.MakeShaderEffect(new float4(0, 1, 0, 1)),
                                            SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                        }
                                    },
                                    // BLUE FOREARM
                                    new SceneNode
                                    {
                                        Components = new List <SceneComponent>
                                        {
                                            _foreArmTransform,
                                        },
                                        Children = new ChildList
                                        {
                                            new SceneNode
                                            {
                                                Components = new List <SceneComponent>
                                                {
                                                    new Transform
                                                    {
                                                        Rotation = new float3(0, 0, 0),
                                                        Scale = new float3(1, 1, 1),
                                                        Translation = new float3(0, 4, 0)
                                                    },
                                                    ShaderCodeBuilder.MakeShaderEffect(new float4(0, 0, 1, 1)),
                                                    SimpleMeshes.CreateCuboid(new float3(2, 10, 2))
                                                }
                                            }
                                        }
                                    }
                                }
                            },
                        }
                    }
                }
            });
        }
Пример #12
0
        // Init is called on startup.
        public override void Init()
        {
            _gui = CreateGui();

            // Create the interaction handler
            _sih = new SceneInteractionHandler(_gui);

            // Initial "Zoom" value (it's rather the distance in view direction, not the camera's focal distance/opening angle)
            _zoom = 400;

            _angleRoll        = 0;
            _angleRollInit    = 0;
            _twoTouchRepeated = false;
            _offset           = float2.Zero;
            _offsetInit       = float2.Zero;

            // Set the clear color for the back buffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            //----- DUMMY SCENE BELOW - use the fus file when the exporter is able to export bones again ---- //
            //_scene = AssetStorage.Get<SceneContainer>("BoneAnim.fus");

            _scene = new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Rotation    = float3.Zero,
                                Translation = new float3(0, 0, 0),
                                Scale       = float3.One
                            },
                            new Engine.Core.Scene.Bone()
                        },
                        Children = new ChildList()
                        {
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Rotation    = float3.Zero,
                                        Translation = new float3(0, 0.5f, 0),
                                        Scale       = new float3(10, 100, 10)
                                    },
                                    new Engine.Core.Scene.Bone(),
                                    new Weight(),
                                    ShaderCodeBuilder.MakeShaderEffect(albedoColor: new float4(1.0f, 0.4f, 0.2f, 1.0f)),
                                    new Cube()
                                }
                            }
                        }
                    }
                }
            };

            var mesh      = _scene.Children[0].Children[0].GetComponent <Cube>();
            var wm        = _scene.Children[0].Children[0].GetComponent <Weight>();
            var WeightMap = new List <VertexWeightList>();

            for (var i = 0; i < mesh.Vertices.Length; i++)
            {
                WeightMap.Add(new VertexWeightList
                {
                    VertexWeights = new List <VertexWeight>
                    {
                        new VertexWeight
                        {
                            JointIndex = 0,
                            Weight     = (mesh.Vertices[i].y > 0 ? 1: 0f)
                        },
                        new VertexWeight()
                        {
                            JointIndex = 1,
                            Weight     = (mesh.Vertices[i].y <= 0 ? 1f: 0f)
                        }
                    }
                });
            }
            wm.WeightMap = WeightMap;
            var weightMapFromScene = _scene.Children[0].Children[0].Components[1];

            #region LEGACY / REFERENCE CODE
            // Add a weightcomponent with weight matrices etc:
            // binding matrices is the start point of every transformation
            // as many entries as vertices are present in current model
            //var cube = _scene.Children[0].GetComponent<Mesh>();
            //var vertexCount = cube.Vertices.Length;

            //var bindingMatrices = new List<float4x4>();
            //for (var i = 0; i < vertexCount; i++)
            //{
            //    bindingMatrices.Add(float4x4.Identity);
            //}

            //_scene.Children.Insert(0, new SceneNode()
            //{
            //    Name = "BoneContainer1",
            //    Components = new List<SceneComponentContainer>()
            //    {
            //        new TransformComponent()
            //        {
            //            Translation = new float3(0, 2, 0),
            //            Scale = new float3(1, 1, 1)
            //        },

            //    },
            //    Children = new ChildList
            //    {
            //        new SceneNode()
            //        {
            //            Components = new List<SceneComponentContainer>
            //            {
            //                new TransformComponent
            //                {
            //                    Translation = new float3(0, -1f, 0),
            //                    Scale = new float3(1, 2, 1)
            //                },
            //                new BoneComponent(),
            //                new Cube()
            //            }
            //        },

            //        new SceneNode()
            //        {
            //            Name = "BoneContainer2",
            //            Components = new List<SceneComponentContainer>
            //            {
            //                new TransformComponent
            //                {
            //                    Translation = new float3(0, -2, 0),
            //                    Scale = new float3(1, 2, 1)
            //                },

            //            },

            //            Children = new ChildList
            //            {
            //                new SceneNode
            //                {
            //                Components = new List<SceneComponentContainer>()
            //                {
            //                    new TransformComponent()
            //                    {
            //                        Translation = new float3(0, -0.5f, 0),
            //                        Scale = new float3(1,1,1)
            //                    },
            //                    new BoneComponent(),
            //                    new Cube()
            //                }
            //                }
            //            }

            //        }
            //    }

            //});

            //_scene.Children[1].Components.Insert(1, new WeightComponent
            //{
            //    BindingMatrices = bindingMatrices,
            //    WeightMap = WeightMap
            //    // Joints are added automatically during scene conversion (ConvertSceneGraph)
            //});

            #endregion

            var aabbc = new AABBCalculator(_scene);
            var bbox  = aabbc.GetBox();
            if (bbox != null)
            {
                // If the model origin is more than one third away from its bounding box,
                // recenter it to the bounding box. Do this check individually per dimension.
                // This way, small deviations will keep the model's original center, while big deviations
                // will make the model rotate around its geometric center.
                var bbCenter = bbox.Value.Center;
                var bbSize   = bbox.Value.Size;
                var center   = float3.Zero;
                if (System.Math.Abs(bbCenter.x) > bbSize.x * 0.3)
                {
                    center.x = bbCenter.x;
                }
                if (System.Math.Abs(bbCenter.y) > bbSize.y * 0.3)
                {
                    center.y = bbCenter.y;
                }
                if (System.Math.Abs(bbCenter.z) > bbSize.z * 0.3)
                {
                    center.z = bbCenter.z;
                }
                _sceneCenter = float4x4.CreateTranslation(-center);

                // Adjust the model size
                var maxScale = System.Math.Max(bbSize.x, System.Math.Max(bbSize.y, bbSize.z));
                if (maxScale != 0)
                {
                    _sceneScale = float4x4.CreateScale(200.0f / maxScale);
                }
                else
                {
                    _sceneScale = float4x4.Identity;
                }
            }

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_scene);
            _guiRenderer   = new SceneRendererForward(_gui);
        }
Пример #13
0
        //Build a scene graph consisting out of a canvas and other UI elements.
        private SceneContainer CreateNineSliceScene()
        {
            var vsTex       = AssetStorage.Get <string>("texture.vert");
            var psTex       = AssetStorage.Get <string>("texture.frag");
            var vsNineSlice = AssetStorage.Get <string>("nineSlice.vert");
            var psNineSlice = AssetStorage.Get <string>("nineSliceTile.frag");

            var   canvasScaleFactor = _initWindowWidth / _canvasWidth;
            float textSize          = 2;
            float borderScaleFactor = 1;

            if (_canvasRenderMode == CanvasRenderMode.SCREEN)
            {
                textSize         *= canvasScaleFactor;
                borderScaleFactor = canvasScaleFactor;
            }

            var text = new TextNodeContainer(
                "Hallo !",
                "ButtonText",
                vsTex,
                psTex,
                UIElementPosition.GetAnchors(AnchorPos.STRETCH_ALL),
                new MinMaxRect
            {
                Min = new float2(1f, 0.5f),
                Max = new float2(-1f, -0.5f)
            },
                _fontMap,
                ColorUint.Tofloat4(ColorUint.Greenery), textSize);

            var catTextureNode = new TextureNodeContainer(
                "Cat",
                AssetStorage.Get <string>("nineSlice.vert"),
                AssetStorage.Get <string>("nineSliceTile.frag"),
                //Set the diffuse texture you want to use.
                new Texture(AssetStorage.Get <ImageData>("Kitti.jpg")),

                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.STRETCH_HORIZONTAL),//Anchor is in the lower left corner of the parent. Anchor is in the lower right corner of the parent.

                //Define Offset and therefor the size of the element.
                //Min: distance to this elements Min anchor.
                //Max: distance to this elements Max anchor.
                UIElementPosition.CalcOffsets(AnchorPos.STRETCH_HORIZONTAL, new float2(_initCanvasWidth / 2 - 2.5f, 0), _initCanvasHeight, _initCanvasWidth, new float2(5, 4)),
                //Choose in how many tiles you want to split the inner part of the texture. Use float2.one if you want it stretched.
                new float2(5, 5),
                //Tell how many percent of the texture, seen from the edges, belongs to the border. Order: left, right, top, bottom.
                new float4(0.11f, 0.11f, 0.06f, 0.17f),
                4, 4, 4, 4,
                borderScaleFactor

                )
            {
                Children = new ChildList()
                {
                    text
                }
            };

            catTextureNode.Components.Add(_btnCat);

            var bltTextureNode = new TextureNodeContainer(
                "Blt",
                vsTex,
                psTex,
                //Set the diffuse texture you want to use.
                _bltDestinationTex,
                //_fontMap.Image,
                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.DOWN_DOWN_LEFT),//Anchor is in the lower left corner of the parent. Anchor is in the lower right corner of the parent.

                //Define Offset and therefor the size of the element.
                //Min: distance to this elements Min anchor.
                //Max: distance to this elements Max anchor.
                UIElementPosition.CalcOffsets(AnchorPos.DOWN_DOWN_LEFT, new float2(0, 0), _initCanvasHeight, _initCanvasWidth, new float2(4, 4)));

            var quagganTextureNode1 = new TextureNodeContainer(
                "Quaggan1",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(2.5f, 0), 3, 6, new float2(1, 1)),

                new float2(1, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var nineSliceTextureNode = new TextureNodeContainer(
                "testImage",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("9SliceSprites-4.png")),
                //In this setup the element will stay in the upper right corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_RIGHT),//Anchor is in the upper right corner.//Anchor is in the upper right corner.

                UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_RIGHT, new float2(_initCanvasWidth - 6, _initCanvasHeight - 3), _initCanvasHeight, _initCanvasWidth, new float2(6, 3)),

                new float2(2, 3),
                new float4(0.1f, 0.1f, 0.1f, 0.1f),
                2.5f, 2.5f, 2.5f, 2.5f,
                borderScaleFactor
                )
            {
                Children = new ChildList()
                {
                    text, quagganTextureNode1
                }
            };

            var quagganTextureNode = new TextureNodeContainer(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(0, _initCanvasHeight - 1), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var quagganTextureNode2 = new TextureNodeContainer(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TOP_TOP_LEFT), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TOP_TOP_LEFT, new float2(0, _initCanvasHeight - 3), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var quagganTextureNode3 = new TextureNodeContainer(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.STRETCH_VERTICAL), //Anchor is in the lower right corner. Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.STRETCH_VERTICAL, new float2(0, _initCanvasHeight - 5), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var canvas = new CanvasNodeContainer(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-_canvasWidth / 2, -_canvasHeight / 2f),
                Max = new float2(_canvasWidth / 2, _canvasHeight / 2f)
            })
            {
                Children = new ChildList()
                {
                    //Simple Texture Node, contains a Blt"ed" texture.
                    bltTextureNode,
                    //Add nine sliced textures to canvas
                    catTextureNode,
                    quagganTextureNode,
                    nineSliceTextureNode,
                    quagganTextureNode2,
                    quagganTextureNode3
                }
            };

            var canvasMat = new ShaderEffectComponent
            {
                Effect = ShaderCodeBuilder.MakeShaderEffectFromMatComp(new MaterialComponent
                {
                    Diffuse = new MatChannelContainer {
                        Color = new float4(1, 0, 0, 1)
                    },
                })
            };

            var projMethod = _canvasRenderMode == CanvasRenderMode.SCREEN ? ProjectionMethod.ORTHOGRAPHIC : ProjectionMethod.PERSPECTIVE;
            var projComp   = new ProjectionComponent(projMethod, zNear, zFar, fov);

            AddResizeDelegate(delegate { projComp.Resize(Width, Height); });

            canvas.Components.Insert(0, projComp);
            canvas.AddComponent(canvasMat);
            canvas.AddComponent(new Plane());
            canvas.AddComponent(_btnCanvas);

            return(new SceneContainer
            {
                Children = new List <SceneNodeContainer>
                {
                    //Add canvas.
                    canvas
                }
            });
        }
Пример #14
0
        // Init is called on startup.
        public override void Init()
        {
            var fontLato    = AssetStorage.Get <Font>("Lato-Black.ttf");
            var fontLatoMap = new FontMap(fontLato, 32);

            var vsTex = AssetStorage.Get <string>("texture.vert");
            var psTex = AssetStorage.Get <string>("texture.frag");

            var icosphereWithTangents = new Icosphere(5);

            icosphereWithTangents.Tangents   = icosphereWithTangents.CalculateTangents();
            icosphereWithTangents.BiTangents = icosphereWithTangents.CalculateBiTangents();

            icosphereWithTangents.BoundingBox = new AABBf(icosphereWithTangents.Vertices);

            var canvasWidth  = Width / 100f;
            var canvasHeight = Height / 100f;

            var guiDescriptionScene = new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    new CanvasNode("Canvas", CanvasRenderMode.World, new MinMaxRect
                    {
                        Min = new float2(-canvasWidth / 2, -canvasHeight / 2f),
                        Max = new float2(canvasWidth / 2, canvasHeight / 2f)
                    })
                    {
                        Children = new ChildList
                        {
                            new TextNode(
                                "How-To:\n############################\n- Move with WASD\n- Left mouse button rotates spheres\n- Mouse wheel zooms",
                                "howTo",
                                vsTex,
                                psTex,
                                UIElementPosition.GetAnchors(AnchorPos.DownDownLeft),
                                UIElementPosition.CalcOffsets(AnchorPos.DownDownLeft, new float2(-11, -5), canvasHeight, canvasWidth, new float2(12, 1)),
                                fontLatoMap,
                                new float4(1, 1, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Complete", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(-15, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Complete",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center), new TextNode(
                                "NOT YET IMPLEMENTED",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect
                            {
                                Max = new float2(0, 0),
                                Min = new float2(0, -1.25f)
                            },
                                fontLatoMap,
                                new float4(1, 0, 0, 0.5f),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Albedo and specular", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(-10, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Albedo and Specular",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Albedo, specular and albedo texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(-5, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Albedo, specular and\nalbedo texture",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Specular texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(0, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Specular texture",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center),
                            new TextNode(
                                "NOT YET IMPLEMENTED",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect
                            {
                                Max = new float2(0, 0),
                                Min = new float2(0, -1.25f)
                            },
                                fontLatoMap,
                                new float4(1, 0, 0, 0.75f),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Normal map", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(5, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Normal map",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Albedo and emissive", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(10, 2.5f, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Albedo and emissive",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center),
                            new TextNode(
                                "NOT YET IMPLEMENTED",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect
                            {
                                Max = new float2(0, 0),
                                Min = new float2(0, -1.25f)
                            },
                                fontLatoMap,
                                new float4(1, 0, 0, 0.75f),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    },
                    new CanvasNode("Albedo and emissive with texture", CanvasRenderMode.World, MinMaxRect.FromCenterSize(float2.Zero, float2.One))
                    {
                        Components = new List <SceneComponent>
                        {
                            new Transform
                            {
                                Name        = "TextTransform",
                                Translation = new float3(15, 3, 0)
                            }
                        },
                        Children = new ChildList
                        {
                            new TextNode(
                                "Albedo, emissive and\nemissive texture",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect(),
                                fontLatoMap,
                                new float4(0, 0, 0, 1),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center),
                            new TextNode(
                                "NOT YET IMPLEMENTED",
                                "desc",
                                vsTex,
                                psTex,
                                MinMaxRect.FromCenterSize(float2.Zero, float2.One),
                                new MinMaxRect
                            {
                                Max = new float2(0, 0),
                                Min = new float2(0, -1.75f)
                            },
                                fontLatoMap,
                                new float4(1, 0, 0, 0.75f),
                                HorizontalTextAlignment.Left,
                                VerticalTextAlignment.Center)
                        }
                    }
                }
            };

            _scene = new SceneContainer
            {
                Header = new SceneHeader
                {
                    CreatedBy    = "MR",
                    CreationDate = DateTime.Now.ToString(),
                    Generator    = "by hand"
                },
                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Children = new ChildList
                        {
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "complete",
                                        Translation = new float3(-15, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps
                                    {
                                        MatProbs =
                                        {
                                            HasAlbedo        = true,
                                            HasAlbedoTexture = true,
                                            HasSpecular      = true,
                                            //HasSpecularTexture = true,
                                            HasEmissive        = true,
                                            HasEmissiveTexture = true,
                                            HasNormalMap       = true
                                        },
                                        MatType   = MaterialType.Standard,
                                        MatValues =
                                        {
                                            AlbedoColor       = float4.One * 0.25f,
                                            AlbedoMix         =                 1f,
                                            AlbedoTexture     = "albedoTex.jpg",
                                            SpecularColor     = float4.One,
                                            SpecularIntensity =                 2f,
                                            SpecularShininess =                25f,
                                            SpecularMix       =                 1f,
                                            //SpecularTexture = "specularTex.jpg",
                                            NormalMap          = "normalTex.jpg",
                                            NormalMapIntensity =                 1f,
                                            EmissiveColor      = new float4(0, 1, 1, 1),
                                            EmissiveMix        =               0.5f,
                                            EmissiveTexture    = "emissiveTex.jpg"
                                        }
                                    }),
                                    icosphereWithTangents,
                                }
                            },
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "albedo and specular",
                                        Translation = new float3(-10, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectProto(albedoColor: new float4(0.39f, 0.19f, 0, 1),
                                                                            specularColor: new float4(.5f, .5f, .5f, 1),
                                                                            shininess: 25.0f,
                                                                            specularIntensity: 2.5f),
                                    icosphereWithTangents
                                }
                            },
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "albedo, specular, albedo texture",
                                        Translation = new float3(-5, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectProto(albedoColor: new float4(0.39f, 0.19f, 0, 1),
                                                                            specularColor: new float4(.5f, .5f, .5f, 1),
                                                                            albedoTexture: "albedoTex.jpg",
                                                                            albedoTextureMix: 1f,
                                                                            shininess: 256.0f,
                                                                            specularIntensity: 20.0f),
                                    icosphereWithTangents
                                }
                            },
                            // ---- Specular Textures are not implemented yet. There is no fitting shader! ---- //
                            //new SceneNode
                            //{
                            //    Components = new List<SceneComponent>
                            //    {
                            //        new Transform
                            //        {
                            //            Name = "specular texture",
                            //            Translation = new float3(0, 0, 0)
                            //        },
                            //        ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps
                            //        {
                            //            MatProbs =
                            //            {
                            //                HasAlbedo = true,
                            //                HasAlbedoTexture = true,
                            //                HasSpecular = true,
                            //                HasSpecularTexture = true
                            //            },
                            //            MatType = MaterialType.Standard,
                            //            MatValues =
                            //            {
                            //                AlbedoColor = new float4(0.39f, 0.19f, 0, 1),
                            //                SpecularColor = float4.One,
                            //                SpecularIntensity = 2f,
                            //                SpecularShininess = 25f,
                            //                SpecularMix = 1f, // TODO: Implement in ShaderShards
                            //                SpecularTexture = "specularTex.jpg" // TODO: Implement in ShaderShards
                            //            }
                            //        }),
                            //        icosphereWithTangents
                            //    }
                            //},
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "normal map",
                                        Translation = new float3(5, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps
                                    {
                                        MatProbs =
                                        {
                                            HasAlbedo        = true,
                                            HasAlbedoTexture = true,
                                            HasNormalMap     = true,
                                            HasSpecular      = true
                                        },
                                        MatType   = MaterialType.Standard,
                                        MatValues =
                                        {
                                            AlbedoColor        = float4.One * 0.25f,
                                            AlbedoMix          =                 1f,
                                            AlbedoTexture      = "albedoTex.jpg",
                                            SpecularColor      = float4.One,
                                            SpecularIntensity  =                 5f,
                                            SpecularShininess  =               200f,
                                            NormalMap          = "normalTex.jpg",
                                            NormalMapIntensity = 1f
                                        }
                                    }),
                                    icosphereWithTangents
                                }
                            },
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "albedo, emissive",
                                        Translation = new float3(10, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps
                                    {
                                        MatProbs =
                                        {
                                            HasAlbedo        = true,
                                            HasAlbedoTexture = true,
                                            HasEmissive      = true
                                        },
                                        MatType   = MaterialType.Standard,
                                        MatValues =
                                        {
                                            AlbedoColor   = float4.One * 0.25f,
                                            AlbedoMix     =                 1f,
                                            AlbedoTexture = "albedoTex.jpg",
                                            EmissiveColor = new float4(1, 0, 0, 1) // TODO: Implement in ShaderShards
                                        }
                                    }),
                                    icosphereWithTangents
                                }
                            },
                            new SceneNode
                            {
                                Components = new List <SceneComponent>
                                {
                                    new Transform
                                    {
                                        Name        = "albedo, emissive, emissive texture",
                                        Translation = new float3(15, 0, 0)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new ShaderEffectProps
                                    {
                                        MatProbs =
                                        {
                                            HasAlbedo          = true,
                                            HasAlbedoTexture   = true,
                                            HasEmissive        = true,
                                            HasEmissiveTexture = true
                                        },
                                        MatType   = MaterialType.Standard,
                                        MatValues =
                                        {
                                            AlbedoColor     = float4.One * 0.25f,
                                            AlbedoMix       =                 1f,
                                            AlbedoTexture   = "albedoTex.jpg",
                                            EmissiveColor   = new float4(0, 1, 1, 1), // TODO: Implement in ShaderShards
                                            EmissiveMix     =               0.5f,     // TODO: Implement in ShaderShards
                                            EmissiveTexture = "emissiveTex.jpg"       // TODO: Implement in ShaderShards
                                        }
                                    }),
                                    icosphereWithTangents
                                }
                            }
                        }
                    }
                }
            };

            _guiDescRenderer = new SceneRendererForward(guiDescriptionScene);
            _renderer        = new SceneRendererDeferred(_scene);
        }
        SceneContainer CreateScene()
        {
            // Initialize transform components that need to be changed inside "RenderAFrame"
            _baseTransform = new Transform
            {
                Rotation    = new float3(0, 0, 0),
                Scale       = new float3(1, 1, 1),
                Translation = new float3(0, 0, 0)
            };

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

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

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

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

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

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

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

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

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

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

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

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

                                                                    ShaderCodeBuilder.MakeShaderEffect(new float4(0, 1, 1, 1)),
                                                                    SimpleMeshes.CreateCuboid(new float3(1, 2, 1))
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Пример #16
0
        //Build a scene graph consisting out of a canvas and other UI elements.
        private SceneContainer CreateNineSliceScene()
        {
            var vsTex       = AssetStorage.Get <string>("texture.vert");
            var psTex       = AssetStorage.Get <string>("texture.frag");
            var vsNineSlice = AssetStorage.Get <string>("nineSlice.vert");
            var psNineSlice = AssetStorage.Get <string>("nineSliceTile.frag");

            var canvasScaleFactor = _initWindowWidth / _canvasWidth;

            float borderScaleFactor = 1;

            if (_canvasRenderMode == CanvasRenderMode.Screen)
            {
                borderScaleFactor = canvasScaleFactor;
            }

            var fps = new TextNode(
                "FPS: 0.00",
                "FPSText",
                vsTex,
                psTex,
                UIElementPosition.GetAnchors(AnchorPos.DownDownRight),
                new MinMaxRect
            {
                Min = new float2(-2, 0),
                Max = new float2(0, 1)
            },
                _fontMap,
                ColorUint.Tofloat4(ColorUint.White),
                HorizontalTextAlignment.Center,
                VerticalTextAlignment.Center
                );

            _fpsText = fps.GetComponentsInChildren <GUIText>().FirstOrDefault();

            var text = new TextNode(
                "The five\n" +
                "boxing wizards\n" +
                "jump\n" +
                "quickly.",
                "ButtonText",
                vsTex,
                psTex,
                UIElementPosition.GetAnchors(AnchorPos.StretchAll),
                new MinMaxRect
            {
                Min = new float2(1f, 0.5f),
                Max = new float2(-1f, -0.5f)
            },
                _fontMap,
                ColorUint.Tofloat4(ColorUint.Greenery),
                HorizontalTextAlignment.Center,
                VerticalTextAlignment.Center);

            var catTextureNode = new TextureNode(
                "Cat",
                AssetStorage.Get <string>("nineSlice.vert"),
                AssetStorage.Get <string>("nineSliceTile.frag"),
                //Set the albedo texture you want to use.
                new Texture(AssetStorage.Get <ImageData>("Kitti.jpg")),

                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal),//Anchor is in the lower left corner of the parent. Anchor is in the lower right corner of the parent.

                //Define Offset and therefor the size of the element.
                //Min: distance to this elements Min anchor.
                //Max: distance to this elements Max anchor.
                UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(_initCanvasWidth / 2 - 2.5f, 0), _initCanvasHeight, _initCanvasWidth, new float2(5, 4)),
                //Choose in how many tiles you want to split the inner part of the texture. Use float2.one if you want it stretched.
                new float2(5, 5),
                //Tell how many percent of the texture, seen from the edges, belongs to the border. Order: left, right, top, bottom.
                new float4(0.11f, 0.11f, 0.06f, 0.17f),
                4, 4, 4, 4,
                borderScaleFactor

                )
            {
                Children = new ChildList()
                {
                    text
                }
            };

            catTextureNode.Components.Add(_btnCat);

            var bltTextureNode = new TextureNode(
                "Blt",
                vsTex,
                psTex,
                //Set the albedo texture you want to use.
                _bltDestinationTex,
                //_fontMap.Image,
                //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent.
                //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled.
                UIElementPosition.GetAnchors(AnchorPos.DownDownLeft),//Anchor is in the lower left corner of the parent. Anchor is in the lower right corner of the parent.

                //Define Offset and therefor the size of the element.
                //Min: distance to this elements Min anchor.
                //Max: distance to this elements Max anchor.
                UIElementPosition.CalcOffsets(AnchorPos.DownDownLeft, new float2(0, 0), _initCanvasHeight, _initCanvasWidth, new float2(4, 4)));

            var quagganTextureNode1 = new TextureNode(
                "Quaggan1",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(2.5f, 0), 3, 6, new float2(1, 1)),

                new float2(1, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var nineSliceTextureNode = new TextureNode(
                "testImage",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("9SliceSprites-4.png")),
                //In this setup the element will stay in the upper right corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TopTopRight),//Anchor is in the upper right corner.//Anchor is in the upper right corner.

                UIElementPosition.CalcOffsets(AnchorPos.TopTopRight, new float2(_initCanvasWidth - 6, _initCanvasHeight - 3), _initCanvasHeight, _initCanvasWidth, new float2(6, 3)),

                new float2(2, 3),
                new float4(0.1f, 0.1f, 0.1f, 0.1f),
                2.5f, 2.5f, 2.5f, 2.5f,
                borderScaleFactor
                )
            {
                Children = new ChildList()
                {
                    quagganTextureNode1, text
                }
            };

            var quagganTextureNode = new TextureNode(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, _initCanvasHeight - 1), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var quagganTextureNode2 = new TextureNode(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), //Anchor is in the lower right corner.Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, _initCanvasHeight - 3), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var quagganTextureNode3 = new TextureNode(
                "Quaggan",
                vsNineSlice,
                psNineSlice,
                new Texture(AssetStorage.Get <ImageData>("testTex.jpg")),
                //In this setup the element will stay in the upper left corner of the parent and will not be stretched at all.
                UIElementPosition.GetAnchors(AnchorPos.StretchVertical), //Anchor is in the lower right corner. Anchor is in the lower left corner.
                UIElementPosition.CalcOffsets(AnchorPos.StretchVertical, new float2(0, _initCanvasHeight - 5), _initCanvasHeight, _initCanvasWidth, new float2(6, 1)),
                new float2(5, 1),
                new float4(0.1f, 0.1f, 0.1f, 0.09f),
                1, 1, 1, 1,
                borderScaleFactor
                );

            var canvas = new CanvasNode(
                "Canvas",
                _canvasRenderMode,
                new MinMaxRect
            {
                Min = new float2(-_canvasWidth / 2, -_canvasHeight / 2f),
                Max = new float2(_canvasWidth / 2, _canvasHeight / 2f)
            })
            {
                Children = new ChildList()
                {
                    //Simple Texture Node, contains a Blt"ed" texture.
                    bltTextureNode,
                    //Add nine sliced textures to canvas
                    catTextureNode,
                    quagganTextureNode,
                    nineSliceTextureNode,
                    quagganTextureNode2,
                    quagganTextureNode3,
                    fps
                }
            };

            var canvasMat = ShaderCodeBuilder.MakeShaderEffect(new float4(1, 0, 0, 1));

            canvas.AddComponent(canvasMat);
            canvas.AddComponent(new Plane());
            canvas.AddComponent(_btnCanvas);

            return(new SceneContainer
            {
                Children = new List <SceneNode>
                {
                    //Add canvas.

                    new SceneNode()
                    {
                        Components = new List <SceneComponent>()
                        {
                            new Transform()
                            {
                                Translation = new float3(0, 0, 0)
                            }
                        },
                        Children = new ChildList()
                        {
                            canvas
                        }
                    },
                }
            });
        }
Пример #17
0
        public override void Init()
        {
            // Create a scene with a cube
            // The three components: one XForm, one Material and the Mesh
            _cubeTransform = new Transform {
                Scale = new float3(1, 1, 1), Translation = new float3(0, 0, 0), Rotation = new float3(0, 0, 0)
            };
            var cubeShader = ShaderCodeBuilder.MakeShaderEffect(new float4(50 / 255f, 100 / 255f, 180 / 255f, 1));
            var cubeMesh   = SimpleMeshes.CreateCuboid(new float3(10, 10, 10));

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

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

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

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

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

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

            var cubeNode2 = new SceneNode();

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

            var cubeNode3 = new SceneNode();

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

            var cubeNode4 = new SceneNode();

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

            var cubeNode5 = new SceneNode();

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

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Пример #18
0
        // Init is called on startup.
        public override void Init()
        {
            VSync = false;

            _mainCam.Viewport        = new float4(0, 0, 100, 100);
            _mainCam.BackgroundColor = new float4(0f, 0f, 0f, 1);
            _mainCam.Layer           = -1;

            _sndCam.Viewport        = new float4(60, 60, 40, 40);
            _sndCam.BackgroundColor = new float4(0.5f, 0.5f, 0.5f, 1);
            _sndCam.Layer           = 10;

            _guiCam.ClearColor       = false;
            _guiCam.ClearDepth       = false;
            _guiCam.FrustumCullingOn = false;


            _mainCamTransform = _guiCamTransform = new Transform()
            {
                Rotation    = float3.Zero,
                Translation = new float3(0, 1, -30),
                Scale       = new float3(1, 1, 1)
            };

            _gui = CreateGui();
            // Create the interaction handler
            _sih = new SceneInteractionHandler(_gui);

            _frustum = new WireframeCube();
            var frustumNode = new SceneNode()
            {
                Name       = "Frustum",
                Components = new List <SceneComponent>()
                {
                    new Transform(),
                    ShaderCodeBuilder.MakeShaderEffect(new float4(1, 1, 0, 1), float4.One, 0),
                    _frustum
                }
            };

            var cam = new SceneNode()
            {
                Name       = "MainCam",
                Components = new List <SceneComponent>()
                {
                    _mainCamTransform,
                    _mainCam,
                    ShaderCodeBuilder.MakeShaderEffect(new float4(1, 0, 0, 1), float4.One, 10),
                    new Cube(),
                },
                Children = new ChildList()
                {
                    new SceneNode()
                    {
                        Components = new List <SceneComponent>()
                        {
                            new Transform()
                            {
                                Scale       = new float3(0.5f, 0.5f, 1f),
                                Translation = new float3(0, 0, 1f)
                            },
                            new Cube()
                        }
                    }
                }
            };

            _sndCamTransform = new Transform()
            {
                Rotation    = new float3(M.PiOver6, 0, 0),//float3.Zero,
                Translation = new float3(10, 40, -60),
                Scale       = float3.One
            };

            var cam1 = new SceneNode()
            {
                Name       = "SecondCam",
                Components = new List <SceneComponent>()
                {
                    _sndCamTransform,
                    _sndCam,
                }
            };

            _anlgeHorznd   = _sndCamTransform.Rotation.y;
            _angleVertSnd  = _sndCamTransform.Rotation.x;
            _anlgeHorzMain = _mainCamTransform.Rotation.y;
            _angleVertMain = _mainCamTransform.Rotation.x;

            // Load the rocket model
            _rocketScene = AssetStorage.Get <SceneContainer>("rnd.fus");
            //_rocketScene = Rocket.Build();


            _cubeOneTransform = _rocketScene.Children[0].GetComponent <Transform>();
            //_cubeOneTransform.Rotate(new float3(0, M.PiOver4, 0));

            _rocketScene.Children.Add(cam);
            _rocketScene.Children.Add(cam1);
            _rocketScene.Children.Add(frustumNode);

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_rocketScene);
            _guiRenderer   = new SceneRendererForward(_gui);

            _rotAxis  = float3.UnitY * float4x4.CreateRotationYZ(new float2(M.PiOver4, M.PiOver4));
            _rotPivot = _rocketScene.Children[1].GetComponent <Transform>().Translation;
        }
Пример #19
0
 private SceneContainer CreateScene()
 {
     return(new SceneContainer
     {
         Header = new SceneHeader
         {
             CreationDate = "April 2017",
             CreatedBy = "*****@*****.**",
             Generator = "Handcoded with pride",
         },
         Children = new List <SceneNode>
         {
             new SceneNode
             {
                 Name = "Base",
                 Components = new List <SceneComponent>
                 {
                     new Transform {
                         Scale = float3.One
                     },
                     ShaderCodeBuilder.MakeShaderEffect(
                         albedoColor: ColorUint.Tofloat4(ColorUint.Red),
                         specularColor: ColorUint.Tofloat4(ColorUint.White),
                         shininess: 4.0f,
                         specularIntensity: 1.0f
                         ),
                     CreateCuboid(new float3(100, 20, 100))
                 },
                 Children = new ChildList
                 {
                     new SceneNode
                     {
                         Name = "Arm01",
                         Components = new List <SceneComponent>
                         {
                             new Transform {
                                 Translation = new float3(0, 60, 0), Scale = float3.One
                             },
                             ShaderCodeBuilder.MakeShaderEffect(
                                 albedoColor: ColorUint.Tofloat4(ColorUint.Green),
                                 specularColor: ColorUint.Tofloat4(ColorUint.White),
                                 shininess: 4.0f,
                                 specularIntensity: 1.0f
                                 ),
                             CreateCuboid(new float3(20, 100, 20))
                         },
                         Children = new ChildList
                         {
                             new SceneNode
                             {
                                 Name = "Arm02Rot",
                                 Components = new List <SceneComponent>
                                 {
                                     new Transform {
                                         Translation = new float3(-20, 40, 0), Rotation = new float3(0.35f, 0, 0), Scale = float3.One
                                     },
                                 },
                                 Children = new ChildList
                                 {
                                     new SceneNode
                                     {
                                         Name = "Arm02",
                                         Components = new List <SceneComponent>
                                         {
                                             new Transform {
                                                 Translation = new float3(0, 40, 0), Scale = float3.One
                                             },
                                             ShaderCodeBuilder.MakeShaderEffect(
                                                 albedoColor: ColorUint.Tofloat4(ColorUint.Yellow),
                                                 specularColor: ColorUint.Tofloat4(ColorUint.White),
                                                 shininess: 4.0f,
                                                 specularIntensity: 1.0f
                                                 ),
                                             CreateCuboid(new float3(20, 100, 20))
                                         },
                                         Children = new ChildList
                                         {
                                             new SceneNode
                                             {
                                                 Name = "Arm03Rot",
                                                 Components = new List <SceneComponent>
                                                 {
                                                     new Transform {
                                                         Translation = new float3(20, 40, 0), Rotation = new float3(0.25f, 0, 0), Scale = float3.One
                                                     },
                                                 },
                                                 Children = new ChildList
                                                 {
                                                     new SceneNode
                                                     {
                                                         Name = "Arm03",
                                                         Components = new List <SceneComponent>
                                                         {
                                                             new Transform {
                                                                 Translation = new float3(0, 40, 0), Scale = float3.One
                                                             },
                                                             ShaderCodeBuilder.MakeShaderEffect(
                                                                 albedoColor: ColorUint.Tofloat4(ColorUint.Blue),
                                                                 specularColor: ColorUint.Tofloat4(ColorUint.White),
                                                                 shininess: 4.0f,
                                                                 specularIntensity: 1.0f
                                                                 ),
                                                             CreateCuboid(new float3(20, 100, 20))
                                                         }
                                                     },
                                                 }
                                             }
                                         }
                                     },
                                 }
                             }
                         }
                     },
                 }
             },
         }
     });
 }
Пример #20
0
        public static SceneContainer SceneShouldGT()
        {
            return(new SceneContainer
            {
                Header = new SceneHeader
                {
                    CreationDate = DateTime.Today.ToString(),
                    Generator = "SerializationTest",
                    CreatedBy = "Fusee Test Code"
                },

                Children = new List <SceneNode>
                {
                    new SceneNode
                    {
                        Name = "Base",
                        Components = new List <SceneComponent>
                        {
                            new CanvasTransform(Engine.Core.Scene.CanvasRenderMode.Screen)
                            {
                                Name = "CanvasTransform",
                                Scale = float2.One * 2,
                                ScreenSpaceSize = new MinMaxRect
                                {
                                    Max = float2.One * 22,
                                    Min = float2.One * -1
                                },
                                Size = new MinMaxRect
                                {
                                    Min = float2.One * 22,
                                    Max = float2.One * -1
                                }
                            },
                            new XFormText
                            {
                                Name = "XFormText",
                                Height = 10,
                                HorizontalAlignment = Engine.Core.Scene.HorizontalTextAlignment.Center,
                                VerticalAlignment = Engine.Core.Scene.VerticalTextAlignment.Top,
                                Width = 200
                            },
                            new XForm
                            {
                                Name = "XForm"
                            },
                            new RectTransform
                            {
                                Anchors = new MinMaxRect
                                {
                                    Max = float2.Zero,
                                    Min = float2.One
                                },
                                Name = "Rect",
                                Offsets = new MinMaxRect
                                {
                                    Max = float2.Zero,
                                    Min = float2.One
                                }
                            },
                            new Transform {
                                Scale = new float3(100, 20, 100)
                            },
                            new Bone
                            {
                                Name = "MyBone"
                            },
                            new Weight
                            {
                                BindingMatrices = new List <float4x4>(),
                                Joints = new List <SceneNode>(),
                                Name = "MyWeight",
                                WeightMap = new List <Engine.Core.Scene.VertexWeightList>
                                {
                                    new Engine.Core.Scene.VertexWeightList
                                    {
                                        VertexWeights = new List <Engine.Core.Scene.VertexWeight>
                                        {
                                            new Engine.Core.Scene.VertexWeight
                                            {
                                                Weight = 20,
                                                JointIndex = 0
                                            },
                                            new Engine.Core.Scene.VertexWeight
                                            {
                                                Weight = 30,
                                                JointIndex = 1
                                            },
                                        }
                                    }
                                }
                            },
                            ShaderCodeBuilder.MakeShaderEffectProto(
                                albedoColor: ColorUint.Tofloat4(ColorUint.Red),
                                specularColor: ColorUint.Tofloat4(ColorUint.White),
                                shininess: 4.0f,
                                specularIntensity: 1.0f),

                            new Light
                            {
                                Name = "MyLight",
                                Bias = 0,
                                MaxDistance = 100,
                                Active = true,
                                Color = float4.One,
                                InnerConeAngle = 20,
                                IsCastingShadows = true,
                                OuterConeAngle = 20,
                                Strength = 100,
                                Type = LightType.Point
                            },
                            new Octant
                            {
                                Center = double3.One,
                                Guid = new Guid(1, 2, 3, new byte[] { 4, 4, 4, 4, 4, 4, 4, 4 }),
                                IsLeaf = false,
                                Level = 10,
                                Name = "MyOctant",
                                NumberOfPointsInNode = 2,
                                PosInHierarchyTex = 0,
                                PosInParent = 5,
                                Size = 20,
                                VisibleChildIndices = 1,
                                WasLoaded = true
                            },
                            new Camera(Engine.Core.Scene.ProjectionMethod.Orthographic, 0, 500, 2000),
                            ShaderCodeBuilder.MakeShaderEffectFromShaderEffectPropsProto(new Engine.Core.ShaderShards.ShaderEffectProps
                            {
                                MatValues =
                                {
                                    FresnelReflectance = 100,
                                    DiffuseFraction    = 200,
                                    RoughnessValue     = 1
                                }
                            }),
                            new Cube()
                        },
                        Children = new ChildList
                        {
                            new SceneNode
                            {
                                Name = "Arm01",
                                Components = new List <SceneComponent>
                                {
                                    new Transform {
                                        Translation = new float3(0, 60, 0), Scale = new float3(20, 100, 20)
                                    },
                                    ShaderCodeBuilder.MakeShaderEffectProto(
                                        albedoColor: ColorUint.Tofloat4(ColorUint.Green),
                                        specularColor: ColorUint.Tofloat4(ColorUint.White),
                                        specularIntensity: 1.0f,
                                        shininess: 4.0f),
                                    new Cube()
                                },
                                Children = new ChildList
                                {
                                    new SceneNode
                                    {
                                        Name = "Arm02Rot",
                                        Components = new List <SceneComponent>
                                        {
                                            new Bone
                                            {
                                                Name = "MyBone2"
                                            },
                                            new Transform {
                                                Translation = new float3(-20, 40, 0), Rotation = new float3(0.35f, 0, 0), Scale = float3.One
                                            },
                                        },
                                        Children = new ChildList
                                        {
                                            new SceneNode
                                            {
                                                Name = "Arm02",
                                                Components = new List <SceneComponent>
                                                {
                                                    new Transform {
                                                        Translation = new float3(0, 40, 0), Scale = new float3(20, 100, 20)
                                                    },
                                                    ShaderCodeBuilder.MakeShaderEffectProto(
                                                        albedoColor: ColorUint.Tofloat4(ColorUint.Yellow),
                                                        specularColor: ColorUint.Tofloat4(ColorUint.White),
                                                        specularIntensity: 1.0f,
                                                        shininess: 4.0f),
                                                    new Cube()
                                                },
                                                Children = new ChildList
                                                {
                                                    new SceneNode
                                                    {
                                                        Name = "Arm03Rot",
                                                        Components = new List <SceneComponent>
                                                        {
                                                            new Transform {
                                                                Translation = new float3(20, 40, 0), Rotation = new float3(0.25f, 0, 0), Scale = float3.One
                                                            },
                                                        },
                                                        Children = new ChildList
                                                        {
                                                            new SceneNode
                                                            {
                                                                Name = "Arm03",
                                                                Components = new List <SceneComponent>
                                                                {
                                                                    new Transform {
                                                                        Translation = new float3(0, 40, 0), Scale = new float3(20, 100, 20)
                                                                    },
                                                                    ShaderCodeBuilder.MakeShaderEffectProto(
                                                                        albedoColor: ColorUint.Tofloat4(ColorUint.Blue),
                                                                        specularColor: ColorUint.Tofloat4(ColorUint.White),
                                                                        specularIntensity: 1.0f,
                                                                        shininess: 4.0f),
                                                                    new Cube()
                                                                }
                                                            },
                                                        }
                                                    }
                                                }
                                            },
                                        }
                                    }
                                }
                            },
                        }
                    },
                }
            });
        }