CMSC 405

The Text class must contain a constructor that is supplied
CMSC 405 - Computer Graphics
Programming Project 1

The first project involves adding several classes to a skeleton project that you will be provided, which reads in a scene definition file that defines the graphic objects in a scene and creates those objects, inserts them into the scene and displays that scene. The UML diagram for the whole project is shown below:

You will be provided the code for all the classes shown in black and you must complete the project by writing those classes shown in red. The skeleton project contains a parser that will parse a scene definition file that defines the scene to be displayed. The grammar for the scene definition file is shown below:

scene - SCENE IDENTIFIER number_list graphics END '.'
graphics - graphic graphics | graphic
graphic - isosceles | parallelogram | regular_polygon |text
isosceles - ISOSCELES COLOR number_list AT number_list HEIGHT NUMBER WIDTH NUMBER ';'
parallelogram - PARALLELOGRAM COLOR number_list AT number_list number_list OFFSET NUMBER ';'
regular_polygon - REGULAR_POLYGON COLOR number_list AT number_list SIDES NUMBER RADIUS NUMBER ';' 
text - TEXT COLOR number_list AT number_list STRING ';'
number_list - '(' numbers ')'
numbers - NUMBER | NUMBER ',' numbers

Below is a description of each of the five classes that you must write:

The Text class must contain a constructor that is supplied the Color that defines the text color, a Point that specifies the text location and a string containing the text to be displayed. It must also contain a draw function because it is extends the abstract class Graphic. The draw function must draw the text using GLUT bitmap 9 by 15 characters.

The ConvexPolygon class must contain a constructor declared protected that is called only by its subclasses. That constructor is passed the number of vertices in the polygon and its color. The number of vertices together with an array of Points that defined those vertices should be protected data elements of the class. It must also contain a draw function because it is extends the abstract class Graphic. That draw function should be used to all three types of convex polygons.

The IsoscelesTriangle class must have a constructor that is supplied the Color of the triangle, a Point that specifies the location of the top vertex, and the height and width of the triangle. It must allocate the array of Points that defined the triangle and compute their values.

The Parallelogram class must have a constructor that is supplied the Color of the parallelogram, two Points that specifies the location of the upper left and lower right vertices in addition to an x offset value that specifies the x distance between the upper and lower left vertices. It must allocate the array of Points that defined the parallelogram and compute their values.

The RegularPolygon class must contain a constructor that is supplied the Color of the polygon, the number of sides, a Point that specifies the location of its center, and the radius, which defines the distance between the center and each of the vertices. It must allocate the array of Points that defined the regular polygon and compute their values.

Below is a sample of a scene definition file that would provide input to the program:

Scene Polygons (500, 500)
Isosceles Color (1.0, 0.0, 0.0) at (20.0, 20.0) Height 100.0 Width 300.0;
Parallelogram Color (0.0, 0.0, 1.0) at (40., 10.) (100., 70.) Offset 10.;
RegularPolygon Color(1.0, 0.0, 1.0) at (-100., 100.) Sides 6 Radius 80.;
Text Color(0.0, 0.0, 0.0) at (-200., 200.) "Hello World";
End.

OpenGl c++

The Text class must contain a constructor that is supplied
Customer Question
CMSC 405 - Computer Graphics
Programming Project 1

The first project involves adding several classes to a skeleton project that you will be provided, which reads in a scene definition file that defines the graphic objects in a scene and creates those objects, inserts them into the scene and displays that scene. The UML diagram for the whole project is shown below:

You will be provided the code for all the classes shown in black and you must complete the project by writing those classes shown in red. The skeleton project contains a parser that will parse a scene definition file that defines the scene to be displayed. The grammar for the scene definition file is shown below:

scene - SCENE IDENTIFIER number_list graphics END '.'
graphics - graphic graphics | graphic
graphic - isosceles | parallelogram | regular_polygon |text
isosceles - ISOSCELES COLOR number_list AT number_list HEIGHT NUMBER WIDTH NUMBER ';'
parallelogram - PARALLELOGRAM COLOR number_list AT number_list number_list OFFSET NUMBER ';'
regular_polygon - REGULAR_POLYGON COLOR number_list AT number_list SIDES NUMBER RADIUS NUMBER ';' 
text - TEXT COLOR number_list AT number_list STRING ';'
number_list - '(' numbers ')'
numbers - NUMBER | NUMBER ',' numbers

Below is a description of each of the five classes that you must write:

The Text class must contain a constructor that is supplied the Color that defines the text color, a Point that specifies the text location and a string containing the text to be displayed. It must also contain a draw function because it is extends the abstract class Graphic. The draw function must draw the text using GLUT bitmap 9 by 15 characters.

The ConvexPolygon class must contain a constructor declared protected that is called only by its subclasses. That constructor is passed the number of vertices in the polygon and its color. The number of vertices together with an array of Points that defined those vertices should be protected data elements of the class. It must also contain a draw function because it is extends the abstract class Graphic. That draw function should be used to all three types of convex polygons.

The IsoscelesTriangle class must have a constructor that is supplied the Color of the triangle, a Point that specifies the location of the top vertex, and the height and width of the triangle. It must allocate the array of Points that defined the triangle and compute their values.

The Parallelogram class must have a constructor that is supplied the Color of the parallelogram, two Points that specifies the location of the upper left and lower right vertices in addition to an x offset value that specifies the x distance between the upper and lower left vertices. It must allocate the array of Points that defined the parallelogram and compute their values.

The RegularPolygon class must contain a constructor that is supplied the Color of the polygon, the number of sides, a Point that specifies the location of its center, and the radius, which defines the distance between the center and each of the vertices. It must allocate the array of Points that defined the regular polygon and compute their values.

Below is a sample of a scene definition file that would provide input to the program:

Scene Polygons (500, 500)
Isosceles Color (1.0, 0.0, 0.0) at (20.0, 20.0) Height 100.0 Width 300.0;
Parallelogram Color (0.0, 0.0, 1.0) at (40., 10.) (100., 70.) Offset 10.;
RegularPolygon Color(1.0, 0.0, 1.0) at (-100., 100.) Sides 6 Radius 80.;
Text Color(0.0, 0.0, 0.0) at (-200., 200.) "Hello World";
End.

OpenGl c++
Powered by