MashData

MashData — An object that contains the data for a model.

Synopsis

#define             MASH_DATA_ERROR
                    MashData;
struct              MashDataClass;
enum                MashDataError;
enum                MashDataFlags;
MashData *          mash_data_new                       (void);
gboolean            mash_data_load                      (MashData *self,
                                                         MashDataFlags flags,
                                                         const gchar *filename,
                                                         GError **error);
void                mash_data_render                    (MashData *self);
void                mash_data_get_extents               (MashData *self,
                                                         ClutterVertex *min_vertex,
                                                         ClutterVertex *max_vertex);

Object Hierarchy

  GObject
   +----MashData

Description

MashData is an object that can represent the data contained in a 3D model file. The data is internally converted to a Cogl vertex buffer so that it can be rendered efficiently.

The MashData object is usually associated with a MashModel so that it can be animated as a regular actor. The data is separated from the actor in this way to make it easy to share data with multiple actors without having to keep two copies of the data.

Details

MASH_DATA_ERROR

#define MASH_DATA_ERROR mash_data_error_quark ()

Error domain for MashData errors


MashData

typedef struct _MashData MashData;

The MashData structure contains only private data.


struct MashDataClass

struct MashDataClass {
};

The MashDataClass structure contains only private data.


enum MashDataError

typedef enum
  {
    MASH_DATA_ERROR_UNKNOWN_FORMAT,
    MASH_DATA_ERROR_UNKNOWN,
    MASH_DATA_ERROR_MISSING_PROPERTY,
    MASH_DATA_ERROR_INVALID,
    MASH_DATA_ERROR_UNSUPPORTED
  } MashDataError;

Error enumeration for MashData

MASH_DATA_ERROR_UNKNOWN_FORMAT

The file has an unknown format.

MASH_DATA_ERROR_UNKNOWN

The underlying library reported an error.

MASH_DATA_ERROR_MISSING_PROPERTY

A property that is needed by MashData is not present in the file. For example, this will happen if the file does not contain the x, y and z properties.

MASH_DATA_ERROR_INVALID

The file is not valid.

MASH_DATA_ERROR_UNSUPPORTED

The file is not supported by your GL driver. This will happen if your driver can't support GL_UNSIGNED_INT indices but the model has more than 65,536 vertices.

enum MashDataFlags

typedef enum
  {
    MASH_DATA_NONE = 0,
    MASH_DATA_NEGATE_X = 1,
    MASH_DATA_NEGATE_Y = 2,
    MASH_DATA_NEGATE_Z = 4
  } MashDataFlags;

Flags used for modifying the data as it is loaded. These can be passed to mash_data_load().

If any of the negate flags are set then they cause the vertex and normal coordinates for the specified axis to be negated. This could be useful when loading a model from a tool which uses a different coordinate system than the one used in your application. For example, in Blender if the view is rotated such that the x-axis is pointing to the right, and the z-axis is pointing out of the screen then y-axis would be pointing directly up. However in Clutter the default transformation is set up such that the y-axis would be pointing down. Therefore if a model is loaded from Blender it would appear upside-down. Also all of the front faces would be in clockwise order. If backface culling is then enabled then the wrong faces would be culled with the default Cogl settings.

To avoid these issues when exporting from Blender it is common to pass the MASH_DATA_NEGATE_Y flag.

MASH_DATA_NONE

No flags

MASH_DATA_NEGATE_X

Negate the X axis

MASH_DATA_NEGATE_Y

Negate the Y axis

MASH_DATA_NEGATE_Z

Negate the Z axis

mash_data_new ()

MashData *          mash_data_new                       (void);

Constructs a new MashData instance. The object initially has no data so nothing will be drawn when mash_data_render() is called. To load data into the object, call mash_data_load().

Returns :

a new MashData.

mash_data_load ()

gboolean            mash_data_load                      (MashData *self,
                                                         MashDataFlags flags,
                                                         const gchar *filename,
                                                         GError **error);

Loads the data from the file called filename into self. The model can then be rendered using mash_data_render(). If there is an error loading the file it will return FALSE and error will be set to a GError instance.

self :

The MashData instance

flags :

Flags used to specify load-time modifications to the data

filename :

The name of a file to load

error :

Return location for an error or NULL

Returns :

TRUE if the load succeeded or FALSE otherwise.

mash_data_render ()

void                mash_data_render                    (MashData *self);

Renders the data contained in the model to the Clutter scene. The current Cogl source material will be used to affect the appearance of the model. This function is not usually called directly but instead the MashData instance is added to a MashModel and this function will be automatically called by the paint method of the model.

self :

A MashData instance

mash_data_get_extents ()

void                mash_data_get_extents               (MashData *self,
                                                         ClutterVertex *min_vertex,
                                                         ClutterVertex *max_vertex);

Gets the bounding cuboid of the vertices in self. The cuboid is represented by two vertices representing the minimum and maximum extents. The x, y and z components of min_vertex will contain the minimum x, y and z values of all the vertices and max_vertex will contain the maximum. The extents of the model are cached so it is cheap to call this function.

self :

A MashData instance

min_vertex :

A location to return the minimum vertex

max_vertex :

A location to return the maximum vertex