Stellarium 0.14.3
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions
OBJ Class Reference

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...
 
MaterialgetMaterial (int i)
 Returns a Material. More...
 
const StelModelgetStelModel (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 VertexgetVertex (int i) const
 Returns a vertex reference. More...
 
const VertexgetVertexArray () 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 AABBgetBoundingBox ()
 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...
 
OBJoperator= (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 ()
 

Detailed Description

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!

Definition at line 63 of file OBJ.hpp.

Member Enumeration Documentation

OBJ files can have vertices encoded in different order.

Only XYZ and XZY may occur in real life, but we can cope with all...

Definition at line 68 of file OBJ.hpp.

Constructor & Destructor Documentation

OBJ::OBJ ( )

Initializes values.

OBJ::~OBJ ( )

Destructor.

Member Function Documentation

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.

const AABB & OBJ::getBoundingBox ( )
inline

Returns the bounding box for this OBJ.

Definition at line 376 of file OBJ.hpp.

static GLenum OBJ::getIndexBufferType ( )
inlinestatic

Returns the OpenGL index buffer type supported on this hardware.

OpenGL ES may not support integer indices, so this is necessary.

Definition at line 240 of file OBJ.hpp.

OBJ::Material & OBJ::getMaterial ( int  i)
inline

Returns a Material.

Definition at line 343 of file OBJ.hpp.

int OBJ::getNumberOfIndices ( ) const
inline

Getters for various datastructures.

Definition at line 347 of file OBJ.hpp.

const OBJ::StelModel & OBJ::getStelModel ( int  i) const
inline

Returns a StelModel.

Definition at line 345 of file OBJ.hpp.

const OBJ::Vertex & OBJ::getVertex ( int  i) const
inline

Returns a vertex reference.

Definition at line 357 of file OBJ.hpp.

const OBJ::Vertex * OBJ::getVertexArray ( ) const
inline

Returns the vertex array.

Definition at line 359 of file OBJ.hpp.

int OBJ::getVertexSize ( ) const
inline

Returns the vertex size.

Definition at line 361 of file OBJ.hpp.

bool OBJ::isLoaded ( ) const
inline

Returns flags.

Definition at line 363 of file OBJ.hpp.

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)

OBJ& 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.

static void OBJ::setupGL ( )
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.

Parameters
matMatrix 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)


The documentation for this class was generated from the following file: