Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shader.Use ();
- Vector3 cameraPos = localCamera.Position.ToGLVec3 ();
- float yaw = MathHelper.DegreesToRadians ((float) localCamera.Angle), pitch = MathHelper.DegreesToRadians (MathHelper.Clamp ((float) localCamera.Pitch, -89.9f, 89.9f));
- Matrix4 cameraFrontMatrix = Matrix4.Identity;
- cameraFrontMatrix *= Matrix4.CreateRotationZ (pitch);
- cameraFrontMatrix *= Matrix4.CreateRotationY (yaw);
- Vector3 cameraFront = Vector3.Transform (new Vector3 (1.0f, 0.0f, 0.0f), cameraFrontMatrix).Normalized ();
- Vector3 cameraUp = new Vector3 (0.0f, 1.0f, 0.0f);
- Matrix4 view = Matrix4.LookAt (cameraPos, cameraPos + cameraFront, cameraUp);
- GL.ActiveTexture (TextureUnit.Texture0);
- tex.Bind ();
- Matrix4 model;
- shader.Use ();
- shader.SetMatrix ("view", view, false);
- shader.SetMatrix ("projection", projectionMatrix, false);
- shader.SetVector3 ("viewPos", cameraPos);
- shader.SetInt ("matDiffuse", 0);
- shader.SetInt ("matSpecular", 1);
- shader.SetFloat ("material.shininess", 32.0f);
- shader.SetVector3 ("light.position", cameraPos);
- shader.SetVector3 ("light.direction", cameraFront.Normalized ());
- shader.SetFloat ("light.cutOff", (float) Math.Cos (MathHelper.DegreesToRadians (12.5)));
- shader.SetFloat ("light.outerCutOff", (float) Math.Cos (MathHelper.DegreesToRadians (17.5)));
- shader.SetVector3 ("light.ambient", 0.2f, 0.2f, 0.2f);
- shader.SetVector3 ("light.diffuse", 0.5f, 0.5f, 0.5f);
- shader.SetVector3 ("light.specular", 1.0f, 1.0f, 1.0f);
- shader.SetFloat ("light.constant", 1.0f);
- shader.SetFloat ("light.linear", 0.0014f);
- shader.SetFloat ("light.quadratic", 0.000007f);
- GL.ActiveTexture (TextureUnit.Texture0);
- tex.Bind ();
- GL.ActiveTexture (TextureUnit.Texture1);
- specTex.Bind ();
- GL.BindVertexArray (VAO);
- var axis = new Vector3 (1.0f, 0.3f, 0.5f);
- for (int i = 0; i < 10; i++) {
- model = Matrix4.Identity;
- model *= Matrix4.CreateTranslation (cubePositions [i]);
- model *= Matrix4.CreateScale (8.0f);
- float angle = 20.0f * i;
- #pragma warning disable CS0618 // Type or member is obsolete
- model *= Matrix4.Rotate (axis, angle);
- #pragma warning restore CS0618 // Type or member is obsolete
- shader.SetMatrix ("model", model, false);
- GL.DrawArrays (PrimitiveType.Triangles, 0, 36);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement