Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP3170
Assignment 1 Sailing Topics covered: • Drawing 2D meshes • 2D transformations: rotation, translation, scale • Scene graph • 2D camera: view and projection matrices, aspect • Viewpoint and Scissor Rectangle Task Description Your task is to implement a simple ocean scene with a landscape of islands and palm trees, and a sailing ship controlled using the WASD keys.
Figure 1: An example screenshot from the assignment. Framework For this assignment, you will need the Eclipse project containing the JOGL and JOML libraries that we have been using in the workshop classes. See the week 1 workshop for instructions to download and install this project.
Clone this framework into your own Github account.
It contains the files: • Assignment1.java – the main class implementing a JFrame and a GLEventListener. • SceneObject.java – a class that implements a scene graph. Objects in the scene should extend this class. • Ship.java – a class that draws the ship (without sails). • vertex.glsl / fragment.glsl – a basic, simple shader. To complete the assignment, you will need to edit these files and add further classes of your own.
The SceneObject class implements a simple scene graph. You should extend this class to implement objects in your scene, as illustrated by the Ship class. You should not need to change the code in this class. (We will be working with this class in the Week 5 prac, so refer to the prac for more details and examples.) Components You are required to complete each of the components below. Each component contributes a percentage towards your Completeness mark, as described below.
Note: In the spec a lot of specific numbers (e.g. the size and shape of islands, trees, sails, etc) are not specified. You are free to choose whatever values you feel appropriate for these as long as they illustrate the behaviour required. However, remember to use named constants in your code (with comment to indicate units) to allow these values to be easily modified. Clarity marks will be deducted for using ‘magic numbers’ (i.e., embedded numerical constant given without explanation).
Islands (10%) An island is a green, irregular polygon with vertices lying on a circle of radius 1, as shown below. The angle between successive vertices (measured at the centre of the circle) should always be less than 90 degrees.
Figure 2: An island is an irregular polygon with vertices on the unit circle.
Figure 3: Some random islands
Ocean (10%) The ocean map is a blue square 100 units tall and wide. It should contain ten islands with random positions and sizes.
Figure 4: An ocean with ten random islands.
Palm Trees (10%) A palm tree consists of a vertical trunk and four leaves, as shown below. Three palm trees should be randomly positioned on each island. Palm trees should always point upwards and have the same size regardless of the size of the island they are on.
Figure 5: Three palm trees on an island.
Ship (10%) The hull of the ship has already been implemented for you. The ship should have two sails, one at the front of the ship and one at the middle of the ship, as shown below. The two sails should be different sizes.
Figure 6: Ship with two sails.
Vertex colours (5%) Extend the shaders to add vertex colours and implement vertex colours for the island, palm trees and ship.
Figure 7: Island uses vertex colouring to make the centre a lighter shade than the edges. Palm tree leaves are also vertex coloured.
World camera (5%) The program should implement two camera modes: a world camera and a ship camera. Pressing space should switch between the two.
In the default view, the world camera should show the entire ocean and all the islands.
World camera – resizing (10%) If the window is not square, the shortest axis should fit the size of the world, and the world should be centred in the window, as shown below. Space outside the limits of the world should be black.
Figure 8: The world camera shows the entire world, centred in the window. If the window is too wide, black bars are shown on the left & right. Figure 9: If the window is too tall, black bars are shown on the top & bottom.
Ship camera (10%) The ship camera shows a zoomed-in area of the world around the ship and follows the ship so it is always in the centre of the scene. The ship camera should not rotate with the ship, so it is always oriented the same way regardless of which direction the ship is heading.
Figure 10: The ship camera is zoomed in on the ship's position but stays oriented to the world axes regardless of the ship's rotation.
Ship Camera – resizing (10%) In the ship camera view, if the window is resized, more or less of the world can be revealed, but the size of the ship should remain the same, as shown below.
Figure 11: Resizing the window reveals more of the world without changing the size of the ship. Keyboard control (10%) The ship is controlled using the WASD keys: • W and S move the ship forward and backwards in the direction it is currently facing. • A and D rotate the ship anticlockwise and clockwise respectively. Note: The ship can move anywhere on (or outside) the map. You do not need to implement collisions with islands.
Sail movement (10%) When the ship is turning the sails should rotate smoothly relative to the ship in the direction of the turn, to a maximum of 30 degrees, as shown below
Figure 12: Sails turn 30° right and left when ship turns clockwise/anticlockwise. When the ship is moving forwards the sails expand, smoothly increasing in size in the forwards direction, to a maximum value.
Figure 13: Ship stationary (left) and moving forwards (right). Notice how the sails have increased in size in the second picture.
Documentation In addition to your code, you should submit a PDF report following the Word template provided. The report should include: • A completed table indicating the features you have attempted. • An illustration of the scene graph used in your game. • Illustrations of all the meshes used in your game, drawn to scale in model coordinates, including: o the origin o the x and y axes o the coordinates of each vertex o the triangles that make the mesh • Diagrams illustrating the world and ship camera calculations, including: o The viewport rectangle o The scissor rectangle o The mapping from view (camera centric) coordinates to NDC o The mapping from NDC to viewport (pixel) coordinates Show separate examples for when the window has aspects greater than and less than 1. Submission Your Java project will be submitted using Github Classroom. Your most recent commit to the repository before the assignment deadline will be marked.
Your report will be submitted using iLearn as a PDF.
No late submissions will be accepted, except in the case of special consideration (which requires a formal application). Last minute problems with Git are not an excuse for late submission. Remember to commit and push your work regularly as you go.
Marks Your marks will be calculated using three components (according to the rubric below): • Correctness: Whether your code is correctly implemented. • Clarity: Whether your code is easy to understand. • Documentation: Whether your report contains all the required elements. This mark will be scaled based on a Completeness mark, which refers to the total value of the components you have attempted. Each component is worth between 5% and 10%, as detailed in the Report Template.
Your final mark will be determined using the formula:
So, for example if you attempt 80% of the features above, with perfect correctness (100%), slightly sloppy code (70%) and some minor sloppiness in the document (80%), your final mark would be:
On the other hand, if you only attempt 50% of the features above, to the same level of quality (90%) your final mark would be:
SQRT(50% * 90%) = 67.1%
Rubric
Grade Correctness Clarity Documentation HD (100%) Excellent work. Code is free from any apparent errors. Problems are solved in a suitable fashion. Contains no irrelevant code. Good consistent style. Well structured & commented code. Appropriate division into classes and methods, to make implementation clear. All sections are complete and accurately represent the code. All diagrams are neat, clear, and well annotated. D (80%) Very good work. Code has minor errors which do not significantly affect performance. Contains no irrelevant code. Code is readable with no significant code-smell. Code architecture is adequate but could be improved. All sections attempted with minor sloppiness or missing detail. No discrepancies between documentation and code. CR (70%) Good work. Code has one or two minor errors that affect performance. Problems may be solved in ways that are convoluted or otherwise show lack of understanding. Contains some copied code that is not relevant to the problem. Code is readable but has some code-smell that needs to be addressed. Code architecture is adequate but could be improved.
P (60%) Poor. Code is functional but contains major flaws. Contains large passages of copied code that are not relevant to the problem. Significant issues with code quality. Inconsistent application of style. Poor readability with code-smell issues. Code architecture could be improved. All sections attempted with significant sloppiness and missing detail. Minor discrepancies between documentation and code. F (40%) Code compiles and runs, but major elements are not functional. Significant issues with code quality. Inconsistent application of style. Poor readability with code-smell issues. Messy code architecture with significant encapsulation violations. Some aspects incomplete. Diagrams unclear and badly drawn. Does not make use of graph paper. Coordinate systems not properly annotated. Major discrepancies between documentation and code. 0% Code does not compile. Major issues with code quality. Major readability problems and code smell throughout. Messy code architecture with significant encapsulation violations. No document submitted or just the template with no content.