Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Computer Graphics

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls, shielding/insulation/reinforcement (SIR) areas, walkable areas, interior walls, hull windows and interior doors. The deck could contain some simple pieces of furniture, hardware (power plant, shield generator, computer, etc.), and pods. Your program will allow the user to create the hull walls, SIR areas, walkable areas, interior walls, hull windows and interior doors; to place and size objects such as furniture and hardware on the deck; and to delete any object no longer wanted.

For simplicity a hull wall could consist of a thick straight line segment (instead of a curved line segment); thin straight line segments could be used for interior walls and hull windows. Shielding/insulation/reinforcement (SIR) areas could be suitably filled polygons; walkable areas of the deck could be polygons filled with an appropriate stipple pattern.

As a starting point for your work you could use the program contained in DeckPlan.zip. Compile, build and execute this program. Notice that it displays a screen window containing some aligned rectangles (that is, rectangles whose sides are aligned with the coordinate axes). The large rectangle on the left is the drawing region in which the deck plan could be created. On the right hand side appears a button containing a small square: this button allows the user to select a piece of furniture (represented by an aligned rectangle of fixed width and height to begin with) as the current object to be drawn. The following parts ask you to extend this program. A sketch which indicates roughly what your final program GUI, together with a simple hypothetical deck plan layout in its drawing region, might look is provided to you in DeckPlan.pdf. Your GUI does *not* have to be exactly the same as the one suggested in the diagram. In particular, your choice of colours could be different. Note that the upper diagram was obtained from the internet, and served as a kind of inspiration for the sketch below it.

Notice that the program is organised as three files. You could keep the same basic file (and class) structure throughout your extension work if you like. However it is up to you if you wish to add more files or otherwise change the structure of the program. (If you redesign it radically, it would be appreciated if you include some rationale in your Readme.html file.)

1. Draw a grid (equally spaced horizontal and vertical lines) for the drawing region. This will facilitate the creation of a deck plan.

2. Add a button which allows the user to create a hull wall (thick straight line) of desired length. Left mouse button press, drag and release could specify the endpoints. Add a button which allows the user similarly to create an interior wall or hull window (thin line) of desired length. No "rubber line" is requested yet.

3. Add a button which allows the user to create an SIR area (appropriately filled polygon). A succession of left mouse button clicks could specify the corners, with some "finish" action, such as a right mouse button click, indicating completion of the polygon. Add a button which allows the user similarly to create a walkable area (polygon filled with an appropriate stipple pattern).

4. For your furniture (light coloured rectangle with border) creation tool, now allow the user to enter the opposite corners of the desired rectangle using the mouse (with left button press, drag and release). Add a button which allows the user simlarly to create hardware (dark coloured rectangle with border) of desired size. No "rubber rectangle" is requested yet.

5. Add a button which allows the user to create an interior door (thick/thin straight line) of desired length. Left mouse button press, drag and release could specify the endpoints. Add a button which allows the user to create a pod (coloured circle).

6. Currently, drawn objects can extend beyond the drawing region. Arrange for drawn objects to be *clipped* against the drawing region.
Hint. Look at Example 3.2.5 on pages 101 and 102 of Hill and Kelley (or see pages 89 and 90 of the 2nd edition).

7. For the wall, furniture and hardware objects only, provide the user with feedback during the process of drawing an object by displaying a "rubber object" outline that changes shape as the user moves the mouse. Use the XOR logical operation, as described in Section 9.3.3 of Hill and Kelley 3rd edn (Section 10.3.3 of the 2nd edn) in which relevant theory is described and implementation details are outlined.

8. A sigificant disadvantage with the deck plan editor as it currently exists is that objects are drawn and then forgotten, so to speak. Consequently, if the screen window is partially covered by another window, and subsequently exposed by moving the other window away, then the objects which were drawn by the user disappear as the redraw event triggers a call to the display function.
Eliminate this problem by having your program build a model (list) of all the deck objects (walls, deck areas, furniture, etc.) drawn by the user.
A nice way to do this is to use a global vector of deck objects. Let's call our global vector DeckModel. The mouse function should draw and append to DeckModel each new deck object created. The display function should traverse DeckModel, drawing each object stored.
After doing this, move the call to glClear() and the command to fill the drawing region from init() to display(). (They really belongs in display().)

9. Add a button labelled "File". Clicking on this button should cause a pop-up File menu to appear. This menu should provide at least three options: Save (write to file), Open (read from file), Quit. In case Save is selected, the contents of DeckModel should be saved in (written to) the text file DeckPlan.txt. In case Open is selected, the contents of the text file DeckPlan.txt should be read intoDeckModel and displayed.
Details concerning the text file format you are requested to use are found below in a separate section.

10. Add two buttons for select and delete. Provide functionality for these buttons. Selection of an object could result in a simple selection box (rectangle, say) being drawn around the object.

11. Add a small row of 4 different colour buttons and provide the functionality for them.

12. One mark is awarded for an impressive professional looking user interface. One mark is awarded for good programming style.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9307464

Have any Question?


Related Questions in C/C++

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As