QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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_3d.h"
20
21#include <QImage>
22#include <QMap>
23#include <QMatrix4x4>
24#include <QObject>
25#include <QTextStream>
26#include <QVector>
27#include <QVector3D>
28
29#define SIP_NO_FILE
30
32
41class _3D_EXPORT Qgs3DExportObject
42{
43 public:
51
57 Qgs3DExportObject( const QString &name )
58 : mName( name ) {}
59
61 QString name() const { return mName; }
63 void setName( const QString &name ) { mName = name; }
64
66 ObjectType type() const { return mType; }
67
69 bool smoothEdges() const { return mSmoothEdges; }
71 void setSmoothEdges( bool smoothEdges ) { mSmoothEdges = smoothEdges; }
72
74 void setupLine( const QVector<float> &positionsBuffer );
75
77 void setupTriangle( const QVector<float> &positionsBuffer, const QVector<uint> &facesIndexes, const QMatrix4x4 &transform );
78
80 void setupPoint( const QVector<float> &positionsBuffer );
81
83 void setupNormalCoordinates( const QVector<float> &normalsBuffer, const QMatrix4x4 &transform );
85 void setupTextureCoordinates( const QVector<float> &texturesBuffer );
87 void setupMaterial( QgsAbstractMaterialSettings *material );
88
90 void setTextureImage( const QImage &image ) { this->mTextureImage = image; };
92 QImage textureImage() const { return mTextureImage; }
93
99 void objectBounds( float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ ) const;
100
102 void saveTo( QTextStream &out, float scale, const QVector3D &center, int precision = 6 ) const;
104 QString saveMaterial( QTextStream &mtlOut, const QString &folder ) const;
105
107 QVector<float> vertexPosition() const { return mVertexPosition; }
108
110 QVector<float> normals() const { return mNormals; }
111
113 QVector<float> texturesUV() const { return mTexturesUV; }
114
116 QVector<unsigned int> indexes() const { return mIndexes; }
117
118 private:
120 void setupPositionCoordinates( const QVector<float> &positionsBuffer, const QMatrix4x4 &transform = QMatrix4x4() );
121
122 private:
123 QString mName;
124 ObjectType mType = ObjectType::TriangularFaces;
125 QString mParentName;
126 QVector<float> mVertexPosition;
127 QVector<float> mNormals;
128 QVector<float> mTexturesUV;
129 QVector<unsigned int> mIndexes;
130 QMap<QString, QString> mMaterialParameters;
131
132 QImage mTextureImage;
133
134 bool mSmoothEdges = false;
135};
136
137#endif // Qgs3DExportObject_H
QVector< float > texturesUV() const
Returns the vertex texture coordinates.
QImage textureImage() const
Returns the texture image used by the object.
QVector< unsigned int > indexes() const
Returns the vertex indexes.
Qgs3DExportObject(const QString &name)
Qgs3DExportObject Constructs an export object that will be filled with coordinates later.
QVector< float > vertexPosition() const
Returns the vertex coordinates.
ObjectType type() const
Returns the object type.
ObjectType
The type of exported geometry.
QString name() const
Returns the object name.
QVector< float > normals() const
Returns the vertex normal coordinates.
void setTextureImage(const QImage &image)
Sets the texture image used by the object.
bool smoothEdges() const
Returns whether object edges will look smooth.
void setName(const QString &name)
Sets the object name.
void setSmoothEdges(bool smoothEdges)
Sets whether triangles edges will look smooth.
Abstract base class for material settings.