Stellarium 0.14.3
|
A basic Wavefront .OBJ format model loader. More...
#include <OBJ.hpp>
Classes | |
struct | Material |
Encapsulates all information that the describes the surface appearance of a StelModel. More... | |
struct | StelModel |
Structure for a Mesh, will be used with Stellarium to render Holds the starting index, the number of triangles and a pointer to the MTL. 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 } |
OBJ files can have vertices encoded in different order. More... | |
Public Member Functions | |
OBJ () | |
Initializes values. More... | |
~OBJ () | |
Destructor. More... | |
void | clean () |
Cleanup, will be called inside the destructor. More... | |
bool | load (const QString &filename, const enum vertexOrder order, bool rebuildNormals=false) |
Loads the given obj file and, if specified rebuilds normals. More... | |
void | transform (QMatrix4x4 mat) |
Transform all the vertices through multiplication with a 4x4 matrix. More... | |
Material & | getMaterial (int i) |
Returns a Material. More... | |
const StelModel & | getStelModel (int i) const |
Returns a StelModel. More... | |
void | finalizeForRendering () |
This should be called after textures are loaded, and will re-order the StelModels to be grouped by their material. More... | |
void | transparencyDepthSort (const Vec3f &position) |
Sorts the transparent StelModels according to their distance to the specified position. More... | |
int | getNumberOfIndices () const |
Getters for various datastructures. More... | |
int | getNumberOfStelModels () const |
int | getNumberOfTriangles () const |
int | getNumberOfVertices () const |
int | getNumberOfMaterials () const |
const Vertex & | getVertex (int i) const |
Returns a vertex reference. More... | |
const Vertex * | getVertexArray () const |
Returns the vertex array. More... | |
int | getVertexSize () const |
Returns the vertex size. More... | |
bool | isLoaded () const |
Returns flags. More... | |
bool | hasPositions () const |
bool | hasTextureCoords () const |
bool | hasNormals () const |
bool | hasTangents () const |
bool | hasStelModels () const |
const AABB & | getBoundingBox () |
Returns the bounding box for this OBJ. More... | |
void | renderAABBs () |
size_t | memoryUsage () |
Returns an estimate of the memory usage of this instance (not fully accurate, but good enough) More... | |
void | uploadTexturesGL () |
Uploads the textures to GL (requires valid context) More... | |
void | uploadBuffersGL () |
Uploads the vertex and index data to GL buffers (requires valid context) More... | |
void | bindGL () |
Binds the necessary GL objects, making the OBJ ready for drawing. Uses a VAO if the platform supports it. More... | |
void | unbindGL () |
Unbinds this object's GL objects. More... | |
OBJ & | operator= (const OBJ &other) |
Copy assignment operator. No deep copies are performed, but QVectors have copy-on-write semantics, so this is no problem. Does not copy GL objects. More... | |
Static Public Member Functions | |
static void | setupGL () |
Set up some stuff that requires a valid OpenGL context. More... | |
static GLenum | getIndexBufferType () |
Returns the OpenGL index buffer type supported on this hardware. More... | |
static size_t | getIndexBufferTypeSize () |
A basic Wavefront .OBJ format model loader.
FS: The internal loader still is not very robust, uses many C IO functions (fopen,fscanf...) and will have serious problems handling a malformed file including many potential buffer overflows. Meaning: Do NOT use for untrusted, downloaded files!
enum OBJ::vertexOrder |
OBJ::OBJ | ( | ) |
Initializes values.
OBJ::~OBJ | ( | ) |
Destructor.
void OBJ::bindGL | ( | ) |
Binds the necessary GL objects, making the OBJ ready for drawing. Uses a VAO if the platform supports it.
void OBJ::clean | ( | ) |
Cleanup, will be called inside the destructor.
void OBJ::finalizeForRendering | ( | ) |
This should be called after textures are loaded, and will re-order the StelModels to be grouped by their material.
Furthermore, this is a prerequisite for transparencyDepthSort.
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool OBJ::load | ( | const QString & | filename, |
const enum vertexOrder | order, | ||
bool | rebuildNormals = false |
||
) |
Loads the given obj file and, if specified rebuilds normals.
size_t OBJ::memoryUsage | ( | ) |
Returns an estimate of the memory usage of this instance (not fully accurate, but good enough)
Copy assignment operator. No deep copies are performed, but QVectors have copy-on-write semantics, so this is no problem. Does not copy GL objects.
|
static |
Set up some stuff that requires a valid OpenGL context.
void OBJ::transform | ( | QMatrix4x4 | mat | ) |
Transform all the vertices through multiplication with a 4x4 matrix.
mat | Matrix to multiply vertices with. |
void OBJ::transparencyDepthSort | ( | const Vec3f & | position | ) |
Sorts the transparent StelModels according to their distance to the specified position.
They are sorted so that they can be drawn back-to-front.
void OBJ::unbindGL | ( | ) |
Unbinds this object's GL objects.
void OBJ::uploadBuffersGL | ( | ) |
Uploads the vertex and index data to GL buffers (requires valid context)
void OBJ::uploadTexturesGL | ( | ) |
Uploads the textures to GL (requires valid context)