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
#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(PlayerIndex idx, const U64 deltaTimeUS) {
    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(idx, deltaTimeUS);
}

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

    if (_guiTimersMS[1] >= TimeDisplay) {
        _GUI->modifyText(_ID("timeDisplay"),
                         Util::StringFormat("Elapsed time: %5.0f", time));
        _guiTimersMS[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());
        _guiTimersMS[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();
    playerCamera()->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);

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

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

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

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

    _GUI->addButton(
        _ID("getPing"), "ping me",
        pixelPosition(60, to_I32(resolution.height / 1.1f)),
        pixelScale(100, 25),
        DELEGATE_BIND(&NetworkScene::test, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("disconnect"), "disconnect",
        pixelPosition(180, to_I32(resolution.height / 1.1f)),
        pixelScale(100, 25),
        DELEGATE_BIND(&NetworkScene::disconnect, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("connect"), "connect",
        pixelPosition(300, to_I32(resolution.height / 1.1f)),
        pixelScale(100, 25),
        DELEGATE_BIND(&NetworkScene::connect, this, std::placeholders::_1));
    _GUI->addButton(
        _ID("patch"), "patch",
        pixelPosition(420, to_I32(resolution.height / 1.1f)),
        pixelScale(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
1003 Diff Diff IonutCava picture IonutCava Tue 19 Dec, 2017 17:08:06 +0000

[Ionut]
- GUI cleanup

979 Diff Diff IonutCava picture IonutCava Tue 21 Nov, 2017 23:24:57 +0000

[Ionut]
- W.I.P. Rework GUI element positioning and scaling
- Update ImGUI and IMGUI_ADDONS

968 Diff Diff IonutCava picture IonutCava Tue 07 Nov, 2017 17:32:31 +0000

[Ionut]
- Consistent naming between timing variables

957 Diff Diff IonutCava picture IonutCava Tue 31 Oct, 2017 17:15:51 +0000

[Ionut]
- Some SGN node search refactoring
- typedef PlayerIndex

950 Diff Diff IonutCava picture IonutCava Sun 22 Oct, 2017 22:25:05 +0000

[Ionut]
- Revamp camera management
- More work on improving the command buffer system:
— Performance tweaks
— Validation
— Debug features
- Some code cleanup for Object3D stuff (preRender/onRender changes)

Still haven’t fixed random flashing issue

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 IonutCava picture IonutCava Wed 25 Jan, 2017 23:52:34 +0000

[IonutCava]
- More path related updates