示例#1
0
        public void Min_Is0()
        {
            var rect = MinMaxRect.FromCenterSize(new float2(1, 1), new float2(2, 2));

            var actual = rect.Min;

            Assert.Equal(new float2(0, 0), actual);
        }
示例#2
0
 /// <summary>
 /// Creates a SceneNodeContainer with the proper components and children for rendering a nine sliced texture.
 /// </summary>
 /// <param name="name">Name of the SceneNodeContainer.</param>
 /// <param name="vs">The vertex shader you want to use.</param>
 /// <param name="ps">The pixel shader you want to use.</param>
 /// /<param name="tex">Diffuse texture.</param>
 /// <param name="anchors">Anchors for the mesh. Influences the scaling of the object if the enclosing canvas is resized.</param>
 /// <param name="offsets">Offsets for the mesh. Defines the position of the object relative to its enclosing UI element.</param>
 /// <returns></returns>
 public TextureNodeContainer(string name, string vs, string ps, Texture tex, MinMaxRect anchors,
                             MinMaxRect offsets)
 {
     Name       = name;
     Components = new List <SceneComponentContainer>
     {
         new RectTransformComponent
         {
             Name    = name + "_RectTransform",
             Anchors = anchors,
             Offsets = offsets
         },
         new XFormComponent
         {
             Name = name + "_XForm",
         },
         new ShaderEffectComponent
         {
             Effect = new ShaderEffect(new[]
             {
                 new EffectPassDeclaration
                 {
                     VS       = vs,
                     PS       = ps,
                     StateSet = new RenderStateSet
                     {
                         AlphaBlendEnable = true,
                         SourceBlend      = Blend.SourceAlpha,
                         DestinationBlend = Blend.InverseSourceAlpha,
                         BlendOperation   = BlendOperation.Add,
                         ZEnable          = false
                     }
                 }
             },
                                       new[]
             {
                 new EffectParameterDeclaration
                 {
                     Name  = "DiffuseTexture",
                     Value = tex
                 },
                 new EffectParameterDeclaration {
                     Name = "DiffuseColor", Value = float4.One
                 },
                 new EffectParameterDeclaration {
                     Name = "DiffuseMix", Value = 1f
                 },
                 new EffectParameterDeclaration {
                     Name = "FUSEE_ITMV", Value = float4x4.Identity
                 },
                 new EffectParameterDeclaration {
                     Name = "FUSEE_MVP", Value = float4x4.Identity
                 },
             })
         },
         new Plane()
     };
 }
示例#3
0
        void DrawSelector(Transform selectedObject)
        {
            MinMaxRect    farthestCorners = SelectionIndicatorFactory.GetFarthestCorners(selectedObject.transform, mouseController);
            RectTransform rt = GetComponent <RectTransform>();

            rt.position  = new Vector2(farthestCorners.minX, farthestCorners.minY);
            rt.sizeDelta = new Vector2(farthestCorners.maxX - farthestCorners.minX, farthestCorners.maxY - farthestCorners.minY);
            GetComponentInChildren <Text>().text = selectedObject.GetComponent <InteractableObject>().objectName;
        }
示例#4
0
        public void ToString_NoCulture()
        {
            var rect = new MinMaxRect()
            {
                Min = new float2(1, 1), Max = new float2(2.2f, 3.3f)
            };

            Assert.NotNull(rect.ToString());
        }
示例#5
0
        public void ToString_CultureDE()
        {
            var rect = new MinMaxRect()
            {
                Min = new float2(1, 1), Max = new float2(2.2f, 3.3f)
            };

            var actual = rect.ToString(new CultureInfo("de-DE"));

            Assert.Equal("Min: (1; 1) Max: (2,2; 3,3)", actual);
        }
示例#6
0
        public void ToString_InvariantCulture()
        {
            var rect = new MinMaxRect()
            {
                Min = new float2(1, 1), Max = new float2(2.2f, 3.3f)
            };

            var actual = rect.ToString(CultureInfo.InvariantCulture);

            Assert.Equal("Min: (1, 1) Max: (2.2, 3.3)", actual);
        }
示例#7
0
 /// <summary>
 /// Creates a SceneNodeContainer with the proper components and children for rendering a canvas.
 /// </summary>
 /// <param name="name">The name of the canvas.</param>
 /// <param name="canvasRenderMode">Choose in which mode you want to render this canvas.</param>
 /// <param name="size">The size of the canvas.</param>
 /// By default Scale in SCREEN mode is set to 0.1.</param>
 public CanvasNodeContainer(string name, CanvasRenderMode canvasRenderMode, MinMaxRect size)
 {
     Name       = name;
     Components = new List <SceneComponentContainer>
     {
         new CanvasTransformComponent(canvasRenderMode)
         {
             Name = name + "_CanvasTransform",
             Size = size
         },
         new XFormComponent
         {
             Name = name + "_Canvas_XForm"
         }
     };
 }
示例#8
0
    public bool IsInRect(MinMaxRect minMaxRect)
    {
        float posX = Input.GetInputPosition().x;
        float posY = Input.GetInputPosition().y;

        var displayInfo = GetSingleton <DisplayInfo>();

        float targetWidth  = displayInfo.width;
        float targetHeight = displayInfo.height;

        float playableCanvasWidth  = displayInfo.width;
        float playableCanvasHeight = displayInfo.height;

        float targetRatio  = 1920.0f / 1080.0f; // internal aspect ratio
        float currentRatio = (float)displayInfo.width / displayInfo.height;

        float ratioDifference = targetRatio / currentRatio;

        if (targetRatio < currentRatio)
        {
            playableCanvasWidth = targetWidth * ratioDifference;
            float boundingBoxWidth = (targetWidth - playableCanvasWidth) / 2;

            posX -= boundingBoxWidth;
        }
        else
        {
            playableCanvasHeight = targetHeight / ratioDifference;
            float boundingBoxHeight = (targetHeight - playableCanvasHeight) / 2;

            posY -= boundingBoxHeight;
        }

        float percentualPosX = posX / playableCanvasWidth;
        float percentualPosY = posY / playableCanvasHeight;

#if !UNITY_DOTSPLAYER
        percentualPosX = UnityEngine.Input.mousePosition.x / UnityEngine.Screen.width;
        percentualPosY = UnityEngine.Input.mousePosition.y / UnityEngine.Screen.height;
#endif

        return
            ((minMaxRect.MinX <= percentualPosX) &&
             (percentualPosX <= minMaxRect.MaxX) &&
             (minMaxRect.MinY <= percentualPosY) &&
             (percentualPosY <= minMaxRect.MaxY));
    }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextNodeContainer"/> class.
        /// </summary>
        /// <param name="text">The text you want to disply.</param>
        /// <param name="name">The name of the SceneNodeContainer.</param>
        /// <param name="vs">The vertex shader you want to use..</param>
        /// <param name="ps">The pixel shader you want to use.</param>
        /// <param name="anchors">Anchors for the mesh. Influences the scaling of the object if the enclosing canvas is resized.</param>
        /// <param name="offsets">The offsets.</param>
        /// <param name="fontMap">Offsets for the mesh. Defines the position of the object relative to its enclosing UI element.</param>
        /// <param name="color">The color.</param>
        /// <param name="textScaleFactor">By default a text has the with of 1 fusee unit. Set this to adapt the text size.</param>
        public TextNodeContainer(string text, string name, string vs, string ps, MinMaxRect anchors, MinMaxRect offsets,
                                 FontMap fontMap, float4 color, float textScaleFactor = 1)
        {
            Name       = name;
            Components = new List <SceneComponentContainer>
            {
                new RectTransformComponent
                {
                    Name    = name + "_RectTransform",
                    Anchors = anchors,
                    Offsets = offsets
                },
                new XFormComponent
                {
                    Name = name + "_XForm",
                }
            };

            Children = new ChildList()
            {
                new SceneNodeContainer()
                {
                    Components = new List <SceneComponentContainer>()
                    {
                        new XFormTextComponent(textScaleFactor),
                        new ShaderEffectComponent
                        {
                            Effect = new ShaderEffect(new[]
                            {
                                new EffectPassDeclaration
                                {
                                    VS       = vs,
                                    PS       = ps,
                                    StateSet = new RenderStateSet
                                    {
                                        AlphaBlendEnable = true,
                                        SourceBlend      = Blend.SourceAlpha,
                                        DestinationBlend = Blend.InverseSourceAlpha,
                                        BlendOperation   = BlendOperation.Add,
                                        ZEnable          = false
                                    }
                                }
                            },
                                                      new[]
                            {
                                new EffectParameterDeclaration
                                {
                                    Name  = "DiffuseTexture",
                                    Value = new Texture(fontMap.Image)
                                },
                                new EffectParameterDeclaration
                                {
                                    Name = "DiffuseColor", Value = color
                                },
                                new EffectParameterDeclaration {
                                    Name = "DiffuseMix", Value = 0.0f
                                },
                                new EffectParameterDeclaration {
                                    Name = "FUSEE_ITMV", Value = float4x4.Identity
                                },
                                new EffectParameterDeclaration {
                                    Name = "FUSEE_MVP", Value = float4x4.Identity
                                },
                            })
                        },
                        new GUIText(fontMap, text)
                        {
                            Name = name + "textMesh"
                        }
                    }
                }
            };
        }
示例#10
0
        /// <summary>
        /// Creates a SceneNodeContainer with the proper components and children for rendering a nine sliced texture.
        /// By default the border thickness is calculated relative to a unit plane. For a thicker border set the border thickness to the desired value, 2 means a twice as thick border.
        /// </summary>
        /// <param name="name">Name of the SceneNodeContainer.</param>
        /// <param name="vs">The vertex shader you want to use.</param>
        /// <param name="ps">The pixel shader you want to use.</param>
        /// /<param name="tex">Diffuse texture.</param>
        /// <param name="anchors">Anchors for the mesh. Influences the scaling of the object if the enclosing canvas is resized.</param>
        /// <param name="offsets">Offsets for the mesh. Defines the position of the object relative to its enclosing UI element.</param>
        /// <param name="tiles">Defines the tiling of the inner rectangle of the texture. Use float2.one if you do not desire tiling.</param>
        /// <param name="borders">Defines the nine tiles of the texture. Order: left, right, top, bottom. Value is measured in percent from the respective edge of texture.</param>
        /// <param name="borderThicknessBottom">Border thickness for the bottom border.</param>
        /// <param name="borderScaleFactor">Default value is 1. Set this to scale the border thickness if you use canvas render mode SCREEN.</param>
        /// <param name="borderThicknessLeft">Border thickness for the left border.</param>
        /// <param name="borderThicknessRight">Border thickness for the right border.</param>
        /// <param name="borderThicknessTop">Border thickness for the top border.</param>
        /// <returns></returns>
        public TextureNodeContainer(string name, string vs, string ps, Texture tex, MinMaxRect anchors,
                                    MinMaxRect offsets, float2 tiles, float4 borders, float borderThicknessLeft = 1, float borderThicknessRight = 1, float borderThicknessTop = 1, float borderThicknessBottom = 1, float borderScaleFactor = 1)
        {
            var borderThickness = new float4(borderThicknessLeft, borderThicknessRight, borderThicknessTop,
                                             borderThicknessBottom);

            Name       = name;
            Components = new List <SceneComponentContainer>
            {
                new RectTransformComponent
                {
                    Name    = name + "_RectTransform",
                    Anchors = anchors,
                    Offsets = offsets
                },
                new XFormComponent
                {
                    Name = name + "_XForm",
                },
                new ShaderEffectComponent
                {
                    Effect = new ShaderEffect(new[]
                    {
                        new EffectPassDeclaration
                        {
                            VS       = vs,
                            PS       = ps,
                            StateSet = new RenderStateSet
                            {
                                AlphaBlendEnable = true,
                                SourceBlend      = Blend.SourceAlpha,
                                DestinationBlend = Blend.InverseSourceAlpha,
                                BlendOperation   = BlendOperation.Add,
                                ZEnable          = false
                            }
                        }
                    },
                                              new[]
                    {
                        new EffectParameterDeclaration
                        {
                            Name  = "DiffuseTexture",
                            Value = tex
                        },
                        new EffectParameterDeclaration {
                            Name = "DiffuseColor", Value = float4.One
                        },
                        new EffectParameterDeclaration {
                            Name = "Tile", Value = tiles
                        },
                        new EffectParameterDeclaration {
                            Name = "DiffuseMix", Value = 1f
                        },
                        new EffectParameterDeclaration
                        {
                            Name  = "borders",
                            Value = borders
                        },
                        new EffectParameterDeclaration {
                            Name = "borderThickness", Value = borderThickness * borderScaleFactor
                        },
                        new EffectParameterDeclaration {
                            Name = "FUSEE_ITMV", Value = float4x4.Identity
                        },
                        new EffectParameterDeclaration {
                            Name = "FUSEE_M", Value = float4x4.Identity
                        },
                        new EffectParameterDeclaration {
                            Name = "FUSEE_V", Value = float4x4.Identity
                        },
                        new EffectParameterDeclaration {
                            Name = "FUSEE_P", Value = float4x4.Identity
                        }
                    })
                },
                new NineSlicePlane()
            };
        }
示例#11
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);
        }
示例#12
0
 public CanvasTransformComponent(CanvasRenderMode canvasRenderMode)
 {
     CanvasRenderMode = canvasRenderMode;
     Size             = ScreenSpaceSize;
 }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextNode"/> class.
        /// </summary>
        /// <param name="text">The text you want to display.</param>
        /// <param name="name">The name of the SceneNode.</param>
        /// <param name="vs">The vertex shader you want to use..</param>
        /// <param name="ps">The pixel shader you want to use.</param>
        /// <param name="anchors">Anchors for the mesh. Influences the scaling of the object if the enclosing canvas is resized.</param>
        /// <param name="offsets">The offsets.</param>
        /// <param name="fontMap">Offsets for the mesh. Defines the position of the object relative to its enclosing UI element.</param>
        /// <param name="color">The color.</param>
        /// <param name="horizontalAlignment">The <see cref="HorizontalTextAlignment"/> defines the text's placement along the enclosing <see cref="MinMaxRect"/>'s x-axis.</param>
        /// <param name="verticalTextAlignment">The <see cref="HorizontalTextAlignment"/> defines the text's placement along the enclosing <see cref="MinMaxRect"/>'s y-axis.</param>
        public TextNode(string text, string name, string vs, string ps, MinMaxRect anchors, MinMaxRect offsets,
                        FontMap fontMap, float4 color, HorizontalTextAlignment horizontalAlignment = HorizontalTextAlignment.Left, VerticalTextAlignment verticalTextAlignment = VerticalTextAlignment.Top)
        {
            var textMesh = new GUIText(fontMap, text, horizontalAlignment)
            {
                Name = name + "textMesh"
            };

            var xFormText = new XFormText
            {
                Width  = textMesh.Width,
                Height = textMesh.Height,
                HorizontalAlignment = textMesh.HorizontalAlignment,
                VerticalAlignment   = verticalTextAlignment
            };

            Name       = name;
            Components = new List <SceneComponent>
            {
                new RectTransform
                {
                    Name    = name + "_RectTransform",
                    Anchors = anchors,
                    Offsets = offsets
                },
                new XForm
                {
                    Name = name + "_XForm",
                }
            };

            Children = new ChildList()
            {
                new SceneNode()
                {
                    Components = new List <SceneComponent>()
                    {
                        xFormText,
                        new ShaderEffect(new[]
                        {
                            new EffectPassDeclaration
                            {
                                VS       = vs,
                                PS       = ps,
                                StateSet = new RenderStateSet
                                {
                                    AlphaBlendEnable = true,
                                    SourceBlend      = Blend.SourceAlpha,
                                    DestinationBlend = Blend.InverseSourceAlpha,
                                    BlendOperation   = BlendOperation.Add,
                                    ZEnable          = false
                                }
                            }
                        },
                                         new[]
                        {
                            new EffectParameterDeclaration
                            {
                                Name  = "DiffuseTexture",
                                Value = new Texture(fontMap.Image)
                            },
                            new EffectParameterDeclaration
                            {
                                Name = "DiffuseColor", Value = color
                            },
                            new EffectParameterDeclaration {
                                Name = "DiffuseMix", Value = 0.0f
                            },
                            new EffectParameterDeclaration {
                                Name = "FUSEE_ITMV", Value = float4x4.Identity
                            },
                            new EffectParameterDeclaration {
                                Name = "FUSEE_MVP", Value = float4x4.Identity
                            },
                        }),
                        textMesh
                    }
                }
            };
        }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FusCanvasTransform"/> class.
 /// </summary>
 /// <param name="canvasRenderMode">The canvas render mode. Is the UI on this canvas placed in the 3D world or overlaid onto the 2D screen.</param>
 public FusCanvasTransform(CanvasRenderMode canvasRenderMode)
 {
     CanvasRenderMode = canvasRenderMode;
     Size             = ScreenSpaceSize;
 }