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

#include "Headers/CubeScene.h"

#include "Managers/Headers/SceneManager.h"
#include "Geometry/Shapes/Predefined/Headers/Quad3D.h"
#include "Rendering/Headers/DeferredShadingRenderer.h"

#include "Core/Time/Headers/ApplicationTimer.h"
#include "Core/Headers/PlatformContext.h"

namespace Divide {

void CubeScene::processTasks(const U64 deltaTimeUS) {
    D64 updateLights = Time::SecondsToMilliseconds(0.05);

    if (_taskTimers[0] >= updateLights) {
        for (U8 row = 0; row < 3; row++)
            for (U8 col = 0; col < _lightNodes.size() / 3.0f; col++) {
                F32 x = col * 150.0f - 5.0f +
                        cos(to_F32(Time::ElapsedMilliseconds()) * (col - row + 2) *
                            0.008f) *
                            200.0f;
                F32 y = cos(to_F32(Time::ElapsedSeconds()) * (col - row + 2) * 0.01f) *
                            200.0f +
                        20;
                ;
                F32 z = row * 500.0f - 500.0f -
                        cos(to_F32(Time::ElapsedMilliseconds()) * (col - row + 2) *
                            0.009f) *
                            200.0f +
                        10;
                F32 r = 1;
                F32 g = 1.0f - (row / 3.0f);
                F32 b = col / (_lightNodes.size() / 3.0f);

                _lightNodes[row * 10 + col]->getNode<Light>()->setDiffuseColour(vec3<F32>(r, g, b));
                _lightNodes[row * 10 + col]->get<TransformComponent>()->setPosition(vec3<F32>(x, y, z));
            }

        _taskTimers[0] = 0.0;
    }
    Scene::processTasks(deltaTimeUS);
}

I8 g_j = 1;
F32 g_i = 0;
bool _switch = false;

void CubeScene::processInput(PlayerIndex idx, const U64 deltaTimeUS) {
    if (g_i >= 360)
        _switch = true;
    else if (g_i <= 0)
        _switch = false;

    if (!_switch)
        g_i += 0.1f;
    else
        g_i -= 0.1f;

    g_i >= 180 ? g_j = -1 : g_j = 1;

    SceneGraphNode* cutia1(_sceneGraph->findNode("Cutia1"));
    SceneGraphNode* hellotext(_sceneGraph->findNode("HelloText"));
    SceneGraphNode* bila(_sceneGraph->findNode("Bila"));
    SceneGraphNode* dwarf(_sceneGraph->findNode("dwarf"));

    cutia1->get<TransformComponent>()->rotate(
        0.3f * g_i, 0.6f * g_i, 0);
    hellotext->get<TransformComponent>()->rotate(
        vec3<F32>(0.6f, 0.2f, 0.4f), g_i);
    bila->get<TransformComponent>()->translateY(g_j * 0.25f);
    dwarf->get<TransformComponent>()->rotate(vec3<F32>(0, 1, 0), g_i);

    Scene::processInput(idx, deltaTimeUS);
}

bool CubeScene::load(const stringImpl& name) {
    _context.gfx().setRenderer(RendererType::RENDERER_DEFERRED_SHADING);
    // Load scene resources
    return SCENE_LOAD(name, true, true);
}

bool CubeScene::loadResources(bool continueOnErrors) {
    // 30 lights? >:)
    static const U32 normalMask = to_base(ComponentType::TRANSFORM) |
                                  to_base(ComponentType::BOUNDS) |
                                  to_base(ComponentType::RENDERING) |
                                  to_base(ComponentType::NETWORKING);

    for (U8 row = 0; row < 3; row++) {
        for (U8 col = 0; col < 10; col++) {
            U8 lightID = to_U8(row * 10 + col);
            stringstreamImpl ss;
            ss << to_U32(lightID);
            ResourceDescriptor tempLight("Light Deferred " + ss.str());
            tempLight.setEnumValue(to_base(LightType::POINT));
            tempLight.setUserPtr(_lightPool);

            std::shared_ptr<Light> light = CreateResource<Light>(_resCache, tempLight);
            light->setDrawImpostor(true);
            light->setRange(30.0f);
            light->setCastShadows(false);
            _lightNodes.push_back(_sceneGraph->getRoot().addNode(light, normalMask, PhysicsGroup::GROUP_IGNORE));
        }
    }

    _taskTimers.push_back(0.0);

    return true;
}

};

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

Diff revisions: vs.
Revision Author Commited Message
996 Diff Diff IonutCava picture IonutCava Tue 12 Dec, 2017 17:16:54 +0000

[Ionut]
- Update and improve SGN creation and destruction
- Fix cleanup issues
- Fix GPU object memory leaks
- Fix duplicate GUID values being generated
- Misc cleanups and optimizations

994 Diff Diff IonutCava picture IonutCava Mon 11 Dec, 2017 18:01:11 +0000

[Ionut]
- Moved remaining components to new ECS system
- Started cleaning up code that was made redundant by the ECS system

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

992 Diff Diff IonutCava picture IonutCava Thu 07 Dec, 2017 18:01:51 +0000

[Ionut]
- Split PhysicsComponent into 2, ECS-based, components: TransformComponent and RigidBodyComponent
UNTESTED

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

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

872 Diff Diff IonutCava picture IonutCava Mon 06 Mar, 2017 23:23:20 +0000

[IonutCava]
- Optimise static casts

867 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.