public override void Init() { _angleHorz = 0.2f; _angleVert = 0.2f; // is called on startup RC.ClearColor = new float4(1, 1, 1, 1); // initialize the variables _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _meshSphere = MeshReader.LoadMesh(@"Assets/Sphere.obj.model"); _meshCylinder = MeshReader.LoadMesh(@"Assets/Cylinder.obj.model"); _meshPlatonic = MeshReader.LoadMesh(@"Assets/Platonic.obj.model"); //RC.CreateShader(Vs, Ps); _spColor = RC.CreateShader(Vs, Ps); //MoreShaders.GetShader("simple", RC); _spTexture = RC.CreateShader(Vt, Pt); //MoreShaders.GetShader("texture", RC); _spCustom = RC.CreateShader(VLin, PLin); _colorParam = _spColor.GetShaderParam("vColor"); _colorCustom = _spCustom.GetShaderParam("vColor"); _textureParam = _spTexture.GetShaderParam("vTexture"); // load texture var imgData = RC.LoadImage("Assets/world_map.jpg"); _iTex = RC.CreateTexture(imgData); _physic = new Physics(); _gui = new GUI(RC); _gui.SetUp(_physic.GetNumRB(), _physic.GetShapes()); }
public override void Init() { _world = new World(RC); // load mesh as geometry var geo1 = MeshReader.LoadGeometry("Assets/Cube.obj.model"); // create and set shader var sp = RC.CreateShader(VsSimpleTexture, PsSimpleTexture); RC.SetShader(sp); var material = new ShaderMaterial(sp); // load a texture and write a text on it var imgData = RC.LoadImage("Assets/cube_tex.jpg"); imgData = RC.TextOnImage(imgData, "Verdana", 80f, "FUSEE rocks!", "Black", 0, 30); var iTex = RC.CreateTexture(imgData); Texture1Param = sp.GetShaderParam("texture1"); RC.SetShaderParamTexture(Texture1Param, iTex); // add object with material _world.AddObject(geo1, material, 0, 0, 500); RC.ClearColor = new float4(0.1f, 0.1f, 0.1f, 1); }
// 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"); }
public override void Init() { RC.ClearColor = new float4(0.5f, 0.5f, 0.5f, 1); // load meshes Body = MeshReader.LoadMesh(@"Assets/mageBodyOBJ.obj.model"); GloveL = MeshReader.LoadMesh(@"Assets/mageGloveLOBJ.obj.model"); GloveR = MeshReader.LoadMesh(@"Assets/mageGloveROBJ.obj.model"); // set up shader, lights and textures var spBody = RC.CreateShader(VsBump, PsBump); RC.SetShader(spBody); RC.SetLightActive(0, 1); RC.SetLightPosition(0, new float3(5.0f, 0.0f, 2.0f)); RC.SetLightAmbient(0, new float4(0.2f, 0.2f, 0.2f, 1.0f)); RC.SetLightSpecular(0, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(0, new float4(0.8f, 0.8f, 0.8f, 1.0f)); RC.SetLightDirection(0, new float3(-1.0f, 0.0f, 0.0f)); RC.SetLightActive(1, 1); RC.SetLightPosition(1, new float3(-5.0f, 0.0f, 2.0f)); RC.SetLightAmbient(1, new float4(0.5f, 0.5f, 0.5f, 1.0f)); RC.SetLightSpecular(1, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(1, new float4(1.0f, 1.0f, 1.0f, 1.0f)); RC.SetLightDirection(1, new float3(1.0f, 0.0f, 0.0f)); _texture1ParamBody = spBody.GetShaderParam("texture1"); _texture2ParamBody = spBody.GetShaderParam("normalTex"); _specularLevelBody = spBody.GetShaderParam("specularLevel"); var imgDataGlove = RC.LoadImage("Assets/HandAOMap.jpg"); var imgData2Glove = RC.LoadImage("Assets/HandschuhNormalMap.jpg"); _iTexGlove = RC.CreateTexture(imgDataGlove); _iTex2Glove = RC.CreateTexture(imgData2Glove); var imgData = RC.LoadImage("Assets/TextureAtlas.jpg"); var imgData2 = RC.LoadImage("Assets/TextureAtlasNormal.jpg"); _iTex = RC.CreateTexture(imgData); _iTex2 = RC.CreateTexture(imgData2); // misc settings _angleHorz = 0; _angleVert = 0; _rotationSpeed = 1.5f; }
private void UpdateVideos() { if (count < 300) { var frameL = capL.QueryFrame(); var imgData = new ImageData(); imgData.Width = frameL.Width; imgData.Height = frameL.Height; imgData.PixelFormat = ImagePixelFormat.RGB; imgData.Stride = 3; imgData.PixelData = frameL.GetData(); _screen.TexturesLR_DLR.Left = RC.CreateTexture(imgData); imgData.PixelData = capLD.QueryFrame().GetData(); _screen.TexturesLR_DLR.LeftDepth = RC.CreateTexture(imgData); imgData.PixelData = capR.QueryFrame().GetData(); _screen.TexturesLR_DLR.Right = RC.CreateTexture(imgData); imgData.PixelData = capRD.QueryFrame().GetData(); _screen.TexturesLR_DLR.RightDepth = RC.CreateTexture(imgData); //_screen.TexturesLR_DLR.Left = RC.CreateTexture(vl.GetCurrentFrame()); count++; } else { capL.Dispose(); capLD.Dispose(); capR.Dispose(); capRD.Dispose(); capL = null; capLD = null; capR = null; capRD = null; capL = new Capture("Assets/left.mkv"); capLD = new Capture("Assets/depthLeft.mkv"); capR = new Capture("Assets/right.mkv"); capRD = new Capture("Assets/depthRight.mkv"); count = 0; } }
// is called on startup public override void Init() { _theColor = new float4(0.5f, 0.8f, 0, 1); RC.ClearColor = new float4(1, 1, 1, 1); // initialize the variables _meshTea = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); _meshFace = MeshReader.LoadMesh(@"Assets/Face.obj.model"); _spColor = MoreShaders.GetShader("simple", RC); _spTexture = MoreShaders.GetShader("texture", RC); _colorParam = _spColor.GetShaderParam("vColor"); _textureParam = _spTexture.GetShaderParam("texture1"); // load texture var imgData = RC.LoadImage("Assets/world_map.jpg"); _iTex = RC.CreateTexture(imgData); }
private void InitShader() { var imgData = RC.LoadImage("Assets/art_billard.jpg"); var iTex = RC.CreateTexture(imgData); _shaderEffect = new ShaderEffect( new[] { new EffectPassDeclaration { VS = @" attribute vec4 fuColor; attribute vec3 fuVertex; attribute vec3 fuNormal; attribute vec2 fuUV; varying vec4 vColor; varying vec3 vNormal; varying vec2 vUV; uniform mat4 FUSEE_MVP; uniform mat4 FUSEE_ITMV; uniform vec2 uLineWidth; void main() { vNormal = mat3(FUSEE_ITMV[0].xyz, FUSEE_ITMV[1].xyz, FUSEE_ITMV[2].xyz) * fuNormal; vNormal = normalize(vNormal); gl_Position = (FUSEE_MVP * vec4(fuVertex, 1.0) ) + vec4(uLineWidth * vNormal.xy, 0, 0) + vec4(0, 0, 0.06, 0); vUV = fuUV; }", PS = @" #ifdef GL_ES precision highp float; #endif uniform vec4 uLineColor; varying vec3 vNormal; void main() { gl_FragColor = uLineColor; }", StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true } }, new EffectPassDeclaration { VS = @" attribute vec4 fuColor; attribute vec3 fuVertex; attribute vec3 fuNormal; attribute vec2 fuUV; varying vec3 vNormal; varying vec2 vUV; uniform mat4 FUSEE_MVP; uniform mat4 FUSEE_ITMV; void main() { gl_Position = (FUSEE_MVP * vec4(fuVertex, 1.0) ); vNormal = normalize(mat3(FUSEE_ITMV[0].xyz, FUSEE_ITMV[1].xyz, FUSEE_ITMV[2].xyz) * fuNormal); vUV = fuUV; }", PS = @" #ifdef GL_ES precision highp float; #endif uniform sampler2D texture1; varying vec3 vNormal; varying vec2 vUV; void main() { gl_FragColor = vec4(texture2D(texture1, vNormal.xy * 0.5 + vec2(0.5, 0.5)).rgb, 0.85); }", StateSet = new RenderStateSet { AlphaBlendEnable = false, ZEnable = true, } } }, new[] { new EffectParameterDeclaration { Name = "uLineColor", Value = new float4(0, 0, 0, 1) }, new EffectParameterDeclaration { Name = "texture1", Value = iTex }, new EffectParameterDeclaration { Name = "uLineWidth", Value = new float2(5, 5) } }); _shaderEffect.AttachToContext(RC); }
public override void Init() { VSync = false; SetWindowSize(1280, 720); // Start the application in demo mode? demoMode = true; #region MeshImports _Geo = new Geometry(); _Geo.LoadAsset("Assets/Cube.obj.model"); //_Geo.LoadAsset("Assets/Cube_quads.obj.model"); //_Geo.LoadAsset("Assets/Sphere.obj.model"); //_Geo.LoadAsset("Assets/Sphere_quads.obj.model"); //_Geo.LoadAsset("Assets/SharedCorners.obj.model"); //_Geo.LoadAsset("Assets/Cylinder.obj.model"); //_Geo.LoadAsset("Assets/Cylinder_quads.obj.model"); //_Geo.LoadAsset("Assets/SharedCorners_pro.obj.model"); //_Geo.LoadAsset("Assets/Teapot.obj.model"); #endregion MeshImports // Set the smoothing angle for the edge based vertex normal calculation // Feel free to test around. _Geo._SmoothingAngle = 89.0; // The shader colors here are not supposed to be changed. They don't have an effect. If you want to change the shaders // then please change the values in the ShaderChanger() method. These ones are just for declaration. #region Shaders #region TextureShader _msDiffuse = Shaders.GetDiffuseTextureShader(RC); _vLightShaderParam = _msDiffuse.GetShaderParam("texture1"); //ImageData imgData = RC.LoadImage("Assets/Cube_Mat_uv.jpg"); ImageData imgData = RC.LoadImage("Assets/world_map.jpg"); //ImageData imgData = RC.LoadImage("Assets/Teapot_Texture.jpg"); // Due to copyright reasons, this file will not be delivered with the project. //ImageData imgData = RC.LoadImage("Assets/Hellknight.jpg"); _tex = RC.CreateTexture(imgData); #endregion TextureShader #region ColorShader _spColor = Shaders.GetDiffuseColorShader(RC); _colorParam = _spColor.GetShaderParam("color"); RC.SetShader(_spColor); RC.SetShaderParam(_colorParam, new float4(0f, 0f, 0f, 1f)); #endregion ColorShader #region LightPos RC.SetLightActive(0, 0f); RC.SetLightAmbient(0, new float4(0.0f, 0.0f, 0.0f, 1.0f)); RC.SetLightDiffuse(0, new float4(1.0f, 1.0f, 1.0f, 1.0f)); RC.SetLightDirection(0, new float3(0.0f, -1.0f, 0.0f)); RC.SetLightActive(1, 0f); RC.SetLightAmbient(1, new float4(0.0f, 0.0f, 0.0f, 1.0f)); RC.SetLightDiffuse(1, new float4(0.5f, 0.5f, 0.5f, 1.0f)); RC.SetLightDirection(1, new float3(1.0f, 0.0f, 0.0f)); #endregion LightPos #endregion // Convert the loaded lfg model to a fusee mesh the first time. _lfgmesh = _Geo.ToMesh(); RC.ClearColor = new float4(0.2f, 0.2f, 0.2f, 1f); // For Benchmarking only. _ShaderType = 1; runDemoAnimation = true; _Geo._DoCalcVertexNormals = true; }
public override void Init() { // Set ToonShaderEffect _shaderEffect.AttachToContext(RC); // Setup GUI // GUIHandler _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(RC); // font + text _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18); _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24); _guiText = new GUIText("FUSEE Shader Demo", _guiFontCabin24, 30, Height - 30) { TextColor = new float4(1, 1, 1, 1) }; _guiHandler.Add(_guiText); // image _guiImage = new GUIImage("Assets/repbg.jpg", 0, 0, -5, Width, Height); _guiHandler.Add(_guiImage); _borderImage = new GUIImage("Assets/redbg.png", 0, 0, -4, 230, 32); //_guiHandler.Add(_borderImage); //* Menu1: Select Shader _panelSelectShader = new GUIPanel("Select Shader", _guiFontCabin24, 10, 10, 230, 230); _panelSelectShader.ChildElements.Add(_borderImage); _guiHandler.Add(_panelSelectShader); //** Possible Shader Buttons _btnDiffuseColorShader = new GUIButton("Diffuse Color", _guiFontCabin18, 25, 40, 180, 25); _btnTextureShader = new GUIButton("Texture Only", _guiFontCabin18, 25, 70, 180, 25); _btnDiffuseTextureShader = new GUIButton("Diffuse Texture", _guiFontCabin18, 25, 100, 180, 25); _btnDiffuseBumpTextureShader = new GUIButton("Diffuse Bump Texture", _guiFontCabin18, 25, 130, 180, 25); _btnSpecularTexture = new GUIButton("Specular Texture", _guiFontCabin18, 25, 160, 180, 25); _btnToon = new GUIButton("Toon", _guiFontCabin18, 25, 190, 180, 25); //*** Add Handlers _btnDiffuseColorShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseColorShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseColorShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseColorShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnDiffuseTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnDiffuseBumpTextureShader.OnGUIButtonDown += OnMenuButtonDown; _btnDiffuseBumpTextureShader.OnGUIButtonUp += OnMenuButtonUp; _btnDiffuseBumpTextureShader.OnGUIButtonEnter += OnMenuButtonEnter; _btnDiffuseBumpTextureShader.OnGUIButtonLeave += OnMenuButtonLeave; _btnSpecularTexture.OnGUIButtonDown += OnMenuButtonDown; _btnSpecularTexture.OnGUIButtonUp += OnMenuButtonUp; _btnSpecularTexture.OnGUIButtonEnter += OnMenuButtonEnter; _btnSpecularTexture.OnGUIButtonLeave += OnMenuButtonLeave; _btnToon.OnGUIButtonDown += OnMenuButtonDown; _btnToon.OnGUIButtonUp += OnMenuButtonUp; _btnToon.OnGUIButtonEnter += OnMenuButtonEnter; _btnToon.OnGUIButtonLeave += OnMenuButtonLeave; //**** Add Buttons to Panel _panelSelectShader.ChildElements.Add(_btnDiffuseColorShader); _panelSelectShader.ChildElements.Add(_btnTextureShader); _panelSelectShader.ChildElements.Add(_btnDiffuseTextureShader); _panelSelectShader.ChildElements.Add(_btnDiffuseBumpTextureShader); _panelSelectShader.ChildElements.Add(_btnSpecularTexture); _panelSelectShader.ChildElements.Add(_btnToon); //* Menu3: Select Mesh _panelSelectMesh = new GUIPanel("Select Mesh", _guiFontCabin24, 270, 10, 230, 130); _panelSelectMesh.ChildElements.Add(_borderImage); _guiHandler.Add(_panelSelectMesh); //** Possible Meshes _btnCube = new GUIButton("Cube", _guiFontCabin18, 25, 40, 180, 25); _btnSphere = new GUIButton("Sphere", _guiFontCabin18, 25, 70, 180, 25); _btnTeapot = new GUIButton("Teapot", _guiFontCabin18, 25, 100, 180, 25); _panelSelectMesh.ChildElements.Add(_btnCube); _panelSelectMesh.ChildElements.Add(_btnSphere); _panelSelectMesh.ChildElements.Add(_btnTeapot); //** Add handlers _btnCube.OnGUIButtonDown += OnMenuButtonDown; _btnCube.OnGUIButtonUp += OnMenuButtonUp; _btnCube.OnGUIButtonEnter += OnMenuButtonEnter; _btnCube.OnGUIButtonLeave += OnMenuButtonLeave; _btnSphere.OnGUIButtonDown += OnMenuButtonDown; _btnSphere.OnGUIButtonUp += OnMenuButtonUp; _btnSphere.OnGUIButtonEnter += OnMenuButtonEnter; _btnSphere.OnGUIButtonLeave += OnMenuButtonLeave; _btnTeapot.OnGUIButtonDown += OnMenuButtonDown; _btnTeapot.OnGUIButtonUp += OnMenuButtonUp; _btnTeapot.OnGUIButtonEnter += OnMenuButtonEnter; _btnTeapot.OnGUIButtonLeave += OnMenuButtonLeave; //* Menu2: Light Settings _panelLightSettings = new GUIPanel("Light Settings", _guiFontCabin24, 530, 10, 230, 130); _panelLightSettings.ChildElements.Add(_borderImage); _guiHandler.Add(_panelLightSettings); //** Possible Light Settings _btnDirectionalLight = new GUIButton("Directional Light", _guiFontCabin18, 25, 40, 180, 25); _btnPointLight = new GUIButton("Point Light", _guiFontCabin18, 25, 70, 180, 25); _btnSpotLight = new GUIButton("Spot Light", _guiFontCabin18, 25, 100, 180, 25); _panelLightSettings.ChildElements.Add(_btnDirectionalLight); _panelLightSettings.ChildElements.Add(_btnPointLight); _panelLightSettings.ChildElements.Add(_btnSpotLight); //*** Add Handlers _btnDirectionalLight.OnGUIButtonDown += OnMenuButtonDown; _btnDirectionalLight.OnGUIButtonUp += OnMenuButtonUp; _btnDirectionalLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnDirectionalLight.OnGUIButtonLeave += OnMenuButtonLeave; _btnPointLight.OnGUIButtonDown += OnMenuButtonDown; _btnPointLight.OnGUIButtonUp += OnMenuButtonUp; _btnPointLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnPointLight.OnGUIButtonLeave += OnMenuButtonLeave; _btnSpotLight.OnGUIButtonDown += OnMenuButtonDown; _btnSpotLight.OnGUIButtonUp += OnMenuButtonUp; _btnSpotLight.OnGUIButtonEnter += OnMenuButtonEnter; _btnSpotLight.OnGUIButtonLeave += OnMenuButtonLeave; // Setup 3D Scene // Load Images and Assign iTextures var imgTexture = RC.LoadImage("Assets/crateTexture.jpg"); var imgBumpTexture = RC.LoadImage("Assets/crateNormal.jpg"); _texCube = RC.CreateTexture(imgTexture); _texBumpCube = RC.CreateTexture(imgBumpTexture); imgTexture = RC.LoadImage("Assets/earthTexture.jpg"); imgBumpTexture = RC.LoadImage("Assets/earthNormal.jpg"); _texSphere = RC.CreateTexture(imgTexture); _texBumpSphere = RC.CreateTexture(imgBumpTexture); imgTexture = RC.LoadImage("Assets/porcelainTexture.png"); imgBumpTexture = RC.LoadImage("Assets/normalRust.jpg"); _texTeapot = RC.CreateTexture(imgTexture); _texBumpTeapot = RC.CreateTexture(imgBumpTexture); _currentTexture = _texCube; _currentBumpTexture = _texBumpCube; // Load Meshes _meshCube = MeshReader.LoadMesh(@"Assets/Cube.obj.model"); _meshSphere = MeshReader.LoadMesh(@"Assets/Sphere.obj.model"); _meshTeapot = MeshReader.LoadMesh(@"Assets/Teapot.obj.model"); // Set current Mesh and Update GUI _currentMesh = _meshCube; _btnCube.ButtonColor = ColorHighlightedButton; // Setup Shaderprograms and Update GUI _shaderDiffuseColor = Shaders.GetDiffuseColorShader(RC); _shaderDiffuseTexture = Shaders.GetDiffuseTextureShader(RC); _shaderTexture = Shaders.GetTextureShader(RC); _shaderDiffuseBumpTexture = Shaders.GetBumpDiffuseShader(RC); _shaderSpecularTexture = Shaders.GetSpecularShader(RC); _btnDiffuseColorShader.ButtonColor = ColorHighlightedButton; _currentShader = _shaderDiffuseColor; RC.SetShader(_shaderDiffuseColor); // Setup ShaderParams _paramColor = _shaderDiffuseColor.GetShaderParam("color"); // Setup Light and Update GUI RC.SetLightActive(0, 1); RC.SetLightPosition(0, new float3(5.0f, 0.0f, -2.0f)); RC.SetLightAmbient(0, new float4(0.2f, 0.2f, 0.2f, 1.0f)); RC.SetLightSpecular(0, new float4(0.1f, 0.1f, 0.1f, 1.0f)); RC.SetLightDiffuse(0, new float4(0.8f, 0.8f, 0.8f, 1.0f)); RC.SetLightDirection(0, new float3(-1.0f, 0.0f, 0.0f)); RC.SetLightSpotAngle(0, 10); _btnDirectionalLight.ButtonColor = ColorHighlightedButton; }
// is called on startup public override void Init() { RC.ClearColor = new float4(0.2f, 0.2f, 0.2f, 1); _smokeTexture = RC.CreateShader(_smokeEmitter.VsSimpleTexture, _smokeEmitter.PsSimpleTexture); _fireRedTexture = RC.CreateShader(_fireRedEmitter.VsSimpleTexture, _fireRedEmitter.PsSimpleTexture); _fireYellowTexture = RC.CreateShader(_fireYellowEmitter.VsSimpleTexture, _fireYellowEmitter.PsSimpleTexture); _starTexture = RC.CreateShader(_starEmitter.VsSimpleTexture, _starEmitter.PsSimpleTexture); _smokeParam = _smokeTexture.GetShaderParam("texture1"); _fireRedParam = _fireRedTexture.GetShaderParam("texture1"); _fireYellowParam = _fireYellowTexture.GetShaderParam("texture1"); _starParam = _starTexture.GetShaderParam("texture1"); // load texture var imgSmokeData = RC.LoadImage("Assets/smoke_particle.png"); var imgFireRedData = RC.LoadImage("Assets/fireRed.png"); var imgFireYellowData = RC.LoadImage("Assets/fireYellowTexture.png"); var imgStarData = RC.LoadImage("Assets/star.png"); _iSmoke = RC.CreateTexture(imgSmokeData); _iFireRed = RC.CreateTexture(imgFireRedData); _iFireYellow = RC.CreateTexture(imgFireYellowData); _iStar = RC.CreateTexture(imgStarData); RC.SetRenderState(new RenderStateSet { ZEnable = false, AlphaBlendEnable = true, BlendOperation = BlendOperation.Add, SourceBlend = Blend.SourceAlpha, DestinationBlend = Blend.InverseSourceAlpha }); // GUIHandler _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(RC); // font + text _guiFontCabin18 = RC.LoadFont("Assets/Cabin.ttf", 18); _guiFontCabin24 = RC.LoadFont("Assets/Cabin.ttf", 24); _guiText = new GUIText("Fusee3D Particle System ", _guiFontCabin24, 510, 35); _guiText.TextColor = new float4(1, 1, 1, 1); _guiHandler.Add(_guiText); // panel _guiPanel = new GUIPanel("Menu", _guiFontCabin18, 10, 10, 150, 150); _guiHandler.Add(_guiPanel); // Example 1 button _guiExampleOneButton = new GUIButton("Fog", _guiFontCabin18, 25, 40, 100, 25); _guiExampleOneButton.OnGUIButtonDown += OnMenuButtonDown; _guiExampleOneButton.OnGUIButtonUp += OnMenuButtonUp; _guiExampleOneButton.OnGUIButtonEnter += OnMenuButtonEnter; _guiExampleOneButton.OnGUIButtonLeave += OnMenuButtonLeave; _guiPanel.ChildElements.Add(_guiExampleOneButton); // Example 2 button _guiExampleTwoButton = new GUIButton("Fire", _guiFontCabin18, 25, 70, 100, 25); _guiExampleTwoButton.OnGUIButtonDown += OnMenuButtonDown; _guiExampleTwoButton.OnGUIButtonUp += OnMenuButtonUp; _guiExampleTwoButton.OnGUIButtonEnter += OnMenuButtonEnter; _guiExampleTwoButton.OnGUIButtonLeave += OnMenuButtonLeave; _guiPanel.ChildElements.Add(_guiExampleTwoButton); // Example 2 button _guiExampleThreeButton = new GUIButton("Stars", _guiFontCabin18, 25, 100, 100, 25); _guiExampleThreeButton.OnGUIButtonDown += OnMenuButtonDown; _guiExampleThreeButton.OnGUIButtonUp += OnMenuButtonUp; _guiExampleThreeButton.OnGUIButtonEnter += OnMenuButtonEnter; _guiExampleThreeButton.OnGUIButtonLeave += OnMenuButtonLeave; _guiPanel.ChildElements.Add(_guiExampleThreeButton); }