LightWrap++
AC++wrapperfortheLightWave3DSDK
objectinfo.h
Go to the documentation of this file.
1 #ifndef LWPP_OBJECTINFO_H
2 #define LWPP_OBJECTINFO_H
3 
4 #include <lwpp/wrapper.h>
5 #include <lwsurf.h>
6 #include <set>
7 
8 namespace lwpp
9 {
10 
13  class ObjectInfo : protected GlobalBase<LWObjectInfo>
14  {
15  LWItemID item;
16  public:
18 
21  ObjectInfo(LWItemID _item = 0)
22  : item (_item)
23  {
24  ;
25  }
26  void setObject(LWItemID _item)
27  {
28  item = _item;
29  }
30  const char *filename() const {return globPtr->filename(item);}
31  int numPoints() const {return globPtr->numPoints(item);}
32  int numPolygons() const {return globPtr->numPolygons(item);}
33  unsigned int shadowOpts() const {return globPtr->shadowOpts(item);}
34  double dissolve(LWTime time) const {return globPtr->dissolve(item, time);}
35  LWMeshInfoID meshInfo(bool frozen = false) const {return globPtr->meshInfo(item, frozen);}
36  unsigned int flags() const {return globPtr->flags(item);}
37  double fog(LWTime time) const {return globPtr->fog(item, time);}
38  LWTextureID dispMap() const {return globPtr->dispMap(item);}
39  LWTextureID clipMap() const {return globPtr->clipMap(item);}
40  void patchLevel(int *display, int *render) const {globPtr->patchLevel(item, display, render);}
41  void metaballRes(double *display, double *render) const {globPtr->metaballRes(item, display, render);}
42  LWItemID boneSource() const {return globPtr->boneSource(item);}
43  LWItemID morphTarget() const {return globPtr->morphTarget(item);}
44  double morphAmount(LWTime time) const {return globPtr->morphAmount(item, time);}
45  unsigned int edgeOpts() const {return globPtr->edgeOpts(item);}
46  void edgeColor(LWTime time, LWDVector color) const {globPtr->edgeColor(item, time, color);}
47  int subdivOrder() const {return globPtr->subdivOrder(item);}
48  double polygonSize(LWTime time) const {return globPtr->polygonSize(item, time);}
49  bool excluded (LWItemID light) const
50  {
51  if (!available()) return false; // safguard to evaluation in Modeler
52  return globPtr->excluded(item, light) != 0;
53  }
54  void matteColor(LWTime time, LWDVector color) const {globPtr->matteColor(item, time, color);}
55  double thickness(LWTime time, int type) const {return globPtr->thickness(item, time, type);}
56  double edgeZScale(LWTime time) const {return globPtr->edgeZScale(item, time);}
57  };
58 
59  class SceneObjects : protected GlobalBase<LWObjectFuncs>
60  {
61  public:
62  SceneObjects(void) {;}
63 
64  int numObjects(void) const {return globPtr->numObjects();}
65  const char *filename(int obj) const {return globPtr->filename(obj);}
66  int maxLayers(int obj) const {return globPtr->maxLayers(obj);}
67  int layerExists(int obj, int layer) const {return globPtr->layerExists(obj, layer);}
68  LWMeshInfoID layerMesh(int obj, int layer) const {return globPtr->layerMesh(obj, layer);}
69  const char *vmapName(LWID type, int index) const {return globPtr->vmapName(type, index);}
70  int numVMaps (LWID type) const {return globPtr->numVMaps(type);}
71  int vmapDim (LWID type, int index) const {return globPtr->vmapDim(type, index);}
72  const char *userName(int obj) const {return globPtr->userName(obj);}
73  const char *refName(int obj) const {return globPtr->refName(obj);}
74  // Helper functions
75  int findVmapIndex(const std::string &name, LWID id)
76  {
77  if (!name.empty())
78  {
79  int max = numVMaps(id);
80  for (int i = 0; i < max; ++i)
81  {
82  if (name == vmapName(id, i)) return i;
83  }
84  }
85  return -1;
86  }
87  int findObject (const std::string &objectName);
88  std::set <LWSurfaceID> getSurfaces(int idx);
89 /*
90  typedef struct st_LWObjectFuncs {
91  void (*pivotPoint) (int obj, int lnum, LWFVector pos);
92  LWID (*vmapType) (int index);
93  const char * (*layerName) (int obj, int lnum);
94  int (*layerVis) (int obj, int lnum);
95  } LWObjectFuncs;
96 */
97 
98  };
99 
101 
106  template <bool showNone = true>
108  {
109  protected:
111  virtual size_t popCount (void)
112  {
113  return numObjects() + (showNone ? 1 : 0);
114  }
116  virtual const char *popName (int idx)
117  {
118  if (showNone)
119  {
120  if (idx == 0) return "(none)";
121  --idx;
122  }
123  return userName(idx);
124  }
125  public:
129  int *DataGet ()
130  {
131  return &index;
132  }
134  void DataSet(void *value)
135  {
136  index = *((int *)value);
137  }
138  };
139 
141  {
142  private:
143  LWID type; // VMap ID
144  SceneObjects so;
145  bool showNone;
146  protected:
147  virtual size_t popCount(void)
148  {
149  return so.numVMaps(type) + (showNone ? 1 : 0);
150  }
151  virtual const char *popName(int n)
152  {
153  if (showNone)
154  {
155  if (n == 0) return "(none)";
156  --n;
157  }
158  return so.vmapName(type, n );
159  }
160  public:
161  VMapCallbacks (LWID _type, bool _showNone = true) : type(_type), showNone(_showNone) {;}
162  virtual ~VMapCallbacks() {;}
163  };
164 }
165 #endif //LWPP_OBJECTINFO_H