Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void draw (Renderer renderer, Framebuffer framebuffer) {
- // Get camera values
- float aspect = framebuffer.getAspect();
- Camera camera = _cameras.get(_renderCamera);
- Mat4 projectionMatrix = camera.getProjectionMatrix(aspect);
- Mat4 viewMatrix = camera.getViewMatrix();
- Vec3 cameraLocation = camera.getLocation().homogenize3();
- Light lights[] = getLights();
- // Draw all geometry objects
- for (Geometry geo : _geometries.values()) {
- if (!geo.isVisible()) {
- continue;
- }
- Mat4 modelMatrix = geo.getModelMatrix();
- Mat3 normalMatrix = geo.getNormalMatrix();
- // Draw all surfaces of each geometry
- Iterator<Surface> surfaces = geo.getSurfaces();
- while (surfaces.hasNext()) {
- Surface s = surfaces.next();
- SurfaceShader shader = s.getShader();
- /**
- * TODO 5:
- * - Pass normalMatrix to shader
- * - Pass camera location and light sources to shader.
- */
- /**
- * TODO 3:
- * - Calculate and set modelViewProjectionMatrix for shader.
- */
- /**
- * TODO 2:
- * - Pass the geometry's modelMatrix to the shader.
- */
- Mesh mesh = s.getMesh();
- renderer.draw(mesh, shader, framebuffer);
Add Comment
Please, Sign In to add comment