Debian Codegraph @

src/screen.hpp

raw
1 /*
2 * This file is part of Bino, a 3D video player.
3 *
4 * Copyright (C) 2017 Computer Graphics Group, University of Siegen
5 * Written by Martin Lambers <[email protected]>
6 *
7 * Copyright (C) 2022
8 * Martin Lambers <[email protected]>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * SOFTWARE.
27 */
28
29 /* This VR screen functionality is adapted from qvr-videoplayer */
30
31 #pragma once
32
33 #include <QtCore>
34 #include <QVector>
35 #include <QVector3D>
36
37 class Screen
38 {
39 Q_DECLARE_TR_FUNCTIONS(Screen)
40
41 public:
42 QVector<float> positions; // each position consists of 3 floats
43 QVector<float> texcoords; // each texcoord consists of 2 floats
44 QVector<unsigned int> indices;
45 float aspectRatio;
46
47 // Default constructor for a viewport-filling quad for GUI mode.
48 // The aspectRatio will unknown (set to 0) since it depends on the viewport.
49 Screen();
50
51 // Construct a planar screen from three corners.
52 // The aspect ratio is computed automatically.
53 Screen(const QVector3D& bottomLeftCorner,
54 const QVector3D& bottomRightCorner,
55 const QVector3D& topLeftCorner);
56
57 // Construct a screen by reading the specified OBJ file.
58 // If the given shape name is not empty, only this shape will be considered.
59 // Since the aspect ratio cannot be computed, it has to be specified.
60 // The OBJ data must contain positions and texture coordinates;
61 // everything else is ignored. If indices.size() == 0
62 // after constructing the screen in this way, then loading
63 // the OBJ file failed.
64 Screen(const QString& objFileName, const QString& shapeName, float aspectRatio);
65 };
66
67 QDataStream &operator<<(QDataStream& ds, const Screen& screen);
68 QDataStream &operator>>(QDataStream& ds, Screen& screen);