OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
material.h File Reference
#include <glib-object.h>
#include "mape/group.h"
#include "mape/texture.h"
Include dependency graph for material.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MapeMaterialMapClass
 
struct  _MapeMaterialMap
 

Macros

#define MAPE_TYPE_MATERIAL_MAP   (mape_material_map_get_type())
 
#define MAPE_MATERIAL_MAP(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMap))
 
#define MAPE_MATERIAL_MAP_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMapClass))
 
#define MAPE_IS_MATERIAL_MAP(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), MAPE_TYPE_MATERIAL_MAP))
 
#define MAPE_IS_MATERIAL_MAP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), MAPE_TYPE_MATERIAL_MAP))
 
#define MAPE_MATERIAL_MAP_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMapClass))
 
#define MAPE_TYPE_MATERIAL   (mape_material_get_type())
 

Typedefs

typedef struct _MapeMaterial MapeMaterial
 
typedef struct _MapeMaterialMap MapeMaterialMap
 
typedef struct
_MapeMaterialMapClass 
MapeMaterialMapClass
 
typedef enum _MapeMaterialMapError MapeMaterialMapError
 

Enumerations

enum  _MapeMaterialMapError { MAPE_MATERIAL_MAP_ERROR_LOAD }
 

Functions

GType mape_material_get_type (void) G_GNUC_CONST
 
GType mape_material_map_get_type (void) G_GNUC_CONST
 
MapeMaterialMapmape_material_map_new (void)
 
gboolean mape_material_map_load (MapeMaterialMap *map, MapeGroup *from, GError **error)
 
guint mape_material_map_get_material_count (MapeMaterialMap *map)
 
void mape_material_map_set_default_textures (MapeMaterialMap *matmap, MapeTextureMap *texmap)
 
const MapeMaterialmape_material_map_get_material (MapeMaterialMap *map, guint index)
 
MapeMaterialmape_material_map_get_material_by_name (MapeMaterialMap *map, const gchar *name)
 
const gchar * mape_material_get_name (const MapeMaterial *material)
 
const gchar * mape_material_get_texture_overlay (const MapeMaterial *material)
 

Class Documentation

struct _MapeMaterialMapClass

MapeMaterialMapClass:

This structure does not contain any public fields.

Definition at line 56 of file material.h.

Class Members
GObjectClass parent_class
struct _MapeMaterialMap

MapeMaterialMap:

MapeMaterialMap is an opaque data type. You should only access it via the public API functions.

Definition at line 67 of file material.h.

Class Members
GObject parent

Macro Definition Documentation

#define MAPE_IS_MATERIAL_MAP (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE((obj), MAPE_TYPE_MATERIAL_MAP))
#define MAPE_IS_MATERIAL_MAP_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), MAPE_TYPE_MATERIAL_MAP))

Definition at line 30 of file material.h.

#define MAPE_MATERIAL_MAP (   obj)    (G_TYPE_CHECK_INSTANCE_CAST((obj), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMap))

Definition at line 27 of file material.h.

Referenced by mape_material_map_new().

#define MAPE_MATERIAL_MAP_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST((klass), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMapClass))

Definition at line 28 of file material.h.

#define MAPE_MATERIAL_MAP_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS((obj), MAPE_TYPE_MATERIAL_MAP, MapeMaterialMapClass))

Definition at line 31 of file material.h.

#define MAPE_TYPE_MATERIAL   (mape_material_get_type())

Definition at line 33 of file material.h.

#define MAPE_TYPE_MATERIAL_MAP   (mape_material_map_get_type())

Definition at line 26 of file material.h.

Referenced by mape_material_map_new().

Typedef Documentation

typedef struct _MapeMaterial MapeMaterial

Definition at line 35 of file material.h.

Definition at line 37 of file material.h.

Definition at line 38 of file material.h.

MapeMaterialMapError: : An error occured when loading a material map.

These errors are from the MAPE_MATERIAL_MAP_ERROR error domain. They can occur when operating on material maps.

Enumeration Type Documentation

MapeMaterialMapError: : An error occured when loading a material map.

These errors are from the MAPE_MATERIAL_MAP_ERROR error domain. They can occur when operating on material maps.

Enumerator
MAPE_MATERIAL_MAP_ERROR_LOAD 

Definition at line 47 of file material.h.

47  {
enum _MapeMaterialMapError MapeMaterialMapError

Function Documentation

const gchar* mape_material_get_name ( const MapeMaterial material)

mape_material_get_name: : A MapeMaterial.

Returns the material's name.

Return Value: The name of the material. The string is owned by the MapeMaterial and must not be freed by the user.

Definition at line 371 of file material.c.

References c4_material_handle_get_name().

Referenced by mape_mat_tex_view_reload().

372 {
373  g_return_val_if_fail(material != NULL, NULL);
375 }
const gchar * c4_material_handle_get_name(C4MaterialHandle *material)
typedefG_BEGIN_DECLS struct _C4MaterialHandle C4MaterialHandle

Here is the call graph for this function:

Here is the caller graph for this function:

const gchar* mape_material_get_texture_overlay ( const MapeMaterial material)

mape_material_get_texture_overlay: : A MapeMaterial.

Returns the material's texture overlay as a string. This can be used to make a texture lookup in a corresponding MapeTextureMap.

Return Value: The texture overlay of the material. The string is owned by the MapeMaterial and must not be freed by the user.

Definition at line 388 of file material.c.

References c4_material_handle_get_texture_overlay().

389 {
390  g_return_val_if_fail(material != NULL, NULL);
392 }
const gchar * c4_material_handle_get_texture_overlay(C4MaterialHandle *material)
typedefG_BEGIN_DECLS struct _C4MaterialHandle C4MaterialHandle

Here is the call graph for this function:

GType mape_material_get_type ( void  )

Definition at line 194 of file material.c.

195 {
196  static GType material_type = 0;
197 
198  if(material_type == 0)
199  {
200  material_type = g_boxed_type_register_static(
201  "MapeMaterial",
202  (GBoxedCopyFunc)mape_material_copy,
203  (GBoxedFreeFunc)mape_material_free);
204  }
205 
206  return material_type;
207 }
const MapeMaterial* mape_material_map_get_material ( MapeMaterialMap map,
guint  index 
)

mape_material_map_get_material: : A MapeMaterialMap. : A material index.

Returns the entry with the given index in the map.

Returns: A MapeMaterial representing the indexed material. It is owned by #map and must not be used anymore after the map is finalized.

Definition at line 310 of file material.c.

References c4_material_map_handle_get_num(), _MapeMaterialMapPrivate::handle, MAPE_IS_MATERIAL_MAP, and MAPE_MATERIAL_MAP_PRIVATE.

Referenced by mape_mat_tex_view_reload().

312 {
314 
315  g_return_val_if_fail(MAPE_IS_MATERIAL_MAP(map), NULL);
316 
317  priv = MAPE_MATERIAL_MAP_PRIVATE(map);
318  g_return_val_if_fail(index < c4_material_map_handle_get_num(priv->handle),
319  NULL);
320 
321  return mape_material_new(map, index);
322 }
#define MAPE_IS_MATERIAL_MAP(obj)
Definition: material.h:29
C4MaterialMapHandle * handle
Definition: material.c:45
guint c4_material_map_handle_get_num(C4MaterialMapHandle *material_map)
#define MAPE_MATERIAL_MAP_PRIVATE(obj)
Definition: material.c:55

Here is the call graph for this function:

Here is the caller graph for this function:

MapeMaterial* mape_material_map_get_material_by_name ( MapeMaterialMap map,
const gchar *  name 
)

Definition at line 336 of file material.c.

References c4_material_handle_get_name(), c4_material_map_handle_get_material(), c4_material_map_handle_get_num(), _MapeMaterialMapPrivate::handle, MAPE_IS_MATERIAL_MAP, and MAPE_MATERIAL_MAP_PRIVATE.

338 {
340  const gchar* cur_name;
341  guint i;
342 
343  g_return_val_if_fail(MAPE_IS_MATERIAL_MAP(map), NULL);
344  g_return_val_if_fail(name != NULL, NULL);
345 
346  priv = MAPE_MATERIAL_MAP_PRIVATE(map);
347 
348  for(i = 0; i < c4_material_map_handle_get_num(priv->handle); ++i)
349  {
350  cur_name = c4_material_handle_get_name(
352  );
353 
354  if(g_ascii_strcasecmp(cur_name, name) == 0)
355  return mape_material_new(map, i);
356  }
357 
358  return NULL;
359 }
C4MaterialHandle * c4_material_map_handle_get_material(C4MaterialMapHandle *material_map, guint index)
const gchar * c4_material_handle_get_name(C4MaterialHandle *material)
#define MAPE_IS_MATERIAL_MAP(obj)
Definition: material.h:29
C4MaterialMapHandle * handle
Definition: material.c:45
guint c4_material_map_handle_get_num(C4MaterialMapHandle *material_map)
#define MAPE_MATERIAL_MAP_PRIVATE(obj)
Definition: material.c:55

Here is the call graph for this function:

guint mape_material_map_get_material_count ( MapeMaterialMap map)

mape_material_map_get_material_count: : A MapeMaterialMap.

Returns the number of materials contained in .

Return Value: The number of materials in .

Definition at line 274 of file material.c.

References c4_material_map_handle_get_num(), MAPE_IS_MATERIAL_MAP, and MAPE_MATERIAL_MAP_PRIVATE.

Referenced by mape_mat_tex_view_reload().

275 {
276  g_return_val_if_fail(MAPE_IS_MATERIAL_MAP(map), 0);
278  MAPE_MATERIAL_MAP_PRIVATE(map)->handle);
279 }
#define MAPE_IS_MATERIAL_MAP(obj)
Definition: material.h:29
guint c4_material_map_handle_get_num(C4MaterialMapHandle *material_map)
#define MAPE_MATERIAL_MAP_PRIVATE(obj)
Definition: material.c:55

Here is the call graph for this function:

Here is the caller graph for this function:

GType mape_material_map_get_type ( void  )
gboolean mape_material_map_load ( MapeMaterialMap map,
MapeGroup from,
GError **  error 
)

mape_material_map_load: : A MapeMaterialMap. : An open MapeGroup to load materials from. : Location to store error information, if any.

Loads all the material files (*.c4m) from the group . If this includes materials with the same name as materials already contained in , then the new materials will not be loaded. If an error occurs while loading the material map the function returns FALSE and is set.

Returns: TRUE on success, FALSE on failure.

Definition at line 242 of file material.c.

References _mape_group_get_handle(), c4_material_map_handle_load(), _MapeMaterialMapPrivate::handle, mape_group_is_open(), MAPE_IS_GROUP, MAPE_IS_MATERIAL_MAP, and MAPE_MATERIAL_MAP_PRIVATE.

Referenced by mape_mat_tex_view_reload().

245 {
247  guint new_count;
248 
249  g_return_val_if_fail(MAPE_IS_MATERIAL_MAP(map), FALSE);
250  g_return_val_if_fail(MAPE_IS_GROUP(from), FALSE);
251  g_return_val_if_fail(mape_group_is_open(from), FALSE);
252  g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
253 
254  priv = MAPE_MATERIAL_MAP_PRIVATE(map);
255 
256  new_count = c4_material_map_handle_load(
257  priv->handle, _mape_group_get_handle(from));
258 
259  if(new_count > 0)
260  g_object_notify(G_OBJECT(map), "n-materials");
261 
262  return TRUE;
263 }
guint c4_material_map_handle_load(C4MaterialMapHandle *material_map, C4GroupHandle *group)
C4GroupHandle * _mape_group_get_handle(MapeGroup *group)
Definition: group.c:682
#define MAPE_IS_MATERIAL_MAP(obj)
Definition: material.h:29
C4MaterialMapHandle * handle
Definition: material.c:45
gboolean mape_group_is_open(MapeGroup *group)
Definition: group.c:220
#define MAPE_MATERIAL_MAP_PRIVATE(obj)
Definition: material.c:55
#define MAPE_IS_GROUP(obj)
Definition: group.h:26

Here is the call graph for this function:

Here is the caller graph for this function:

MapeMaterialMap* mape_material_map_new ( void  )

mape_material_map_new:

Creates a new MapeMaterialMap. The map is initially empty. Use mape_material_map_load() to load materials from one or more Material.ocg group files.

Return Value: A new MapeMaterialMap. Free with g_object_unref().

Definition at line 223 of file material.c.

References MAPE_MATERIAL_MAP, and MAPE_TYPE_MATERIAL_MAP.

Referenced by mape_mat_tex_view_reload().

224 {
225  return MAPE_MATERIAL_MAP(g_object_new(MAPE_TYPE_MATERIAL_MAP, NULL));
226 }
#define MAPE_MATERIAL_MAP(obj)
Definition: material.h:27
#define MAPE_TYPE_MATERIAL_MAP
Definition: material.h:26

Here is the caller graph for this function:

void mape_material_map_set_default_textures ( MapeMaterialMap matmap,
MapeTextureMap texmap 
)

mape_material_map_set_default_textures: : A MapeMaterialMap. : A MapeTextureMap to load textures from.

Sets the default textures for the materials in by looking up the texture overlay specified in the material file in .

Definition at line 290 of file material.c.

References _mape_texture_map_get_handle(), c4_material_map_crossmap_materials(), and MAPE_MATERIAL_MAP_PRIVATE.

Referenced by mape_mat_tex_view_reload().

292 {
294  MAPE_MATERIAL_MAP_PRIVATE(matmap)->handle,
296  );
297 }
void c4_material_map_crossmap_materials(C4MaterialMapHandle *material_map, C4TextureMapHandle *texture_map)
C4TextureMapHandle * _mape_texture_map_get_handle(MapeTextureMap *map)
Definition: texture.c:591
#define MAPE_MATERIAL_MAP_PRIVATE(obj)
Definition: material.c:55

Here is the call graph for this function:

Here is the caller graph for this function: