public void DrawLabel() { if (isVisible) { PreRenderLabel(); MoveIntoPosition(false, ref labelModelMatrix); if (isActive) { Matrix4 scaleMatrix = Matrix4.CreateScale(Vector3.One * 1.3f); labelModelMatrix = scaleMatrix * labelModelMatrix; if (IsDirectory) { Matrix4 translationMatrix = Matrix4.CreateTranslation(new Vector3(0.14f, 0.35f, 0.0f)); labelModelMatrix = translationMatrix * labelModelMatrix; } else { Matrix4 translationMatrix = Matrix4.CreateTranslation(new Vector3(0.0f, 0.35f, 0.0f)); labelModelMatrix = translationMatrix * labelModelMatrix; } GL.Disable(EnableCap.DepthTest); LabelShader.Instance.LabelColor = new Color4(1.0f, 0.4f, 0.4f, parentSlice.Alpha); } else { LabelShader.Instance.LabelColor = new Color4(0.4f, 1f, 0.8f, parentSlice.Alpha); } GL.UseProgram(LabelShader.Instance.ShaderProgramID); LabelShader.Instance.SetShaderUniforms(labelModelMatrix); //Draw using VBO VBOUtil.Draw(NodeManager.labelVao, NodeManager.labelVbo); if (isActive) { GL.Enable(EnableCap.DepthTest); } PostRenderLabel(); } }
public void DrawSkyBox(float frameDelta) { /* In some cases, you might want to disable depth testing and still allow the depth buffer updated while you are rendering your objects. * It turns out that if you disable depth testing (glDisable(GL_DEPTH_TEST)), GL also disables writes to the depth buffer. * The correct solution is to tell GL to ignore the depth test results with glDepthFunc(GL_ALWAYS). * Be careful because in this state, if you render a far away object last, the depth buffer will contain the values of that far object. */ //GL.DepthFunc(DepthFunction.Always); //GL.Disable (EnableCap.DepthTest); //GL.DepthMask (false); // use the shader program (must be initiated firstly by calling InitSkyBoxShadersProgram()) GL.UseProgram(SkyBoxShader.Instance.ShaderProgramID); // bind texture to texture unit 0 GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, skyBoxSingleTexture); //Only one texture used //Rotates, making sure it rotates around the center of the cube; the spot lights also move around in the cube //The spot lights are moving in constant speed SkyBoxShader.Instance.SpotLightDirectionAngle += 0.0057f * frameDelta * 300; //fps independent animation // set up transforms which are inverse of our position // ie bring the world to meet the camera rather than move the camera Matrix4 initialTranslationMatrix = Matrix4.Identity; //Matrix4.CreateTranslation (0.5f, 1.0f, 0.0f); Matrix4 rotationXMatrix = Matrix4.CreateRotationX(Util.DegreesToRadians(SkyBoxShader.Instance.SpotLightDirectionAngle * 3.0f)); //please note that the lights movement speed is faster than skyBox rotation Matrix4 rotationYMatrix = Matrix4.CreateRotationY(Util.DegreesToRadians(SkyBoxShader.Instance.SpotLightDirectionAngle * 3.0f)); //please note that the lights movement speed is faster than skyBox rotation Matrix4 rotationZMatrix = Matrix4.CreateRotationZ(Util.DegreesToRadians(SkyBoxShader.Instance.SpotLightDirectionAngle * 3.0f)); //please note that the lights movement speed is faster than skyBox rotation Matrix4 finalTranslationMatrix = Matrix4.Identity; //Matrix4.CreateTranslation (-0.5f, -1.0f, 0.0f); Matrix4 skyBoxModelMatrix = finalTranslationMatrix * rotationZMatrix * rotationYMatrix * rotationXMatrix * initialTranslationMatrix; SkyBoxShader.Instance.SetShaderUniforms(skyBoxModelMatrix); VBOUtil.Draw(vao, vbo); //GL.DepthMask(true); //GL.Clear(ClearBufferMask.DepthBufferBit); //GL.Enable(EnableCap.DepthTest); }
public override void DrawBox(int offset, float frameDelta) { PreRenderBox(frameDelta); MoveIntoPosition(true, ref boxModelMatrix); if (isThumbnailed && !isDimmed) { //GL.TexEnv (TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (float)TextureEnvModeCombine.Replace); NodeShader.Instance.TextureEnvModeCombine = TextureEnvModeCombine.Replace; //No lightening applied to thumbnailed nodes - for better visual quality } /* * if (isNodeActivated) { //Node on which ENTER was pressed (color changing disabled at the moment) * GL.Color4 (currentColour [0], currentColour [1], currentColour [2], fadeAmount); * GL.Enable (EnableCap.ColorMaterial); * } else if (isDirFaded) { //Directories fading disabled at the moment (directories were fading when active node was being changed to file) * GL.Color4 (currentColour [0], currentColour [1], currentColour [2], fadeAmount); * GL.Enable (EnableCap.ColorMaterial); * } */ if (isActive) { Matrix4 scaleMatrix = Matrix4.CreateScale(ACTIVE_SCALE, ACTIVE_SCALE, ACTIVE_SCALE); Matrix4 translationMatrix = Matrix4.CreateTranslation(Vector3.UnitY * 0.5f); boxModelMatrix = scaleMatrix * boxModelMatrix; boxModelMatrix = translationMatrix * boxModelMatrix; } //On changing active slice, the file nodes are "growing" to their full size if (parentSlice.IsScaled) { float scaleValue = parentSlice.Scale - (offset / (float)parentSlice.NumFiles); if (scaleValue > 1.0f) { scaleValue = 1.0f; } else if (scaleValue <= 0f) { scaleValue = 0.01f; } //Cannot be 0.0f as then we will have singular matrix to inverse, which would cause exception Matrix4 scaleMatrix = Matrix4.CreateScale(scaleValue, scaleValue, scaleValue); boxModelMatrix = scaleMatrix * boxModelMatrix; } if (isSelected) { GL.PushAttrib(AttribMask.EnableBit | AttribMask.PolygonBit | AttribMask.CurrentBit); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); GL.Color4(Color.White); GL.UseProgram(NodeShader.Instance.ShaderProgramID); NodeShader.Instance.SetShaderUniforms(boxModelMatrix); VBOUtil.Draw(NodeManager.vao[(int)type], NodeManager.vbo[(int)type]); GL.PopAttrib(); Matrix4 scaleMatrix = Matrix4.CreateScale(0.8f, 0.8f, 0.8f); boxModelMatrix = scaleMatrix * boxModelMatrix; } GL.UseProgram(NodeShader.Instance.ShaderProgramID); NodeShader.Instance.SetShaderUniforms(boxModelMatrix); VBOUtil.Draw(NodeManager.vao[(int)type], NodeManager.vbo[(int)type]); PostRenderBox(); }
public override void DrawBox(int offset, float frameDelta) { PreRenderBox(frameDelta); MoveIntoPosition(true, ref boxModelMatrix); Matrix4 translationMatrix = Matrix4.CreateTranslation(0f, dirHeight - 1.0f, 0f); Matrix4 scaleMatrix = Matrix4.CreateScale(1f, dirHeight, 1f); boxModelMatrix = translationMatrix * boxModelMatrix; boxModelMatrix = scaleMatrix * boxModelMatrix; /* * if (isNodeActivated) { //Node on which ENTER was pressed (color changing disabled at the moment) * GL.Color4 (currentColour [0], currentColour [1], currentColour [2], fadeAmount); * GL.Enable (EnableCap.ColorMaterial); * } else if (isDirFaded) { //Directories fading disabled at the moment (directories were fading when active node was being changed to file) * GL.Color4 (currentColour [0], currentColour [1], currentColour [2], fadeAmount); * GL.Enable (EnableCap.ColorMaterial); * } */ if (isActive) { NodeShader.Instance.TextureEnvModeCombine = TextureEnvModeCombine.Replace; //Makes a nice enlighted ice-cube like node (no colour mixing with texture is allowed) //GL.Color4(activeColour[0], activeColour[1], activeColour[2], parentSlice.Alpha); //GL.Enable (EnableCap.ColorMaterial); } //On changing active slice, the file nodes are "growing" to their full size if (parentSlice.IsScaled) { float scaleValue = parentSlice.Scale - (offset / (float)parentSlice.NumFiles); if (scaleValue > 1.0f) { scaleValue = 1.0f; } else if (scaleValue <= 0f) { scaleValue = 0.01f; } //Cannot be 0.0f as then we will have singular matrix to inverse, which would cause exception Matrix4 growingScaleMatrix = Matrix4.CreateScale(scaleValue, scaleValue, scaleValue); boxModelMatrix = growingScaleMatrix * boxModelMatrix; } if (isSelected) { GL.PushAttrib(AttribMask.EnableBit | AttribMask.PolygonBit | AttribMask.CurrentBit); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); GL.Color4(Color.White); GL.UseProgram(NodeShader.Instance.ShaderProgramID); NodeShader.Instance.SetShaderUniforms(boxModelMatrix); VBOUtil.Draw(NodeManager.vao[(int)type], NodeManager.vbo[(int)type]); GL.PopAttrib(); Matrix4 selectedScaleMatrix = Matrix4.CreateScale(0.8f, 0.8f, 0.8f); boxModelMatrix = selectedScaleMatrix * boxModelMatrix; } GL.UseProgram(NodeShader.Instance.ShaderProgramID); NodeShader.Instance.SetShaderUniforms(boxModelMatrix); VBOUtil.Draw(NodeManager.vao[(int)type], NodeManager.vbo[(int)type]); PostRenderBox(); }