summaryrefslogtreecommitdiffstats
path: root/src/Runtime/Source/Runtime/Include/Qt3DSSceneManager.h
blob: 7b8a4aabe869ed20d2f70b5268a73451ba9dfc4c (plain)
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
/****************************************************************************
**
** Copyright (C) 1993-2009 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#pragma once

//==============================================================================
//	Includes
//==============================================================================
#include "Qt3DSPickFrame.h"
#include "Qt3DSIStateful.h"
#include "foundation/Qt3DSDataRef.h"
#include "foundation/Qt3DSRefCounted.h"
#include "Qt3DSIScene.h"

namespace qt3ds {
namespace foundation {
    class IInStream;
    class IOutStream;
    class Mutex;
}
}

namespace qt3ds {
class Q3DSVariantConfig;
namespace render {
    class IQt3DSRenderContextCore;
    class ILoadedBuffer;
}
}

//==============================================================================
//	Namespace
//==============================================================================
namespace Q3DStudio {

//==============================================================================
//	Forwards
//==============================================================================
class IScene;
class IPresentation;
class CRenderEngine;
class CRenderEngine;
class IUIPParser;
class CFileStream;
class IRuntimeFactory;
class IScriptBridge;
class ISceneManager;

class ISceneBinaryLoader : public qt3ds::foundation::NVRefCounted
{
protected:
    virtual ~ISceneBinaryLoader() {}

public:
    virtual qt3ds::foundation::NVDataRef<qt3ds::QT3DSU8>
    BinaryLoadManagerData(qt3ds::foundation::IInStream &inStream, const char *inBinaryDir) = 0;

    // threadsafe
    // Can be called from any thread
    virtual bool GetBinaryLoadFileName(eastl::string &inPresentationFilename,
                                       eastl::string &outResult) = 0;

    // threadsafe
    // returns a handle to the loaded object. Return value of zero means error.
    virtual qt3ds::QT3DSU32 LoadSceneStage1(qt3ds::foundation::CRegisteredString inPresentationDirectory,
                                      qt3ds::render::ILoadedBuffer &inData) = 0;

    // threadsafe
    // still does not require openGL context but has dependency on a few other things.
    virtual void LoadSceneStage2(qt3ds::QT3DSU32 inSceneHandle, IPresentation &inPresentation,
                                 size_t inElementMemoryOffset, IScriptBridge &inBridge) = 0;
};
struct FacePositionPlanes
{
    enum Enum { XY = 0, YZ, XZ };
};

//==============================================================================
/**
*	@class	ISceneManager
*	@brief	Container class that creates and manages all the Scenes.
*/
class ISceneManager : public qt3ds::foundation::NVRefCounted
{
protected:
    virtual ~ISceneManager(){}

public: // Presentations
    //==============================================================================
    /**
     *	Load a new scene based on an existing presentation.  This will create a new
     *	CScene-based class from the factory method at "CreateScene".  To supply
     *	your own class, simply set "CreateScene" to the desired factory method.
     *	After creating the new scene, a load will be triggered.
     *	@param inPresentation		the current presentation loaded
     */
    virtual IScene *LoadScene(IPresentation *inPresentation, IUIPParser *inParser,
                              IScriptBridge &inBridge,
                              const qt3ds::Q3DSVariantConfig &variantConfig) = 0;
    virtual void LoadRenderPlugin(const CHAR *inAssetIDString, const CHAR *inPath,
                                  const CHAR *inArgs) = 0;

    virtual void LoadQmlStreamerPlugin(const CHAR *inAssetIDString) = 0;

    virtual void BinarySaveManagerData(qt3ds::foundation::IOutStream &inStream,
                                       const char *inBinaryDir) = 0;
    // Loading flow data needs to return the string table memory block.  This allows
    // other systems to use remap their string table strings assuming they had mapped them before
    // serialization.  In general this is a horrible hack and abstraction leak but assuming you have
    // a string
    // table I guess it isn't too bad.
    virtual qt3ds::foundation::NVDataRef<qt3ds::QT3DSU8>
    BinaryLoadManagerData(qt3ds::foundation::IInStream &inStream, const char *inBinaryDir) = 0;

    virtual void BinarySave(Q3DStudio::IScene &inScene) = 0;

public: // Update Cycle
    virtual BOOL Update() = 0;
    virtual BOOL RenderPresentation(IPresentation *inPresentation) = 0;
    virtual void OnViewResize(INT32 inViewWidth, INT32 inViewHeight) = 0;
    virtual void GetViewSize(INT32 &outWidth, INT32 &outHeight) = 0;

    virtual STextSizes GetDisplayDimensions(Q3DStudio::IPresentation *inPrimaryPresentation) = 0;

public: // Picking
    virtual Q3DStudio::TElement *UserPick(float mouseX, float mouseY) = 0;
    virtual SPickFrame AdvancePickFrame(const SInputFrame &inInputFrame) = 0;
    // Get the relative UV coord position of an element.  This matches how mouse picking works where
    // we pick out
    virtual qt3ds::foundation::Option<qt3ds::QT3DSVec2>
    FacePosition(Q3DStudio::TElement &inElement, float mouseX, float mouseY,
                 qt3ds::foundation::NVDataRef<Q3DStudio::TElement *> inMapperElements,
                 FacePositionPlanes::Enum inPlane) = 0;

    virtual void Release() = 0;

    static ISceneManager &Create(IRuntimeFactory &inFactory, CRenderEngine &inRenderEngine);
};

} // namespace Q3DStudio