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
/*
   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 _SCENE_STATE_H_
#define _SCENE_STATE_H_

#include "Managers/Headers/CameraManager.h"
#include "Platform/Audio/Headers/SFXDevice.h"
#include "Platform/Video/Headers/RenderAPIEnums.h"
#include "Platform/Audio/Headers/AudioDescriptor.h"
#include "Core/Resources/Headers/ResourceCache.h"
#include "Core/Headers/Console.h"
#include "Utility/Headers/Localization.h"

///This class contains all the variables that define each scene's "unique"-ness:
///background music, wind information, visibility settings, camera movement,
///BB and Skeleton visibility, fog info, etc

///Fog information (fog is so game specific, that it belongs in SceneState not SceneRenderState

namespace Divide {

struct FogDescriptor{
    F32 _fogDensity;
    vec3<F32> _fogColor;
};

///Contains all the information needed to render the scene: camera position, render state, etc
class SceneRenderState {
public:
    enum GizmoState {
        NO_GIZMO       = toBit(0),
        SCENE_GIZMO    = toBit(1),
        SELECTED_GIZMO = toBit(2),
        ALL_GIZMO      = SCENE_GIZMO | SELECTED_GIZMO
    };
    
    enum ObjectRenderState {
        NO_DRAW           = toBit(0),
        DRAW_OBJECT       = toBit(1),
        DRAW_BOUNDING_BOX = toBit(2),
        DRAW_OBJECT_WITH_BOUNDING_BOX = DRAW_OBJECT | DRAW_BOUNDING_BOX
    };

    SceneRenderState(): _drawBB(false),
                        _drawSkeletons(false),
                        _drawObjects(true),
                        _debugDrawLines(false),
                        _debugDrawTargetLines(false),
                        _cameraMgr(nullptr)
    {
        _gizmoState = NO_GIZMO;
        _objectState = DRAW_OBJECT;
    }

    inline bool drawSkeletons()           const {return  _drawSkeletons;}
    inline void drawSkeletons(bool visibility)  {_drawSkeletons = visibility;}
    inline void drawDebugLines(bool visibility) {_debugDrawLines = visibility;}
    inline void drawDebugTargetLines(bool visibility) {_debugDrawTargetLines = visibility;}
    inline GizmoState gizmoState()      const   { return _gizmoState; }
    inline void gizmoState(GizmoState newState) { _gizmoState = newState; }
    inline ObjectRenderState objectState()       const      { return _objectState; }
    inline void objectState(ObjectRenderState newState)     { _objectState = newState; }
    /// Render skeletons for animated geometry
    inline void toggleSkeletons() {
        D_PRINT_FN(Locale::get("TOGGLE_SCENE_SKELETONS"));
        drawSkeletons(!drawSkeletons()); 
    }

    /// Show/hide bounding boxes and/or objects
    inline void toggleBoundingBoxes(){
        D_PRINT_FN(Locale::get("TOGGLE_SCENE_BOUNDING_BOXES"));
        if (objectState() == NO_DRAW) {
            objectState(DRAW_OBJECT);
        } else if (objectState() == DRAW_OBJECT) {
            objectState(DRAW_OBJECT_WITH_BOUNDING_BOX);
        } else if (objectState() == DRAW_OBJECT_WITH_BOUNDING_BOX) {
            objectState(DRAW_BOUNDING_BOX);
        } else {
            objectState(NO_DRAW);
        }
    }

    /// Show/hide axis gizmos
    inline void toggleAxisLines() {
        D_PRINT_FN(Locale::get("TOGGLE_SCENE_AXIS_GIZMO"));
        if (gizmoState() == NO_GIZMO) {
            gizmoState(SELECTED_GIZMO);
        } else if (gizmoState() == SELECTED_GIZMO) {
            gizmoState(ALL_GIZMO);
        } else if (gizmoState() == ALL_GIZMO) {
            gizmoState(SCENE_GIZMO);
        } else {
            gizmoState(NO_GIZMO);
        }
    }

    inline CameraManager& getCameraMgr()         { return *_cameraMgr;}
    inline       Camera&  getCamera()            { return *_cameraMgr->getActiveCamera(); }
    inline const Camera&  getCameraConst() const { return *_cameraMgr->getActiveCamera(); }
    inline vec2<U16>&     cachedResolution() {return _cachedResolution;}

protected:

    friend class Scene;
    bool _drawBB;
    bool _drawObjects;
    bool _drawSkeletons;
    bool _debugDrawLines;
    bool _debugDrawTargetLines;
    GizmoState _gizmoState;
    ObjectRenderState _objectState;
    CameraManager*  _cameraMgr;
    ///cached resolution
    vec2<U16> _cachedResolution;
};

class SceneState{
public:
    SceneState() :
      _cameraUnderwater(false),
      _cameraUpdated(false),
      _isRunning(false)
    {
        resetMovement();
        _fog._fogColor = vec3<F32>(0.2f, 0.2f, 0.2f);
        _fog._fogDensity = 0.01f;
    }

    virtual ~SceneState()
    {
        for (MusicPlaylist::value_type& it : _backgroundMusic) {
            RemoveResource( it.second );
        }
        _backgroundMusic.clear();
    }

    inline FogDescriptor&    getFogDesc()     {return _fog;}
    inline SceneRenderState& getRenderState() {return _renderState;}

    inline F32& getWindSpeed()                 {return _windSpeed;}
    inline F32& getWindDirX()                  {return _windDirX;}
    inline F32& getWindDirZ()                  {return _windDirZ;}
    inline F32& getGrassVisibility()           {return _grassVisibility;}
    inline F32& getTreeVisibility()               {return _treeVisibility;}
    inline F32& getGeneralVisibility()         {return _generalVisibility;}
    inline F32& getWaterLevel()                {return _waterHeight;}
    inline F32& getWaterDepth()                {return _waterDepth;}
    inline bool getRunningState()        const {return _isRunning;}
    inline void toggleRunningState(bool state) {_isRunning = state;}

    inline void resetMovement() {
        _moveFB = 0;
        _moveLR = 0;
        _angleUD = 0;
        _angleLR = 0;
        _roll = 0;
    }
    F32 _mouseXDelta;
    F32 _mouseYDelta;
    I32 _moveFB;  ///< forward-back move change detected
    I32 _moveLR;  ///< left-right move change detected
    I32 _angleUD; ///< up-down angle change detected
    I32 _angleLR; ///< left-right angle change detected
    I32 _roll;    ///< roll left or right change detected

    F32 _waterHeight;
    F32 _waterDepth;
    bool _cameraUnderwater;
    bool _cameraUpdated; //was the camera moved or rotated this frame
    ///Background music map
    typedef hashMapImpl<stringImpl /*trackName*/, AudioDescriptor* /*track*/> MusicPlaylist;
    MusicPlaylist _backgroundMusic;

protected:
    friend class Scene;
    FogDescriptor _fog;
    ///saves all the rendering information for the scene (camera position, light info, draw states)
    SceneRenderState _renderState;
    bool _isRunning;
    F32  _grassVisibility;
    F32  _treeVisibility;
    F32  _generalVisibility;
    F32  _windSpeed;
    F32  _windDirX;
    F32  _windDirZ;
};

}; //namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Scenes/Headers/SceneState.h

Diff revisions: vs.
Revision Author Commited Message
337 Diff Diff IonutCava picture IonutCava Wed 17 Dec, 2014 17:25:16 +0000

[Ionut]
- Replaced all tabs with 4 spaces (some spacing may be off now. no way to check all the files.)
- Moved implementation details for ParamHandler, BoundingBox, BoundingSphere and ProfileTimer to proper .inl and .cpp files. (more to follow)
- Update all forward declared enums with the required storage type (as requested by the C++11 standard)

334 Diff Diff IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

[Ionut]
- Reorganized the Hardware project and renamed to "Platform"
- Reorganized the Server project

333 Diff Diff IonutCava picture IonutCava Tue 09 Dec, 2014 16:15:44 +0000

[Ionut]
- Removed “core.h” and moved everything to their appropriate header files
- Renamed MathClasses to MathMatrices (finally)
- Renamed “-Inl.h” files to ".inl"
- Some String wrapper refactoring
- Update “InstallLibraries.bat” so that it still offers valid options

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)

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

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)

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

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)

316 IonutCava picture IonutCava Mon 25 Aug, 2014 22:04:03 +0000

[Ionut]
- Cleaned up AI classes
- Added basic Order <-> Goal system