Mash Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy |
#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
);
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.
struct MashDataClass { };
The MashDataClass structure contains only private data.
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
The file has an unknown format. | |
The underlying library reported an error. | |
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. | |
The file is not valid. | |
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. |
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.
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. |
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.
|
The MashData instance |
|
Flags used to specify load-time modifications to the data |
|
The name of a file to load |
|
Return location for an error or NULL
|
Returns : |
TRUE if the load succeeded or FALSE otherwise. |
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.
|
A MashData instance |
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.
|
A MashData instance |
|
A location to return the minimum vertex |
|
A location to return the maximum vertex |