Browse Source

Fixed StaticModel rotation

Thomas Buck 9 years ago
parent
commit
3e15451d64

+ 5
- 4
CMakeLists.txt View File

@@ -111,18 +111,19 @@ if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
111 111
 
112 112
     # Target for running cppcheck
113 113
     set (CHECK_STD "--std=c++11" "--std=posix")
114
-    set (CHECK_FLAGS "--quiet" "--force")
114
+    set (CHECK_FLAGS "--quiet" "--force" "-I${PROJECT_SOURCE_DIR}/include")
115
+    set (CHECK_FLAGS ${CHECK_FLAGS} "-i${PROJECT_SOURCE_DIR}/src/deps")
115 116
     set (CHECK_NORMAL "--enable=information,warning,performance,portability")
116 117
     set (CHECK_FULL "--enable=all")
117 118
     set (CHECK_CONFIG "--check-config")
118 119
     add_custom_target (cppcheck echo "Running cppcheck..."
119
-        COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_STD} ${CHECK_NORMAL} ${PROJECT_SOURCE_DIR}
120
+        COMMAND cppcheck ${CHECK_FLAGS} ${CHECK_STD} ${CHECK_NORMAL} ${PROJECT_SOURCE_DIR}
120 121
     )
121 122
     add_custom_target (cppcheckFull echo "Running full cppcheck..."
122
-        COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_STD} ${CHECK_FULL} ${PROJECT_SOURCE_DIR}
123
+        COMMAND cppcheck ${CHECK_FLAGS} ${CHECK_STD} ${CHECK_FULL} ${PROJECT_SOURCE_DIR}
123 124
     )
124 125
     add_custom_target (cppcheckConfig echo "Checking cppcheck config..."
125
-        COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_CONFIG} ${PROJECT_SOURCE_DIR}
126
+        COMMAND cppcheck ${CHECK_FLAGS} ${CHECK_CONFIG} ${PROJECT_SOURCE_DIR}
126 127
     )
127 128
 
128 129
     #################################################################

+ 3
- 0
ChangeLog.md View File

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20141220 ]
6
+    * Fixed Room StaticModel rotation
7
+
5 8
     [ 20141217 ]
6 9
     * Introduced texel-offset in getUV() in an attempt to fix the texture-bleeding
7 10
     * Mesh is now called RoomMesh

+ 6
- 6
README.md View File

@@ -39,16 +39,16 @@ A more or less recent [Doxygen documentation](http://xythobuz.github.io/OpenRaid
39 39
 Basically, OpenRaider depends on the following:
40 40
 
41 41
 * C++11 compiler
42
-* cmake
43
-* OpenGL
44
-* GLM
42
+* cmake (>= 2.8.8)
43
+* OpenGL (3.3 Core Profile compatible)
44
+* GLM (>= 0.9.6)
45 45
 * zlib
46
-* SDL2
47
-* SDL2-TTF (optional, needed if you want to use TTF fonts)
46
+* SDL2 or GLFW
47
+* SDL2-TTF (optional, doesn’t work with GLFW, needed if you want to use TTF fonts)
48 48
 * OpenAL & ALUT (optional, needed for sound output)
49 49
 * libpng (optional)
50 50
 
51
-On Mac OS X 10.9 with [XCode](https://developer.apple.com/xcode/) and [MacPorts](http://www.macports.org) installed, the following should be enough to get all dependencies that are available as port:
51
+On Mac OS X 10.9 / 10.10 with [XCode](https://developer.apple.com/xcode/) and [MacPorts](http://www.macports.org) installed, the following should be enough to get all dependencies that are available as port:
52 52
 
53 53
     sudo port install cmake zlib glm libsdl2 libsdl2_ttf
54 54
 

+ 7
- 12
include/Room.h View File

@@ -23,8 +23,10 @@ enum RoomFlags {
23 23
 
24 24
 class Room {
25 25
   public:
26
-    Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f)
27
-        : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f) { }
26
+    Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
27
+         int a, int x, int z)
28
+       : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f), alternateRoom(a),
29
+         numXSectors(x), numZSectors(z) { }
28 30
 
29 31
     void prepare() { mesh->prepare(); }
30 32
     void display(glm::mat4 view, glm::mat4 projection);
@@ -39,18 +41,11 @@ class Room {
39 41
     BoundingBox& getBoundingBox() { return *bbox; }
40 42
     RoomMesh& getMesh() { return *mesh; }
41 43
 
42
-    void setNumXSectors(unsigned int n) { numXSectors = n; }
43 44
     unsigned int getNumXSectors() { return numXSectors; }
44
-
45
-    void setNumZSectors(unsigned int n) { numZSectors = n; }
46 45
     unsigned int getNumZSectors() { return numZSectors; }
47 46
 
48 47
     unsigned int getFlags() { return flags; }
49 48
 
50
-    unsigned long sizeAdjacentRooms();
51
-    long getAdjacentRoom(unsigned long index);
52
-    void addAdjacentRoom(long r);
53
-
54 49
     unsigned long sizePortals();
55 50
     Portal& getPortal(unsigned long index);
56 51
     void addPortal(Portal* p);
@@ -77,10 +72,10 @@ class Room {
77 72
     std::unique_ptr<RoomMesh> mesh;
78 73
 
79 74
     unsigned int flags;
80
-    unsigned int numXSectors;
81
-    unsigned int numZSectors;
75
+    int numXSectors;
76
+    int numZSectors;
77
+    int alternateRoom;
82 78
 
83
-    std::vector<long> adjacentRooms;
84 79
     std::vector<std::unique_ptr<Sprite>> sprites;
85 80
     std::vector<std::unique_ptr<StaticModel>> models;
86 81
     std::vector<std::unique_ptr<Portal>> portals;

+ 2
- 13
include/SkeletalModel.h View File

@@ -59,13 +59,11 @@ class AnimationFrame {
59 59
 
60 60
 class SkeletalModel {
61 61
   public:
62
-    SkeletalModel(int i);
62
+    SkeletalModel(int i) : id(i) { }
63 63
     ~SkeletalModel();
64 64
     void display(unsigned long aframe, unsigned long bframe);
65 65
 
66
-    int getId();
67
-    void setPigTail(bool b);
68
-    void setPonyPos(float x, float y, float z, float angle);
66
+    int getId() { return id; }
69 67
 
70 68
     unsigned long size();
71 69
     AnimationFrame& get(unsigned long i);
@@ -73,15 +71,6 @@ class SkeletalModel {
73 71
 
74 72
   private:
75 73
     int id;
76
-    bool tr4Overlay;
77
-    bool pigtails;
78
-    long ponytailId;
79
-    float ponytail[3];
80
-    long ponytailMeshId;
81
-    unsigned int ponytailNumMeshes;
82
-    float ponytailAngle;
83
-    float ponyOff;
84
-    float ponyOff2;
85 74
     std::vector<AnimationFrame*> animation;
86 75
 };
87 76
 

+ 0
- 14
include/commands/CommandGame.h View File

@@ -24,19 +24,5 @@ class CommandViewmodel : public Command {
24 24
     virtual int execute(std::istream& args);
25 25
 };
26 26
 
27
-class CommandPigtail : public Command {
28
-  public:
29
-    virtual std::string name();
30
-    virtual std::string brief();
31
-    virtual int execute(std::istream& args);
32
-};
33
-
34
-class CommandPonypos : public Command {
35
-  public:
36
-    virtual std::string name();
37
-    virtual std::string brief();
38
-    virtual int execute(std::istream& args);
39
-};
40
-
41 27
 #endif
42 28
 

+ 2
- 2
src/Menu.cpp View File

@@ -100,14 +100,14 @@ void Menu::displayDialog() {
100 100
             w1 = wMax;
101 101
         unsigned int h1 = Font::heightText(1.0f, w1, dialogButton1) + 10;
102 102
 
103
-        unsigned int wOverlay = wMax, hOverlay, w2 = 0, h2 = 0;
103
+        unsigned int wOverlay = wMax, hOverlay, w2 = 0;
104 104
 
105 105
         if (dialogButton2.length() > 0) {
106 106
             // Show text and two buttons
107 107
             w2 = Font::widthText(1.0f, dialogButton2) + 20;
108 108
             if (w2 > wMax)
109 109
                 w2 = wMax;
110
-            h2 = Font::heightText(1.0f, w2, dialogButton2) + 10;
110
+            unsigned int h2 = Font::heightText(1.0f, w2, dialogButton2) + 10;
111 111
 
112 112
             if (w0 > (w1 + w2)) {
113 113
                 if (w0 < wMax) {

+ 5
- 3
src/Render.cpp View File

@@ -95,6 +95,7 @@ void Render::display() {
95 95
 }
96 96
 
97 97
 void Render::screenShot(const char* filenameBase) {
98
+    /*
98 99
     int sz = getWindow().getWidth() * getWindow().getHeight();
99 100
     unsigned char* image = new unsigned char[sz * 3];
100 101
     static int count = 0;
@@ -115,10 +116,11 @@ void Render::screenShot(const char* filenameBase) {
115 116
         }
116 117
     }
117 118
 
118
-    //glReadPixels(0, 0, getWindow().getWidth(), getWindow().getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE,
119
-    //             image);
120
-    //tgaSave(filename.str().c_str(), image, getWindow().getWidth(), getWindow().getHeight(), 0);
119
+    glReadPixels(0, 0, getWindow().getWidth(), getWindow().getHeight(), GL_BGR_EXT, GL_UNSIGNED_BYTE,
120
+                 image);
121
+    tgaSave(filename.str().c_str(), image, getWindow().getWidth(), getWindow().getHeight(), 0);
121 122
     delete [] image;
123
+    */
122 124
 }
123 125
 
124 126
 void Render::drawTexture(float x, float y, float w, float h, glm::vec4 color,

+ 0
- 13
src/Room.cpp View File

@@ -87,19 +87,6 @@ int Room::getAdjoiningRoom(float x, float y, float z,
87 87
 
88 88
 // --------------------------------------
89 89
 
90
-unsigned long Room::sizeAdjacentRooms() {
91
-    return adjacentRooms.size();
92
-}
93
-
94
-long Room::getAdjacentRoom(unsigned long index) {
95
-    assert(index < adjacentRooms.size());
96
-    return adjacentRooms.at(index);
97
-}
98
-
99
-void Room::addAdjacentRoom(long r) {
100
-    adjacentRooms.emplace_back(r);
101
-}
102
-
103 90
 unsigned long Room::sizePortals() {
104 91
     return portals.size();
105 92
 }

+ 17
- 15
src/RoomMesh.cpp View File

@@ -75,21 +75,23 @@ void RoomMesh::prepare() {
75 75
 void RoomMesh::display(glm::mat4 model, glm::mat4 view, glm::mat4 projection) {
76 76
     glm::mat4 MVP = projection * view * model;
77 77
 
78
-    unsigned int indexStart = 0;
79
-    unsigned int indexPos = 1;
80
-    unsigned int texture = textures.at(indices.at(0));
81
-
82
-    while ((indexStart != indexPos) && (indexPos < indices.size())) {
83
-        while ((indexPos < indices.size()) && (textures.at(indices.at(indexPos)) == texture))
84
-            indexPos++;
85
-
86
-        std::vector<unsigned short> ind(indices.begin() + indexStart, indices.begin() + indexPos);
87
-        Window::drawGL(vertices, uvs, ind, MVP, texture);
88
-
89
-        if (indexPos < indices.size()) {
90
-            indexStart = indexPos;
91
-            indexPos += 1;
92
-            texture = textures.at(indices.at(indexStart));
78
+    if (indices.size() > 0) {
79
+        unsigned int indexStart = 0;
80
+        unsigned int indexPos = 1;
81
+        unsigned int texture = textures.at(indices.at(0));
82
+
83
+        while ((indexStart != indexPos) && (indexPos < indices.size())) {
84
+            while ((indexPos < indices.size()) && (textures.at(indices.at(indexPos)) == texture))
85
+                indexPos++;
86
+
87
+            std::vector<unsigned short> ind(indices.begin() + indexStart, indices.begin() + indexPos);
88
+            Window::drawGL(vertices, uvs, ind, MVP, texture);
89
+
90
+            if (indexPos < indices.size()) {
91
+                indexStart = indexPos;
92
+                indexPos += 1;
93
+                texture = textures.at(indices.at(indexStart));
94
+            }
93 95
         }
94 96
     }
95 97
 }

+ 0
- 26
src/SkeletalModel.cpp View File

@@ -102,10 +102,6 @@ void AnimationFrame::add(BoneFrame* f) {
102 102
 
103 103
 // ----------------------------------------------------------------------------
104 104
 
105
-SkeletalModel::SkeletalModel(int i) {
106
-    id = i;
107
-}
108
-
109 105
 SkeletalModel::~SkeletalModel() {
110 106
     for (unsigned long i = 0; i < animation.size(); i++)
111 107
         delete animation[i];
@@ -152,28 +148,6 @@ void SkeletalModel::display(unsigned long aframe, unsigned long bframe) {
152 148
     */
153 149
 }
154 150
 
155
-int SkeletalModel::getId() {
156
-    return id;
157
-}
158
-
159
-void SkeletalModel::setPigTail(bool b) {
160
-    pigtails = b;
161
-    if (b) {
162
-        ponyOff -= 20;
163
-        ponytail[1] -= 32;
164
-    } else {
165
-        ponyOff += 20;
166
-        ponytail[1] += 32;
167
-    }
168
-}
169
-
170
-void SkeletalModel::setPonyPos(float x, float y, float z, float angle) {
171
-    ponytail[0] = x;
172
-    ponytail[1] = y;
173
-    ponytail[2] = z;
174
-    ponytailAngle = angle;
175
-}
176
-
177 151
 unsigned long SkeletalModel::size() {
178 152
     return animation.size();
179 153
 }

+ 0
- 2
src/commands/Command.cpp View File

@@ -39,8 +39,6 @@ void Command::fillCommandList() {
39 39
     commands.push_back(std::shared_ptr<Command>(new CommandMode()));
40 40
     commands.push_back(std::shared_ptr<Command>(new CommandPos()));
41 41
     commands.push_back(std::shared_ptr<Command>(new CommandViewmodel()));
42
-    commands.push_back(std::shared_ptr<Command>(new CommandPigtail()));
43
-    commands.push_back(std::shared_ptr<Command>(new CommandPonypos()));
44 42
     commands.push_back(std::shared_ptr<Command>(new CommandQuit()));
45 43
 }
46 44
 

+ 0
- 55
src/commands/CommandGame.cpp View File

@@ -61,58 +61,3 @@ int CommandViewmodel::execute(std::istream& args) {
61 61
     }
62 62
 }
63 63
 
64
-// --------------------------------------
65
-
66
-std::string CommandPigtail::name() {
67
-    return "pigtail";
68
-}
69
-
70
-std::string CommandPigtail::brief() {
71
-    return "BOOL";
72
-}
73
-
74
-int CommandPigtail::execute(std::istream& args) {
75
-    if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
76
-        getLog() << "Use pigtail command interactively!" << Log::endl;
77
-        return -1;
78
-    }
79
-
80
-    bool b;
81
-    args >> b;
82
-    if (!args) {
83
-        getLog() << "Pass BOOL to pigtail command!" << Log::endl;
84
-        return -2;
85
-    }
86
-
87
-    getGame().getLara().getModel().setPigTail(b);
88
-    getLog() << "Pigtail is now " << (b ? "on" : "off") << Log::endl;
89
-    return 0;
90
-}
91
-
92
-// --------------------------------------
93
-
94
-std::string CommandPonypos::name() {
95
-    return "ponypos";
96
-}
97
-
98
-std::string CommandPonypos::brief() {
99
-    return "FLOAT FLOAT FLOAT FLOAT - x y z angle";
100
-}
101
-
102
-int CommandPonypos::execute(std::istream& args) {
103
-    if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
104
-        getLog() << "Use ponypos command interactively!" << Log::endl;
105
-        return -1;
106
-    }
107
-
108
-    float a, b, c, d;
109
-    args >> a >> b >> c >> d;
110
-    if (!args) {
111
-        getLog() << "Pass four FLOATs to ponypos command!" << Log::endl;
112
-        return -2;
113
-    }
114
-
115
-    getGame().getLara().getModel().setPonyPos(a, b, c, d);
116
-    return 0;
117
-}
118
-

+ 4
- 9
src/loader/LoaderTR2.cpp View File

@@ -272,8 +272,6 @@ void LoaderTR2::loadRooms() {
272 272
             // TODO store sprites somewhere
273 273
         }
274 274
 
275
-        //room->addAdjacentRoom(i); // Always set room itself as first
276
-
277 275
         uint16_t numPortals = file.readU16();
278 276
         for (unsigned int p = 0; p < numPortals; p++) {
279 277
             // Which room this portal leads to
@@ -306,8 +304,6 @@ void LoaderTR2::loadRooms() {
306 304
 
307 305
         uint16_t numZSectors = file.readU16();
308 306
         uint16_t numXSectors = file.readU16();
309
-        //room->setNumXSectors(numXSectors);
310
-        //room->setNumZSectors(numZSectors);
311 307
         for (unsigned int s = 0; s < (numZSectors * numXSectors); s++) {
312 308
             // Sectors are 1024*1024 world coordinates. Floor and Ceiling are
313 309
             // signed numbers of 256 units of height.
@@ -365,7 +361,6 @@ void LoaderTR2::loadRooms() {
365 361
             // High two bits (0xC000) indicate steps of
366 362
             // 90 degrees (eg. (rotation >> 14) * 90)
367 363
             uint16_t rotation = file.readU16();
368
-            assert((rotation & 0x3FFF) == 0);
369 364
 
370 365
             // Constant lighting, 0xFFFF means use mesh lighting
371 366
             uint16_t intensity1 = file.readU16();
@@ -375,11 +370,11 @@ void LoaderTR2::loadRooms() {
375 370
             uint16_t objectID = file.readU16();
376 371
 
377 372
             staticModels.push_back(new StaticModel(glm::vec3(x, y, z),
378
-                                                   (rotation >> 14) * 90.0f,
373
+                                                   glm::radians((rotation >> 14) * 90.0f),
379 374
                                                    objectID));
380 375
         }
381 376
 
382
-        int16_t alternateRoom = file.read16(); // TODO
377
+        int16_t alternateRoom = file.read16();
383 378
 
384 379
         uint16_t flags = file.readU16();
385 380
         unsigned int roomFlags = 0;
@@ -389,7 +384,8 @@ void LoaderTR2::loadRooms() {
389 384
 
390 385
         BoundingBox* boundingbox = new BoundingBox(bbox[0], bbox[1]);
391 386
         RoomMesh* mesh = new RoomMesh(vertices, rectangles, triangles);
392
-        Room* room = new Room(pos, boundingbox, mesh, roomFlags);
387
+        Room* room = new Room(pos, boundingbox, mesh, roomFlags, alternateRoom,
388
+                              numXSectors, numZSectors);
393 389
 
394 390
         for (auto m : staticModels)
395 391
             room->addModel(m);
@@ -1095,7 +1091,6 @@ void LoaderTR2::loadExternalSoundFile(std::string f) {
1095 1091
         for (int i = 0; i < (riffSize + 8); i++)
1096 1092
             buff[i] = sfx.readU8();
1097 1093
 
1098
-        unsigned long src;
1099 1094
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1100 1095
         assert(ret >= 0);
1101 1096
 

Loading…
Cancel
Save