Browse Source

Removed Emitter and Particle

Thomas Buck 10 years ago
parent
commit
e898b03a05
15 changed files with 39 additions and 883 deletions
  1. 0
    1
      CMakeLists.txt
  2. 12
    0
      ChangeLog
  3. BIN
      data/snow.tga
  4. BIN
      data/snow2.tga
  5. 2
    2
      include/Camera.h
  6. 0
    179
      include/Emitter.h
  7. 0
    119
      include/Particle.h
  8. 15
    38
      include/Render.h
  9. 1
    4
      src/CMakeLists.txt
  10. 1
    2
      src/Camera.cpp
  11. 0
    243
      src/Emitter.cpp
  12. 4
    1
      src/Menu.cpp
  13. 0
    17
      src/OpenRaider.cpp
  14. 0
    162
      src/Particle.cpp
  15. 4
    115
      src/Render.cpp

+ 0
- 1
CMakeLists.txt View File

@@ -41,7 +41,6 @@ set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
41 41
 
42 42
 # Flags for all builds
43 43
 set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11 ${WARNINGS}")
44
-set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_EMITTER")
45 44
 
46 45
 # Flags for Debug build
47 46
 set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")

+ 12
- 0
ChangeLog View File

@@ -5,6 +5,18 @@
5 5
 
6 6
  OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140405 ]
9
+	* "Ported" all commands from old source
10
+	* Slimmed down Camera considerably
11
+	* Removed Emitter & Particle
12
+
13
+	[ 20140403 ]
14
+	* Now using "service locator" pattern for global singleton objects:
15
+	  http://gameprogrammingpatterns.com/service-locator.html
16
+	* Made abstract sound interface to provide different implementations
17
+	  in the future (eg. for Windows)
18
+	* "Backported" more commands from old source
19
+
8 20
 	[ 20140330 ]
9 21
 	* Fixed some segfaults relating to missing upper-bound-checks
10 22
 	  while accessing std::vectors in World/Render

BIN
data/snow.tga View File


BIN
data/snow2.tga View File


+ 2
- 2
include/Camera.h View File

@@ -1,6 +1,6 @@
1 1
 /*!
2 2
  * \file include/Camera.h
3
- * \brief OpenGL camera class
3
+ * \brief Camera class
4 4
  *
5 5
  * \author Mongoose
6 6
  * \author xythobuz
@@ -23,7 +23,7 @@ enum camera_command {
23 23
 };
24 24
 
25 25
 /*!
26
- * \brief OpenGL camera class
26
+ * \brief Camera class
27 27
  */
28 28
 class Camera {
29 29
 public:

+ 0
- 179
include/Emitter.h View File

@@ -1,179 +0,0 @@
1
-/*!
2
- * \file include/Emitter.h
3
- * \brief Particle emitter class.
4
- *
5
- * \author Mongoose
6
- */
7
-
8
-#ifndef _EMITTER_H_
9
-#define _EMITTER_H_
10
-
11
-#include "Particle.h"
12
-
13
-/*!
14
- * \brief Particle emitter class.
15
- */
16
-class Emitter {
17
-public:
18
-
19
-    /*!
20
-     * \brief Flags an Emitter can have
21
-     */
22
-    typedef enum {
23
-        fUseFrustumCulling = (1 << 0), //!< Use frustum culling
24
-        fUseDepthSorting   = (1 << 1)  //!< Use depth sorting
25
-    } EmitterFlags;
26
-
27
-
28
-    /*!
29
-     * \brief Constructs an object of Emitter
30
-     * \param name valid C string
31
-     * \param n greater than 0
32
-     */
33
-    Emitter(const char *name, int n);
34
-
35
-    /*!
36
-     * \brief Deconstructs an object of Emitter
37
-     */
38
-    ~Emitter();
39
-
40
-    /*!
41
-     * \brief Get the particles
42
-     * \returns array of Particles
43
-     */
44
-    Particle *Particles();
45
-
46
-    /*!
47
-     * \brief Number of particles emitted
48
-     * \returns Number of particles emitted
49
-     */
50
-    int Count();
51
-
52
-    /*!
53
-     * \brief Sets position of emitter in 3D space
54
-     * \param x X coordinate
55
-     * \param y Y coordinate
56
-     * \param z Z coordinate
57
-     */
58
-    void Pos(float x, float y, float z);
59
-
60
-    /*!
61
-     * \brief Returns position of emitter in 3D space
62
-     * \param x Where X coordinate will be stored
63
-     * \param y Where Y coordinate will be stored
64
-     * \param z Where Z coordinate will be stored
65
-     */
66
-    void Pos(float *x, float *y, float *z);
67
-
68
-    /*!
69
-     * \brief Sets orientation of emitter in 3D space
70
-     * \param x X coordinate
71
-     * \param y Y coordinate
72
-     * \param z Z coordinate
73
-     */
74
-    void Orientation(float x, float y, float z);
75
-
76
-    /*!
77
-     * \brief Returns orientation of emitter in 3D space
78
-     * \param x Where X coordinate will be stored
79
-     * \param y Where Y coordinate will be stored
80
-     * \param z Where Z coordinate will be stored
81
-     */
82
-    void Orientation(float *x, float *y, float *z);
83
-
84
-    /*!
85
-     * \brief Get the flags of this Emitter
86
-     * \returns EmitterFlags
87
-     */
88
-    unsigned int Flags();
89
-
90
-    /*!
91
-     * \brief Set or Unset a flag
92
-     * \param flag EmitterFlag to change
93
-     * \param op new state (true - set)
94
-     */
95
-    void Flags(unsigned int flag, bool op);
96
-
97
-    /*!
98
-     * \brief Allocates the particle array and sets the count.
99
-     * If the array has been allocated previously it will be
100
-     * deallocated and a new one made.
101
-     * \param n new size, greater than 0
102
-     */
103
-    void ParticleArray(int n);
104
-
105
-    /*!
106
-     * \brief Renders the particles
107
-     */
108
-    void Draw();
109
-
110
-    /*!
111
-     * \brief Sets the emitters name
112
-     * \param name is a valid C string
113
-     */
114
-    void Name(const char *name);
115
-
116
-    /*!
117
-     * \brief Resets all particle texture ids
118
-     * \param id new id
119
-     * \sa Particle::TextureId()
120
-     */
121
-    void SetTextureId(int id);
122
-
123
-    /*!
124
-     * \brief Set the texture id for a range of particles in the array
125
-     * \param particle_start start of range
126
-     * \param particle_end end of range
127
-     * \param id new id
128
-     * \sa Particle::TextureId()
129
-     */
130
-    void TextureId(unsigned int particle_start, unsigned int particle_end, int id);
131
-
132
-    /*!
133
-     * \brief Set the color of a range of particles in the array
134
-     * \param particle_start start of range
135
-     * \param particle_end end of range
136
-     * \param r new red part of color (0.0 to 1.0)
137
-     * \param g new green part of color (0.0 to 1.0)
138
-     * \param b new blue part of color (0.0 to 1.0)
139
-     * \sa Particle::Color()
140
-     */
141
-    void Color(unsigned int particle_start, unsigned int particle_end, float r, float g, float b);
142
-
143
-    /*!
144
-     * \brief Set the speed of a range of particles in the array.
145
-     * Take note that the speed starts out at 2000, and lower means faster.
146
-     * \param particle_start start of range
147
-     * \param particle_end end of range
148
-     * \param x X speed
149
-     * \param y Y speed
150
-     * \param z Z speed
151
-     * \sa Particle::Speed
152
-     */
153
-    void Speed(unsigned int particle_start, unsigned int particle_end, float x, float y, float z);
154
-
155
-    /*!
156
-     * \brief Let a force (eg. Gravity) act on a range of particles in the array
157
-     * \param particle_start start of range
158
-     * \param particle_end end of range
159
-     * \param x X force
160
-     * \param y Y force
161
-     * \param z Z force
162
-     * \sa Particle::Force()
163
-     */
164
-    void Force(unsigned int particle_start, unsigned int particle_end, float x, float y, float z);
165
-
166
-    static vec_t mFrustum[6][4]; //!< View Volume copy
167
-
168
-private:
169
-    static int compareParticleDist(const void *voidA, const void *voidB);
170
-
171
-    char *_name;         //!< Emitter name
172
-    unsigned int _flags; //!< Emitter flags
173
-    vec3_t _pos;         //!< Position in 3D space
174
-    vec3_t _mangle;      //!< Oreintation in 3D space
175
-    Particle *_particle; //!< Array of particles
176
-    unsigned int _count; //!< Particle count
177
-};
178
-
179
-#endif

+ 0
- 119
include/Particle.h View File

@@ -1,119 +0,0 @@
1
-/*!
2
- * \file include/Particle.h
3
- * \brief Particle system base header
4
- *
5
- * \author Mongoose
6
- */
7
-
8
-#ifndef _PARTICLE_H_
9
-#define _PARTICLE_H_
10
-
11
-#include "math/math.h"
12
-
13
-/*!
14
- * \brief Partcle systems atomic base
15
- */
16
-class Particle {
17
-public:
18
-
19
-    /*!
20
-     * \brief Constructs an object of Sound
21
-     */
22
-    Particle();
23
-
24
-    /*!
25
-     * \brief Toggles active state of particle
26
-     * \param active new state
27
-     */
28
-    void setActive(bool active);
29
-
30
-    /*!
31
-     * \brief Sets gravity/force acting on particle
32
-     * \param x X part of force vector
33
-     * \param y Y part
34
-     * \param z Z part
35
-     */
36
-    void Force(float x, float y, float z);
37
-
38
-    /*!
39
-     * \brief Resets particle to defaults
40
-     */
41
-    void Reset();
42
-
43
-    /*!
44
-     * \brief Sets gravity/force acting on particle
45
-     * \note speed inits at 2000, lower is faster
46
-     * \param x X part of speed vector
47
-     * \param y Y part
48
-     * \param z Z part
49
-     */
50
-    void Speed(float x, float y, float z);
51
-
52
-    /*!
53
-     * \brief Sets new particle coloring
54
-     * \note White {1.0, 1.0, 1.0} is the init color
55
-     * \param r Red part, from 0.0 to 1.0
56
-     * \param g Green part, from 0.0 to 1.0
57
-     * \param b Blue part, from 0.0 to 1.0
58
-     */
59
-    void Color(float r, float g, float b);
60
-
61
-    /*!
62
-     * \brief Returns position of particle in 3 space
63
-     * \param x not NULL!
64
-     * \param y not NULL!
65
-     * \param z not NULL!
66
-     */
67
-    void Pos(float *x, float *y, float *z);
68
-
69
-    /*!
70
-     * \brief Returns current color of particle
71
-     * \param r not NULL!
72
-     * \param g not NULL!
73
-     * \param b not NULL!
74
-     */
75
-    void Color(float *r, float *g, float *b);
76
-
77
-    /*!
78
-     * \brief Returns current life (blend) of particle
79
-     * \returns fade of particle
80
-     */
81
-    float Life();
82
-
83
-    /*!
84
-     * \brief Adjusts for particle life cycle
85
-     */
86
-    void Update();
87
-
88
-    /*!
89
-     * \brief Returns texture binding for this particle
90
-     * \returns texture id
91
-     */
92
-    int Texture();
93
-
94
-    /*!
95
-     * \brief Returns active value
96
-     * \returns state
97
-     */
98
-    bool isActive();
99
-
100
-    /*!
101
-     * \brief Set the texture for this particle
102
-     * \param t new texture id
103
-     */
104
-    void TextureId(int t);
105
-
106
-
107
-private:
108
-    bool _active;  //!< Is this particle in use?
109
-    float _life;   //!< Life of particle
110
-    float _blend;  //!< Blend amount or fade
111
-    int _texture;  //!< Texture polygon to use
112
-    vec3_t _pos;   //!< Current position in 3 space
113
-    vec3_t _color; //!< Current color
114
-    vec3_t _dir;   //!< Current direction
115
-    vec3_t _force; //!< Current force or 'gravity'
116
-    vec3_t _speed; //!< Speed of particle movement
117
-};
118
-
119
-#endif

+ 15
- 38
include/Render.h View File

@@ -20,10 +20,6 @@
20 20
 #include "Texture.h"
21 21
 #include "Camera.h"
22 22
 
23
-#ifdef USING_EMITTER
24
-#include "Emitter.h"
25
-#endif
26
-
27 23
 /*!
28 24
  * \brief The GL light class
29 25
  */
@@ -96,22 +92,21 @@ public:
96 92
     } RenderMode;
97 93
 
98 94
     typedef enum {
99
-        fParticles              = (1 << 0),
100
-        fPortals                = (1 << 1),
101
-        fRoomAlpha              = (1 << 2),
102
-        fViewModel              = (1 << 3),
103
-        fSprites                = (1 << 4),
104
-        fRoomModels             = (1 << 5),
105
-        fEntityModels           = (1 << 6),
106
-        fFog                    = (1 << 7),
107
-        fUsePortals             = (1 << 8),
108
-        fGL_Lights              = (1 << 9),
109
-        fOneRoom                = (1 << 10),
110
-        fRenderPonytail         = (1 << 11),
111
-        // fMultiTexture           = (1 << 12), //! \todo Whats up with Multitexture stuff? Where is it needed?
112
-        fUpdateRoomListPerFrame = (1 << 13),
113
-        fAnimateAllModels       = (1 << 14),
114
-        fAllRooms               = (1 << 15)
95
+        fPortals                = (1 << 0),
96
+        fRoomAlpha              = (1 << 1),
97
+        fViewModel              = (1 << 2),
98
+        fSprites                = (1 << 3),
99
+        fRoomModels             = (1 << 4),
100
+        fEntityModels           = (1 << 5),
101
+        fFog                    = (1 << 6),
102
+        fUsePortals             = (1 << 7),
103
+        fGL_Lights              = (1 << 8),
104
+        fOneRoom                = (1 << 9),
105
+        fRenderPonytail         = (1 << 10),
106
+        // fMultiTexture           = (1 << 11), //! \todo Whats up with Multitexture stuff? Where is it needed?
107
+        fUpdateRoomListPerFrame = (1 << 12),
108
+        fAnimateAllModels       = (1 << 13),
109
+        fAllRooms               = (1 << 14)
115 110
     } RenderFlags;
116 111
 
117 112
     typedef enum {
@@ -167,20 +162,6 @@ public:
167 162
                             unsigned int *nextId);
168 163
 
169 164
     /*!
170
-     * \brief Initializes Emitter.
171
-     *
172
-     * Emitter is set up for rendering with 2 textures in
173
-     * a overhead rain or snow like pattern.
174
-     * Textures have to be initialized!
175
-     * \param name valid C-String name
176
-     * \param size valid size
177
-     * \param snowTex1 valid first texture
178
-     * \param snowTex2 valid second texture
179
-     */
180
-    void initEmitter(const char *name, unsigned int size,
181
-                          unsigned int snowTex1, unsigned int snowTex2);
182
-
183
-    /*!
184 165
      * Removes current world/entity/etc geometry
185 166
      */
186 167
     void ClearWorld();
@@ -342,10 +323,6 @@ private:
342 323
     int mLock;
343 324
     int mSkyMesh;                         //!< Skymesh model id
344 325
     bool mSkyMeshRotation;                //!< Should Skymesh be rotated?
345
-
346
-#ifdef USING_EMITTER
347
-    Emitter *mEmitter;                    //!< Particle emitter test
348
-#endif
349 326
 };
350 327
 
351 328
 #endif

+ 1
- 4
src/CMakeLists.txt View File

@@ -33,13 +33,11 @@ set (LIBS ${LIBS} ${ZLIB_LIBRARIES})
33 33
 # Set Source files
34 34
 set (SRCS ${SRCS} "Camera.cpp")
35 35
 set (SRCS ${SRCS} "Console.cpp")
36
-set (SRCS ${SRCS} "Emitter.cpp")
37 36
 set (SRCS ${SRCS} "Game.cpp")
38 37
 set (SRCS ${SRCS} "main.cpp")
39 38
 set (SRCS ${SRCS} "Menu.cpp")
40 39
 set (SRCS ${SRCS} "Mesh.cpp")
41 40
 set (SRCS ${SRCS} "OpenRaider.cpp")
42
-set (SRCS ${SRCS} "Particle.cpp")
43 41
 set (SRCS ${SRCS} "Render.cpp")
44 42
 set (SRCS ${SRCS} "SkeletalModel.cpp")
45 43
 set (SRCS ${SRCS} "Sound.cpp")
@@ -93,8 +91,7 @@ if (APPLE)
93 91
     set (SRCS ${SRCS} ${MAC_ICON})
94 92
 
95 93
     # Copy Data
96
-    set (MAC_DATA "../data/OpenRaider.ini" "../data/test.ttf")
97
-    set (MAC_DATA ${MAC_DATA} "../data/snow.tga" "../data/snow2.tga" "../data/splash.tga")
94
+    set (MAC_DATA "../data/OpenRaider.ini" "../data/test.ttf" "../data/splash.tga")
98 95
     set_source_files_properties (${MAC_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/defaults)
99 96
     set (SRCS ${SRCS} ${MAC_DATA})
100 97
 endif (APPLE)

+ 1
- 2
src/Camera.cpp View File

@@ -1,6 +1,6 @@
1 1
 /*!
2 2
  * \file src/Camera.cpp
3
- * \brief OpenGL camera class
3
+ * \brief Camera class
4 4
  *
5 5
  * \author Mongoose
6 6
  * \author xythobuz
@@ -9,7 +9,6 @@
9 9
 #include <stdio.h>
10 10
 #include <math.h>
11 11
 
12
-#include "main.h"
13 12
 #include "Camera.h"
14 13
 
15 14
 Camera::Camera() {

+ 0
- 243
src/Emitter.cpp View File

@@ -1,243 +0,0 @@
1
-/*!
2
- * \file src/Emitter.cpp
3
- * \brief Particle emitter class.
4
- *
5
- * \author Mongoose
6
- */
7
-
8
-#include <stdlib.h>
9
-#include <string.h>
10
-#include <stdio.h>
11
-
12
-#ifdef __APPLE__
13
-#include <OpenGL/gl.h>
14
-#else
15
-#include <GL/gl.h>
16
-#endif
17
-
18
-#include "Emitter.h"
19
-
20
-vec_t Emitter::mFrustum[6][4];
21
-
22
-int Emitter::compareParticleDist(const void *voidA, const void *voidB) {
23
-    Particle *a = const_cast<Particle *>(static_cast<const Particle *>(voidA));
24
-    Particle *b = const_cast<Particle *>(static_cast<const Particle *>(voidB));
25
-    float x, y, z, distA, distB;
26
-
27
-    if (!a || !b)
28
-        return -1; // error really
29
-
30
-    a->Pos(&x, &y, &z);
31
-    distA = (Emitter::mFrustum[5][0] * x +
32
-            Emitter::mFrustum[5][1] * y +
33
-            Emitter::mFrustum[5][2] * z +
34
-            Emitter::mFrustum[5][3]);
35
-
36
-    b->Pos(&x, &y, &z);
37
-    distB = (Emitter::mFrustum[5][0] * x +
38
-            Emitter::mFrustum[5][1] * y +
39
-            Emitter::mFrustum[5][2] * z +
40
-            Emitter::mFrustum[5][3]);
41
-
42
-    // reverse less/greater than
43
-    // less than
44
-    if (distA > distB)
45
-        return -1;
46
-
47
-    // greater than ( no need for equal )
48
-    return 1;
49
-}
50
-
51
-Emitter::Emitter(const char *name, int n) {
52
-    _name = NULL;
53
-    _flags = 0;
54
-    _particle = NULL;
55
-    _count = 0;
56
-    _pos[0] = _pos[1] = _pos[2] = 0.0;
57
-    _mangle[0] = _mangle[1] = _mangle[2] = 0.0;
58
-
59
-    Name(name);
60
-    ParticleArray(n);
61
-}
62
-
63
-Emitter::~Emitter() {
64
-    if (_name)
65
-        delete [] _name;
66
-
67
-    if (_particle)
68
-        delete [] _particle;
69
-
70
-    _count = 0;
71
-}
72
-
73
-Particle *Emitter::Particles() {
74
-    return _particle;
75
-}
76
-
77
-
78
-int Emitter::Count() {
79
-    return _count;
80
-}
81
-
82
-void Emitter::Pos(float *x, float *y, float *z) {
83
-    *x = _pos[0];
84
-    *y = _pos[1];
85
-    *z = _pos[2];
86
-}
87
-
88
-void Emitter::Pos(float x, float y, float z) {
89
-    _pos[0] = x;
90
-    _pos[1] = y;
91
-    _pos[2] = z;
92
-}
93
-
94
-void Emitter::Orientation(float *x, float *y, float *z) {
95
-    *x = _mangle[0];
96
-    *y = _mangle[1];
97
-    *z = _mangle[2];
98
-}
99
-
100
-void Emitter::Orientation(float x, float y, float z) {
101
-    _mangle[0] = x;
102
-    _mangle[1] = y;
103
-    _mangle[2] = z;
104
-}
105
-
106
-unsigned int Emitter::Flags() {
107
-    return _flags;
108
-}
109
-
110
-void Emitter::Flags(unsigned int flag, bool op) {
111
-    _flags |= flag;
112
-
113
-    if (!op)
114
-        _flags ^= flag;
115
-}
116
-
117
-void Emitter::ParticleArray(int n) {
118
-    if (n) {
119
-        if (_particle) {
120
-            _count = 0;
121
-            delete [] _particle;
122
-        }
123
-
124
-        _count = n;
125
-        _particle = new Particle[_count];
126
-    }
127
-}
128
-
129
-void Emitter::Name(const char *name) {
130
-    if (name && name[0]) {
131
-        if (_name)
132
-            delete [] _name;
133
-
134
-        int l = strlen(name);
135
-        _name = new char[l+1];
136
-
137
-        // Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
138
-        strncpy(_name, name, l);
139
-        _name[l] = 0;
140
-    }
141
-}
142
-
143
-void Emitter::SetTextureId(int id) {
144
-    for (unsigned int i = 0; i < _count; i++)
145
-        _particle[i].TextureId(id);
146
-}
147
-
148
-void Emitter::TextureId(unsigned int particle_start, unsigned int particle_end, int id) {
149
-    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
150
-        for (unsigned int i = particle_start; i < particle_end; i++)
151
-            _particle[i].TextureId(id);
152
-    }
153
-}
154
-
155
-void Emitter::Color(unsigned int particle_start, unsigned int particle_end, float r, float g, float b) {
156
-    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
157
-        for (unsigned int i = particle_start; i < particle_end; i++)
158
-            _particle[i].Color(r, g, b);
159
-    }
160
-}
161
-
162
-void Emitter::Speed(unsigned int particle_start, unsigned int particle_end, float x, float y, float z) {
163
-    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
164
-        for (unsigned int i = particle_start; i < particle_end; i++)
165
-            _particle[i].Speed(x, y, z);
166
-    }
167
-}
168
-
169
-void Emitter::Force(unsigned int particle_start, unsigned int particle_end, float x, float y, float z) {
170
-    if ((particle_start < _count) && (particle_end > 0 && particle_end <= _count) && (particle_start < particle_end)) {
171
-        for (unsigned int i = particle_start; i < particle_end; i++)
172
-            _particle[i].Force(x, y, z);
173
-    }
174
-}
175
-
176
-void Emitter::Draw() {
177
-    unsigned int i, p;
178
-    float x, y, z;
179
-    float r, g, b;
180
-    float life;
181
-
182
-    if (!_count || !_particle) {
183
-        printf("Emitter::Draw> No particles!\n");
184
-        return;
185
-    }
186
-
187
-    glPushMatrix();
188
-
189
-    //glRotatef(_mangle[0], 1.0, 0.0, 0.0);
190
-    //glRotatef(_mangle[1], 0.0, 1.0, 0.0);
191
-    //glRotatef(_mangle[2], 0.0, 0.0, 1.0);
192
-    //glTranslatef(_pos[0], _pos[1], _pos[2]);
193
-
194
-    if (_flags & fUseDepthSorting)
195
-        qsort(_particle, _count, sizeof(Particle), compareParticleDist);
196
-
197
-    for (i = 0; i < _count; i++) {
198
-        if (_particle[i].isActive()) {
199
-            _particle[i].Pos(&x, &y, &z);
200
-
201
-            if (_flags & fUseFrustumCulling) {
202
-                for (p = 0; p < 6; ++p) {
203
-                    if (((mFrustum[p][0] * x) + (mFrustum[p][1] * y) + (mFrustum[p][2] * z) + mFrustum[p][3]) < 0) {
204
-                        _particle[i].setActive(false);
205
-                        break;
206
-                    }
207
-                }
208
-
209
-                if (!_particle[i].isActive())
210
-                    continue;
211
-            }
212
-
213
-            _particle[i].Color(&r, &g, &b);
214
-            life = _particle[i].Life();
215
-
216
-            // Mongoose 2002.01.01, Removed Texture agent dep
217
-            glBindTexture(GL_TEXTURE_2D, _particle[i].Texture());
218
-
219
-            // Alpha is determined by life, which is affected by blend amount
220
-            glColor4f(r, g, b, life);
221
-
222
-            // Render tristrip quad
223
-            glBegin(GL_TRIANGLE_STRIP);
224
-            glTexCoord2d(1.0, 1.0);
225
-            glVertex3f(x + 0.5f, y + 0.5f, z);
226
-
227
-            glTexCoord2d(0.0, 1.0);
228
-            glVertex3f(x - 0.5f, y + 0.5f, z);
229
-
230
-            glTexCoord2d(1.0, 0.0);
231
-            glVertex3f(x + 0.5f, y - 0.5f, z);
232
-
233
-            glTexCoord2d(0.0, 0.0);
234
-            glVertex3f(x - 0.5f, y - 0.5f, z);
235
-            glEnd();
236
-
237
-            // Update particle's attributes for it's life cycle
238
-            _particle[i].Update();
239
-        }
240
-    }
241
-
242
-    glPopMatrix();
243
-}

+ 4
- 1
src/Menu.cpp View File

@@ -140,8 +140,11 @@ void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
140 140
             handleKeyboard(up, true);
141 141
     } else if (key == enter) {
142 142
         char *tmp = bufferString("load %s", getOpenRaider().mMapList[mCursor]);
143
-        if (getOpenRaider().command(tmp) == 0)
143
+        if (getOpenRaider().command(tmp) == 0) {
144 144
             setVisible(false);
145
+        } else {
146
+            //! \todo Display something if an error occurs
147
+        }
145 148
         delete [] tmp;
146 149
     }
147 150
 }

+ 0
- 17
src/OpenRaider.cpp View File

@@ -458,22 +458,6 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
458 458
             getConsole().print("Invalid use of upf-command!");
459 459
             return -31;
460 460
         }
461
-    } else if (strcmp(command, "particle") == 0) {
462
-        if (args->size() > 0) {
463
-            bool b;
464
-            if (readBool(args->at(0), &b) < 0) {
465
-                getConsole().print("Pass BOOL to particle command!");
466
-                return -32;
467
-            }
468
-            if (b)
469
-                getRender().setFlags(Render::fParticles);
470
-            else
471
-                getRender().clearFlags(Render::fParticles);
472
-            getConsole().print("Particles are now %s", b ? "on" : "off");
473
-        } else {
474
-            getConsole().print("Invalid use of particle-command!");
475
-            return -33;
476
-        }
477 461
     } else if (strcmp(command, "sprite") == 0) {
478 462
         if (args->size() > 0) {
479 463
             bool b;
@@ -631,7 +615,6 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
631 615
             getConsole().print("  portal    - BOOL");
632 616
             getConsole().print("  vis       - BOOL - Use Portals");
633 617
             getConsole().print("  upf       - BOOL - Update Room List Per Frame");
634
-            getConsole().print("  particle  - BOOL");
635 618
             getConsole().print("  sprite    - BOOL");
636 619
             getConsole().print("  roommodel - BOOL");
637 620
             getConsole().print("  entmodel  - BOOL");

+ 0
- 162
src/Particle.cpp View File

@@ -1,162 +0,0 @@
1
-/*!
2
- * \file src/Particle.cpp
3
- * \brief Particle system base implementation
4
- *
5
- * \author Mongoose
6
- */
7
-
8
-#include <stdlib.h>
9
-#include <stdio.h>
10
-#include <assert.h>
11
-
12
-#include "Particle.h"
13
-
14
-Particle::Particle()
15
-{
16
-    setActive(true);
17
-    TextureId(0);
18
-    Speed(2000.0f, 2000.0f, 2000.0f);
19
-    Color(1.0f, 1.0f, 1.0f);
20
-    Force(0.0f, 0.8f, 0.0f);
21
-
22
-    Reset();
23
-}
24
-
25
-
26
-void Particle::TextureId(int id)
27
-{
28
-    _texture = id;
29
-}
30
-
31
-
32
-void Particle::setActive(bool active)
33
-{
34
-    _active = active;
35
-}
36
-
37
-
38
-void Particle::Speed(float x, float y, float z)
39
-{
40
-    _speed[0] = x;
41
-    _speed[1] = y;
42
-    _speed[2] = z;
43
-}
44
-
45
-
46
-void Particle::Color(float r, float g, float b)
47
-{
48
-    _color[0] = r;
49
-    _color[1] = g;
50
-    _color[2] = b;
51
-}
52
-
53
-
54
-void Particle::Force(float x, float y, float z)
55
-{
56
-    _force[0] = x;
57
-    _force[1] = y;
58
-    _force[2] = z;
59
-}
60
-
61
-
62
-void Particle::Reset()
63
-{
64
-    // Mongoose 2002.01.01, Ah, how old is that code?
65
-#ifdef OBSOLETE
66
-    _active = true;
67
-    _life = 1.0;
68
-    _blend = (float)(rand() % 100) / 1000.0 + 0.003;
69
-
70
-    _pos[0] = _pos[1] = _pos[2] = 0.0;
71
-
72
-    _dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
73
-    _dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
74
-    _dir[2] = _dir[1];
75
-
76
-    _force[0] = 0.0;
77
-    _force[1] = -0.8;
78
-    _force[2] = 0.0;
79
-#else
80
-    //! \fixme _blend prob should have nonstatic range
81
-    _blend = (float)(0.003 + (0.1 * rand() / (RAND_MAX + 1.0))); // high order
82
-    //_blend = (float)(rand() % 100) / 1000.0 + 0.003;
83
-
84
-    //! \fixme Reset these using some nonstatic functions and values later
85
-    _life = 1.0;
86
-
87
-    _pos[0] = _pos[1] = _pos[2] = 0.0;
88
-
89
-    _dir[0] = (float)(-26.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
90
-    _dir[0] *= 10.0;
91
-    //_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
92
-    _dir[1] = (float)(-25.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
93
-    _dir[1] *= 10.0;
94
-    //_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
95
-    _dir[2] = _dir[1];
96
-#endif
97
-}
98
-
99
-
100
-void Particle::Pos(float *x, float *y, float *z)
101
-{
102
-    assert(x != NULL);
103
-    assert(y != NULL);
104
-    assert(z != NULL);
105
-
106
-    *x = _pos[0];
107
-    *y = _pos[1];
108
-    *z = _pos[2];
109
-}
110
-
111
-
112
-void Particle::Color(float *r, float *g, float *b)
113
-{
114
-    assert(r != NULL);
115
-    assert(g != NULL);
116
-    assert(b != NULL);
117
-
118
-    *r = _color[0];
119
-    *g = _color[1];
120
-    *b = _color[2];
121
-}
122
-
123
-
124
-float Particle::Life()
125
-{
126
-    return _life;
127
-}
128
-
129
-
130
-void Particle::Update()
131
-{
132
-    // Adjust particle position
133
-    _pos[0] += _dir[0] / _speed[0];
134
-    _pos[1] += _dir[1] / _speed[1];
135
-    _pos[2] += _dir[2] / _speed[2];
136
-
137
-    // Adjust particle direction
138
-    _dir[0] += _force[0];
139
-    _dir[1] += _force[1];
140
-    _dir[2] += _force[2];
141
-
142
-    // Adjust particle blending/life
143
-    _life -= _blend;
144
-
145
-    // Reset 'dead' OR fully blended particles
146
-    if (_life < 0.0)
147
-    {
148
-        Reset();
149
-    }
150
-}
151
-
152
-
153
-int Particle::Texture()
154
-{
155
-    return _texture;
156
-}
157
-
158
-
159
-bool Particle::isActive()
160
-{
161
-    return _active;
162
-}

+ 4
- 115
src/Render.cpp View File

@@ -18,10 +18,6 @@
18 18
 #include <math.h>
19 19
 #include <string.h>
20 20
 
21
-#ifdef USING_EMITTER
22
-#include "Emitter.h"
23
-#endif
24
-
25 21
 #include "global.h"
26 22
 #include "main.h"
27 23
 #include "Game.h"
@@ -89,15 +85,12 @@ bool compareRoomDist(const void *voidA, const void *voidB)
89 85
 
90 86
 Render::Render()
91 87
 {
92
-#ifdef USING_EMITTER
93
-    mEmitter = 0x0;
94
-#endif
95 88
     mSkyMesh = -1;
96 89
     mSkyMeshRotation = false;
97 90
     mMode = Render::modeDisabled;
98 91
     mLock = 0;
99 92
     mFlags = (fRoomAlpha | fViewModel | fSprites |
100
-            fRoomModels | fEntityModels | // fParticles |
93
+            fRoomModels | fEntityModels |
101 94
             fUsePortals | fUpdateRoomListPerFrame);
102 95
 
103 96
     mNextTextureId = NULL;
@@ -148,8 +141,7 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
148 141
         unsigned int *nextId)
149 142
 {
150 143
     char filename[128];
151
-    int snow1_id;
152
-    int snow2_id;
144
+    int bg;
153 145
     unsigned int numTextures = 0;
154 146
     unsigned char color[4];
155 147
 
@@ -176,62 +168,17 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
176 168
     snprintf(filename, 126, "%s/%s", textureDir, "splash.tga");
177 169
     filename[127] = 0;
178 170
 
179
-    if (mTexture.loadTGA(filename) > -1)
180
-        numTextures++;
181
-
182
-    snprintf(filename, 126, "%s/%s", textureDir, "snow.tga");
183
-    filename[127] = 0;
184
-
185
-    if ((snow1_id = mTexture.loadTGA(filename)) > -1)
186
-        numTextures++;
187
-
188
-    snprintf(filename, 126, "%s/%s", textureDir, "snow2.tga");
189
-    filename[127] = 0;
190
-
191
-    if ((snow2_id = mTexture.loadTGA(filename)) > -1)
171
+    if ((bg = mTexture.loadTGA(filename)) > -1)
192 172
         numTextures++;
193 173
 
194 174
     // Weird that it isn't linear, must be some storage deal in Texture
195 175
     // I forgot about Id allocation
196
-    *nextId = snow2_id;
197
-
198
-    // Setup particle system test
199
-    initEmitter("Snow test", 650, snow1_id, snow2_id);
176
+    *nextId = bg;
200 177
 
201 178
     *numLoaded = numTextures;
202 179
 }
203 180
 
204 181
 
205
-void Render::initEmitter(const char *name, unsigned int size,
206
-        unsigned int snowTex1, unsigned int snowTex2)
207
-{
208
-#ifdef USING_EMITTER
209
-    if (mEmitter)
210
-        delete mEmitter; // Public, so avoid possible leak
211
-
212
-    // Mongoose 2002.01.01, Screwing around with particle emitter test
213
-    //   note this is backwards b/c load screen is rendered upsidedown
214
-    //mEmitter = new Emitter(/*name*/"snow", size);
215
-    mEmitter = new Emitter(name, size);
216
-    mEmitter->SetTextureId(snowTex1 + 2); //! \fixme What's up with this +2 offset?
217
-    mEmitter->TextureId(120, 280, snowTex2 + 2);
218
-    mEmitter->TextureId(400, 450, snowTex2 + 2);
219
-    mEmitter->TextureId(500, 550, snowTex2 + 2);
220
-
221
-    // Mongoose 2002.01.01, Varing force and speed should look
222
-    //   like varing mass/SA in wind, maybe
223
-    mEmitter->Speed(0, 150, 3500, 3000, 3500);
224
-    mEmitter->Speed(150, 350, 3000, 4000, 3000);
225
-    mEmitter->Speed(400, 500, 2000, 5000, 2000);
226
-    mEmitter->Speed(400, 500, 2000, 5000, 2000);
227
-    mEmitter->Force(100, 200, 0.0, 7.0, 0.0);
228
-    mEmitter->Force(200, 300, 0.0, 5.0, 0.0);
229
-    mEmitter->Force(300, 500, 0.0, 10.0, 0.0);
230
-    mEmitter->Force(500, 650, 0.0, 9.0, 0.0);
231
-#endif
232
-}
233
-
234
-
235 182
 void Render::ClearWorld()
236 183
 {
237 184
     getGame().mLara = NULL;
@@ -249,14 +196,6 @@ void Render::ClearWorld()
249 196
             delete mModels[i];
250 197
     }
251 198
     mModels.clear();
252
-
253
-#ifdef USING_EMITTER
254
-    if (mEmitter)
255
-    {
256
-        delete mEmitter;
257
-        mEmitter = 0x0;
258
-    }
259
-#endif
260 199
 }
261 200
 
262 201
 
@@ -712,37 +651,9 @@ void Render::display()
712 651
         }
713 652
     }
714 653
 
715
-#ifdef USING_EMITTER_IN_GAME
716
-    // Mongoose 2002.01.01, Test particle prototype in game
717
-    if (EMIT && mFlags & RENDER_F_PARTICLES)
718
-    {
719
-        glBlendFunc(GL_SRC_ALPHA, GL_ONE);
720
-
721
-        glPushMatrix();
722
-        glLoadIdentity();
723
-
724
-        glEnable(GL_BLEND);
725
-        glRotatef(180.0, 1.0, 0.0, 0.0);
726
-        glTranslatef(0.0, -820.0, 575.0);
727
-        glScalef(80.0, 80.0, 80.0);
728
-
729
-        EMIT->Draw();
730
-
731
-        glPopMatrix();
732
-
733
-        // Mongoose 2002.03.26, Account for particle system
734
-        //   not using new binds by setting WHITE texture here
735
-        mTexture.bindTextureId(0);
736
-    }
737
-#endif
738
-
739 654
     if (mMode == Render::modeWireframe)
740 655
         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
741 656
 
742
-#ifdef USING_EMITTER
743
-    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
744
-#endif
745
-
746 657
     // Mongoose 2002.01.01, Test matrix ops
747 658
 #ifdef DEBUG_MATRIX
748 659
     if (gl_test_val())
@@ -798,28 +709,6 @@ void Render::drawLoadScreen()
798 709
     if (mFlags & Render::fGL_Lights)
799 710
         glEnable(GL_LIGHTING);
800 711
 
801
-#ifdef USING_EMITTER
802
-    // Mongoose 2002.01.01, Test particle prototype on load screen
803
-    if (mEmitter && mFlags & Render::fParticles)
804
-    {
805
-        glPushMatrix();
806
-        glLoadIdentity();
807
-
808
-        glEnable(GL_BLEND);
809
-        glRotatef(180.0, 1.0, 0.0, 0.0);
810
-        glTranslatef(0.0, -820.0, 575.0);
811
-        glScalef(80.0, 80.0, 80.0);
812
-
813
-        // Update view volume for vising
814
-        updateViewVolume();
815
-        mViewVolume.getFrustum(mEmitter->mFrustum);
816
-        mEmitter->Flags(Emitter::fUseDepthSorting, true);
817
-        mEmitter->Draw();
818
-
819
-        glPopMatrix();
820
-    }
821
-#endif
822
-
823 712
     glFlush();
824 713
 }
825 714
 

Loading…
Cancel
Save