QuestionQuestion

You should read the file PIXA.DAT, perform World to Screen coordinate transformations to draw the data on the screen, and allow for the following transformations given this keyboard input:

L: Move the object left
R: Move the object right
U: Move the object up
D: Move the object down
I: Move the object 'in' (increase the Z)
O: Move the object 'out' (decrease the Z)
X: Rotate about the X axis
Y: Rotate about the Y axis
Z: Rotate about the Z axis
1: Reset to the beginning state
Q: Exit the program

    Solution PreviewSolution Preview

    These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    #include <iostream>
    #include <list>
    #include <fstream>
    #include <string>
    #include <sstream>
    #include <vector>
    #include <iomanip>
    #include <cmath>
    using namespace std;

    struct vector3D{
        double x;
        double y;
        double z;
    };

    /**
    * print v3d to screen using its 2d coordiante
    */
    void worldToScreen(vector3D & v3d){
        cout << setw(10) << v3d.x << " " << setw(10) << v3d.y << "\n";
    }

    int readFile(string file_name, list<string> & a_list){
        // make a stream to read the file
        fstream in;
        // open the file
        in.open(file_name, ios::in);
       
        // check the state of the stream
        if (in.is_open() == false) {
           return 0;
        }
       
        // declare a string and a list
        string line;
       
        // read each line of the file until reaching to the end of file
        while (getline(in, line, '\n')) {
           /// push the line to the end of the list
           a_list.push_back(line);
        }
        // close the input stream
        in.close();
        return 1;
    }

    void listToFaces(list<string> & a_list, list<vector<vector3D>> & faces){
        faces.clear();
        string line;
        vector3D v3d;
        vector<vector3D> vt;
       
        // iterate over the list
        // print each line out
        for (list<string>::iterator it = a_list.begin(); it != a_list.end(); it++) {
           // get a line from vector of lines
           // it is iterator or a pointer to a string which is a line in thiscase
           // *it is the value pointed by the pointer (iterator)
           // so it it the string "line" we are expecting for
           line = *it;
          
           // the line which contains "J" always has length of 1
           // there isn't any vector
           if (line.length() <= 1) {
                //cout << line << "\n";
                if (vt.empty() == false) {
                    faces.push_back(vt);
                    vt.clear();
                }...

    By purchasing this solution you'll be able to access the following files:
    Solution.zip.

    50% discount

    Hours
    Minutes
    Seconds
    $73.00 $36.50
    for this solution

    or FREE if you
    register a new account!

    PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

    Find A Tutor

    View available 3D Graphics Tutors

    Get College Homework Help.

    Are you sure you don't want to upload any files?

    Fast tutor response requires as much info as possible.

    Decision:
    Upload a file
    Continue without uploading

    SUBMIT YOUR HOMEWORK
    We couldn't find that subject.
    Please select the best match from the list below.

    We'll send you an email right away. If it's not in your inbox, check your spam folder.

    • 1
    • 2
    • 3
    Live Chats