source: golgotha/src/golg/objs/model_id.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.1 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef G1_MODEL_ID_HH
10#define G1_MODEL_ID_HH
11
12#include "arch.hh"
13#include "g1_limits.hh"
14#include "memory/growheap.hh"
15#include "init/init.hh"
16#include "error/error.hh"
17#include "memory/array.hh"
18
19class i4_str;
20class g1_quad_object_class;
21class r1_render_api_class;
22class r1_texture_manager_class;
23
24typedef w16 g1_model_id_type;
25
26// G3d model repository for the game
27class g1_model_list_class : public i4_init_class
28{
29  friend g1_model_info_compare(const void *a, const void *b);
30  struct model_info
31  {
32    g1_quad_object_class *model;
33    char *name_start;
34  } *array;
35
36
37  i4_grow_heap_class *name_buffer;
38  int   total_models;
39
40  virtual void init();
41  virtual void uninit();
42
43public:
44  void reset(i4_array<i4_str *> &model_names, r1_texture_manager_class *tmap);
45
46
47  g1_quad_object_class *get_model(w16 handle) const
48  {
49    if (handle>=total_models)
50      i4_error("get_model : bad handle");
51
52    return array[handle].model;
53  }
54
55  g1_model_id_type find_handle(const char *name) const;
56  void cleanup();
57 
58  char *get_model_name(w16 handle) const
59  {
60    return array[handle].name_start;
61  }
62};
63
64extern g1_model_list_class g1_model_list_man;
65
66
67class g1_model_ref
68{
69public:
70  char *name;
71  g1_model_id_type value;
72  g1_model_ref *next;
73 
74  g1_model_ref(char *name=0);  // assumes name is a static value (it is not copied)
75  void set_name(char *name);
76  ~g1_model_ref();
77
78  g1_model_id_type id() const { return value; }
79  g1_quad_object_class *get() const { return g1_model_list_man.get_model(value); }
80  g1_quad_object_class *operator()() const { return g1_model_list_man.get_model(value); }
81};
82
83#endif
Note: See TracBrowser for help on using the repository browser.