QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <QObject>
20#include <QTextStream>
21#include <QVector>
22#include <QVector3D>
23#include <QImage>
24#include <QMap>
25
26#include "qgis_3d.h"
27
28#define SIP_NO_FILE
29
31
40class _3D_EXPORT Qgs3DExportObject
41{
42 public:
50
56 Qgs3DExportObject( const QString &name )
57 : mName( name ) {}
58
60 QString name() const { return mName; }
62 void setName( const QString &name ) { mName = name; }
63
65 ObjectType type() const { return mType; }
67 void setType( ObjectType type ) { mType = type; }
68
70 bool smoothEdges() const { return mSmoothEdges; }
72 void setSmoothEdges( bool smoothEdges ) { mSmoothEdges = smoothEdges; }
73
75 void setupPositionCoordinates( const QVector<float> &positionsBuffer, const QMatrix4x4 &transform );
77 void setupFaces( const QVector<uint> &facesIndexes );
79 void setupLine( const QVector<uint> &facesIndexes );
80
82 void setupNormalCoordinates( const QVector<float> &normalsBuffer, const QMatrix4x4 &transform );
84 void setupTextureCoordinates( const QVector<float> &texturesBuffer );
86 void setupMaterial( QgsAbstractMaterialSettings *material );
87
89 void setTextureImage( const QImage &image ) { this->mTextureImage = image; };
91 QImage textureImage() const { return mTextureImage; }
92
98 void objectBounds( float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ );
99
101 void setMaterialParameter( const QString &parameter, const QString &value ) { mMaterialParameters[parameter] = value; }
102
104 void saveTo( QTextStream &out, float scale, const QVector3D &center, int precision = 6 );
106 QString saveMaterial( QTextStream &mtlOut, const QString &folder );
107
109 QVector<float> vertexPosition() const { return mVertexPosition; }
110
112 QVector<float> normals() const { return mNormals; }
113
115 QVector<float> texturesUV() const { return mTexturesUV; }
116
118 QVector<unsigned int> indexes() const { return mIndexes; }
119
120 private:
121 QString mName;
122 ObjectType mType = ObjectType::TriangularFaces;
123 QString mParentName;
124 QVector<float> mVertexPosition;
125 QVector<float> mNormals;
126 QVector<float> mTexturesUV;
127 QVector<unsigned int> mIndexes;
128 QMap<QString, QString> mMaterialParameters;
129
130 QImage mTextureImage;
131
132 bool mSmoothEdges = false;
133};
134
135#endif // Qgs3DExportObject_H
Manages the data of each object of the scene (positions, normals, texture coordinates ....
QVector< float > texturesUV() const
Returns the vertex texture coordinates.
QImage textureImage() const
Returns the texture image used by the object.
void setMaterialParameter(const QString &parameter, const QString &value)
Sets a material parameter to be exported in the .mtl file.
QVector< unsigned int > indexes() const
Returns the vertex indexes.
void setType(ObjectType type)
Sets the object type.
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.
@ Points
Point based rendering, requires point data.
int precision