首页 > > 详细

辅导 COMP3170 Assignment 1 Sailing Drawing 2D meshes

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.

A basic framework for the assignment has been provided in GitHub Classroom:
https://classroom.github.com/a/9u96iMRY

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:

联系我们 - QQ: 99515681 微信:codinghelp
© 2021 www.7daixie.com
程序辅导网!