/// <summary>
 /// If rendered with FXAA we'll need an additional (final) pass, that takes the lighted scene, rendered to a texture, as input.
 /// </summary>
 /// <param name="srcTex">RenderTarget, that contains a single texture in the Albedo/Specular channel, that contains the lighted scene.</param>
 /// <param name="screenParams">The width and height of the screen.</param>
 // see: http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
 // http://blog.simonrodriguez.fr/articles/30-07-2016_implementing_fxaa.html
 public static ShaderEffect FXAARenderTargetEffect(WritableTexture srcTex, float2 screenParams)
 {
     //TODO: #define constants to uniforms
     return(new ShaderEffect(new[]
     {
         new EffectPassDeclaration
         {
             VS = AssetStorage.Get <string>("Deferred.vert"),
             PS = AssetStorage.Get <string>("FXAA.frag"),
             StateSet = new RenderStateSet
             {
                 AlphaBlendEnable = false,
                 ZEnable = true,
             }
         }
     },
                             new[]
     {
         new EffectParameterDeclaration {
             Name = UniformNameDeclarations.DeferredRenderTextures[(int)RenderTargetTextureTypes.Albedo], Value = srcTex
         },
         new EffectParameterDeclaration {
             Name = UniformNameDeclarations.ScreenParams, Value = screenParams
         },
     }));
 }
        public static bool Transfer(UInt160 from, UInt160 to, BigInteger amount, object data)
        {
            Assert(from.IsValid && to.IsValid, "Invalid From or To Address");
            Assert(amount > 0, "The parameter amount MUST be greater than 0.");
            Assert(Runtime.CheckWitness(from), "No authorization.");
            var me = Runtime.ExecutingScriptHash;

            if (to == me)
            {
                Assert(CheckIsRouter(Runtime.CallingScriptHash), "Not Allowed To Transfer");
            }
            Assert(AssetStorage.Get(from) >= amount, "Insufficient balance.");
            if (from == to)
            {
                return(true);
            }

            AssetStorage.Reduce(from, amount);
            AssetStorage.Increase(to, amount);

            onTransfer(from, to, amount);

            // Validate payable
            if (ContractManagement.GetContract(to) != null)
            {
                Contract.Call(to, "onNEP17Payment", CallFlags.All, new object[] { from, amount, data });
            }
            return(true);
        }
Exemple #3
0
        // Init is called on startup.
        public override void Init()
        {
            // Load the scene file "Cube.fus"
            SceneContainer sc = AssetStorage.Get <SceneContainer>("Cube.fus");

            // Extract the 'First' object of type 'MeshComponent' found in 'sc'`s list of 'Children' without
            // further specifying any search criterion ('c => true' means: any found MeshComponent will do).
            MeshComponent mc = sc.Children.FindComponents <MeshComponent>(c => true).First();

            // Generate a mesh from the MeshComponent's vertices, normals and triangles.
            _mesh = new Mesh
            {
                Vertices  = mc.Vertices,
                Normals   = mc.Normals,
                Triangles = mc.Triangles
            };

            var shader = RC.CreateShader(_vertexShader, _pixelShader);

            RC.SetShader(shader);
            _xformParam = RC.GetShaderParam(shader, "xform");
            _xform      = float4x4.Identity;

            // Set the clear color for the backbuffer
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
Exemple #4
0
        // Init is called on startup.
        public override void Init()

        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).

            RC.ClearColor = new float4(0.7f, 0.9f, 0.5f, 1);



            // Load the drone model
            _droneScene = AssetStorage.Get <SceneContainer>("GroundNoMat.fus");
            var droneBody = _droneScene.Children.FindNodes(node => node.Name == "Body")?.FirstOrDefault();

            _drone = new Drone(droneBody);

            _camera = new Camera();

            //Add resize delegate
            var projComp = _droneScene.Children[0].GetComponent <ProjectionComponent>();

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

            // Wrap a SceneRenderer around the model.

            _sceneRenderer = new SceneRenderer(_droneScene);
            //_guiRenderer = new SceneRenderer(_gui);

            DroneRoot = _droneScene.Children.FindNodes(node => node.Name == "Body")?.FirstOrDefault();
        }
Exemple #5
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the model
            _scene = AssetStorage.Get <SceneContainer>("roboter_arm.fus");

            //Set Transforms for the Axles
            _lowerAxleTransform  = _scene.Children.FindNodes(node => node.Name == "LowerAxle")?.FirstOrDefault()?.GetTransform();
            _middleAxleTransform = _scene.Children.FindNodes(node => node.Name == "MiddleAxle")?.FirstOrDefault()?.GetTransform();
            _upperAxleTransform  = _scene.Children.FindNodes(node => node.Name == "UpperAxle")?.FirstOrDefault()?.GetTransform();

            _footTransform = _scene.Children.FindNodes(node => node.Name == "Foot")?.FirstOrDefault()?.GetTransform();

            _rightPincerTransform   = _scene.Children.FindNodes(node => node.Name == "RightLowerAxle")?.FirstOrDefault()?.GetTransform();
            _leftPincerTransform    = _scene.Children.FindNodes(node => node.Name == "LeftLowerAxle")?.FirstOrDefault()?.GetTransform();
            _rightPincerTransformUp = _scene.Children.FindNodes(node => node.Name == "RightHigherAxle")?.FirstOrDefault()?.GetTransform();
            _leftPincerTransformUp  = _scene.Children.FindNodes(node => node.Name == "LeftHigherAxle")?.FirstOrDefault()?.GetTransform();

            _pointer = _scene.Children.FindNodes(node => node.Name == "Pointer")?.FirstOrDefault()?.GetTransform();

            _virtualPos = new float3(0, 5, 0); //at the position of the upper axle

            _open = false;

            AddResizeDelegate(delegate { _scene.Children[0].GetComponent <ProjectionComponent>().Resize(Width, Height); });

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_scene);
        }
        /// <summary>
        /// [Parallel light only] ShaderEffect that performs the lighting calculation according to the textures from the Geometry Pass. Shadow is calculated with cascaded shadow maps.
        /// </summary>
        /// <param name="srcRenderTarget">The source render target.</param>
        /// <param name="lc">The light component.</param>
        /// <param name="shadowMaps">The cascaded shadow maps.</param>
        /// <param name="clipPlanes">The clip planes of the frustums. Each frustum is associated with one shadow map.</param>
        /// <param name="numberOfCascades">The number of sub-frustums, used for cascaded shadow mapping.</param>
        /// <param name="backgroundColor">Sets the background color. Could be replaced with a texture or other sky color calculations in the future.</param>
        /// <returns></returns>
        public static ShaderEffect DeferredLightingPassEffect(RenderTarget srcRenderTarget, Light lc, WritableTexture[] shadowMaps, float2[] clipPlanes, int numberOfCascades, float4 backgroundColor)
        {
            var effectParams = DeferredLightingEffectParams(srcRenderTarget, backgroundColor);

            effectParams.Add(new EffectParameterDeclaration {
                Name = "LightSpaceMatrices[0]", Value = Array.Empty <float4x4>()
            });
            effectParams.Add(new EffectParameterDeclaration {
                Name = "ShadowMaps[0]", Value = shadowMaps
            });
            effectParams.Add(new EffectParameterDeclaration {
                Name = "ClipPlanes[0]", Value = clipPlanes
            });

            return(new ShaderEffect(new[]
            {
                new EffectPassDeclaration
                {
                    VS = AssetStorage.Get <string>("Deferred.vert"),
                    PS = CreateDeferredLightingPixelShader(lc, true, numberOfCascades),
                    StateSet = new RenderStateSet
                    {
                        AlphaBlendEnable = true,
                        ZEnable = true,
                        BlendOperation = BlendOperation.Add,
                        SourceBlend = Blend.One,
                        DestinationBlend = Blend.One,
                        ZFunc = Compare.LessEqual,
                    }
                }
            },
                                    effectParams.ToArray()));
        }
Exemple #7
0
        // Init is called on startup.
        public override void Init()
        {
            #if GUI_SIMPLE
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            _guiFuseeLink                   = new GUIButton(6, 6, 157, 87);
            _guiFuseeLink.ButtonColor       = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor       = new float4(0, 0.6f, 0.2f, 1);
            _guiFuseeLink.BorderWidth       = 0;
            _guiFuseeLink.OnGUIButtonDown  += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;
            _guiFuseeLink.OnGUIButtonLeave += _guiFuseeLink_OnGUIButtonLeave;
            _guiHandler.Add(_guiFuseeLink);
            _guiFuseeLogo = new GUIImage(AssetStorage.Get <ImageData>("FuseeLogo150.png"), 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");
            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 18);
            _guiSubText           = new GUIText("Simple FUSEE Example", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);
            #endif

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

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

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);
        }
Exemple #8
0
        // Init is called on startup.
        public override void Init()
        {
            // Load the scene
            _scene      = AssetStorage.Get <SceneContainer>("WuggyLand.fus");
            _sceneScale = float4x4.CreateScale(0.04f);


            // Instantiate our self-written renderer
            _renderer = new Renderer(RC);

            // Find some transform nodes we want to manipulate in the scene
            _wuggyTransform = _scene.Children.FindNodes(c => c.Name == "Wuggy").First()?.GetTransform();
            _wgyWheelBigR   = _scene.Children.FindNodes(c => c.Name == "WheelBigR").First()?.GetTransform();
            _wgyWheelBigL   = _scene.Children.FindNodes(c => c.Name == "WheelBigL").First()?.GetTransform();
            _wgyWheelSmallR = _scene.Children.FindNodes(c => c.Name == "WheelSmallR").First()?.GetTransform();
            _wgyWheelSmallL = _scene.Children.FindNodes(c => c.Name == "WheelSmallL").First()?.GetTransform();
            _wgyNeckHi      = _scene.Children.FindNodes(c => c.Name == "NeckHi").First()?.GetTransform();

            // Find the trees and store them in a list
            _trees = new List <SceneNodeContainer>();
            _trees.AddRange(_scene.Children.FindNodes(c => c.Name.Contains("Tree")));

            // Set the clear color for the backbuffer
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
Exemple #9
0
        /// <summary>
        /// Create shader program with vertex and fragment shader for this render entity.
        /// </summary>
        protected override ShaderProgram CreateShaderProgram()
        {
            string vertsh = AssetStorage.Get <string>("VertexShaderDP.vert");
            string pixsh  = AssetStorage.Get <string>("PixelShaderDP.frag");

            return(_rc.CreateShader(vertsh, pixsh));
        }
        private ITexture LoadTexture(string path)
        {
            // string texturePath = Path.Combine(_scenePathDirectory, path);
            var image = AssetStorage.Get <ImageData>(path);

            return(_rc.CreateTexture(image));
        }
Exemple #11
0
        // Init is called on startup. 
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intentsity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0.8f, 0.9f, 0.7f, 1);

            _scene = AssetStorage.Get<SceneContainer>("Traktor.fus");

            _bodyTransform = _scene.Children.FindNodes(Node => Node.Name == "Body")?.FirstOrDefault()?.GetTransform();

            _schaufelTransform = _scene.Children.FindNodes(Node => Node.Name == "Schaufel")?.FirstOrDefault()?.GetTransform();

            _oberarmTransform = _scene.Children.FindNodes(Node => Node.Name == "Oberarm")?.FirstOrDefault()?.GetTransform();

            _unterarmTransform = _scene.Children.FindNodes(Node => Node.Name == "Arm")?.FirstOrDefault()?.GetTransform();

            _leftFrontWheelTransform = _scene.Children.FindNodes(Node => Node.Name == "LeftFrontWheel")?.FirstOrDefault()?.GetTransform();
            _rightFrontWheelTransform = _scene.Children.FindNodes(Node => Node.Name == "RightFrontWheel")?.FirstOrDefault()?.GetTransform();
            _leftRearWheelTransform = _scene.Children.FindNodes(Node => Node.Name == "LeftRearWheel")?.FirstOrDefault()?.GetTransform();
            _rightRearWheelTransform = _scene.Children.FindNodes(Node => Node.Name == "RightRearWheel")?.FirstOrDefault()?.GetTransform();
           

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
            _scenePicker = new ScenePicker(_scene);
        }
Exemple #12
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the model - Monkey.fus for flat shading, MonkeySmooth.fus for smooth shading
            _rocketScene = AssetStorage.Get <SceneContainer>("terrain.fus");

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);
            _scenePicker   = new ScenePicker(_rocketScene);

            _LookAtDefaultPosition   = float3.Zero;
            _LookFromDefaultPosition = new float3(0, 1, -4);
            _LookUpDefault           = float3.UnitY;

            _LookAtPositionLerpFrom   = _LookAtDefaultPosition;
            _LookAtPositionLerpTo     = _LookAtDefaultPosition;
            _LookFromPositionLerpFrom = _LookFromDefaultPosition;
            _LookFromPositionLerpTo   = _LookFromDefaultPosition;

            _LerpTimer = 0;
            _LerpSpeed = 3;

            _DistanceFactor = 1.5f;
        }
 /// <summary>
 /// ShaderEffect that renders the depth map from a lights point of view - this depth map is used as a shadow map.
 /// </summary>
 /// <returns></returns>
 public static ShaderEffect ShadowMapEffect()
 {
     return(new ShaderEffect(new[]
     {
         new EffectPassDeclaration
         {
             VS = AssetStorage.Get <string>("ShadowMap.vert"),
             PS = AssetStorage.Get <string>("ShadowMap.frag"),
             StateSet = new RenderStateSet
             {
                 AlphaBlendEnable = false,
                 ZEnable = true,
                 CullMode = Cull.Clockwise,
                 ZFunc = Compare.LessEqual,
             }
         }
     },
                             new[]
     {
         new EffectParameterDeclaration {
             Name = UniformNameDeclarations.Model, Value = float4x4.Identity
         },
         new EffectParameterDeclaration {
             Name = UniformNameDeclarations.LightSpaceMatrix, Value = float4x4.Identity
         },
     }));
 }
Exemple #14
0
 private void LoadTextures(String[] names)
 {
     foreach (var name in names)
     {
         textures.Add(name, RC.CreateTexture(AssetStorage.Get <ImageData>(name)));
     }
 }
        // Init is called on startup.
        public override void Init()
        {
            RC.ClearColor = new float4(0.8f, 0.9f, 0.7f, 1);

            // _scene = CreateScene();
            _scene = AssetStorage.Get <SceneContainer>("Excavator_new.fus");

            //Search children of _scene and find the nodes with the exact name. Then get the transform component of each and give the value to the variable.
            _firstExcavatorArmTransform = _scene.Children.FindNodes(node => node.Name == "FirstExcavatorArm")?.FirstOrDefault()?.GetTransform(); // or GetComponent<Transform>();

            _rightWheelFrontTransform = _scene.Children.FindNodes(node => node.Name == "RightWheelFront")?.FirstOrDefault()?.GetTransform();     // or GetComponent<Transform>();
            _leftWheelFrontTransform  = _scene.Children.FindNodes(node => node.Name == "LeftWheelFront")?.FirstOrDefault()?.GetTransform();
            _rightWheelBackTransform  = _scene.Children.FindNodes(node => node.Name == "RightWheelBack")?.FirstOrDefault()?.GetTransform();
            _leftWheelBackTransform   = _scene.Children.FindNodes(node => node.Name == "LeftWheelBack")?.FirstOrDefault()?.GetTransform();

            _bodyTransform = _scene.Children.FindNodes(node => node.Name == "Body")?.FirstOrDefault()?.GetTransform();

            //Search children of _scene and find the nodes with the exact name. Then get the SourceEffect component of each and give the value to the variable.
            _rightWheelFrontEffect = _scene.Children.FindNodes(node => node.Name == "RightWheelFront") !.FirstOrDefault()?.GetComponent <SurfaceEffect>();
            _leftWheelFrontEffect  = _scene.Children.FindNodes(node => node.Name == "LeftWheelFront")?.FirstOrDefault()?.GetComponent <SurfaceEffect>();
            _rightWheelBackEffect  = _scene.Children.FindNodes(node => node.Name == "RightWheelBack")?.FirstOrDefault()?.GetComponent <SurfaceEffect>();
            _leftWheelBackEffect   = _scene.Children.FindNodes(node => node.Name == "LeftWheelBack")?.FirstOrDefault()?.GetComponent <SurfaceEffect>();

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

            //Change colors of nodes
            _rightWheelFrontEffect.SurfaceInput.Albedo = (float4)ColorUint.DarkOliveGreen;
            _leftWheelFrontEffect.SurfaceInput.Albedo  = (float4)ColorUint.SkyBlue;
            _rightWheelBackEffect.SurfaceInput.Albedo  = (float4)ColorUint.Cornsilk;
            _leftWheelBackEffect.SurfaceInput.Albedo   = (float4)ColorUint.Green;
        }
Exemple #16
0
        public Renderer(RenderContext rc)
        {
            RC = rc;
            // Initialize the shader(s)

            var vertsh = AssetStorage.Get <string>("VertexShader.vert");
            var pixsh  = AssetStorage.Get <string>("PixelShader.frag");
            var shader = RC.CreateShader(vertsh, pixsh);

            RC.SetShader(shader);
            AlbedoParam    = RC.GetShaderParam(shader, "albedo");
            ShininessParam = RC.GetShaderParam(shader, "shininess");
            ImageData maleModelED = AssetStorage.Get <ImageData>("maleModel_ED.jpg");

            _maleModelTexture = RC.CreateTexture(maleModelED);
            ImageData maleModelNM = AssetStorage.Get <ImageData>("maleFigure_NM_switch_red_ch.png");

            _maleModelTextureNM = RC.CreateTexture(maleModelNM);
            TextureParam        = RC.GetShaderParam(shader, "texture");
            Texture2Param       = RC.GetShaderParam(shader, "normalTex");
            TexMixParam         = RC.GetShaderParam(shader, "texmix");

            LightPosFrontLeftParam  = RC.GetShaderParam(shader, "lightposFrontLeft");
            LightPosBackLeftParam   = RC.GetShaderParam(shader, "lightposBackLeft");
            LightPosFrontRightParam = RC.GetShaderParam(shader, "lightposFrontRight");
            LightPosBackRightParam  = RC.GetShaderParam(shader, "lightposBackRight");
        }
Exemple #17
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

            // Load the rocket model
            _houseScene = AssetStorage.Get <SceneContainer>("rover.fus");

            //Get transform components
            for (int i = 0; i < 3; i++)
            {
                leftWheelTransforms[i] = _houseScene.Children.FindNodes(node => node.Name == "Rad_L_0" + (i + 1))?.FirstOrDefault()?.GetTransform();
            }
            for (int i = 0; i < 3; i++)
            {
                rightWheelTransforms[i] = _houseScene.Children.FindNodes(node => node.Name == "Rad_R_0" + (i + 1))?.FirstOrDefault()?.GetTransform();
            }
            for (int i = 0; i < 2; i++)
            {
                armTransforms[i] = _houseScene.Children.FindNodes(node => node.Name == "Arm_0" + (i + 1))?.FirstOrDefault()?.GetTransform();
            }

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_houseScene);

            _scenePicker = new ScenePicker(_houseScene);
        }
Exemple #18
0
        // Init is called on startup.
        public override void Init()
        {
            _initWindowWidth  = Width;
            _initWindowHeight = Height;
            if (_canvasRenderMode == CanvasRenderMode.Screen)
            {
                _initCanvasWidth  = Width / 100f;
                _initCanvasHeight = Height / 100f;
            }
            else
            {
                _initCanvasWidth  = 16;
                _initCanvasHeight = 9;
            }
            _canvasHeight = _initCanvasHeight;
            _canvasWidth  = _initCanvasWidth;

            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");

            _fontMap1 = new FontMap(fontLato, 8);
            _fontMap  = new FontMap(fontLato, 24);

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

            _bltDestinationTex = new Texture(AssetStorage.Get <ImageData>("townmusicians.jpg"));
            var bltScrTex = new Texture(AssetStorage.Get <ImageData>("censored_79_16.png"));

            _bltDestinationTex.Blt(180, 225, bltScrTex);

            _btnCanvas = new GUIButton
            {
                Name = "Canvas_Button"
            };
            _btnCanvas.OnMouseUp    += OnBtnCanvasUp;
            _btnCanvas.OnMouseDown  += OnBtnCanvasDown;
            _btnCanvas.OnMouseEnter += OnBtnCanvasEnter;
            _btnCanvas.OnMouseExit  += OnBtnCanvasExit;
            _btnCanvas.OnMouseOver  += OnMouseOverBtnCanvas;

            _btnCat = new GUIButton
            {
                Name = "Cat_Button"
            };
            _btnCat.OnMouseUp    += OnBtnCatUp;
            _btnCat.OnMouseDown  += OnBtnCatDown;
            _btnCat.OnMouseEnter += OnBtnCatEnter;
            _btnCat.OnMouseExit  += OnBtnCatExit;
            _btnCat.OnMouseOver  += OnMouseOverBtnCat;

            // Set the scene by creating a scene graph
            _scene = CreateNineSliceScene();

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

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRendererForward(_scene);
        }
Exemple #19
0
        // Init is called on startup.
        public override void Init()
        {
            #if GUI_SIMPLE
            _guiHandler = new GUIHandler();
            _guiHandler.AttachToContext(RC);

            _guiFuseeLink                   = new GUIButton(6, 6, 157, 87);
            _guiFuseeLink.ButtonColor       = new float4(0, 0, 0, 0);
            _guiFuseeLink.BorderColor       = new float4(0, 0.6f, 0.2f, 1);
            _guiFuseeLink.BorderWidth       = 0;
            _guiFuseeLink.OnGUIButtonDown  += _guiFuseeLink_OnGUIButtonDown;
            _guiFuseeLink.OnGUIButtonEnter += _guiFuseeLink_OnGUIButtonEnter;
            _guiFuseeLink.OnGUIButtonLeave += _guiFuseeLink_OnGUIButtonLeave;
            _guiHandler.Add(_guiFuseeLink);
            _guiFuseeLogo = new GUIImage(AssetStorage.Get <ImageData>("FuseeLogo150.png"), 10, 10, -5, 150, 80);
            _guiHandler.Add(_guiFuseeLogo);
            var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf");
            fontLato.UseKerning   = true;
            _guiLatoBlack         = new FontMap(fontLato, 18);
            _guiSubText           = new GUIText("FUSEE Example", _guiLatoBlack, 100, 100);
            _guiSubText.TextColor = new float4(0.05f, 0.25f, 0.15f, 0.8f);
            _guiHandler.Add(_guiSubText);
            _subtextWidth  = GUIText.GetTextWidth(_guiSubText.Text, _guiLatoBlack);
            _subtextHeight = GUIText.GetTextHeight(_guiSubText.Text, _guiLatoBlack);
            #endif

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

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

            //Create StereoCam for S3D rendering
            _stereoCam = new StereoCameraRig(Stereo3DMode.Anaglyph, Width, Height, 6.5f);
            _stereoCam.AttachToContext(RC);

            //Create ScreenS3DTextures object holding the 4 textures to be used with the ScreenS3D object
            ScreenS3DTextures screenTex = new ScreenS3DTextures();
            screenTex.Left       = RC.CreateTexture(AssetStorage.Get <ImageData>("left.png"));
            screenTex.LeftDepth  = RC.CreateTexture(AssetStorage.Get <ImageData>("depthLeft.png"));
            screenTex.Right      = RC.CreateTexture(AssetStorage.Get <ImageData>("right.png"));
            screenTex.RightDepth = RC.CreateTexture(AssetStorage.Get <ImageData>("depthRight.png"));
            //Create ScreenS3D Object using the ScreenS3Dtextures object from above
            _screen = new ScreenS3D(RC, screenTex);
            //Set the config fort the Screen objet. This can also be doene using a whole ScreenConfig object and assiging direktly to the ScreenS3D object
            _screen.Config.ScaleSize  = 1000;
            _screen.Config.ScaleDepth = 5;
            _screen.Config.Transform  = float4x4.CreateTranslation(0, 200, 0);
            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);


            // vl = AssetStorage.Get<VideoStream>("left.mkv");
            capL  = new Capture("Assets/left.mkv");
            capLD = new Capture("Assets/depthLeft.mkv");
            capR  = new Capture("Assets/right.mkv");
            capRD = new Capture("Assets/depthRight.mkv");
        }
Exemple #20
0
        // Init is called on startup.
        public override void Init()
        {
            var vertsh = AssetStorage.Get <string>("VertexShader.vert");
            var pixsh  = AssetStorage.Get <string>("PixelShader.frag");

            // Initialize the shader(s)
            var shader = RC.CreateShader(vertsh, pixsh);

            RC.SetShader(shader);
            _albedoParam = RC.GetShaderParam(shader, "albedo");

            // Load some meshes
            Mesh cube     = LoadMesh("Cube.fus");
            Mesh cylinder = LoadMesh("Cylinder.fus");
            Mesh sphere   = LoadMesh("Sphere.fus");

            // Setup a list of objects
            _root = new SceneOb {
                Children = new List <SceneOb>(new []
                {
                    // Body
                    new SceneOb {
                        Mesh = cube, Pos = new float3(0, 2.75f, 0), ModelScale = new float3(0.5f, 1, 0.25f), Albedo = new float3(0.2f, 0.6f, 0.3f)
                    },
                    // Legs
                    new SceneOb {
                        Mesh = cylinder, Pos = new float3(-0.25f, 1, 0), ModelScale = new float3(0.15f, 1, 0.15f),
                    },
                    new SceneOb {
                        Mesh = cylinder, Pos = new float3(0.25f, 1, 0), ModelScale = new float3(0.15f, 1, 0.15f),
                    },
                    // Shoulders
                    new SceneOb {
                        Mesh = sphere, Pos = new float3(-0.75f, 3.5f, 0), ModelScale = new float3(0.25f, 0.25f, 0.25f),
                    },
                    new SceneOb {
                        Mesh = sphere, Pos = new float3(0.75f, 3.5f, 0), ModelScale = new float3(0.25f, 0.25f, 0.25f),
                    },
                    // Arms
                    new SceneOb {
                        Mesh = cylinder, Pos = new float3(-0.75f, 2.5f, 0), ModelScale = new float3(0.15f, 1, 0.15f),
                    },
                    new SceneOb {
                        Mesh = cylinder, Pos = new float3(0.75f, 2.5f, 0), ModelScale = new float3(0.15f, 1, 0.15f),
                    },
                    // Head
                    new SceneOb
                    {
                        Mesh   = sphere, Pos = new float3(0, 4.2f, 0), ModelScale = new float3(0.35f, 0.5f, 0.35f),
                        Albedo = new float3(0.9f, 0.6f, 0.5f)
                    },
                })
            };

            // Set the clear color for the backbuffer
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
Exemple #21
0
        // Init is called on startup.
        public override void Init()
        {
            // Load some meshes
            _wuggy     = AssetStorage.Get <SceneContainer>("wuggy.fus");
            _wheelBigL = _wuggy.Children.FindNodes(n => n.Name == "WheelBigL").First().GetTransform();
            _renderer  = new Renderer(RC);

            // Set the clear color for the backbuffer
            RC.ClearColor = new float4(1, 1, 1, 1);
        }
Exemple #22
0
        public bool AddTexture(String name)
        {
            if (!textures.ContainsKey(name))
            {
                textures.Add(name, RC.CreateTexture(AssetStorage.Get <ImageData>(name)));
                return(true);
            }

            return(false);
        }
Exemple #23
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(1, 1, 1, 1);

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

            // Wrap a SceneRenderer around the model.
            _sceneRenderer = new SceneRenderer(_rocketScene);
        }
        /// <summary>
        /// Shader effect for the SSAO pass.
        /// </summary>
        /// <param name="geomPassRenderTarget">RenderTarget filled in the previous geometry pass.</param>
        /// <param name="kernelLength">SSAO kernel size.</param>
        /// <param name="screenParams">Width and Height of the screen.</param>
        public static ShaderEffect SSAORenderTargetTextureEffect(RenderTarget geomPassRenderTarget, int kernelLength, float2 screenParams)
        {
            var ssaoKernel   = SSAOHelper.CreateKernel(kernelLength);
            var ssaoNoiseTex = SSAOHelper.CreateNoiseTex(16);

            //TODO: is there a smart(er) way to set #define KERNEL_LENGTH in file?
            var ps = AssetStorage.Get <string>("SSAO.frag");

            if (kernelLength != 64)
            {
                var lines = ps.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                lines[1] = $"#define KERNEL_LENGTH {kernelLength}";
                ps       = string.Join("\n", lines);
            }

            return(new ShaderEffect(new[]
            {
                new EffectPassDeclaration
                {
                    VS = AssetStorage.Get <string>("Deferred.vert"),
                    PS = ps,
                    StateSet = new RenderStateSet
                    {
                        AlphaBlendEnable = false,
                        ZEnable = true,
                    }
                }
            },
                                    new[]
            {
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.DeferredRenderTextures[(int)RenderTargetTextureTypes.Position], Value = geomPassRenderTarget.RenderTextures[(int)RenderTargetTextureTypes.Position]
                },
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.DeferredRenderTextures[(int)RenderTargetTextureTypes.Normal], Value = geomPassRenderTarget.RenderTextures[(int)RenderTargetTextureTypes.Normal]
                },
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.DeferredRenderTextures[(int)RenderTargetTextureTypes.Albedo], Value = geomPassRenderTarget.RenderTextures[(int)RenderTargetTextureTypes.Albedo]
                },

                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.ScreenParams, Value = screenParams
                },
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.SSAOKernel, Value = ssaoKernel
                },
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.NoiseTex, Value = ssaoNoiseTex
                },
                new EffectParameterDeclaration {
                    Name = UniformNameDeclarations.Projection, Value = float4x4.Identity
                },
            }));
        }
Exemple #25
0
        // Init is called on startup.
        public override void Init()
        {
            // Set the clear color for the backbuffer to white (100% intensity in all color channels R, G, B, A).
            RC.ClearColor = new float4(0.2f, 0.3f, 1.0f, 1);

            _scene = AssetStorage.Get <SceneContainer>("fahrzeug.fus");

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRenderer(_scene);
            _scenePicker   = new ScenePicker(_scene);
        }
Exemple #26
0
        public static Mesh LoadMesh(string assetName)
        {
            SceneContainer sc = AssetStorage.Get <SceneContainer>(assetName);
            MeshComponent  mc = sc.Children.FindComponents <MeshComponent>(c => true).First();

            return(new Mesh
            {
                Vertices = mc.Vertices,
                Normals = mc.Normals,
                Triangles = mc.Triangles
            });
        }
Exemple #27
0
        public Renderer(RenderContext rc)
        {
            RC = rc;
            // Initialize the shader(s)
            var vertsh = AssetStorage.Get <string>("VertexShader.vert");
            var pixsh  = AssetStorage.Get <string>("PixelShader.frag");
            var shader = RC.CreateShader(vertsh, pixsh);

            RC.SetShader(shader);
            AlbedoParam    = RC.GetShaderParam(shader, "albedo");
            ShininessParam = RC.GetShaderParam(shader, "shininess");
        }
Exemple #28
0
        // Init is called on startup.
        public override void Init()
        {
            RC.ClearColor = new float4(0.8f, 0.9f, 0.7f, 1);

            _scene = AssetStorage.Get <SceneContainer>("CubeCar.fus");

            _rightRearTransform = _scene.Children.FindNodes(node => node.Name == "RightRearWheel")?.FirstOrDefault()?.GetTransform();

            // Create a scene renderer holding the scene above
            _sceneRenderer = new SceneRendererForward(_scene);
            _scenePicker   = new ScenePicker(_scene);
        }
Exemple #29
0
        private ImageData LookUpImage(string imageFile)
        {
            ITexture  texture;
            ImageData image = AssetStorage.Get <ImageData>(imageFile);

            if (!_textures.TryGetValue(imageFile, out texture))
            {
                texture = RC.CreateTexture(image);
                _textures[imageFile] = texture;
            }

            return(image);
        }
        // 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, 0.9f, 0.7f, 1);

            _scene = AssetStorage.Get <SceneContainer>("CubeCar.fus");

            _rightRearTransform = _scene.Children.FindNodes(node => node.Name == "RightRearWheel")?.FirstOrDefault()?.GetTransform();

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