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
#include "stdafx.h"

#include "Headers/NetworkScene.h"

#include "Core/Headers/ParamHandler.h"
#include "Core/Headers/StringHelper.h"
#include "Core/Headers/XMLEntryData.h"
#include "Core/Networking/Headers/LocalClient.h"
#include "Core/Headers/PlatformContext.h"
#include "Core/Time/Headers/ApplicationTimer.h"
#include "Managers/Headers/SceneManager.h"

namespace Divide {
NetworkScene::NetworkScene(PlatformContext& context, ResourceCache& cache, SceneManager& parent, const stringImpl& name)
    : Scene(context, cache, parent, name)
{
}

NetworkScene::~NetworkScene()
{
}

void NetworkScene::processInput(U8 playerIndex, const U64 deltaTime) {
    Light* light = _lightPool->getLight(0, LightType::DIRECTIONAL);
    vec4<F32> vSunColour = Lerp(vec4<F32>(1.0f, 0.5f, 0.0f, 1.0f),
        vec4<F32>(1.0f, 1.0f, 0.8f, 1.0f),
        0.25f + cosf(_sunAngle.y) * 0.75f);

    light->setDiffuseColour(vSunColour);

    //_currentSky = addSky();
    Scene::processInput(playerIndex, deltaTime);
}

void NetworkScene::processGUI(const U64 deltaTime) {
    D64 FpsDisplay = Time::SecondsToMilliseconds(0.3);
    D64 TimeDisplay = Time::SecondsToMilliseconds(0.01);
    D64 ServerPing = Time::SecondsToMilliseconds(1.0);
    if (_guiTimers[0] >= FpsDisplay) {
        _GUI->modifyText(_ID("fpsDisplay"),
                         Util::StringFormat("FPS: %5.2f", Time::ApplicationTimer::instance().getFps()));
        _guiTimers[0] = 0.0;
    }

    if (_guiTimers[1] >= TimeDisplay) {
        _GUI->modifyText(_ID("timeDisplay"),
                         Util::StringFormat("Elapsed time: %5.0f", time));
        _guiTimers[1] = 0.0;
    }

    if (_taskTimers[2] >= ServerPing) {
        _GUI->modifyText(
            _ID("statusText"),
            (char*)_paramHandler.getParam<stringImpl>(_ID("asioStatus")).c_str());
        _GUI->modifyText(_ID("serverMessage"),
                         (char*)_paramHandler.getParam<stringImpl>(
                             _ID("serverResponse")).c_str());
        _guiTimers[2] = 0.0;
    }
}

void NetworkScene::checkPatches(I64 btnGUID) {
    if (_modelDataArray.empty()) return;
    WorldPacket p(OPCodesEx::CMSG_GEOMETRY_LIST);
    p << stringImpl("NetworkScene");
    p << _modelDataArray.size();

    /*for(vectorImpl<FileData>::iterator _iter = std::begin(_modelDataArray);
    _iter != std::end(_modelDataArray); ++_iter)    {
        p << (*_iter).ItemName;
        p << (*_iter).ModelName;
        p << (*_iter).version;
    }*/
    _context.client().sendPacket(p);
}

bool NetworkScene::load(const stringImpl& name) {
    // Load scene resources
    bool loadState = SCENE_LOAD(name, true, true);

    _paramHandler.setParam(_ID("serverResponse"), "waiting");
    addLight(LightType::DIRECTIONAL, _sceneGraph->getRoot());
    _currentSky = addSky();
    Camera::activeCamera()->setEye(vec3<F32>(0, 30, -30));

    return loadState;
}

void NetworkScene::test(I64 btnGUID) {
    WorldPacket p(OPCodesEx::CMSG_PING);
    p << Time::ElapsedMilliseconds();
    _context.client().sendPacket(p);
}

void NetworkScene::connect(I64 btnGUID) {
    _GUI->modifyText(_ID("statusText"), "Connecting to server ...");
    _context.client().connect(_context.entryData().serverAddress.c_str(), 443);
}

void NetworkScene::disconnect(I64 btnGUID) {
    if (!_context.client().isConnected()) {
        _GUI->modifyText(_ID("statusText"), "Disconnecting to server ...");
    }
    _context.client().disconnect();
}

bool NetworkScene::loadResources(bool continueOnErrors) {
    _sunAngle = vec2<F32>(0.0f, Angle::to_RADIANS(45.0f));
    _sunvector =
        vec4<F32>(-cosf(_sunAngle.x) * sinf(_sunAngle.y), -cosf(_sunAngle.y),
                  -sinf(_sunAngle.x) * sinf(_sunAngle.y), 0.0f);

    _guiTimers.push_back(0.0f);  // Fps
    _guiTimers.push_back(0.0f);  // Time
    _guiTimers.push_back(0.0f);  // Server Ping
    return true;
}

void NetworkScene::postLoadMainThread() {
    const vec2<U16>& resolution = _context.app().windowManager().getActiveWindow().getDimensions();

    _GUI->addText(_ID("fpsDisplay"),  // Unique ID
        vec2<I32>(60, 60),  // Position
        Font::DIVIDE_DEFAULT,  // Font
        vec4<U8>(0, 164, 255, 255),  // Colour
        Util::StringFormat("FPS: %d", 0));  // Text and arguments
    _GUI->addText(_ID("timeDisplay"), vec2<I32>(60, 70), Font::DIVIDE_DEFAULT,
        vec4<U8>(164, 64, 64, 255),
        Util::StringFormat("Elapsed time: %5.0f", Time::ElapsedSeconds()));

    _GUI->addText(_ID("serverMessage"),
        vec2<I32>(resolution.width / 4,
            resolution.height / 1),
        Font::DIVIDE_DEFAULT,
        vec4<U8>(128, 128, 64, 255),
        Util::StringFormat("Server says: %s", "<< nothing yet >>"));
    _GUI->addText(_ID("statusText"),
        vec2<I32>(resolution.width / 3,
            resolution.height / 2),
        Font::DIVIDE_DEFAULT,
        vec4<U8>(64, 128, 64, 255),
        "");

    _GUI->addButton(
        _ID("getPing"), "ping me",
        vec2<I32>(60, to_I32(resolution.height / 1.1f)),
        vec2<U32>(100, 25),
        DELEGATE_BIND(&NetworkScene::test, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("disconnect"), "disconnect",
        vec2<I32>(180, to_I32(resolution.height / 1.1f)),
        vec2<U32>(100, 25),
        DELEGATE_BIND(&NetworkScene::disconnect, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("connect"), "connect",
        vec2<I32>(300, to_I32(resolution.height / 1.1f)),
        vec2<U32>(100, 25),
        DELEGATE_BIND(&NetworkScene::connect, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("patch"), "patch",
        vec2<I32>(420, to_I32(resolution.height / 1.1f)),
        vec2<U32>(100, 25),
        DELEGATE_BIND(&NetworkScene::checkPatches, this, std::placeholders::_1));

    Scene::postLoadMainThread();
}

};

Commits for Divide-Framework/trunk/Source Code/Scenes/NetworkScene/NetworkScene.cpp

Diff revisions: vs.
Revision Author Commited Message
909 Diff Diff IonutCava picture IonutCava Thu 29 Jun, 2017 23:57:18 +0000

[Ionut]
- Rework RenderTarget class
— RTAttachment now deal with textures directly
— RT size needs to be specified upfront
- Application class is no longer a Singleton but passed around in the PlatformContext

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

838 Diff Diff IonutCava picture IonutCava Mon 30 Jan, 2017 17:28:35 +0000

[IonutCava]
- Added a NetworkingComponent to SGNs
- Started cleaning up Client / Server architecture

831 Diff Diff IonutCava picture IonutCava Wed 25 Jan, 2017 23:52:34 +0000

[IonutCava]
- More path related updates

829 Diff Diff IonutCava picture IonutCava Tue 24 Jan, 2017 17:28:39 +0000

[IonutCava]
- Separate resourceLocation for resources into resourceLocation and resourceName.
- More XML config loading refactoring

816 Diff Diff IonutCava picture IonutCava Fri 13 Jan, 2017 17:05:20 +0000

[IonutCava]
- Allow per player scene state and input source
— Add SceneStatePerPlayer class
— Add device index to InputParams objects.
— ToDo: map players to devide indices

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
784 Diff Diff IonutCava picture IonutCava Mon 17 Oct, 2016 16:20:49 +0000

[IonutCava]
- Removed the CameraManager and move most of its functionality into static members of the Camera class
- Removed Camera push/pop system in favour of a stateless ptr based system to better fit the RenderPass structure

721 IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better