![]() |
Stellarium
0.16.1
|
Representation of a custom subset of a Wavefront .obj file, including only triangle data and materials. More...
#include <StelOBJ.hpp>
Classes | |
struct | Material |
Defines a material loaded from an .mtl file. More... | |
struct | MaterialGroup |
Represents a bunch of faces following after each other that use the same material. More... | |
struct | Object |
Represents an OBJ object as defined with the 'o' statement. More... | |
struct | Vertex |
A Vertex struct holds the vertex itself (position), corresponding texture coordinates, normals, tangents and bitangents It does not use Vec3f etc. More... | |
Public Types | |
enum | VertexOrder { XYZ, XZY, YXZ, YZX, ZXY, ZYX } |
Possible vertex orderings with load() More... | |
typedef QVector< MaterialGroup > | MaterialGroupList |
typedef QVector< Vec3f > | V3Vec |
typedef QVector< Vec2f > | V2Vec |
typedef QVector< Vertex > | VertexList |
typedef QVector< unsigned int > | IndexList |
typedef QVector< unsigned short > | ShortIndexList |
typedef QVector< Material > | MaterialList |
typedef QMap< QString, int > | MaterialMap |
typedef QVector< Object > | ObjectList |
typedef QMap< QString, int > | ObjectMap |
Public Member Functions | |
StelOBJ () | |
Constructs an empty StelOBJ. Use load() to load data from a .obj file. More... | |
void | clear () |
Resets all data contained in this StelOBJ. More... | |
unsigned int | getFaceCount () const |
Returns the number of faces. More... | |
const VertexList & | getVertexList () const |
Returns an vertex list, suitable for loading into OpenGL arrays. More... | |
const IndexList & | getIndexList () const |
Returns an index list, suitable for use with OpenGL element arrays. More... | |
const MaterialList & | getMaterialList () const |
Returns the list of materials. More... | |
const ObjectList & | getObjectList () const |
Returns the list of objects. More... | |
const ObjectMap & | getObjectMap () const |
Returns the object map (mapping the object names to their indices in the object list) More... | |
const AABBox & | getAABBox () const |
Returns the global AABB of all vertices of the OBJ. More... | |
const Vec3f & | getCentroid () const |
Returns the global centroid of all vertices of the OBJ. More... | |
bool | load (const QString &filename, const VertexOrder vertexOrder=VertexOrder::XYZ) |
Loads an .obj file by name. More... | |
bool | load (QIODevice &device, const QString &basePath, const VertexOrder vertexOrder=VertexOrder::XYZ) |
Loads an .obj file from the specified device. More... | |
bool | isLoaded () const |
Returns true if this object contains valid data from a load() method. More... | |
void | rebuildNormals () |
Rebuilds vertex normals as the average of face normals. More... | |
bool | canUseShortIndices () const |
Returns if unsigned short indices can be used instead of unsigned int indices, to save some memory. More... | |
ShortIndexList | getShortIndexList () const |
Converts the index list (as returned by getIndexList()) to use unsigned short instead of integer. More... | |
void | scale (double factor) |
Scales the vertex positions according to the given factor. More... | |
void | transform (const QMatrix4x4 &mat, bool onlyPosition=false) |
Applies the given transformation matrix to the vertex data. More... | |
void | splitVertexData (V3Vec *position, V2Vec *texCoord=Q_NULLPTR, V3Vec *normal=Q_NULLPTR, V3Vec *tangent=Q_NULLPTR, V3Vec *bitangent=Q_NULLPTR) const |
Splits the vertex data into separate arrays. More... | |
void | clearVertexData () |
Clears the internal vertex list to save space, meaning getVertexList() returns an empty list! The other members are unaffected (indices, materials, objects etc. More... | |
Representation of a custom subset of a Wavefront .obj file, including only triangle data and materials.
Definition at line 37 of file StelOBJ.hpp.
enum StelOBJ::VertexOrder |
Possible vertex orderings with load()
Definition at line 41 of file StelOBJ.hpp.
|
inline |
Returns if unsigned short indices can be used instead of unsigned int indices, to save some memory.
This can only be done if the model has less vertices than std::numeric_limits<unsigned short>::max()
Definition at line 264 of file StelOBJ.hpp.
void StelOBJ::clear | ( | ) |
Resets all data contained in this StelOBJ.
void StelOBJ::clearVertexData | ( | ) |
Clears the internal vertex list to save space, meaning getVertexList() returns an empty list! The other members are unaffected (indices, materials, objects etc.
still work). The vertex list can only be restored when the OBJ data is freshly loaded again, so don't do this if you require it later.
This is intended to be used together with splitVertexData(), when you want your own vertex format.
|
inline |
Returns the global AABB of all vertices of the OBJ.
Definition at line 237 of file StelOBJ.hpp.
|
inline |
Returns the global centroid of all vertices of the OBJ.
Definition at line 242 of file StelOBJ.hpp.
|
inline |
Returns the number of faces.
We only use triangle faces, so this is always the index count divided by 3.
Definition at line 224 of file StelOBJ.hpp.
|
inline |
Returns an index list, suitable for use with OpenGL element arrays.
Definition at line 229 of file StelOBJ.hpp.
|
inline |
Returns the list of materials.
Definition at line 231 of file StelOBJ.hpp.
|
inline |
Returns the list of objects.
Definition at line 233 of file StelOBJ.hpp.
|
inline |
Returns the object map (mapping the object names to their indices in the object list)
Definition at line 235 of file StelOBJ.hpp.
ShortIndexList StelOBJ::getShortIndexList | ( | ) | const |
Converts the index list (as returned by getIndexList()) to use unsigned short instead of integer.
If this is not possible (canUseShortIndices() returns false), an empty list is returned.
|
inline |
Returns an vertex list, suitable for loading into OpenGL arrays.
Definition at line 227 of file StelOBJ.hpp.
|
inline |
Returns true if this object contains valid data from a load() method.
Definition at line 256 of file StelOBJ.hpp.
bool StelOBJ::load | ( | const QString & | filename, |
const VertexOrder | vertexOrder = VertexOrder::XYZ |
||
) |
Loads an .obj file by name.
Supports .gz decompression, and then calls load(QIODevice) for the actual loading.
bool StelOBJ::load | ( | QIODevice & | device, |
const QString & | basePath, | ||
const VertexOrder | vertexOrder = VertexOrder::XYZ |
||
) |
Loads an .obj file from the specified device.
device | The device to load OBJ data from |
basePath | The path to use to find additional files (like material definitions) |
vertexOrder | The order to use for vertex positions |
void StelOBJ::rebuildNormals | ( | ) |
Rebuilds vertex normals as the average of face normals.
void StelOBJ::scale | ( | double | factor | ) |
Scales the vertex positions according to the given factor.
This may be useful for importing, because many exporters don't handle very large or very small models well. For example, the solar system objects are modeled with kilometer units, and then converted to AU on loading.
void StelOBJ::splitVertexData | ( | V3Vec * | position, |
V2Vec * | texCoord = Q_NULLPTR , |
||
V3Vec * | normal = Q_NULLPTR , |
||
V3Vec * | tangent = Q_NULLPTR , |
||
V3Vec * | bitangent = Q_NULLPTR |
||
) | const |
Splits the vertex data into separate arrays.
If a given parameter vector is null, it is not filled.
void StelOBJ::transform | ( | const QMatrix4x4 & | mat, |
bool | onlyPosition = false |
||
) |
Applies the given transformation matrix to the vertex data.
onlyPosition | If true, only the position information is transformed, the normals/tangents are skipped |