QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
3d
qgs3dexportobject.h
Go to the documentation of this file.
1
/***************************************************************************
2
Qgs3DExportObject.h
3
--------------------------------------
4
Date : June 2020
5
Copyright : (C) 2020 by Belgacem Nedjima
6
Email : gb underscore nedjima at esi dot dz
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef Qgs3DExportObject_H
17
#define Qgs3DExportObject_H
18
19
#include "
qgis.h
"
20
#include "qgis_3d.h"
21
22
#include <QImage>
23
#include <QMap>
24
#include <QMatrix4x4>
25
#include <QObject>
26
#include <QTextStream>
27
#include <QVector>
28
#include <QVector3D>
29
30
#define SIP_NO_FILE
31
32
class
QgsAbstractMaterialSettings
;
33
42
class
_3D_EXPORT
Qgs3DExportObject
43
{
44
public
:
46
enum
ObjectType
47
{
48
TriangularFaces
,
49
LineStrip
,
50
Points
51
};
52
58
Qgs3DExportObject
(
const
QString &
name
)
59
: mName(
name
)
60
{}
61
63
QString
name
()
const
{
return
mName; }
65
void
setName
(
const
QString &
name
) { mName =
name
; }
66
68
ObjectType
type
()
const
{
return
mType; }
69
71
bool
smoothEdges
()
const
{
return
mSmoothEdges; }
73
void
setSmoothEdges
(
bool
smoothEdges
) { mSmoothEdges =
smoothEdges
; }
74
76
void
setupLine(
const
QVector<float> &positionsBuffer );
77
79
void
setupTriangle(
const
QVector<float> &positionsBuffer,
const
QVector<uint> &facesIndexes,
const
QMatrix4x4 &transform );
80
82
void
setupPoint(
const
QVector<float> &positionsBuffer );
83
85
void
setupNormalCoordinates(
const
QVector<float> &normalsBuffer,
const
QMatrix4x4 &transform );
87
void
setupTextureCoordinates(
const
QVector<float> &texturesBuffer );
89
void
setupMaterial(
QgsAbstractMaterialSettings
*material );
90
92
void
setTextureImage
(
const
QImage &image ) { this->mTextureImage = image; };
94
QImage
textureImage
()
const
{
return
mTextureImage; }
95
101
void
objectBounds(
float
&minX,
float
&minY,
float
&minZ,
float
&maxX,
float
&maxY,
float
&maxZ )
const
;
102
119
void
saveTo(
120
QTextStream &out,
float
scale,
const
QVector3D ¢er,
const
Qgis::Export3DSceneFormat
&exportFormat =
Qgis::Export3DSceneFormat::Obj
,
int
precision = 6, QString materialName = QString()
121
)
const
;
122
124
QString saveMaterial( QTextStream &mtlOut,
const
QString &folder )
const
;
125
127
QVector<float>
vertexPosition
()
const
{
return
mVertexPosition; }
128
130
QVector<float>
normals
()
const
{
return
mNormals; }
131
133
QVector<float>
texturesUV
()
const
{
return
mTexturesUV; }
134
136
QVector<unsigned int>
indexes
()
const
{
return
mIndexes; }
137
138
private
:
140
void
setupPositionCoordinates(
const
QVector<float> &positionsBuffer,
const
QMatrix4x4 &transform = QMatrix4x4() );
141
143
void
saveToObj( QTextStream &out,
float
scale,
const
QVector3D ¢er,
int
precision = 6, QString materialName = QString() )
const
;
144
146
void
saveToStl( QTextStream &out,
float
scale,
const
QVector3D ¢er,
int
precision = 6 )
const
;
147
148
private
:
149
QString mName;
150
ObjectType mType = ObjectType::TriangularFaces;
151
QString mParentName;
152
QVector<float> mVertexPosition;
153
QVector<float> mNormals;
154
QVector<float> mTexturesUV;
155
QVector<unsigned int> mIndexes;
156
QMap<QString, QString> mMaterialParameters;
157
158
QImage mTextureImage;
159
160
bool
mSmoothEdges =
false
;
161
};
162
163
#endif
// Qgs3DExportObject_H
Qgis::Export3DSceneFormat
Export3DSceneFormat
The file format used when exporting a 3D scene.
Definition
qgis.h:4638
Qgis::Export3DSceneFormat::Obj
@ Obj
Wavefront OBJ format.
Definition
qgis.h:4639
Qgs3DExportObject::texturesUV
QVector< float > texturesUV() const
Returns the vertex texture coordinates.
Definition
qgs3dexportobject.h:133
Qgs3DExportObject::textureImage
QImage textureImage() const
Returns the texture image used by the object.
Definition
qgs3dexportobject.h:94
Qgs3DExportObject::indexes
QVector< unsigned int > indexes() const
Returns the vertex indexes.
Definition
qgs3dexportobject.h:136
Qgs3DExportObject::Qgs3DExportObject
Qgs3DExportObject(const QString &name)
Qgs3DExportObject Constructs an export object that will be filled with coordinates later.
Definition
qgs3dexportobject.h:58
Qgs3DExportObject::vertexPosition
QVector< float > vertexPosition() const
Returns the vertex coordinates.
Definition
qgs3dexportobject.h:127
Qgs3DExportObject::type
ObjectType type() const
Returns the object type.
Definition
qgs3dexportobject.h:68
Qgs3DExportObject::ObjectType
ObjectType
The type of exported geometry.
Definition
qgs3dexportobject.h:47
Qgs3DExportObject::TriangularFaces
@ TriangularFaces
Definition
qgs3dexportobject.h:48
Qgs3DExportObject::LineStrip
@ LineStrip
Definition
qgs3dexportobject.h:49
Qgs3DExportObject::Points
@ Points
Definition
qgs3dexportobject.h:50
Qgs3DExportObject::name
QString name() const
Returns the object name.
Definition
qgs3dexportobject.h:63
Qgs3DExportObject::normals
QVector< float > normals() const
Returns the vertex normal coordinates.
Definition
qgs3dexportobject.h:130
Qgs3DExportObject::setTextureImage
void setTextureImage(const QImage &image)
Sets the texture image used by the object.
Definition
qgs3dexportobject.h:92
Qgs3DExportObject::smoothEdges
bool smoothEdges() const
Returns whether object edges will look smooth.
Definition
qgs3dexportobject.h:71
Qgs3DExportObject::setName
void setName(const QString &name)
Sets the object name.
Definition
qgs3dexportobject.h:65
Qgs3DExportObject::setSmoothEdges
void setSmoothEdges(bool smoothEdges)
Sets whether triangles edges will look smooth.
Definition
qgs3dexportobject.h:73
QgsAbstractMaterialSettings
Abstract base class for material settings.
Definition
qgsabstractmaterialsettings.h:42
qgis.h
Generated on
for QGIS API Documentation by
1.17.0