LightWrap++
AC++wrapperfortheLightWave3DSDK
camerainfo.h
Go to the documentation of this file.
1 #ifndef LWPP_CAMINFO_H
2 #define LWPP_CAMINFO_H
3 
4 #include <lwpp/global.h>
5 #include <lwrender.h>
6 #include <lwpp/lw_version.h>
7 #include <lwpp/math.h>
8 
9 namespace lwpp
10 {
12 
15  class CameraInfo : protected GlobalBase<LWCameraInfo>
16  {
17  private:
18  LWItemID camera;
19  public:
21  CameraInfo(LWItemID _camera = LWITEM_NULL)
22  : camera(_camera) {;}
23 
25  LWItemID getID() const {return camera;}
26 
30  void setID(LWItemID _camera) {camera = _camera;}
31 
35  double zoomFactor (LWTime time) {return globPtr->zoomFactor(camera, time);}
36 
40  double focalLength (LWTime time) {return globPtr->focalLength(camera, time);}
41 
45  double focalDistance (LWTime time) {return globPtr->focalDistance(camera, time);}
46 
50  double fStop (LWTime time) {return globPtr->fStop(camera, time);}
51 
56  double blurLength (LWTime time) {return globPtr->blurLength(camera, time);}
57 
64  void fovAngles (LWTime time, double *hfov, double *vfov) {globPtr->fovAngles (camera, time, hfov, vfov);}
65 
67  unsigned int flags () {return globPtr->flags(camera);}
68 
70  bool isStereo () {return (flags() & LWCAMF_STEREO);}
71 
72 #ifndef LWCAMF_EYE
73 #define LWCAMF_EYE (1<<9) /* In Stereo Rendering, This Indicates Which Eye Is Being Processed. */
74 #endif
75  bool isRightEye () {return (flags() & LWCAMF_EYE) != 0;}
76 
78  bool hasLimitedRegion () {return (flags() & LWCAMF_LIMITED_REGION) != 0;}
79 
81  bool hasMask () {return (flags() & LWCAMF_MASK) != 0;}
82 
84  bool hasDOF () {return (flags() & LWCAMF_DOF) != 0;}
85 
89  bool hasParticleBlur() {return (flags() & LWCAMF_PARTICLE_BLUR) != 0;}
90 
92  bool hasNoLRBorders () {return (flags() & LWCAMF_LR_NOBORDERS) != 0;}
93 
97  const char *whichField () {return (flags() & LWCAMF_FIELD) ? "Even/Upper First" : "Odd/Lower First";}
98 
100  bool usePlugin () {return (flags() & LWCAMF_USECAMTYPE) != 0;}
101 
105  bool supportsDOF () {return (flags() & LWCAMF_SUPPORTS_DOF) != 0;}
106 
111  void resolution(int *w, int *h) {globPtr->resolution(camera, w, h);}
112 
119  double pixelAspect(LWTime time) {return globPtr->pixelAspect(camera, time);}
120 
125  double separation(LWTime time) {return globPtr->separation(camera, time);}
126 
134  void regionLimits(int *x0, int *y0, int *x1, int *y1) const {globPtr->regionLimits(camera, x0, y0, x1, y1);}
135 
144  void maskLimits(int *x0, int *y0, int *x1, int *y1) const {globPtr->maskLimits(camera, x0, y0, x1, y1);}
145 
150  void maskColor(LWDVector color) {globPtr->maskColor(camera, color);}
151 
159  unsigned int motionBlur() {return globPtr->motionBlur(camera);}
160 
168  unsigned int fieldRendering() {return globPtr->fieldRendering(camera);}
169 
173  bool hasNotFields() { return (this->fieldRendering() == LWCAMFIELDR_OFF) == 1;}
174 
178  bool evenFirst() { return (this->fieldRendering() == LWCAMFIELDR_EVENFIRST) == 1;}
179 
183  bool oddFirst() { return (this->fieldRendering() == LWCAMFIELDR_ODDFIRST) == 1;}
184 
195  int irisPos( LWTime time, int pass, float *irisx, float *irisy){return globPtr->irisPos(camera, time, pass, irisx, irisy);}
196 
198  bool usingGlobalResolution () {return (globPtr->usingGlobalResolution( camera ) == 1);}
199 
201  bool usingGlobalBlur () {return (globPtr->usingGlobalBlur( camera ) == 1);}
202 
204  bool usingGlobalMask () {return (globPtr->usingGlobalMask( camera ) == 1);}
205 
210  int motionBlurPasses(LWTime time) {return globPtr->motionBlurPasses(camera, time);}
211 
217  double shutterEfficiency( LWTime time ) {return globPtr->shutterEfficiency(camera, time);}
218 
220  unsigned int noiseSampler() {return globPtr->noiseSampler(camera);}
221 
227  void filmSize (double *width, double *height) {globPtr->filmSize(camera, width, height);}
228 
235  bool frameTiming (LWFrame frame, LWFrameTimingInfo *timingInfo) {return globPtr->frameTiming (camera, frame, timingInfo) ? true : false;}
236 
240  unsigned int antiAliasing ( LWTime time ) { return globPtr->antiAliasing (camera, time);}
241 
245  double overSampling ( LWTime time) { return globPtr->overSampling(camera, time);}
246 
252  void diaphragm( LWTime time, int *sides, double* rotation ) { globPtr->diaphragm(camera, time, sides, rotation);}
253 
254  };
255 
256  //added evaluator
257  //Usage, CameraEvaluator myEvaluator(LWItemID cameraID);
258  //then myEvaluator.Evaluate(imagex,imagey,CameraRay*);
259  class CameraEvaluator : protected GlobalBase<LWCameraEvaluationFuncs>
260  {
261  private:
262  LWCameraEvaluatorID cameraEvaluator;
263 
264  bool init;
265  bool newframe;
266  bool cleanup;
267  public:
268  LWCameraRay camRay;
269  //Simple constructor, loads first camera
270  CameraEvaluator() : init(false), newframe(false), cleanup(false), cameraEvaluator(0)
271  {
272  ItemInfo myItem;
273  Create(myItem.first(LWI_CAMERA, NULL));
274  }
275  //Define which camera you want to use
276  CameraEvaluator(LWItemID _camera) : init(false), newframe(false), cleanup(false), cameraEvaluator(0)
277  {
278  Create(_camera);
279  }
280  CameraEvaluator(CameraInfo _caminfo) : init(false), newframe(false), cleanup(false), cameraEvaluator(0)
281  {
282  Create(_caminfo.getID());
283  }
285  {
286  if(!cleanup)CleanUp();
287  Destroy();
288  }
289  //Create evaluator
290  void Create(LWItemID cameraID)
291  {
292  if(cameraEvaluator) Destroy();
293  cameraEvaluator = globPtr->create(cameraID);
294  init=false; newframe=false; cleanup=false;
295  }
296 
297  void Destroy()
298  {
299  if(!cleanup) CleanUp();
300  globPtr->destroy(cameraEvaluator);
301  }
302 
303  LWError Init(int mode)
304  {
305  init=true;
306  return globPtr->init(cameraEvaluator, mode);
307  }
308 
309  void CleanUp()
310  {
311  cleanup=true;
312  globPtr->cleanUp(cameraEvaluator);
313  }
314 
315  LWError NewTime(LWFrame frame, LWTime time)
316  {
317  return globPtr->newTime(cameraEvaluator, frame, time);
318  }
319 
320  int Preview(double lpx, double lpy, LWDMatrix4 projection)
321  {
322  return globPtr->preview(cameraEvaluator, lpx, lpy, projection);
323  }
324  LWError NewFrame()
325  {
326  if(!init) Init(LWINIT_RENDER);
327  newframe=true;
328  return globPtr->newFrame(cameraEvaluator);
329  }
330 
331  /* Evaluation Functions
332  Overloaded so you can use simple or complex calls
333  */
334  /* Full Evaluation function */
335  int Evaluate(double fpx, double fpy, double lpx, double lpy, double fractime, LWCameraRay* mycamray)
336  {
337  if(!init) Init(LWINIT_RENDER);
338  if(!newframe) NewFrame();
339  int retValue = globPtr->evaluate(cameraEvaluator,fpx,fpy,lpx,lpy,fractime,mycamray);
340  camRay = *mycamray;
341  return retValue;
342  }
343  /* Simple, non DOF lens, takes image position and time only */
344  inline int Evaluate(double fpx, double fpy, double fractime)
345  {
346  return Evaluate(fpx, fpy, 0.0, 0.0, fractime, &camRay);
347  }
348  };
349 }
350 #endif // LWPP_CAMINFO_H