1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef ASSIMPHELPERS_H
5#define ASSIMPHELPERS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18// ASSIMP INCLUDES
19#include <assimp/IOStream.hpp>
20#include <assimp/IOSystem.hpp>
21#include <QtCore/QIODevice>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DRender {
26namespace AssimpHelper {
27
28//CUSTOM FILE STREAM
29class AssimpIOStream : public Assimp::IOStream
30{
31public :
32 AssimpIOStream(QIODevice *device);
33 ~AssimpIOStream();
34
35 size_t Read(void *pvBuffer, size_t pSize, size_t pCount) override;
36 size_t Write(const void *pvBuffer, size_t pSize, size_t pCount) override;
37 aiReturn Seek(size_t pOffset, aiOrigin pOrigin) override;
38 size_t Tell() const override;
39 size_t FileSize() const override;
40 void Flush() override;
41
42private:
43 QIODevice *const m_device;
44};
45
46//CUSTOM FILE IMPORTER TO HANDLE QT RESOURCES WITHIN ASSIMP
47class AssimpIOSystem : public Assimp::IOSystem
48{
49public :
50 bool Exists(const char *pFile) const override;
51 char getOsSeparator() const override;
52 Assimp::IOStream *Open(const char *pFile, const char *pMode) override;
53 void Close(Assimp::IOStream *pFile) override;
54};
55
56} // namespace AssimpHelper
57} // namespace Qt3DRender
58
59QT_END_NAMESPACE
60
61#endif // ASSIMPHELPERS_H
62

source code of qt3d/src/plugins/sceneparsers/assimp/assimphelpers.h