Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
   Copyright (c) 2014 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy of this software
   and associated documentation files (the "Software"), to deal in the Software without restriction,
   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _INPUT_VARIABLES_H_
#define _INPUT_VARIABLES_H_

#include "core.h"
#include "EventHandler.h"
namespace Divide {
    namespace Input {
//////////// Variable classes ////////////////////////////////////////////////////////

class Variable
{
  protected:

    D32 _dInitValue;
    D32 _dValue;

  public:

    Variable(D32 dInitValue) : _dInitValue(dInitValue) { reset(); }

    D32 getValue() const { return _dValue; }

    void reset() { _dValue = _dInitValue; }

    virtual void setValue(D32 dValue) { _dValue = dValue; }

    virtual stringImpl toString() const
    {
      std::ostringstream oss;
      oss << _dValue;
      return stringAlg::toBase(oss.str());
    }

    virtual void update() {};
};

class Constant : public Variable
{
  public:

    Constant(D32 dInitValue) : Variable(dInitValue) {}

    virtual void setValue(D32 dValue) { }
};

class LimitedVariable : public Variable
{
  protected:

    D32 _dMinValue;
    D32 _dMaxValue;

  public:

    LimitedVariable(D32 dInitValue, D32 dMinValue, D32 dMaxValue)
    : _dMinValue(dMinValue), _dMaxValue(dMaxValue), Variable(dInitValue)
    {}

    virtual void setValue(D32 dValue)
    {
      _dValue = dValue;
      if (_dValue > _dMaxValue)
        _dValue = _dMaxValue;
      else if (_dValue < _dMinValue)
        _dValue = _dMinValue;
    }

/*    virtual string toString() const
    {
      ostringstream oss;
      oss << setiosflags(ios_base::right) << setw(4)
          << (I32)(200.0 * getValue()/(_dMaxValue - _dMinValue)); // [-100%, +100%]
      return oss.str();
    }*/
};

class TriangleVariable : public LimitedVariable
{
  protected:

    D32 _dDeltaValue;

  public:

    TriangleVariable(D32 dInitValue, D32 dDeltaValue, D32 dMinValue, D32 dMaxValue)
    : LimitedVariable(dInitValue, dMinValue, dMaxValue), _dDeltaValue(dDeltaValue) {};

    virtual void update()
    {
      D32 dValue = getValue() + _dDeltaValue;
      if (dValue > _dMaxValue)
      {
        dValue = _dMaxValue;
        _dDeltaValue = -_dDeltaValue;
        //cout << "Decreasing variable towards " << _dMinValue << endl;
      }
      else if (dValue < _dMinValue)
      {
        dValue = _dMinValue;
        _dDeltaValue = -_dDeltaValue;
        //cout << "Increasing variable towards " << _dMaxValue << endl;
      }
      setValue(dValue);
      //cout << "TriangleVariable::update : delta=" << _dDeltaValue << ", value=" << dValue << endl;
    }
};

//////////// Variable effect class //////////////////////////////////////////////////////////

typedef hashMapImpl<stringImpl, Variable*> MapVariables;
typedef void (*EffectVariablesApplier)(MapVariables& mapVars, OIS::Effect* pEffect);

class VariableEffect
{
  protected:

    // Effect description
    const char* _pszDesc;

    // The associate OIS effect
    OIS::Effect* _pEffect;

    // The effect variables.
    MapVariables _mapVariables;

    // The effect variables applier function.
    EffectVariablesApplier _pfApplyVariables;

    // True if the effect is currently being played.
    bool _bActive;

  public:

    VariableEffect(const char* pszDesc, OIS::Effect* pEffect,
                   const MapVariables& mapVars, const EffectVariablesApplier pfApplyVars)
    : _pszDesc(pszDesc), _pEffect(pEffect),
      _mapVariables(mapVars), _pfApplyVariables(pfApplyVars), _bActive(false)
    {}

    ~VariableEffect()
    {
      MemoryManager::DELETE( _pEffect );
      MapVariables::iterator iterVars;
      for ( iterVars = _mapVariables.begin(); iterVars != _mapVariables.end(); ++iterVars ) {
          MemoryManager::DELETE( iterVars->second );
      }
    }

    inline void setActive(bool bActive = true) { reset(); _bActive = bActive; }
    inline bool isActive(){  return _bActive; }
    inline OIS::Effect* getFFEffect()  { return _pEffect; }

    const char* getDescription() const { return _pszDesc; }

    void update()
    {
      if (isActive())
      {
        // Update the variables.
        MapVariables::iterator iterVars;
        for (iterVars = _mapVariables.begin(); iterVars != _mapVariables.end(); ++iterVars)
          iterVars->second->update();

        // Apply the updated variable values to the effect.
        _pfApplyVariables(_mapVariables, _pEffect);
      }
    }

    void reset()
    {
      MapVariables::iterator iterVars;
      for (iterVars = _mapVariables.begin(); iterVars != _mapVariables.end(); ++iterVars)
        iterVars->second->reset();
      _pfApplyVariables(_mapVariables, _pEffect);
    }

    stringImpl toString() const
    {
      stringImpl str;
      MapVariables::const_iterator iterVars;
      for (iterVars = _mapVariables.begin(); iterVars != _mapVariables.end(); ++iterVars)
        str += iterVars->first + ":" + iterVars->second->toString() + " ";
      return str;
    }
};

    }; //namespace Input
}; //namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Hardware/Input/Headers/InputVariables.h

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

325 Diff Diff IonutCava picture IonutCava Wed 17 Sep, 2014 20:06:13 +0000

[Ionut]
- Reworked transform system:
— Parent transform chain system moved from Transform class to the PhysicsComponent
— PhysicsComponent now returns all transform values needed both global and local (still needs heavy optimization and caching)

- Reworked SceneGraph node management:
— Proper ref counting of SceneNodes and proper removing of resource (ResourceCache is now empty on destruction, as it should be)
— Removed parent transform tracking as that’s the PhysicsComponent’s responsibility
— Only nodes loaded via the ResourceCache are allowed to be added to the SceneGraph (added proper loaders for Impostors, Sky, etc)

- Optimized some of the math classes (mat4, mat3)

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
171 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 18:15:06 +0000

-Replaced all tabs with spaces [[BR]]

160 Diff Diff k1ngp1n picture k1ngp1n Wed 10 Jul, 2013 17:07:04 +0000

[Ionut] [[BR]]
- Changed licensing from LGPL to the MIT license [[BR]]
— Code can now be used in non-commercial or commercial closed or open source projects [[BR]]

152 Diff Diff k1ngp1n picture k1ngp1n Thu 20 Jun, 2013 14:23:31 +0000

[Ionut] [[BR]]
- New rendering pipeline (experimental and unstable): [[BR]]
— OpenGL 3.x clean context (glLight commands are still used for now, but UBO support is there, but not used yet) [[BR]]
— Custom matrix stacks and UBO based shader data (UBOs cause some link errors on some nVidia cards)[[BR]]
— Multi-threaded texture loading and shader compilation (mt shader compilation disabled for now. needs more tests) [[BR]]
— VAO rendering is self contained (no more enable/disable calls before a draw request) [[BR]]
— Render instance class used for rendering information [[BR]]
[[BR]]
- New unique ID generation base class: GUIDWrapper. Each class that derives from this, gets an application wide unique id on construction [[BR]]
- Added base code for an in-game editor using CEGUI [[BR]]
- Replaced some mutex locks with lockless data structures or atomic data [[BR]]
- CEGUI 0.8.2, FTGL-GL3 and GLIM 0.4 modified to support GLEW_MX if defined [[BR]]
- Dropped VS2008 support [[BR]]
- Networking library, server framework and ReCast files are now projects inside the Divide Framework solution [[BR]]
- New console command “setFov” that modifies the horizontal FoV value in realtime [[BR]]
- New console command “recompileShader” that reparses shader files, recompiles shaders and relinks shader programs who’s names match or contain the argument string [[BR]]
- New debug utility: axis angle drawn in corner of the screen if needed [[BR]]
- More ‘const’-s pasted around the code, more loop performance tweaks (allocations before a loop, tighter loops, etc), more utility member functions added to various classes [[BR]]

146 Diff Diff k1ngp1n picture k1ngp1n Wed 10 Apr, 2013 13:20:15 +0000

[Ionut] [[BR]]
*Final LightBranch updates 2/3 : Main trunk merge and build test (VC90, VC100, gDebugger) [[BR]]
-Merged light branch with trunk [[BR]]
-Deleted light branch [[BR]]

141 k1ngp1n picture k1ngp1n Wed 30 Jan, 2013 19:35:31 +0000

[Ionut] [[BR]]
-Updated to boost 1.52 and CEGUI 0.7.9 [[BR]]
-Updated to PhysX 3.2 [[BR]]
-Updated copyright notices [[BR]]