public static void SetScene(Vector2i Size) { if (Window.ENABLE_SHADOW) { depthMap = GL.GenTexture(); GL.BindTexture(TextureTarget.TextureCubeMap, depthMap); for (int i = 0; i < 6; ++i) { GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, PixelInternalFormat.DepthComponent, Window.SHADOW_RESOLUTION, Window.SHADOW_RESOLUTION, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero); } GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (float)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (float)TextureWrapMode.ClampToEdge); GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapR, (float)TextureWrapMode.ClampToEdge); depthMapFBO = GL.GenFramebuffer(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, depthMapFBO); GL.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, depthMap, 0); GL.DrawBuffer(DrawBufferMode.None); GL.ReadBuffer(ReadBufferMode.None); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); } WindowSize = Size; Shader_Color = new Shader("../../../Shaders/shader.vert", "../../../Shaders/shader.frag"); Shader_Wireframe = new Shader("../../../Shaders/shader_line.vert", "../../../Shaders/shader_line.frag"); Shader_Depth = new Shader("../../../Shaders/shader_depth.vert", "../../../Shaders/shader_depth.frag", "../../../Shaders/shader_depth.geom"); LightProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(90f.Rad(), (float)WindowSize.X / (float)WindowSize.Y, 1f, LightFarPlane); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(1, 0, 0), new Vector3(0, -1, 0)) * LightProjectionMatrix); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(-1, 0, 0), new Vector3(0, -1, 0)) * LightProjectionMatrix); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(0, 1, 0), new Vector3(0, 0, 1)) * LightProjectionMatrix); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(0, -1, 0), new Vector3(0, 0, -1)) * LightProjectionMatrix); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(0, 0, 1), new Vector3(0, -1, 0)) * LightProjectionMatrix); LightSpaceMatrix.Add(Matrix4.LookAt(LightPosition, LightPosition + new Vector3(0, 0, -1), new Vector3(0, -1, 0)) * LightProjectionMatrix); scene = new Object("scene"); Leonando.Objects(ref scene); Jeremy.Objects(ref scene); Nicholas.Objects(ref scene); scene.translateZ(-8.8f); scene.rotateZ(45f); scene.init(); lightSphere = new Object("lightsphere"); lightSphere.createBall(); lightSphere.scale(1); lightSphere.setTranslate(LightPosition.X, -LightPosition.Z, LightPosition.Y); lightSphere.setColor(255, 245, 166); lightSphere.init(); }
public static void AnimateScene() { if (Window.PLAYANIMATION) { Leonando.Animations(ref scene); Jeremy.Animations(ref scene); Nicholas.Animations(ref scene); } }