ソースを参照

Started work on Entity system

Thomas Buck 9年前
コミット
6c6d49f2ee

+ 3
- 0
ChangeLog.md ファイルの表示

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140124 ]
6
+    * Started working on Entity system.
7
+
5 8
     [ 20140118 ]
6 9
     * Added ability to visualize font _outline_.
7 10
     * Updated imgui to newest version, now with its own TTF support.

+ 36
- 47
include/Entity.h ファイルの表示

@@ -8,57 +8,46 @@
8 8
 #ifndef _ENTITY_H_
9 9
 #define _ENTITY_H_
10 10
 
11
-#include "SkeletalModel.h"
12
-
13 11
 class Entity {
14 12
   public:
15
-    typedef enum {
16
-        MoveTypeWalkNoSwim = -1,
17
-        MoveTypeWalk       = 0,
18
-        MoveTypeNoClipping = 1,
19
-        MoveTypeFly        = 2,
20
-        MoveTypeSwim       = 3
21
-    } MoveType;
22
-
23
-    Entity(float p[3], float a[3], int id, long r, unsigned int model);
24
-
25
-    void display();
26
-    void move(char movement);
27
-    void print();
28
-
29
-    SkeletalModel& getModel();
30
-    void setSkeletalModel(unsigned int model);
31
-    MoveType getMoveType();
32
-    void setMoveType(MoveType m);
33
-    int getObjectId();
34
-    void setAngles(float a[3]);
35
-    float getPos(unsigned int i);
36
-    float getAngle(unsigned int i);
37
-    long getRoom();
38
-
39
-    // Animation State
40
-    unsigned long getAnimation();
41
-    void setAnimation(unsigned long index);
42
-    unsigned long getBoneFrame();
43
-    void setBoneFrame(unsigned long index);
44
-    unsigned long getIdleAnimation();
45
-    void setIdleAnimation(unsigned long index);
13
+    Entity(int i, int r, glm::vec3 po, glm::vec3 ro)
14
+        : id(i), room(r), pos(po), rot(ro), cache(-1), cacheType(-1),
15
+        sprite(0), animation(0), frame(0) { }
16
+    void display(glm::mat4 VP);
17
+
18
+    int getID() { return id; }
19
+    int getRoom() { return room; }
20
+    glm::vec3 getPosition() { return pos; }
21
+    glm::vec3 getRotation() { return rot; }
22
+
23
+    int getSprite() { return sprite; }
24
+    void setSprite(int i) { sprite = i; }
25
+    int getAnimation() { return animation; }
26
+    void setAnimation(int i) { animation = i; frame = 0; }
27
+    int getFrame() { return frame; }
28
+    void setFrame(int i) { frame = i; }
29
+
30
+    static void setShowEntitySprites(bool s) { showEntitySprites = s; }
31
+    static bool getShowEntitySprites() { return showEntitySprites; }
32
+    static void setShowEntityMeshes(bool s) { showEntityMeshes = s; }
33
+    static bool getShowEntityMeshes() { return showEntityMeshes; }
34
+    static void setShowEntityModels(bool s) { showEntityModels = s; }
35
+    static bool getShowEntityModels() { return showEntityModels; }
46 36
 
47 37
   private:
48
-    float pos[3];
49
-    float angles[3];
50
-    long room;
51
-
52
-    unsigned int skeletalModel;
53
-    MoveType moveType;
54
-
55
-    int state;
56
-    int objectId;
57
-
58
-    // Animation State
59
-    unsigned long boneFrame;
60
-    unsigned long animationFrame;
61
-    unsigned long idleAnimation;
38
+    int id;
39
+    int room;
40
+    glm::vec3 pos;
41
+    glm::vec3 rot;
42
+    int cache, cacheType;
43
+
44
+    int sprite;
45
+    int animation;
46
+    int frame;
47
+
48
+    static bool showEntitySprites;
49
+    static bool showEntityMeshes;
50
+    static bool showEntityModels;
62 51
 };
63 52
 
64 53
 #endif

+ 6
- 4
include/Room.h ファイルの表示

@@ -22,7 +22,7 @@ enum RoomFlags {
22 22
 class Room {
23 23
   public:
24 24
     Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
25
-         int a, int x, int z);
25
+         int a, int x, int z, int i);
26 26
 
27 27
     void prepare() { mesh->prepare(); }
28 28
     void display(glm::mat4 VP);
@@ -37,10 +37,11 @@ class Room {
37 37
     BoundingBox& getBoundingBox() { return *bbox; }
38 38
     RoomMesh& getMesh() { return *mesh; }
39 39
 
40
-    unsigned int getNumXSectors() { return numXSectors; }
41
-    unsigned int getNumZSectors() { return numZSectors; }
42
-
43 40
     unsigned int getFlags() { return flags; }
41
+    int getAlternateRoom() { return alternateRoom; }
42
+    int getNumXSectors() { return numXSectors; }
43
+    int getNumZSectors() { return numZSectors; }
44
+    int getIndex() { return roomIndex; }
44 45
 
45 46
     void addSprite(RoomSprite* s) { sprites.emplace_back(s); }
46 47
     void addModel(StaticModel* s) { models.emplace_back(s); }
@@ -73,6 +74,7 @@ class Room {
73 74
     int alternateRoom;
74 75
     int numXSectors;
75 76
     int numZSectors;
77
+    int roomIndex;
76 78
 
77 79
     std::vector<std::unique_ptr<RoomSprite>> sprites;
78 80
     std::vector<std::unique_ptr<StaticModel>> models;

+ 2
- 2
include/SkeletalModel.h ファイルの表示

@@ -61,9 +61,9 @@ class SkeletalModel {
61 61
   public:
62 62
     SkeletalModel(int i) : id(i) { }
63 63
     ~SkeletalModel();
64
-    void display(unsigned long aframe, unsigned long bframe);
64
+    void display(glm::mat4 MVP, int aframe, int bframe);
65 65
 
66
-    int getId() { return id; }
66
+    int getID() { return id; }
67 67
 
68 68
     unsigned long size();
69 69
     AnimationFrame& get(unsigned long i);

+ 3
- 0
include/Sprite.h ファイルの表示

@@ -24,6 +24,9 @@ class SpriteSequence {
24 24
   public:
25 25
     SpriteSequence(int objectID, int offset, int size)
26 26
         : id(objectID), start(offset), length(size) { }
27
+    void display(glm::mat4 MVP, int index);
28
+
29
+    int getID() { return id; }
27 30
 
28 31
   private:
29 32
     int id;

+ 0
- 28
include/commands/CommandGame.h ファイルの表示

@@ -1,28 +0,0 @@
1
-/*!
2
- * \file include/commands/CommandGame.h
3
- * \brief Game Command interface
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#ifndef _COMMAND_GAME_H_
9
-#define _COMMAND_GAME_H_
10
-
11
-#include "commands/Command.h"
12
-
13
-class CommandPos : public Command {
14
-  public:
15
-    virtual std::string name();
16
-    virtual std::string brief();
17
-    virtual int execute(std::istream& args);
18
-};
19
-
20
-class CommandViewmodel : public Command {
21
-  public:
22
-    virtual std::string name();
23
-    virtual std::string brief();
24
-    virtual int execute(std::istream& args);
25
-};
26
-
27
-#endif
28
-

+ 0
- 22
include/commands/CommandMove.h ファイルの表示

@@ -1,22 +0,0 @@
1
-/*!
2
- * \file include/commands/CommandMove.h
3
- * \brief Move Command interface
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#ifndef _COMMAND_MOVE_H_
9
-#define _COMMAND_MOVE_H_
10
-
11
-#include "commands/Command.h"
12
-
13
-class CommandMove : public Command {
14
-  public:
15
-    virtual std::string name();
16
-    virtual std::string brief();
17
-    virtual void printHelp();
18
-    virtual int execute(std::istream& args);
19
-};
20
-
21
-#endif
22
-

+ 0
- 22
include/commands/CommandRender.h ファイルの表示

@@ -1,22 +0,0 @@
1
-/*!
2
- * \file include/commands/CommandRender.h
3
- * \brief Render Command interface
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#ifndef _COMMAND_RENDER_H_
9
-#define _COMMAND_RENDER_H_
10
-
11
-#include "commands/Command.h"
12
-
13
-class CommandMode : public Command {
14
-  public:
15
-    virtual std::string name();
16
-    virtual std::string brief();
17
-    virtual void printHelp();
18
-    virtual int execute(std::istream& args);
19
-};
20
-
21
-#endif
22
-

+ 1
- 1
src/Camera.cpp ファイルの表示

@@ -36,7 +36,7 @@ static bool equal(glm::vec3 a, float b) {
36 36
 const static float fov = 45.0f;
37 37
 const static float nearDist = 0.1f;
38 38
 const static float farDist = 75000.0f;
39
-const static float maxSpeed = 2048.0f;
39
+const static float maxSpeed = 3072.0f;
40 40
 const static float controllerViewFactor = glm::pi<float>();
41 41
 const static float controllerDeadZone = 0.1f;
42 42
 

+ 64
- 101
src/Entity.cpp ファイルの表示

@@ -6,112 +6,75 @@
6 6
  */
7 7
 
8 8
 #include "global.h"
9
+#include "Camera.h"
9 10
 #include "Log.h"
10 11
 #include "World.h"
11 12
 #include "Entity.h"
12 13
 
13
-Entity::Entity(float p[3], float a[3], int id, long r, unsigned int model) {
14
-    for (int i = 0; i < 3; i++) {
15
-        pos[i] = p[i];
16
-        angles[i] = a[i];
14
+#include <glm/gtc/matrix_transform.hpp>
15
+
16
+#define CACHE_SPRITE 0
17
+#define CACHE_MESH 1
18
+#define CACHE_MODEL 2
19
+
20
+bool Entity::showEntitySprites = true;
21
+bool Entity::showEntityMeshes = true;
22
+bool Entity::showEntityModels = true;
23
+
24
+void Entity::display(glm::mat4 VP) {
25
+    if ((cache == -1) || (cacheType == -1)) {
26
+        for (int i = 0; i < getWorld().sizeSpriteSequence(); i++) {
27
+            auto& s = getWorld().getSpriteSequence(i);
28
+            if (s.getID() == id) {
29
+                cacheType = CACHE_SPRITE;
30
+                cache = i;
31
+                break;
32
+            }
33
+        }
34
+
35
+        for (int i = 0; (i < getWorld().sizeStaticMesh()) && (cache == -1); i++) {
36
+            auto& s = getWorld().getStaticMesh(i);
37
+            if (s.getID() == id) {
38
+                cacheType = CACHE_MESH;
39
+                cache = i;
40
+                break;
41
+            }
42
+        }
43
+
44
+        for (int i = 0; (i < getWorld().sizeSkeletalModel()) && (cache == -1); i++) {
45
+            auto& s = getWorld().getSkeletalModel(i);
46
+            if (s.getID() == id) {
47
+                cacheType = CACHE_MODEL;
48
+                cache = i;
49
+                break;
50
+            }
51
+        }
52
+
53
+        assert(cache > -1);
54
+        assert(cacheType > -1);
17 55
     }
18
-    objectId = id;
19
-    moveType = MoveTypeWalk;
20
-    room = r;
21
-    skeletalModel = model;
22
-    boneFrame = 0;
23
-    animationFrame = 0;
24
-    idleAnimation = 0;
25
-    state = 0;
26
-}
27
-
28
-void Entity::display() {
29
-    /*
30
-    glPushMatrix();
31
-    glTranslatef(pos[0], pos[1], pos[2]);
32
-    glRotatef(glm::degrees(angles[1]), 0, 1, 0);
33
-    glRotatef(glm::degrees(angles[0]), 1, 0, 0);
34
-    //glRotatef(glm::degrees(angles[2]), 0, 0, 1);
35
-    getWorld().getSkeletalModel(skeletalModel).display(animationFrame, boneFrame);
36
-    glPopMatrix();
37
-    */
38
-}
39
-
40
-void Entity::move(char movement) {
41
-
42
-}
43
-
44
-void Entity::print() {
45
-    Log::get(LOG_INFO) << "Entity " << objectId << ":" << Log::endl
46
-                       << "  Room " << room << " (" << getWorld().getRoom(room).getFlags()
47
-                       << ")" << Log::endl
48
-                       << "  " << pos[0] << "x " << pos[1] << "y " << pos[2] << "z"
49
-                       << Log::endl
50
-                       << "  " << glm::degrees(angles[1]) << " Yaw" << Log::endl;
51
-}
52
-
53
-SkeletalModel& Entity::getModel() {
54
-    return getWorld().getSkeletalModel(skeletalModel);
55
-}
56
-
57
-void Entity::setSkeletalModel(unsigned int model) {
58
-    skeletalModel = model;
59
-    animationFrame = 0;
60
-    boneFrame = 0;
61
-    idleAnimation = 0;
62
-}
63
-
64
-Entity::MoveType Entity::getMoveType() {
65
-    return moveType;
66
-}
67
-
68
-void Entity::setMoveType(MoveType m) {
69
-    moveType = m;
70
-}
71
-
72
-int Entity::getObjectId() {
73
-    return objectId;
74
-}
75
-
76
-void Entity::setAngles(float a[3]) {
77
-    for (unsigned int i = 0; i < 3; i++)
78
-        angles[i] = a[i];
79
-}
80
-
81
-float Entity::getPos(unsigned int i) {
82
-    return pos[i];
83
-}
84
-
85
-float Entity::getAngle(unsigned int i) {
86
-    return angles[i];
87
-}
88 56
 
89
-long Entity::getRoom() {
90
-    return room;
91
-}
92
-
93
-unsigned long Entity::getAnimation() {
94
-    return animationFrame;
95
-}
96
-
97
-void Entity::setAnimation(unsigned long index) {
98
-    animationFrame = index;
99
-    boneFrame = 0;
100
-}
101
-
102
-unsigned long Entity::getBoneFrame() {
103
-    return boneFrame;
104
-}
105
-
106
-void Entity::setBoneFrame(unsigned long index) {
107
-    boneFrame = index;
108
-}
109
-
110
-unsigned long Entity::getIdleAnimation() {
111
-    return idleAnimation;
112
-}
113
-
114
-void Entity::setIdleAnimation(unsigned long index) {
115
-    idleAnimation = index;
57
+    glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
58
+    glm::mat4 rotate;
59
+    if (cacheType == 0) {
60
+        rotate = glm::rotate(glm::mat4(1.0f), Camera::getRotation().x, glm::vec3(0.0f, 1.0f, 0.0f));
61
+    } else {
62
+        rotate = glm::rotate(glm::mat4(1.0f), rot.y, glm::vec3(0.0f, 1.0f, 0.0f));
63
+    }
64
+    glm::mat4 model = translate * rotate;
65
+    glm::mat4 MVP = VP * model;
66
+
67
+    if (cacheType == CACHE_SPRITE) {
68
+        if (showEntitySprites)
69
+            getWorld().getSpriteSequence(cache).display(MVP, sprite);
70
+    } else if (cacheType == CACHE_MESH) {
71
+        if (showEntityMeshes)
72
+            getWorld().getStaticMesh(cache).display(MVP);
73
+    } else if (cacheType == CACHE_MODEL) {
74
+        if (showEntityModels)
75
+            getWorld().getSkeletalModel(cache).display(MVP, animation, frame);
76
+    } else {
77
+        assert(false && "This should not happen...");
78
+    }
116 79
 }
117 80
 

+ 3
- 3
src/Game.cpp ファイルの表示

@@ -68,9 +68,9 @@ int Game::loadLevel(const char* level) {
68 68
             Console::setVisible(true);
69 69
             UI::setVisible(true);
70 70
         } else {
71
-            Camera::setPosition(glm::vec3(getLara().getPos(0),
72
-                                          getLara().getPos(1) - 1024.0f,
73
-                                          getLara().getPos(2)));
71
+            Camera::setPosition(glm::vec3(getLara().getPosition().x,
72
+                                          getLara().getPosition().y - 1024.0f,
73
+                                          getLara().getPosition().z));
74 74
         }
75 75
     } else {
76 76
         Log::get(LOG_ERROR) << "No suitable loader for this level!" << Log::endl;

+ 22
- 0
src/Render.cpp ファイルの表示

@@ -55,6 +55,13 @@ void Render::display() {
55 55
 
56 56
     for (int r = roomList.size() - 1; r >= 0; r--) {
57 57
         roomList.at(r)->display(VP);
58
+
59
+        for (int i = 0; i < getWorld().sizeEntity(); i++) {
60
+            auto& e = getWorld().getEntity(i);
61
+            if (roomList.at(r)->getIndex() == e.getRoom()) {
62
+                e.display(VP);
63
+            }
64
+        }
58 65
     }
59 66
 
60 67
     if (displayViewFrustum)
@@ -237,6 +244,21 @@ void Render::displayUI() {
237 244
             Room::setShowRoomSprites(showRoomSprites);
238 245
         }
239 246
 
247
+        bool showEntitySprites = Entity::getShowEntitySprites();
248
+        if (ImGui::Checkbox("Entity Sprites##render", &showEntitySprites)) {
249
+            Entity::setShowEntitySprites(showEntitySprites);
250
+        }
251
+        ImGui::SameLine();
252
+        bool showEntityMeshes = Entity::getShowEntityMeshes();
253
+        if (ImGui::Checkbox("Entity Meshes##render", &showEntityMeshes)) {
254
+            Entity::setShowEntityMeshes(showEntityMeshes);
255
+        }
256
+        ImGui::SameLine();
257
+        bool showEntityModels = Entity::getShowEntityModels();
258
+        if (ImGui::Checkbox("Entity Models##render", &showEntityModels)) {
259
+            Entity::setShowEntityModels(showEntityModels);
260
+        }
261
+
240 262
         ImGui::Separator();
241 263
         if (ImGui::Button("New Splash##render")) {
242 264
             TextureManager::initializeSplash();

+ 2
- 2
src/Room.cpp ファイルの表示

@@ -18,8 +18,8 @@ bool Room::showRoomSprites = true;
18 18
 bool Room::showRoomGeometry = true;
19 19
 
20 20
 Room::Room(glm::vec3 _pos, BoundingBox* _bbox, RoomMesh* _mesh, unsigned int f,
21
-           int a, int x, int z) : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f),
22
-    alternateRoom(a), numXSectors(x), numZSectors(z) {
21
+           int a, int x, int z, int i) : pos(_pos), bbox(_bbox), mesh(_mesh), flags(f),
22
+    alternateRoom(a), numXSectors(x), numZSectors(z), roomIndex(i) {
23 23
     model = glm::translate(glm::mat4(1.0f), pos);
24 24
 }
25 25
 

+ 1
- 1
src/SkeletalModel.cpp ファイルの表示

@@ -107,7 +107,7 @@ SkeletalModel::~SkeletalModel() {
107 107
         delete animation[i];
108 108
 }
109 109
 
110
-void SkeletalModel::display(unsigned long aframe, unsigned long bframe) {
110
+void SkeletalModel::display(glm::mat4 MVP, int aframe, int bframe) {
111 111
     /*
112 112
     assert(aframe < size());
113 113
     assert(bframe < get(aframe).size());

+ 9
- 0
src/Sprite.cpp ファイルの表示

@@ -9,6 +9,7 @@
9 9
 #include "Camera.h"
10 10
 #include "Render.h"
11 11
 #include "TextureManager.h"
12
+#include "World.h"
12 13
 #include "Sprite.h"
13 14
 
14 15
 const static float scale = 4.0f;
@@ -46,3 +47,11 @@ void Sprite::display(glm::mat4 MVP) {
46 47
     Shader::drawGL(vertices, uvs, texture, MVP);
47 48
 }
48 49
 
50
+// ----------------------------------------------------------------------------
51
+
52
+void SpriteSequence::display(glm::mat4 MVP, int index) {
53
+    assert(index >= 0);
54
+    assert(index < length);
55
+    getWorld().getSprite(start + index).display(MVP);
56
+}
57
+

+ 1
- 0
src/World.cpp ファイルの表示

@@ -15,6 +15,7 @@ World::~World() {
15 15
 void World::destroy() {
16 16
     mRooms.clear();
17 17
     mSprites.clear();
18
+    mSpriteSequences.clear();
18 19
     mEntities.clear();
19 20
     mModels.clear();
20 21
     mStaticMeshes.clear();

+ 0
- 3
src/commands/CMakeLists.txt ファイルの表示

@@ -2,9 +2,6 @@
2 2
 set (CMD_SRCS ${CMD_SRCS} "Command.cpp" "../../include/commands/Command.h")
3 3
 set (CMD_SRCS ${CMD_SRCS} "CommandBind.cpp" "../../include/commands/CommandBind.h")
4 4
 set (CMD_SRCS ${CMD_SRCS} "CommandEngine.cpp" "../../include/commands/CommandEngine.h")
5
-set (CMD_SRCS ${CMD_SRCS} "CommandGame.cpp" "../../include/commands/CommandGame.h")
6
-set (CMD_SRCS ${CMD_SRCS} "CommandMove.cpp" "../../include/commands/CommandMove.h")
7
-set (CMD_SRCS ${CMD_SRCS} "CommandRender.cpp" "../../include/commands/CommandRender.h")
8 5
 set (CMD_SRCS ${CMD_SRCS} "CommandSet.cpp" "../../include/commands/CommandSet.h")
9 6
 
10 7
 # Add library

+ 1
- 8
src/commands/Command.cpp ファイルの表示

@@ -14,9 +14,6 @@
14 14
 #include "commands/Command.h"
15 15
 #include "commands/CommandBind.h"
16 16
 #include "commands/CommandEngine.h"
17
-#include "commands/CommandGame.h"
18
-#include "commands/CommandMove.h"
19
-#include "commands/CommandRender.h"
20 17
 #include "commands/CommandSet.h"
21 18
 
22 19
 std::vector<std::shared_ptr<Command>> Command::commands;
@@ -30,15 +27,11 @@ void Command::printHelp() {
30 27
 
31 28
 void Command::fillCommandList() {
32 29
     commands.clear();
33
-    commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
34 30
     commands.push_back(std::shared_ptr<Command>(new CommandBind()));
31
+    commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
35 32
     commands.push_back(std::shared_ptr<Command>(new CommandSet()));
36 33
     commands.push_back(std::shared_ptr<Command>(new CommandGet()));
37 34
     commands.push_back(std::shared_ptr<Command>(new CommandScreenshot()));
38
-    commands.push_back(std::shared_ptr<Command>(new CommandMove()));
39
-    commands.push_back(std::shared_ptr<Command>(new CommandMode()));
40
-    commands.push_back(std::shared_ptr<Command>(new CommandPos()));
41
-    commands.push_back(std::shared_ptr<Command>(new CommandViewmodel()));
42 35
     commands.push_back(std::shared_ptr<Command>(new CommandQuit()));
43 36
 }
44 37
 

+ 0
- 63
src/commands/CommandGame.cpp ファイルの表示

@@ -1,63 +0,0 @@
1
-/*!
2
- * \file src/commands/CommandGame.cpp
3
- * \brief Game meta-commands
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include "global.h"
9
-#include "Game.h"
10
-#include "Log.h"
11
-#include "RunTime.h"
12
-#include "World.h"
13
-#include "commands/CommandGame.h"
14
-
15
-std::string CommandPos::name() {
16
-    return "pos";
17
-}
18
-
19
-std::string CommandPos::brief() {
20
-    return "Print position info";
21
-}
22
-
23
-int CommandPos::execute(std::istream& args) {
24
-    if ((!RunTime::isRunning()) || (!Game::isLoaded())) {
25
-        Log::get(LOG_USER) << "Use pos command interactively!" << Log::endl;
26
-        return -1;
27
-    }
28
-
29
-    Game::getLara().print();
30
-    return 0;
31
-}
32
-
33
-// --------------------------------------
34
-
35
-std::string CommandViewmodel::name() {
36
-    return "viewmodel";
37
-}
38
-
39
-std::string CommandViewmodel::brief() {
40
-    return "INT - Change Laras model";
41
-}
42
-
43
-int CommandViewmodel::execute(std::istream& args) {
44
-    if ((!RunTime::isRunning()) || (!Game::isLoaded())) {
45
-        Log::get(LOG_USER) << "Use viewmodel command interactively!" << Log::endl;
46
-        return -1;
47
-    }
48
-
49
-    //! \fixme Validate input
50
-
51
-    std::string s;
52
-    args >> s;
53
-    unsigned int n = atoi(s.c_str());
54
-
55
-    if (n < getWorld().sizeSkeletalModel()) {
56
-        Game::getLara().setSkeletalModel(n);
57
-        return 0;
58
-    } else {
59
-        Log::get(LOG_USER) << "Invalid SkeletalModel index!" << Log::endl;
60
-        return -2;
61
-    }
62
-}
63
-

+ 0
- 53
src/commands/CommandMove.cpp ファイルの表示

@@ -1,53 +0,0 @@
1
-/*!
2
- * \file src/commands/CommandMove.cpp
3
- * \brief Move command
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include "global.h"
9
-#include "Game.h"
10
-#include "Log.h"
11
-#include "RunTime.h"
12
-#include "commands/CommandMove.h"
13
-
14
-std::string CommandMove::name() {
15
-    return "move";
16
-}
17
-
18
-std::string CommandMove::brief() {
19
-    return "[walk|fly|noclip]";
20
-}
21
-
22
-void CommandMove::printHelp() {
23
-    Log::get(LOG_USER) << "move-Command Usage:" << Log::endl;
24
-    Log::get(LOG_USER) << "  move COMMAND" << Log::endl;
25
-    Log::get(LOG_USER) << "Where COMMAND is one of the following:" << Log::endl;
26
-    Log::get(LOG_USER) << "  walk" << Log::endl;
27
-    Log::get(LOG_USER) << "  fly" << Log::endl;
28
-    Log::get(LOG_USER) << "  noclip" << Log::endl;
29
-}
30
-
31
-int CommandMove::execute(std::istream& args) {
32
-    if ((!RunTime::isRunning()) || (!Game::isLoaded())) {
33
-        Log::get(LOG_USER) << "Use move command interactively!" << Log::endl;
34
-        return -1;
35
-    }
36
-
37
-    std::string s;
38
-    args >> s;
39
-    if (s.compare("walk") == 0) {
40
-        Game::getLara().setMoveType(Entity::MoveTypeWalk);
41
-    } else if (s.compare("fly") == 0) {
42
-        Game::getLara().setMoveType(Entity::MoveTypeFly);
43
-    } else if (s.compare("noclip") == 0) {
44
-        Game::getLara().setMoveType(Entity::MoveTypeNoClipping);
45
-    } else {
46
-        Log::get(LOG_USER) << "Invalid use of move command (" << s << ")!" << Log::endl;
47
-        return -2;
48
-    }
49
-
50
-    Log::get(LOG_USER) << s  << "ing" << Log::endl;
51
-    return 0;
52
-}
53
-

+ 0
- 55
src/commands/CommandRender.cpp ファイルの表示

@@ -1,55 +0,0 @@
1
-/*!
2
- * \file src/commands/CommandRender.cpp
3
- * \brief Renderer commands
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include "global.h"
9
-#include "Log.h"
10
-#include "Render.h"
11
-#include "commands/CommandRender.h"
12
-
13
-std::string CommandMode::name() {
14
-    return "mode";
15
-}
16
-
17
-std::string CommandMode::brief() {
18
-    return "MODE - Render mode";
19
-}
20
-
21
-void CommandMode::printHelp() {
22
-    Log::get(LOG_USER) << "mode-Command Usage:" << Log::endl;
23
-    Log::get(LOG_USER) << "  mode MODE" << Log::endl;
24
-    Log::get(LOG_USER) << "Where MODE is one of the following:" << Log::endl;
25
-    Log::get(LOG_USER) << "  wireframe" << Log::endl;
26
-    Log::get(LOG_USER) << "  solid" << Log::endl;
27
-    Log::get(LOG_USER) << "  texture" << Log::endl;
28
-    Log::get(LOG_USER) << "  titlescreen" << Log::endl;
29
-
30
-}
31
-
32
-int CommandMode::execute(std::istream& args) {
33
-    std::string s;
34
-    args >> s;
35
-
36
-    if (s == "wireframe") {
37
-        Render::setMode(RenderMode::Wireframe);
38
-        Log::get(LOG_USER) << "Wireframe mode" << Log::endl;
39
-    } else if (s == "solid") {
40
-        Render::setMode(RenderMode::Solid);
41
-        Log::get(LOG_USER) << "Solid mode" << Log::endl;
42
-    } else if (s == "texture") {
43
-        Render::setMode(RenderMode::Texture);
44
-        Log::get(LOG_USER) << "Texture Mode" << Log::endl;
45
-    } else if (s == "titlescreen") {
46
-        Render::setMode(RenderMode::LoadScreen);
47
-        Log::get(LOG_USER) << "Titlescreen mode" << Log::endl;
48
-    } else {
49
-        Log::get(LOG_USER) << "Invalid use of mode command (" << s << ")!" << Log::endl;
50
-        return -2;
51
-    }
52
-
53
-    return 0;
54
-}
55
-

+ 18
- 23
src/loader/LoaderTR2.cpp ファイルの表示

@@ -396,7 +396,7 @@ void LoaderTR2::loadRooms() {
396 396
         BoundingBox* boundingbox = new BoundingBox(bbox[0], bbox[1]);
397 397
         RoomMesh* mesh = new RoomMesh(vertices, rectangles, triangles);
398 398
         Room* room = new Room(pos, boundingbox, mesh, roomFlags, alternateRoom,
399
-                              numXSectors, numZSectors);
399
+                              numXSectors, numZSectors, i);
400 400
 
401 401
         for (auto p : portals)
402 402
             room->addPortal(p);
@@ -916,28 +916,23 @@ void LoaderTR2::loadItems() {
916 916
         // 0x3E00 - Activation mask, open, can be XORed with related FloorData list fields.
917 917
         uint16_t flags = file.readU16();
918 918
 
919
-        // TODO for now we're only creating Entities for each Moveable Item
920
-        for (int m = 0; m < getWorld().sizeSkeletalModel(); m++) {
921
-            if (getWorld().getSkeletalModel(m).getId() == objectID) {
922
-                float pos[3] = {
923
-                    static_cast<float>(x),
924
-                    static_cast<float>(y),
925
-                    static_cast<float>(z)
926
-                };
927
-
928
-                float rot[3] = {
929
-                    0.0f,
930
-                    glm::radians(((angle >> 14) & 0x03) * 90.0f),
931
-                    0.0f
932
-                };
933
-
934
-                Entity* e = new Entity(pos, rot, objectID, room, m);
935
-                getWorld().addEntity(e);
936
-
937
-                if (objectID == 0) {
938
-                    Game::setLara(getWorld().sizeEntity() - 1);
939
-                }
940
-            }
919
+        glm::vec3 pos(
920
+            static_cast<float>(x),
921
+            static_cast<float>(y),
922
+            static_cast<float>(z)
923
+        );
924
+
925
+        glm::vec3 rot(
926
+            0.0f,
927
+            glm::radians(((angle >> 14) & 0x03) * 90.0f),
928
+            0.0f
929
+        );
930
+
931
+        Entity* e = new Entity(objectID, room, pos, rot);
932
+        getWorld().addEntity(e);
933
+
934
+        if (objectID == 0) {
935
+            Game::setLara(getWorld().sizeEntity() - 1);
941 936
         }
942 937
     }
943 938
 

読み込み中…
キャンセル
保存