OOD Assignment – To be performed in groups of three people.
Your task is to write a simple logo/turtle emulation program. Your program will read in a file containing a logo (like) program consisting of the commands FORWARD, JUMP, RIGHT, LEFT and REPEAT. Your program load this file into memory then produce the corresponding line drawing.
Instructions should control the motion of the cursor on the screen and can be used to form pictures. The command FORWARD X will move the cursor forwards from its current position by X units drawing a straight line of X units long. RIGHT X will rotate the cursor to the right by X degrees, LEFT X rotates left by X degrees. JUMP has the effect of lifting the cursor off the screen and moving it forward by X units without leaving a line. REPEAT X [ ] repeats the instructions within the square brackets X times.
For example, the following programme draws the figure to the right, each FORWARD command draws a line 1 unit in length, the LEFT 90 rotates the cursor by 90 degrees so each line forms the sides of a square.
The REPEAT command can be used to execute a block of commands within square brakets  multiple times, so the following code produces the corresponding figure.
REPEAT 4 [ FORWARD 1 LEFT 90 ]
REPEAT 10 [ FORWARD 0.5 LEFT 10]
Loops can also be nested, giving spectacular results, see below
REPEAT 36 [ RIGHT 10 REPEAT 360 [ FORWARD .04 RIGHT 1 ] ]
You can use these examples above to test your program as it should reproduce the corresponding image. Additional unseen files will be used in testing to see if your program operates correctly. You MUST therefore ensure that you use command line arguments in your program to load the text file.
You'll be glad to know that you are not expected to build your graphics application from scratch and a sample application has been assembled to simplify the use of graphics. Please copy it to your local directory and compile it (make -f makefile_shape). The program uses openGl and glut, although these have been hidden away as much as possible so should not concern you. Should you wish to develop upon another platform you will need to install Glut to use the sample code.
All the rendering should occur within the draw function (see example), this unfortunately means you may need some global variables but the use of the static keyword will minimise this. Any initialisation within main should be done before the window object is instantiated.
Some basic openGl commands you will need to know are:
glVertex3f( 0.0f, 0.0f, 0.0f); // Top
glVertex3f(1.0f,0.0f, 0.0f); // Bottom Left
This draws a single line of one unit in length to the right of the current cursor position.
glTranslatef(1,0,0) translates the cursor on the screen one unit to the right from the current position.
glRotatef(angle, 0,0,1) rotates the cursor by the desired angle (in degrees) to the left.
You shouldn't need to know anything more about OpenGL and rendering than that but should you wish, more details can be found here.
Design Specification Hints.
Use polymorphism to build an object which renders differently depending upon the type of object.
Use overloaded input/output operators to read in the content of the file.
Although this might sound complicated at first, with a good design it is relatively simple to implement. My implementation consists of just 138 lines of code not including comments and took a few hours to implement. It generated the figures above.
The project will be assessed in three parts:
1) Initial Design: description of design and specification [20%] Due (Week 8) Tues 20/11/2012 4pm
2) Quality of code; good structure, correct use of language features, clarity of implementation, error checking, good comments [60%] Due (Week 11) Tuesday 11/12/2012 4pm
3) Working code: demonstration of full implementation [20%] To be performed in Week 11 laboratory session 14/12/12
Title: Preliminary Design
Due Date: (Week 8) Tues 20/11/2012 4pm.
Length: 1 Page Max A4 11pt text
Contents: The title, names of members of group and login id's. It should then discuss the software design in broad terms: include decisions on the overall software design (with diagram of class hierarchy), the memory management used, error handling and any additional related class and functionality implemented.
Title: Final Submission
Due Date: (Week 11) Tuesday 11/12/2012 4pm. You will demonstrate your program in the laboratories on the 14th December.
Length: 1 Page A4 11pt text + compact printout of code
Content: A Title page stating team members names and login id's and declaring their contributions to the project i.e. 33% each. Each student should sign this declaration to show they agree with the weight of their contribution. A clear class hierarchy diagram should be included followed by a compact printout of the code.
A hardcopy of assignments whether postgrad or undergrad should be submitted to the appropriate assignment submission box or office prior to the deadline of 4pm. No electronic submission is required this year unless I decide I need to do a plagiarism test. In which case you will be contacted.
Failure to adhere to these guidelines will result in marks being deducted. There will be no extensions. Work handed in late will suffer the standard penalties laid out by the university.
Feedback and Marking: The purpose of the initial design is to force the students to think about the problem and solution prior to implementation. Feedback on design will be given to the whole cohort in the lecture immediately following submission (23rd Nov). In this lecture an idealised design will be discussed. This will allow students to judge the suitability of their own designs and make amendments prior to implementation. A mark for the design will be provided at a later date. The final implementation will be marked against the attributes: Design Quality, Code Structure, Use of Language Features, Clarity of Implementation, Error Checking and Comments. Feedback will also be provided on the strengths and weaknesses of the implementation.