COMP330.doc
COMP330: Computer Graphics (2015s1)
Assignment 3
Prepared by Scott McCallum (with significant contribution from Matt Cabanag).
Questions to: [email protected]
Due Date: 11:45pm, Sunday 31 May 2015.
In Assignment 1, we asked you to create a Martian house plan designer. In Assignment 3, we would like you to create a program that simulates in 3D a journey from Earth to Mars by spacecraft.
Please download the file assign3template.zip from the Assignments section of the COMP330 iLearn space. Import the project contained therein into Eclipse. Compile (build) the project, and run it. You will see a perspective view of a portion of the solar system in the main (larger) viewport. The scene objects provided initially are the Sun, the Earth and a small spacecraft (represented by a small sphere). Notice that the Earth is in orbit around the Sun, and spins on its axis. The smaller viewport (located below left) is a "top down" (plan) view of the same scene. Your task is to extend this program by supplying additional features as set out below.
Please provide two additional small viewports (located below centre and below right) on the screen. These additional viewports should be the same size as the one provided (below left). One of the additional viewports should provide a view of 3D space from the spacecraft's bridge (command deck). The other one should contain a view of the spacecraft from the outside at close range. We ask you to provide to the user, in due course, a means by which he or she could cycle through the positions on the screen of the four viewports. That is, we would like the user to have the possibility to select any of the four viewports to be the main one.
We will not be concerned with the internals of the spacecraft; however it may be appropriate to display some simple instrumentation next to the viewport displaying the view from the bridge. Also, the sizes of planets, interplanetary distances, orbit periods etc., do not have to be to scale nor exactly in accord with physics and astronomy.
Further features of the requested program are detailed below under Tasks.
At first, this assignment may seem quite daunting. However, you will hopefully be able to make good progress once you have understood the framework provided (or suggested) to you in the code template, and have started to make appropriate extensions to it. Our suggestion is to first think about how you might manage a solar system with multiple objects (sun, planets, moons, spaceship, etc.) and then create your desired objects within that framework. Keep in mind that some objects may be comprised of multiple smaller objects too. (Remember object hierarchy).
This assignment is designed to give you practice in the following aspects of 3D graphics programming:
A. Hierarchical 3D modelling.
B. Constant and activated animations.
C. Dynamic perspective viewing (moving camera around in 3D).
D. Viewports.
E. Use of lighting, texturing.
F. Scene management, gener.
1. COMP330.doc
COMP330: Computer Graphics (2015s1)
Assignment 3
Prepared by Scott McCallum (with significant contribution from
Matt Cabanag).
Questions to: [email protected]
Due Date: 11:45pm, Sunday 31 May 2015.
In Assignment 1, we asked you to create a Martian house plan
designer. In Assignment 3, we would like you to create a
program that simulates in 3D a journey from Earth to Mars by
spacecraft.
Please download the file assign3template.zip from the
Assignments section of the COMP330 iLearn space. Import the
project contained therein into Eclipse. Compile (build) the
project, and run it. You will see a perspective view of a portion
of the solar system in the main (larger) viewport. The scene
objects provided initially are the Sun, the Earth and a small
spacecraft (represented by a small sphere). Notice that the Earth
is in orbit around the Sun, and spins on its axis. The smaller
viewport (located below left) is a "top down" (plan) view of the
same scene. Your task is to extend this program by supplying
additional features as set out below.
Please provide two additional small viewports (located below
centre and below right) on the screen. These additional
viewports should be the same size as the one provided (below
left). One of the additional viewports should provide a view of
3D space from the spacecraft's bridge (command deck). The
2. other one should contain a view of the spacecraft from the
outside at close range. We ask you to provide to the user, in due
course, a means by which he or she could cycle through the
positions on the screen of the four viewports. That is, we would
like the user to have the possibility to select any of the four
viewports to be the main one.
We will not be concerned with the internals of the spacecraft;
however it may be appropriate to display some simple
instrumentation next to the viewport displaying the view from
the bridge. Also, the sizes of planets, interplanetary distances,
orbit periods etc., do not have to be to scale nor exactly in
accord with physics and astronomy.
Further features of the requested program are detailed below
under Tasks.
At first, this assignment may seem quite daunting. However,
you will hopefully be able to make good progress once you have
understood the framework provided (or suggested) to you in the
code template, and have started to make appropriate extensions
to it. Our suggestion is to first think about how you might
manage a solar system with multiple objects (sun, planets,
moons, spaceship, etc.) and then create your desired objects
within that framework. Keep in mind that some objects may be
comprised of multiple smaller objects too. (Remember object
hierarchy).
This assignment is designed to give you practice in the
following aspects of 3D graphics programming:
A. Hierarchical 3D modelling.
B. Constant and activated animations.
C. Dynamic perspective viewing (moving camera around in 3D).
3. D. Viewports.
E. Use of lighting, texturing.
F. Scene management, generation.
Assignment Template & Support
You are free to use the provided code template as the starting
point for your code development. It gives you some hints on
how to structure your program and guides your strategies on
how to manage a dynamic 3D scene. There are several pre-built
classes and structs you can use to help you understand how
some common things are done in C++, like inheritance and
operator overloads.
Lectures and workshop classes will also provide you with some
of the things you will need to be successful in this assignment.
Tasks
You will be marked out of 40. This mark will be worth 20% of
your final mark for this unit. The requirements are set out
below.
1. (12 marks)
In orbit around Earth: You may have your spacecraft initially in
orbit around the Earth. You may wish to start with a simple
spacecraft design, and add more detail to it later if you have
time. Our suggestion is to make your spacecraft initially
a child of the Earth, to be in geostatic orbit around the Earth.
(This means that the spacecraft is always over the same part of
the Earth, as the Earth spins on its axis.) You might want to
slow down a bit the Earth's spinning at this point. Recall that in
4. total four viewports are needed, as detailed above.
2. (8 marks)
Toward Mars: For the second stage of your project you should
add at least a model for Mars to your scene. The Earth orbits
slowly around the Sun, and Mars orbits the Sun even more
slowly. Initially the spacecraft orbits the Earth, as in stage 1.
Your program should inform the user when a suitable launch
window (that is, a situation in which Earth and Mars have
favourable positions) occurs. At such time the user should have
the option to launch the spacecraft toward Mars. If launched,
the spacecraft should then follow a transfer orbit toward Mars.
You may like to add a comet or a piece of space junk (or
something else) to your scene to add some variety on the
journey. Finally, your spacecraft nears Mars, and enters Martian
orbit. At this point, we suggest that your spacecraft could be a
child of Mars.
This task is probably the most challenging part of the
assignment. We will try to provide some hints in due course if
needed.
3. (8 marks)
Arriving on Mars: For the third and final stage of your journey,
you could add some detail to your model of Mars. For example,
you could add the two tiny Martian moons, Phoebos and Demos,
to the scene. Also, you could add a little detail to the Martian
surface. Allow the user to choose to descend to the surface.
4. (8 marks)
Further features: Time permitting, you could provide further
features such as:
5. · use of lighting and shading
· further use of textures
· a more detailed spacecraft
· more realistic space
· hidden surface removal
As a rough guide, each of the above will earn you
approximately 1 mark, up to a maximum of 4 marks for this
stage.
5. (2 marks)
Coding Style: One mark will be awarded for good coding style,
including such aspects as modularity, understandability and
reusability.
6. (2 marks)
Documentation: One mark will be awarded for good
documentation. This does not have to be extensive; but please
inform the user (marker) about the keyboard commands, mouse
actions, etc. that are available, unless they are clear to a user
simply by looking at the screen upon starting up.
Documentation can be supplied as part of your electronic
submission.
Extra Functionality
There will be some of you that will find this selection of objects
and functionality to be insufficient. You are free to add more of
this as you wish. We cannot give you extra marks, but you won't
be marked down either.
6. Submission
Please submit an exported eclipse project in a .zip file to iLearn
by the due date. Do not include your executable program. Your
documentation can be included in your project folder.
Please format the .zip file as "COMP330_A3_[your student
number].zip".
Questions / Comments
Please direct any questions and comments to [email protected]
or post in the Assignment 3 forum on iLearn.
assignment1.zip
web/a.txt
hello word!
web/main
web/makefile
main: mywebserver.o myinput.o myparser.o myfiles.o
gcc -o main mywebserver.o myinput.o myparser.o
myfiles.o
mywebserver.o: mywebserver.c sys_config.h
gcc -c mywebserver.c
myinput.o: myinput.c sys_config.h
gcc -c myinput.c
myparser.o: myparser.c sys_config.h
gcc -c myparser.c
myfiles.o: myfiles.c sys_config.h
gcc -c myfiles.c
12. {
doGet(s);
memset(s,'0',100);
}
//do the uri
else if(strstr(s,"http:")!=NULL)
{
myParser(s);
memset(s,'0',100);
}
//error
else
{
printf("invalid input:%sn",s);
memset(s,'0',100);
}
}
}
web/myinput.o
web/myparser.c
#include"sys_config.h"
#include<stdio.h>
#include<string.h>
/*
because if can't connect to network
so the default_main is localhost
*/
//parser the uri
void myParser(char * str)
{