Image Component Library (ICL)
SceneObject.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLGeom/src/ICLGeom/SceneObject.h **
10 ** Module : ICLGeom **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/ICLConfig.h>
34 #ifndef ICL_HAVE_OPENGL
35 #if WIN32
36 #pragma WARNING("this header must not be included if ICL_HAVE_OPENGL is not defined");
37 #else
38 #warning "this header must not be included if ICL_HAVE_OPENGL is not defined"
39 #endif
40 #endif
41 
42 #include <ICLUtils/CompatMacros.h>
43 #include <ICLUtils/Mutex.h>
44 #include <ICLGeom/Primitive.h>
45 #include <ICLGeom/ViewRay.h>
46 #include <ICLGeom/Hit.h>
47 #include <ICLQt/GLFragmentShader.h>
48 
49 namespace icl{
50  namespace geom{
51 
53  class Scene;
54  class ShaderUtil;
58 
140  class SceneObject{
141  public:
142 
144  friend class Scene;
145 
148 
150 
164  ICLGeom_API SceneObject(const std::string &type,const float *params);
165 
167  static inline SceneObject *cube(float x, float y, float z, float r){
168  const float p[] = { x,y,z,r };
169  return new SceneObject("cube",p);
170  }
171 
173  static inline SceneObject *cuboid(float x, float y, float z, float dx, float dy, float dz){
174  const float p[] = { x,y,z,dx,dy,dz };
175  return new SceneObject("cuboid",p);
176  }
177 
179  static inline SceneObject *sphere(float x, float y, float z, float r, int rzSteps, int xySlices){
180  const float p[] = { x,y,z,r, float(rzSteps), float(xySlices) };
181  return new SceneObject("sphere",p);
182  }
183 
185  static inline SceneObject *spheroid(float x, float y, float z, float rx, float ry, float rz, int rzSteps, int xySlices){
186  const float p[] = { x,y,z,rx, ry, rz, float(rzSteps), float(xySlices) };
187  return new SceneObject("spheroid",p);
188  }
189 
191  static inline SceneObject *superquadric(float x, float y, float z, float rx, float ry, float rz,
192  float dx, float dy, float dz, float e1, float e2, int rzSteps, int xySlices){
193  const float p[] = { x,y,z,rx, ry, rz, dx, dy, dz, e1, e2, float(rzSteps), float(xySlices) };
194  return new SceneObject("superquadric",p);
195  }
196 
197 
199  ICLGeom_API SceneObject(const std::string &objFileName) ;
200 
202 
204  SceneObject(const SceneObject &other) {
206  m_fragmentShader = 0;
207  *this = other;
208  m_parent = 0;
209  }
210 
212 
215 
217  ICLGeom_API virtual ~SceneObject();
218 
220 
222  ICLGeom_API std::vector<Vec> &getVertices();
223 
225  ICLGeom_API const std::vector<Vec> &getVertices() const;
226 
228  ICLGeom_API const std::vector<Vec> &getNormals() const;
229 
231 
233  ICLGeom_API std::vector<GeomColor> &getVertexColors();
234 
236  ICLGeom_API const std::vector<GeomColor> &getVertexColors() const;
237 
238 
240  ICLGeom_API std::vector<Primitive*> &getPrimitives();
241 
243  ICLGeom_API const std::vector<Primitive*> &getPrimitives() const;
244 
246  ICLGeom_API void setVisible(int oredTypes, bool visible, bool recursive = true);
247 
249 
275  ICLGeom_API void setVisible(const std::string &what, bool recursive=true);
276 
278  inline void setVisible(const char *what, bool recursive=true){
279  setVisible(std::string(what),recursive);
280  }
281 
283  ICLGeom_API bool isVisible(Primitive::Type t) const;
284 
286 
288  ICLGeom_API virtual bool isInvisibleForCamera(int camIndex) const { return false; }
289 
291 
294  ICLGeom_API void addVertex(const Vec &p, const GeomColor &color = GeomColor(255, 0, 0, 255));
295 
298 
301 
302 
304  ICLGeom_API void addNormal(const Vec &n);
305 
307 
308  ICLGeom_API void addLine(int x, int y, const GeomColor &color = GeomColor(100, 100, 100, 255));
309 
311 
312  ICLGeom_API void addTriangle(int a, int b, int c, int na, int nb, int nc,
313  const GeomColor &color=GeomColor(0,100,250,255));
314 
316  inline void addTriangle(int a, int b, int c, const GeomColor &color=GeomColor(0,100,250,255)){
317  addTriangle(a,b,c,-1,-1,-1,color);
318  }
319 
320 
322 
323  ICLGeom_API void addQuad(int a, int b, int c, int d, int na, int nb, int nc, int nd,
324  const GeomColor &color=GeomColor(0,100,250,255));
325 
327  inline void addQuad(int a, int b, int c, int d, const GeomColor &color=GeomColor(0,100,250,255)){
328  addQuad(a,b,c,d,-1,-1,-1,-1,color);
329  }
330 
332 
333  ICLGeom_API void addPolygon(int nPoints, const int *vertexIndices, const GeomColor &color = GeomColor(0, 100, 250, 255),
334  const int *normalIndices=0);
335 
336 
338  ICLGeom_API void addTexture(int a, int b, int c, int d,
339  const core::ImgBase *texture,
340  int na, int nb, int nc, int nd,
341  bool createTextureOnce=true,
343 
345  inline void addTexture(int a, int b, int c, int d,
346  const core::ImgBase *texture,
347  bool createTextureOnce=true,
349  addTexture(a,b,c,d,texture,-1,-1,-1,-1,createTextureOnce,sm);
350  }
351 
353 
355  ICLGeom_API void addTexture(int a, int b, int c, int d,
356  int sharedTextureIndex,
357  int na=-1, int nb=-1, int nc=-1, int nd=-1);
358 
360  ICLGeom_API void addTexture(const core::ImgBase *image, int numPoints, const int *vertexIndices,
361  const utils::Point32f *texCoords, const int *normalIndices = 0,
362  bool createTextureOnce=true);
363 
364 
366  ICLGeom_API void addTextureGrid(int w, int h, const core::ImgBase *image,
367  const icl32f *px, const icl32f *py, const icl32f *pz,
368  const icl32f *pnx=0, const icl32f *pny=0, const icl32f *pnz=0,
369  int stride = 1,bool createTextureOnce=true,core::scalemode sm=core::interpolateLIN);
370 
372 
373  ICLGeom_API void addTwoSidedTextureGrid(int w, int h, const core::ImgBase *front, const core::ImgBase *back,
374  const icl32f *px, const icl32f *py, const icl32f *pz,
375  const icl32f *pnx=0, const icl32f *pny=0, const icl32f *pnz=0,
376  int stride = 1,bool createFrontOnce=true,
377  bool createBackOnce=true, core::scalemode sm=core::interpolateLIN);
378 
379 
381  ICLGeom_API void addTwoSidedTGrid(int w, int h, const Vec *vertices, const Vec *normals = 0,
382  const GeomColor &frontColor=GeomColor(0,100,255,255),
383  const GeomColor &backColor=GeomColor(255,0,100,255),
384  const GeomColor &lineColor=GeomColor(0,255,100,255),
385  bool drawLines=false, bool drawQuads=true);
386 
387 
389 
404  ICLGeom_API void addTextTexture(int a, int b, int c, int d, const std::string &text,
405  const GeomColor &color,
406  int na, int nb, int nc, int nd,
407  int textSize,core::scalemode sm = core::interpolateLIN);
408 
409 
411  inline void addTextTexture(int a, int b, int c, int d, const std::string &text,
412  const GeomColor &color=GeomColor(255,255,255,255),
413  int textSize=30, core::scalemode sm = core::interpolateLIN){
414  addTextTexture(a,b,c,d,text,color,-1,-1,-1,-1,textSize, sm);
415  }
416 
418 
423  ICLGeom_API void addText(int a, const std::string &text, float billboardHeight = 10,
424  const GeomColor &color=GeomColor(255,255,255,255),
425  int textRenderSize=30, core::scalemode sm=core::interpolateLIN);
426 
428 
431  inline void addCustomPrimitive(Primitive *p){
432  m_primitives.push_back(p);
433  }
434 
436 
438  SceneObject *addCube(float x, float y, float z, float d){
439  return addCuboid(x,y,z,d,d,d);
440  }
441 
443 
445  ICLGeom_API SceneObject *addCuboid(float x, float y, float z, float dx, float dy, float dz);
446 
448 
450  SceneObject *addSphere(float x, float y, float z, float r,int rzSteps, int xySlices){
451  return addSpheroid(x,y,z,r,r,r,rzSteps,xySlices);
452  }
453 
455 
457  ICLGeom_API SceneObject *addSpheroid(float x, float y, float z, float rx, float ry, float rz, int rzSteps, int xySlices);
458 
460 
462  ICLGeom_API SceneObject *addCylinder(float x, float y, float z, float rx, float ry, float h, int steps);
463 
465 
467  ICLGeom_API SceneObject *addCone(float x, float y, float z, float rx, float ry, float h, int steps);
468 
469 
471  ICLGeom_API void setColor(Primitive::Type t, const GeomColor &color, bool recursive = true);
472 
474  ICLGeom_API void setPointSize(float pointSize, bool recursive = true);
475 
477  ICLGeom_API void setLineWidth(float lineWidth, bool recursive = true);
478 
480  ICLGeom_API void setUseCustomRender(bool use, bool recursive = true);
481 
483  ICLGeom_API virtual SceneObject *copy() const;
484 
486 
487  virtual void prepareForRendering() {}
488 
490 
494  virtual void customRender() {}
495 
497 
503 
505  ICLGeom_API void setColorsFromVertices(Primitive::Type t, bool on, bool recursive = true);
506 
508  ICLGeom_API bool getSmoothShading() const;
509 
511  ICLGeom_API void setSmoothShading(bool on, bool recursive = true);
512 
513 
515 
519  ICLGeom_API virtual void setTransformation(const Mat &m);
520 
523 
525  ICLGeom_API virtual void transform(const Mat &m);
526 
528 
529  template<class T>
530  void transform(const T &m){
531  transform(Mat(m(0,0),m(1,0),m(2,0),m(3,0),
532  m(0,1),m(1,1),m(2,1),m(3,1),
533  m(0,2),m(1,2),m(2,2),m(3,2),
534  m(0,3),m(1,3),m(2,3),m(3,3)));
535  }
536 
538  ICLGeom_API virtual void rotate(float rx, float ry, float rz,
540 
542  template<class T>
543  inline void rotate(const T &t, icl::math::AXES axes=icl::math::AXES_DEFAULT)
544  { rotate((float)t[0],(float)t[1],(float)t[2]); }
545 
547  ICLGeom_API virtual void translate(float dx, float dy, float dz);
548 
550  template<class T>
551  inline void translate(const T &t) { translate((float)t[0],(float)t[1],(float)t[2]); }
552 
554  ICLGeom_API virtual void scale(float sx, float sy, float sz);
555 
557  template<class T>
558  inline void scale(const T &t) { scale((float)t[0],(float)t[1],(float)t[2]); }
559 
561 
564  ICLGeom_API Mat getTransformation(bool relative = false) const;
565 
567 
568  ICLGeom_API bool hasTransformation(bool relative = false) const;
569 
572 
574  ICLGeom_API const SceneObject *getParent() const;
575 
577 
583  ICLGeom_API void addChild(SceneObject *child, bool passOwnerShip = true);
584 
586 
591 
593 
594  ICLGeom_API void removeChild(SceneObject *child);
595 
598 
600  ICLGeom_API bool hasChildren() const;
601 
603  ICLGeom_API int getChildCount() const;
604 
606  ICLGeom_API SceneObject *getChild(int index);
607 
609  ICLGeom_API const SceneObject *getChild(int index) const;
610 
613 
615  ICLGeom_API bool hasChild(const SceneObject *o) const;
618 
631  ICLGeom_API void createAutoNormals(bool smooth = true);
632 
634 
636  virtual GeomColor getDefaultVertexColor() const{ return GeomColor(255,0,0,255); }
637 
639 
647  ICLGeom_API Hit hit(const ViewRay &v, bool recursive = true);
648 
650  const Hit hit(const ViewRay &v, bool recursive=true) const{
651  return const_cast<SceneObject*>(this)->hit(v,recursive);
652  }
653 
655  ICLGeom_API std::vector<Hit> hits(const ViewRay &v, bool recursive = true);
656 
658  ICLGeom_API std::vector<Vec> getTransformedVertices() const;
659 
661 
663  ICLGeom_API Vec getClosestVertex(const Vec &pWorld, bool relative = false) ;
664 
666  ICLGeom_API void setVisible(bool visible, bool recursive = true);
667 
669  bool isVisible() const { return m_isVisible; }
670 
672  void hide(bool recursive=true){ setVisible(false); }
673 
675  void show(bool recursive=true){ setVisible(true); }
676 
677 
679 
682  inline void setLockingEnabled(bool enabled) {
683  m_mutex.lock();
684  m_enableLocking = enabled;
685  m_mutex.unlock();
686  }
687 
689  bool getLockingEnabled() const {
690  return m_enableLocking;
691  }
692 
694 
698  virtual void lock() const{
699  if(!m_enableLocking) return;
700  m_mutex.lock();
701  }
702 
704 
708  virtual void unlock() const{
709  if(!m_enableLocking) return;
710  m_mutex.unlock();
711  }
712 
713  friend struct Primitive;
714 
715 
717 
719  inline void setPointSmoothingEnabled(bool enabled=true){
720  m_pointSmoothingEnabled = enabled;
721  }
722 
724 
726  inline void setLineSmoothingEnabled(bool enabled=true){
727  m_lineSmoothingEnabled = enabled;
728  }
729 
731 
733  inline void setPolygonSmoothingEnabled(bool enabled=true){
734  m_polygonSmoothingEnabled = enabled;
735  }
736 
739 
741  ICLGeom_API virtual void clearObject(bool deleteAndRemoveChildren=true, bool resetTransform=false);
742 
744 
746 
749 
751 
753 
756 
758  inline const qt::GLFragmentShader *getFragmentShader() const{ return m_fragmentShader; }
759 
760  inline void setCastShadowsEnabled(bool castShadows = true) { m_castShadows = castShadows; }
761 
762  inline bool getCastShadowsEnabled() { return m_castShadows; }
763 
764  inline void setReceiveShadowsEnabled(bool receiveShadows = true) { m_receiveShadows = receiveShadows; }
765 
766  inline bool getReceiveShadowsEnabled() { return m_receiveShadows; }
767 
769  inline void setShininess(icl8u value){
770  m_shininess = value;
771  }
772 
774 
775  inline void setSpecularReflectance(const GeomColor &values){
776  m_specularReflectance = values*(1.0/255);
777  }
778 
780  inline bool getDepthTestEnabled() const{ return m_depthTestEnabled; }
781 
783  inline void setDepthTestEnabled(bool enabled, bool recursive = true){
784  m_depthTestEnabled = enabled;
785  if(recursive) {
786  for(int i = 0; i < this->getChildCount(); i++) {
787  this->getChild(i)->setDepthTestEnabled(enabled,true);
788  }
789  }
790  }
791 
793 
798  inline float getPointHitMaxDistance() const {
799  return m_pointHitMaxDistance;
800  }
801 
803 
804  inline void setPointHitMaxDistance(float d){
806  }
807 
808  protected:
810  static void collect_hits_recursive(SceneObject *obj, const ViewRay &v,
811  std::vector<Hit> &hits,
812  bool recursive);
813 
814  std::vector<Vec> m_vertices;
815  std::vector<Vec> m_normals;
816 
817  std::vector<GeomColor> m_vertexColors;
818  std::vector<Primitive*> m_primitives;
819  std::vector<utils::SmartPtr<qt::GLImg> > m_sharedTextures;
821 
826 
828 
829  float m_pointSize;
830  float m_lineWidth;
831 
834 
839  std::vector<utils::SmartPtr<SceneObject> > m_children;
840 
843 
848 
851 
852  private:
853 
857 
861 
864 
867 
869  };
870  } // namespace geom
871 }
872 
ICLGeom_API SceneObject * addSpheroid(float x, float y, float z, float rx, float ry, float rz, int rzSteps, int xySlices)
adds a cuboid child-object with given parameters
ICLGeom_API void setSmoothShading(bool on, bool recursive=true)
sets whether to use smoothshading (default is false)
Simple wrapper class for OpenGL 2.0 Fragment Shader Programs.
Definition: GLFragmentShader.h:45
ICLGeom_API void setColorsFromVertices(Primitive::Type t, bool on, bool recursive=true)
sets how 2D-geom colors are set
virtual void prepareForRendering()
called by the renderer before the object is rendered
Definition: SceneObject.h:487
ICLGeom_API void setColor(Primitive::Type t, const GeomColor &color, bool recursive=true)
tints all Primitives with given type in given color
ICLGeom_API void setUseCustomRender(bool use, bool recursive=true)
if set, only custom render is used
void transform(const T &m)
utility method for passing arbitrary matrix classes
Definition: SceneObject.h:530
ICLGeom_API void addTwoSidedTextureGrid(int w, int h, const core::ImgBase *front, const core::ImgBase *back, const icl32f *px, const icl32f *py, const icl32f *pz, const icl32f *pnx=0, const icl32f *pny=0, const icl32f *pnz=0, int stride=1, bool createFrontOnce=true, bool createBackOnce=true, core::scalemode sm=core::interpolateLIN)
adds a texture grid that has two different texture for the two faces
bool m_useCustomRender
Definition: SceneObject.h:827
bool m_lineSmoothingEnabled
Definition: SceneObject.h:845
ICLGeom_API SceneObject & operator=(const SceneObject &other)
assignment operator for deep copy
int m_visibleMask
Definition: SceneObject.h:820
ICLGeom_API std::vector< Vec > & getVertices()
returns object vertices
virtual ICLGeom_API void translate(float dx, float dy, float dz)
translates the scene object (this affects it's translates matrix)
bool m_useSmoothShading
Definition: SceneObject.h:832
bool getLockingEnabled() const
returns whether locking is current enabled for this object
Definition: SceneObject.h:689
void setReceiveShadowsEnabled(bool receiveShadows=true)
Definition: SceneObject.h:764
undocument this line if you encounter any issues!
Definition: Any.h:37
bool m_polyColorsFromVertices
Definition: SceneObject.h:825
float m_lineWidth
Definition: SceneObject.h:830
void unlock()
unlocks the mutex
Definition: Mutex.h:111
std::vector< utils::SmartPtr< SceneObject > > m_children
Definition: SceneObject.h:839
virtual void complexCustomRender(icl::geom::ShaderUtil *util)
this function is called when an object is rendered
Definition: SceneObject.h:502
Ipp8u icl8u
8Bit unsigned integer type for the ICL
Definition: BasicTypes.h:64
bool m_isVisible
Definition: SceneObject.h:833
ICLGeom_API SceneObject * addCuboid(float x, float y, float z, float dx, float dy, float dz)
adds a cuboid child-object with given parameters
const qt::GLFragmentShader * getFragmentShader() const
returns the current fragment shader (or NULL if non was given, const version)
Definition: SceneObject.h:758
void setPointHitMaxDistance(float d)
sets the maximum distance to a pointing view-ray
Definition: SceneObject.h:804
static SceneObject * superquadric(float x, float y, float z, float rx, float ry, float rz, float dx, float dy, float dz, float e1, float e2, int rzSteps, int xySlices)
create a superquadric scene object
Definition: SceneObject.h:191
float m_pointHitMaxDistance
Definition: SceneObject.h:868
ICLGeom_API SceneObject * getParent()
returns the parent scene object
ICLGeom_API Mat getTransformation(bool relative=false) const
returns the current transformation matrix
SceneObject * addCube(float x, float y, float z, float d)
adds a cube child-object with given parameters
Definition: SceneObject.h:438
ICLGeom_API void addTextureGrid(int w, int h, const core::ImgBase *image, const icl32f *px, const icl32f *py, const icl32f *pz, const icl32f *pnx=0, const icl32f *pny=0, const icl32f *pnz=0, int stride=1, bool createTextureOnce=true, core::scalemode sm=core::interpolateLIN)
adds a texture that is drawn on a 2D grid of vertices in 3D space
virtual ICLGeom_API bool isInvisibleForCamera(int camIndex) const
this can be overwrittern in subclasses to hide an object for given camera indices
Definition: SceneObject.h:288
void setCastShadowsEnabled(bool castShadows=true)
Definition: SceneObject.h:760
bool m_hasTransformation
Definition: SceneObject.h:837
ICLGeom_API int getChildCount() const
returns the number of children
ICLGeom_API std::vector< GeomColor > & getVertexColors()
returns object vertex colors
ICLGeom_API std::vector< Hit > hits(const ViewRay &v, bool recursive=true)
returns all hits with SceneObjects form the given viewray
GeomColor m_specularReflectance
Definition: SceneObject.h:850
Mat4D32f Mat
Short typedef for 4D float matrices.
Definition: GeomDefs.h:90
#define ICLGeom_API
Definition: CompatMacros.h:179
ICLQt_API void text(ImgQ &image, int x, int y, const string &text)
renders a text into an image (only available with Qt-Support)
ICLGeom_API void addText(int a, const std::string &text, float billboardHeight=10, const GeomColor &color=GeomColor(255, 255, 255, 255), int textRenderSize=30, core::scalemode sm=core::interpolateLIN)
adds a billboard text-texture attached to given node index a
bool m_quadColorsFromVertices
Definition: SceneObject.h:824
ICLGeom_API void removeTransformation()
sets the internal transformation to the identity matrix
ICLGeom_API std::vector< Vec > getTransformedVertices() const
returns all vertices in their final world coordinates
ICLGeom_API SceneObject * addCylinder(float x, float y, float z, float rx, float ry, float h, int steps)
adds a cylindical child object with given parameters
Abastract base type for geoemtric primitives.
Definition: Primitive.h:59
void addTexture(int a, int b, int c, int d, const core::ImgBase *texture, bool createTextureOnce=true, core::scalemode sm=core::interpolateLIN)
convenience method for creation of a texture with auto-normals
Definition: SceneObject.h:345
ICLGeom_API void clearAllPrimitives()
deletes and removes all primitives
void show(bool recursive=true)
calls setVisible(true)
Definition: SceneObject.h:675
ICLGeom_API SceneObject * getChild(int index)
returns child at given index
float m_pointSize
Definition: SceneObject.h:829
bool getDepthTestEnabled() const
returns whether depth test is enabled for this object
Definition: SceneObject.h:780
virtual ICLGeom_API SceneObject * copy() const
performs a deep copy of this object
ICLGeom_API void addTriangle(int a, int b, int c, int na, int nb, int nc, const GeomColor &color=GeomColor(0, 100, 250, 255))
adds a new triangle to this onject
void rotate(const T &t, icl::math::AXES axes=icl::math::AXES_DEFAULT)
utility wrapper for vector based rotation
Definition: SceneObject.h:543
virtual ICLGeom_API ~SceneObject()
Empty destructor (but virtual)
Mat m_transformation
for the scene graph implementation
Definition: SceneObject.h:836
ICLGeom_API void setFragmentShader(qt::GLFragmentShader *shader)
sets a fragment shader to use for this object
std::vector< Vec > m_normals
Definition: SceneObject.h:815
ICLGeom_API bool getSmoothShading() const
returns wheather smooth shading is activated
void addTextTexture(int a, int b, int c, int d, const std::string &text, const GeomColor &color=GeomColor(255, 255, 255, 255), int textSize=30, core::scalemode sm=core::interpolateLIN)
convenience method for creation of a text-texture with auto-normals
Definition: SceneObject.h:411
std::vector< utils::SmartPtr< qt::GLImg > > m_sharedTextures
Definition: SceneObject.h:819
std::vector< Vec > m_vertices
Definition: SceneObject.h:814
ICLMath_API const AXES AXES_DEFAULT
ICLGeom_API void setVisible(int oredTypes, bool visible, bool recursive=true)
changes visibility of given primitive type
ICLGeom_API void createAutoNormals(bool smooth=true)
automatically creates precomputed normals
void addTriangle(int a, int b, int c, const GeomColor &color=GeomColor(0, 100, 250, 255))
convenience method for creation of a triangle with auto-normals
Definition: SceneObject.h:316
const Hit hit(const ViewRay &v, bool recursive=true) const
returns whether this object is hit by the given viewray (const)
Definition: SceneObject.h:650
void * m_displayListHandle
internally used flag
Definition: SceneObject.h:855
Ipp32f icl32f
32Bit floating point type for the ICL
Definition: BasicTypes.h:55
bool m_triangleColorsFromVertices
Definition: SceneObject.h:823
ICLGeom_API void addTextTexture(int a, int b, int c, int d, const std::string &text, const GeomColor &color, int na, int nb, int nc, int nd, int textSize, core::scalemode sm=core::interpolateLIN)
adds text-texture quad -primitive to this object
bool m_polygonSmoothingEnabled
Definition: SceneObject.h:846
ICLGeom_API void setPointSize(float pointSize, bool recursive=true)
sets point size
virtual ICLGeom_API void setTransformation(const Mat &m)
Sets a transformation matrix.
ICLGeom_API void freeDisplayList()
frees the displaylist in the next render cycle
bool isVisible() const
returns whether this object is currently visible
Definition: SceneObject.h:669
utility structure that defines a hit between a ViewRay and SceneObjects
Definition: Hit.h:45
utils::SmartPtr< SceneObject > getChildPtr(int index)
returns a shared pointer to the child at given index
void setSpecularReflectance(const GeomColor &values)
sets the materials specular reflectance
Definition: SceneObject.h:775
ICLGeom_API void addTwoSidedTGrid(int w, int h, const Vec *vertices, const Vec *normals=0, const GeomColor &frontColor=GeomColor(0, 100, 255, 255), const GeomColor &backColor=GeomColor(255, 0, 100, 255), const GeomColor &lineColor=GeomColor(0, 255, 100, 255), bool drawLines=false, bool drawQuads=true)
adds a two sided grid (sides may have different colors)
virtual ICLGeom_API void clearObject(bool deleteAndRemoveChildren=true, bool resetTransform=false)
deletes all primitive and all vertex, color and normal content (and optionally also the children)
ICLGeom_API void setLineWidth(float lineWidth, bool recursive=true)
sets point size
void setShininess(icl8u value)
sets the material shininess (default is 128)
Definition: SceneObject.h:769
Definition: ShaderUtil.h:47
ICLGeom_API void addSharedTexture(utils::SmartPtr< qt::GLImg > gli)
adds a GLImg as shared texture
ICLGeom_API bool hasChildren() const
returns whether the SceneObject has children at all
Scene Implementation that is used to handle a list of objects and cameras.
Definition: Scene.h:138
AXES
axes order specifications for euler angles
Definition: FixedMatrix.h:999
ICLGeom_API void addNormal(const Vec &n)
adds a new normal to this object
qt::GLFragmentShader * getFragmentShader()
returns the current fragment shader (or NULL if non was given)
Definition: SceneObject.h:755
virtual void lock() const
locks the internal mutex if locking enabled is set to true
Definition: SceneObject.h:698
ICLGeom_API const std::vector< Vec > & getNormals() const
returns object normals (const)
virtual void customRender()
this function is called when an object is rendered
Definition: SceneObject.h:494
void setDepthTestEnabled(bool enabled, bool recursive=true)
sets whether depth test is enabled for this object
Definition: SceneObject.h:783
ICLGeom_API std::vector< Primitive * > & getPrimitives()
returns object's primitives (lines, quads, etc...)
SceneObject * m_parent
Definition: SceneObject.h:838
ICLGeom_API bool hasTransformation(bool relative=false) const
returns whether the SceneObject has currently a non-ID-transformation
bool getCastShadowsEnabled()
Definition: SceneObject.h:762
virtual ICLGeom_API void transform(const Mat &m)
multiplies the current transformation matrix by given matrix
ICLGeom_API void removeChild(SceneObject *child)
removes given child
icl8u m_shininess
Definition: SceneObject.h:849
void setPolygonSmoothingEnabled(bool enabled=true)
sets whether faces are visualized in a smoothed manner
Definition: SceneObject.h:733
ICLGeom_API void removeAllChildren()
removes all children
int m_createDisplayListNextTime
internal flag
Definition: SceneObject.h:860
ICLGeom_API void addQuad(int a, int b, int c, int d, int na, int nb, int nc, int nd, const GeomColor &color=GeomColor(0, 100, 250, 255))
adds a new triangle to this onject
bool m_receiveShadows
Definition: SceneObject.h:866
This is a view-ray's line equation in parameter form.
Definition: ViewRay.h:49
scalemode
for scaling of Img images theses functions are provided
Definition: Types.h:84
ICLGeom_API Hit hit(const ViewRay &v, bool recursive=true)
returns whether this object is hit by the given viewray
bool m_pointSmoothingEnabled
Definition: SceneObject.h:844
ICLGeom_API void addTexture(int a, int b, int c, int d, const core::ImgBase *texture, int na, int nb, int nc, int nd, bool createTextureOnce=true, core::scalemode sm=core::interpolateLIN)
ICLGeom_API SceneObject * addCone(float x, float y, float z, float rx, float ry, float h, int steps)
adds a conical child object with given parameters
void addQuad(int a, int b, int c, int d, const GeomColor &color=GeomColor(0, 100, 250, 255))
convenience method for creation of a quad with auto-normals
Definition: SceneObject.h:327
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
virtual ICLGeom_API void rotate(float rx, float ry, float rz, icl::math::AXES axes=icl::math::AXES_DEFAULT)
rotates the scene object (this affects it's transformation matrix)
ICLGeom_API void createDisplayList()
creates a displaylist in the next render cycle
std::vector< GeomColor > m_vertexColors
Definition: SceneObject.h:817
core::Color4D32f GeomColor
color for geometry primitives
Definition: GeomDefs.h:45
ICLGeom_API bool hasChild(const SceneObject *o) const
returns whether the given object is a child of this one
ICLQt_API void color(float r, float g=-1, float b=-1, float alpha=255)
sets the current color to given r,g,b,alpha value
void setVisible(const char *what, bool recursive=true)
explicit version for const char pointer to avoid an explicit cast to bool/int
Definition: SceneObject.h:278
SceneObject * addSphere(float x, float y, float z, float r, int rzSteps, int xySlices)
adds a cuboid child-object with given parameters
Definition: SceneObject.h:450
static SceneObject * spheroid(float x, float y, float z, float rx, float ry, float rz, int rzSteps, int xySlices)
create a shere scene object
Definition: SceneObject.h:185
bool m_castShadows
Definition: SceneObject.h:865
Type
primitive type for dynamic handling of different primitives
Definition: Primitive.h:62
virtual void unlock() const
unlocks the internal mutex if locking enabled is set to true
Definition: SceneObject.h:708
utils::Mutex m_mutex
for asynchronous updates
Definition: SceneObject.h:841
ICLGeom_API Vec getClosestVertex(const Vec &pWorld, bool relative=false)
returns the vertex, that is closest to the given point in wold coordinates
bool m_lineColorsFromVertices
Definition: SceneObject.h:822
std::vector< Primitive * > m_primitives
Definition: SceneObject.h:818
void setLockingEnabled(bool enabled)
sets locking enabled or disabled
Definition: SceneObject.h:682
ICLGeom_API void addPolygon(int nPoints, const int *vertexIndices, const GeomColor &color=GeomColor(0, 100, 250, 255), const int *normalIndices=0)
add a polygon to this object (note triangles and quads are slower here)
bool m_depthTestEnabled
default is true
Definition: SceneObject.h:847
ICLGeom_API void addLine(int x, int y, const GeomColor &color=GeomColor(100, 100, 100, 255))
adds a new line to this object
static SceneObject * cube(float x, float y, float z, float r)
create a cube scene object
Definition: SceneObject.h:167
ICLGeom_API void addVertex(const Vec &p, const GeomColor &color=GeomColor(255, 0, 0, 255))
adds a new vertex to this object
static SceneObject * cuboid(float x, float y, float z, float dx, float dy, float dz)
create a cuboid scene object
Definition: SceneObject.h:173
void hide(bool recursive=true)
calls setVisible(false)
Definition: SceneObject.h:672
ICLGeom_API void addChild(SceneObject *child, bool passOwnerShip=true)
adds a new child to this scene object
void setPointSmoothingEnabled(bool enabled=true)
sets whether points are visualized in a smoothed manner
Definition: SceneObject.h:719
void scale(const T &t)
utility wrapper for vector based scaling
Definition: SceneObject.h:558
Mutex class of the ICL.
Definition: Mutex.h:54
SceneObject(const SceneObject &other)
deep copy of SceneObject instance
Definition: SceneObject.h:204
bool m_enableLocking
can be enabled
Definition: SceneObject.h:842
Definition: Types.h:86
static SceneObject * sphere(float x, float y, float z, float r, int rzSteps, int xySlices)
create a shere scene object
Definition: SceneObject.h:179
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
qt::GLFragmentShader * m_fragmentShader
internal optionally given fragment shader
Definition: SceneObject.h:863
static void collect_hits_recursive(SceneObject *obj, const ViewRay &v, std::vector< Hit > &hits, bool recursive)
recursive picking method
virtual ICLGeom_API void scale(float sx, float sy, float sz)
transformes the current transformation matrix by a scale matrix
void addCustomPrimitive(Primitive *p)
adds a custom primitive
Definition: SceneObject.h:431
Specialization of the SmartPtrBase class for Pointers.
Definition: SmartPtr.h:75
The SceneObject class defines visible objects in scenes or scene graph nodes.
Definition: SceneObject.h:140
void setLineSmoothingEnabled(bool enabled=true)
sets whether lines are visualized in a smoothed manner
Definition: SceneObject.h:726
bool getReceiveShadowsEnabled()
Definition: SceneObject.h:766
void lock()
locks the mutex
Definition: Mutex.h:91
virtual GeomColor getDefaultVertexColor() const
can be reimplemented by subclass to provide and interface for setting default vertex color
Definition: SceneObject.h:636
float getPointHitMaxDistance() const
returns the maximum distance to a pointing viewraw
Definition: SceneObject.h:798
ICLGeom_API SceneObject()
create an object
void translate(const T &t)
utility wrapper for vector based translation
Definition: SceneObject.h:551