Guest User

Untitled

a guest
Feb 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public void draw (Renderer renderer, Framebuffer framebuffer) {
  2.  
  3. // Get camera values
  4. float aspect = framebuffer.getAspect();
  5.  
  6. Camera camera = _cameras.get(_renderCamera);
  7.  
  8. Mat4 projectionMatrix = camera.getProjectionMatrix(aspect);
  9. Mat4 viewMatrix = camera.getViewMatrix();
  10.  
  11. Vec3 cameraLocation = camera.getLocation().homogenize3();
  12.  
  13. Light lights[] = getLights();
  14.  
  15. // Draw all geometry objects
  16. for (Geometry geo : _geometries.values()) {
  17.  
  18. if (!geo.isVisible()) {
  19. continue;
  20. }
  21.  
  22. Mat4 modelMatrix = geo.getModelMatrix();
  23. Mat3 normalMatrix = geo.getNormalMatrix();
  24.  
  25. // Draw all surfaces of each geometry
  26. Iterator<Surface> surfaces = geo.getSurfaces();
  27. while (surfaces.hasNext()) {
  28.  
  29. Surface s = surfaces.next();
  30.  
  31. SurfaceShader shader = s.getShader();
  32.  
  33. /**
  34. * TODO 5:
  35. * - Pass normalMatrix to shader
  36. * - Pass camera location and light sources to shader.
  37. */
  38.  
  39. /**
  40. * TODO 3:
  41. * - Calculate and set modelViewProjectionMatrix for shader.
  42. */
  43.  
  44. /**
  45. * TODO 2:
  46. * - Pass the geometry's modelMatrix to the shader.
  47. */
  48.  
  49. Mesh mesh = s.getMesh();
  50.  
  51. renderer.draw(mesh, shader, framebuffer);
Add Comment
Please, Sign In to add comment