summaryrefslogtreecommitdiffstats
path: root/src/runtime/Qt3DSIScene.h
blob: 421fe9c4b66fbe39ae870f9975aba857837929e1 (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
/****************************************************************************
**
** 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

#include "render/Qt3DSRenderBaseTypes.h"
#include "foundation/StringTable.h"
#include "foundation/Qt3DSBounds3.h"
#include "Qt3DSBoundingBox.h"
namespace qt3ds {
namespace render {
    class IImageLoadListener;
}
    class NVAllocatorCallback;
}

namespace Q3DStudio {

class IPresentation;
class RuntimeMatrix;
struct SPickFrame;

/**
*	@interface	IScene
*
*	Runtime interface to the renderer's representation of a presentation.  Scenes are
*	created by the SceneManager and rendered via a lower level rendering system.
*/
struct STextSizes
{
    INT32 m_Width;
    INT32 m_Height;
    STextSizes()
        : m_Width(0)
        , m_Height(0)
    {
    }
    STextSizes(INT32 w, INT32 h)
        : m_Width(w)
        , m_Height(h)
    {
    }
};

struct SMousePosition
{
    INT32 m_X;
    INT32 m_Y;
    SMousePosition(INT32 x, INT32 y)
        : m_X(x)
        , m_Y(y)
    {
    }
    SMousePosition()
        : m_X(0)
        , m_Y(0)
    {
    }
};

struct SCameraRect
{
    float m_Left;
    float m_Top;
    float m_Right;
    float m_Bottom;
    SCameraRect(float l = 0.0f, float t = 0.0f, float r = 0.0f, float b = 0.0f)
        : m_Left(l)
        , m_Top(t)
        , m_Right(r)
        , m_Bottom(b)
    {
    }

    bool IsValid() const { return fabs(m_Right - m_Left) > 0.0f; }
};

class IScene
{
protected:
    virtual ~IScene() {}

public: // Base Interface
    virtual IPresentation &GetPresentation() = 0;

    virtual void SetUserData(void *inUserData) = 0;
    virtual void *GetUserData() = 0;

    virtual void CalculateGlobalTransform(TElement *inElement, RuntimeMatrix &outTransform) = 0;
    virtual void SetLocalTransformMatrix(TElement *inElement, const RuntimeMatrix &inTransform) = 0;
    // Get bounding box in global space
    virtual CBoundingBox GetBoundingBox(TElement *inElement, bool inSelfOnly) = 0;
    // Get bounding box in local space.
    virtual CBoundingBox GetLocalBoundingBox(TElement *inElement, bool inSelfOnly) = 0;

    // The final argument, inHasTransparency has 3 possible values,
    // 0 for no transparency, 1 for hasTransparency, -1 for unknown
    virtual void SetTextureData(TElement *inElement, const unsigned char *inBuffer,
                                INT32 inBufferLength, INT32 inWidth, INT32 inHeight,
                                qt3ds::render::NVRenderTextureFormats::Enum inFormat,
                                INT32 inHasTransparency = -1) = 0;

    virtual bool CreateOrSetMeshData(const char *inPathStr, unsigned char *vertData,
                                     unsigned int numVerts, unsigned int vertStride,
                                     unsigned int *indexData, unsigned int numIndices,
                                     qt3ds::NVBounds3 &objBounds) = 0;

    virtual STextSizes MeasureText(TElement *inElement, const char *inTextStr) = 0;

    virtual STextSizes GetPresentationDesignDimensions() = 0;
    // If the rect's right - left == 0.0, this method failed.  Possibly because the layer is just
    // direct-rendering a sub-presentation.
    virtual SCameraRect GetCameraBounds(TElement &inElement) = 0;

    virtual void PositionToScreen(TElement &inElement, qt3ds::QT3DSVec3 &inPos,
                                  qt3ds::QT3DSVec3 &outScreen) = 0;
    virtual void ScreenToPosition(TElement &inElement, qt3ds::QT3DSVec3 &inScreen,
                                  qt3ds::QT3DSVec3 &outPos) = 0;

    virtual qt3ds::foundation::CRegisteredString RegisterStr(const char *inStr) = 0;

    virtual SMousePosition WindowToPresentation(const SMousePosition &inWindowPos) = 0;

    virtual void RegisterOffscreenRenderer(const char *inKey) = 0;

    virtual void Release() = 0;

    virtual bool preferKtx() const = 0;

    virtual qt3ds::NVAllocatorCallback &allocator() = 0;
};

} // namespace Q3DStudio