AGX Dynamics  2.35.0.1
agxRender/RenderProxy.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXRENDER_RENDERPROXY_H
18 #define AGXRENDER_RENDERPROXY_H
19 
20 
21 #include <agx/agxPhysics_export.h>
22 #include <agx/DynamicsSystem.h>
23 
24 namespace agxCollide
25 {
26  class Shape;
27  class Geometry;
28  class Sphere;
29  class Box;
30  class HeightField;
31  class Line;
32  class Cylinder;
33  class HollowCylinder;
34  class Capsule;
35  class Cone;
36  class HollowCone;
37  class Trimesh;
38  class Plane;
39  class WireShape;
40 }
41 
42 namespace agxSDK
43 {
44  class Simulation;
45 }
46 
47 namespace agxRender
48 {
49 
50 
69  };
70 
72 
77  {
78  public:
79 
81  enum EventType {
88  RENDERMODE
89  };
90 
91  enum RenderMode {
92  NOT_SET = 0x0,
93  SOLID = 0x1,
94  WIREFRAME = 0x2
95  };
96 
98  RenderProxy( PrimitiveType type, agxCollide::Shape *shape = nullptr );
99 
101  PrimitiveType getType() const;
102 
104  virtual void setTransform( const agx::AffineMatrix4x4& transform );
105 
109  virtual void setColor( const agx::Vec3& color );
110 
114  virtual agx::Vec3 getColor() const;
115 
116 
120  virtual void setAlpha( float alpha );
121 
123  virtual float getAlpha() const;
124 
128  virtual void updateShape() {}
129 
130 
132  const agx::AffineMatrix4x4& getTransform() const;
133 
140  agx::UInt32 getModifiedCount() const;
141 
142 
143  const agxCollide::Shape *getShape() const;
144  const agxCollide::Geometry *getGeometry() const;
145 
147  bool compare() const;
148 
153  void callOnChange( EventType type );
154 
159  void setEnable( bool flag );
160 
162  bool getEnable() const;
163 
165  inline bool isEnabled() const { return getEnable(); }
166 
171  void setRenderMode( RenderMode mode );
172 
174  RenderMode getRenderMode( ) const;
175 
177  virtual void reset();
178 
182  static agx::Bool shouldRender( const agx::RigidBody* rb );
183 
184  protected:
188  virtual void synchronizeParameters() {}
189 
195  virtual void onChange( EventType /*type*/ ) {}
196 
197  friend class RenderManager;
198  void setModifiedCount( agx::UInt32 c );
200  void setShape( agxCollide::Shape* shape, const agxCollide::Geometry *geometry );
201 
203  virtual ~RenderProxy();
204 
207 
208  private:
209  PrimitiveType m_type;
210  const agxCollide::Geometry* m_geometry;
211  agx::UInt32 m_modifiedCount;
212  float m_alpha;
213  agx::Vec3 m_color;
214  bool m_enable;
215  agx::Int32 m_renderMode;
216  };
217 
220  {
221  public:
222 
224  TextProxy( const agx::String& text, const agx::Vec3& pos );
225 
226  void set( const agx::String& text, const agx::Vec3& pos ) {
227  m_text = text;
228  m_transform.setTranslate( pos[0], pos[1], pos[2] );
229  callOnChange( SHAPE );
230  }
232  return m_text;
233  }
235  return m_transform.getTranslate();
236  }
237 
238  protected:
239  virtual ~TextProxy() {}
241  };
242 
245  {
246  public:
247 
249  PlaneProxy( const agx::Vec3& normal, agx::Real distance );
250 
251  void set( const agx::Vec3& normal, agx::Real distance ) {
252  m_normal = normal;
253  m_distance = distance;
254  callOnChange( SHAPE );
255  }
256 
259 
261  return m_normal;
262  }
264  return m_distance;
265  }
266 
267  protected:
268 
270 
271  virtual ~PlaneProxy() {}
274  };
275 
278  {
279  public:
280 
281  SphereProxy() : RenderProxy( PRIMITIVE_SPHERE ), m_radius( 0 ) {}
282  SphereProxy( float radius );
283 
284  void set( float radius ) {
285  m_radius = radius;
286  callOnChange( SHAPE );
287  }
288 
289  float getRadius() const {
290  return m_radius;
291  }
292 
295 
296  protected:
297 
299 
300  virtual ~SphereProxy() {}
301  float m_radius;
302  };
303 
306  {
307  public:
308 
310  LineProxy( const agx::Vec3& p1, const agx::Vec3& p2 );
311 
312  void set( const agx::Vec3& p1, const agx::Vec3& p2 ) {
313  m_p1 = p1;
314  m_p2 = p2;
315  callOnChange( SHAPE );
316  }
317  agx::Vec3 getP1() const {
318  return m_p1;
319  }
320  agx::Vec3 getP2() const {
321  return m_p2;
322  }
323 
326 
327  protected:
328 
330 
331  virtual ~LineProxy() {}
334  };
335 
338  {
339  public:
340 
342  CylinderProxy( float radius, float height );
343  CylinderProxy( const agx::Vec3& begin, const agx::Vec3& end, float radius );
344 
345  void set( float radius, float height ) {
346  m_radius = radius;
347  m_height = height;
348  callOnChange( SHAPE );
349  }
350  void set( const agx::Vec3& begin, const agx::Vec3& end, float radius );
351 
353  float getRadius() const {
354  return m_radius;
355  }
356 
358  float getHeight() const {
359  return m_height;
360  }
361 
364 
365  protected:
366 
368 
369  virtual ~CylinderProxy() {}
370  float m_height;
371  float m_radius;
372  };
373 
374 
377  {
378  public:
379 
381  HollowCylinderProxy( float radius, float height, float thickness );
382  HollowCylinderProxy( const agx::Vec3& begin, const agx::Vec3& end, float radius, float thickness );
383 
384  void set( float radius, float height, float thickness ) {
385  m_radius = radius;
386  m_height = height;
387  m_thickness = thickness;
388  callOnChange( SHAPE );
389  }
390 
391  void set( const agx::Vec3& begin, const agx::Vec3& end, float radius, float thickness );
392 
394  float getRadius() const {
395  return m_radius;
396  }
397 
399  float getHeight() const {
400  return m_height;
401  }
402 
404  float getThickness() const {
405  return m_thickness;
406  }
407 
410 
411  protected:
413 
414  virtual ~HollowCylinderProxy() {}
415  float m_height;
416  float m_radius;
417  float m_thickness;
418  };
419 
420 
421 
424  {
425  public:
426 
428  ConeProxy( float radius, float height );
429  ConeProxy( const agx::Vec3& begin, const agx::Vec3& end, float radius );
430 
431  void set( float radius, float height ) {
432  m_radius = radius;
433  m_height = height;
434  callOnChange( SHAPE );
435  }
436 
437  void set( const agx::Vec3& begin, const agx::Vec3& end, float radius );
438 
440  float getRadius() const {
441  return m_radius;
442  }
443 
445  float getHeight() const {
446  return m_height;
447  }
448 
449 
452  protected:
453 
455 
456  virtual ~ConeProxy() {}
457  float m_radius;
458  float m_height;
459  };
460 
463  {
464  public:
465 
467  TruncatedConeProxy( float topRadius, float bottomRadius, float height );
468  TruncatedConeProxy( const agx::Vec3& begin, const agx::Vec3& end, float topRadius, float bottomRadius );
469 
470  void set( float topRadius, float bottomRadius, float height ) {
471  m_topRadius = topRadius;
472  m_bottomRadius = bottomRadius;
473  m_height = height;
474  callOnChange( SHAPE );
475  }
476 
477  void set( const agx::Vec3& top, const agx::Vec3& bottom, float topRadius, float bottomRadius );
478 
480  float getTopRadius() const {
481  return m_topRadius;
482  }
483 
485  float getBottomRadius() const {
486  return m_bottomRadius;
487  }
488 
490  float getHeight() const {
491  return m_height;
492  }
493 
494 
497  protected:
498 
500 
501  virtual ~TruncatedConeProxy() {}
502  float m_topRadius;
504  float m_height;
505  };
506 
509  {
510  public:
511 
513  HollowTruncatedConeProxy( float topRadius, float bottomRadius, float height, float thickness );
514  HollowTruncatedConeProxy( const agx::Vec3& begin, const agx::Vec3& end, float topRadius, float bottomRadius, float thickness );
515 
516  void set( float topRadius, float bottomRadius, float height, float thickness ) {
517  m_topRadius = topRadius;
518  m_bottomRadius = bottomRadius;
519  m_height = height;
520  m_thickness = thickness;
521  callOnChange( SHAPE );
522  }
523 
524  void set( const agx::Vec3& top, const agx::Vec3& bottom, float topRadius, float bottomRadius, float thickness );
525 
527  float getTopRadius() const {
528  return m_topRadius;
529  }
530 
532  float getBottomRadius() const {
533  return m_bottomRadius;
534  }
535 
537  float getHeight() const {
538  return m_height;
539  }
540 
542  float getThickness() const {
543  return m_thickness;
544  }
545 
546 
549  protected:
550 
552 
554  float m_topRadius;
556  float m_height;
557  float m_thickness;
558  };
559 
560 
563  {
564  public:
565 
567  CapsuleProxy( float radius, float height );
568  CapsuleProxy( const agx::Vec3& begin, const agx::Vec3& end, float radius );
569 
570  void set( float radius, float height ) {
571  m_radius = radius;
572  m_height = height;
573  callOnChange( SHAPE );
574  }
575 
576  void set( const agx::Vec3& begin, const agx::Vec3& end, float radius );
577 
578 
580  float getRadius() const {
581  return m_radius;
582  }
583 
585  float getHeight() const {
586  return m_height;
587  }
588 
591 
592  protected:
593 
595 
596  virtual ~CapsuleProxy() {}
597  float m_height;
598  float m_radius;
599  };
600 
601 
604  {
605  public:
606 
608  WireShapeProxy( float radius, float height,
609  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1 );
611  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1, float radius );
612 
613  void set( float radius, float height) {
614  m_radius = radius;
615  m_height = height;
616  callOnChange( SHAPE );
617  }
618 
619  void set( float radius, float height,
620  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1)
621  {
622  m_radius = radius;
623  m_height = height;
624  m_previousEndPoint0 = previousEndPoint0;
625  m_previousEndPoint1 = previousEndPoint1;
626  callOnChange( SHAPE );
627  }
628 
629  void set( const agx::Vec3& begin, const agx::Vec3& end,
630  const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1, float radius );
631 
632 
634  float getRadius() const {
635  return m_radius;
636  }
637 
639  float getHeight() const {
640  return m_height;
641  }
642 
645  {
646  return m_previousEndPoint0;
647  }
648 
649 
652  {
653  return m_previousEndPoint1;
654  }
655 
656 
659 
660  protected:
662 
663  virtual ~WireShapeProxy() {}
664 
667  float m_height;
668  float m_radius;
669  };
670 
671 
674  {
675  public:
676 
678  BoxProxy( const agx::Vec3& halfExtents );
679 
681  void set( const agx::Vec3& halfExtents ) {
682  m_halfExtents = halfExtents;
683  callOnChange( SHAPE );
684  }
685 
687  return m_halfExtents;
688  }
689 
692 
693  protected:
694 
696 
697 
698  virtual ~BoxProxy() {}
699 
701  };
702 
705  {
706  public:
707 
709 
711 
717  void setHeights(const agx::Vec2iVector& modifiedIndices, const agx::RealVector& heights);
718 
721 
722  protected:
723 
728  virtual void set( const agx::Vec2iVector& modifiedIndices, const agx::RealVector& heights )=0;
729 
731  virtual ~HeightFieldProxy() {}
732 
734  return *this;
735  }
736  };
737 
740  {
741  public:
742 
744 
746 
747  void set( agxCollide::Trimesh *mesh );
748 
750 
751  protected:
752  virtual ~TrimeshProxy() {}
754  return *this;
755  }
756  };
757 
758 #if 0
759  class AGXPHYSICS_EXPORT SphereSpriteBatchRenderProxy : public RenderProxy
760  {
761  public:
762  SphereSpriteBatchRenderProxy() : RenderProxy( PRIMITIVE_SPHERE_BATCH )
763  {
764  this->setColor(agx::Vec3(agx::Real(0.9)));
765  }
766 
767  // SphereSpriteBatchRenderProxy( agxData::Buffer *positions, agxData::Buffer *radii, agxData::Value *bound )
768  // : RenderProxy( PRIMITIVE_SPHERE_BATCH ), m_positions(positions), m_radii(radii), m_bound(bound) {}
769 
770  #if 0
771  // void set( agxData::Array<agx::Vec3> positions, agxData::Array<agx::Real> radii, agx::Bound3 bound )
772  void set( agxData::Buffer *positions, agxData::Buffer *radii, agxData::Value *bound )
773  {
774  m_positions = positions;
775  m_radii = radii;
776  m_bound = bound;
777  callOnChange( SHAPE );
778  }
779  #endif
780 
781  protected:
782  virtual ~SphereSpriteBatchRenderProxy() {}
783 
784  protected:
785  // agxData::Array< agx::Vec3 > m_positions;
786  // agxData::Array< agx::Real > m_radii;
787  // agx::Bound3 m_bound;
788  // agxData::BufferRef m_positions;
789  // agxData::BufferRef m_radii;
790  // agxData::ValueRef m_bound;
791  };
792 
793  typedef agx::ref_ptr< SphereSpriteBatchRenderProxy > SphereSpriteBatchRenderProxyRef;
794 
795 
796  class AGXPHYSICS_EXPORT SphereMeshBatchRenderProxy : public RenderProxy
797  {
798  public:
799  SphereMeshBatchRenderProxy( const agxData::Array< agx::Vec3 >* buffer )
800  : RenderProxy( PRIMITIVE_SPHERE ), m_buffer( buffer ) {}
801 
802  void set( const agxData::Array< agx::Vec3 >* buffer, float /*radius*/ )
803  {
804  m_buffer = buffer;
805  callOnChange( SHAPE );
806  }
807 
808  protected:
809  virtual ~SphereMeshBatchRenderProxy() {}
810 
811  protected:
812  const agxData::Array< agx::Vec3 >* m_buffer;
813  };
814 
815  typedef agx::ref_ptr< SphereMeshBatchRenderProxy > SphereMeshBatchRenderProxyRef;
816 #endif
817 
822  {
823  public:
825 
826  void set( const agxCollide::GeometryContactPtrVector& contacts, float scale )
827  {
828  m_contacts = &contacts;
829  m_scale = scale;
830  callOnChange( SHAPE );
831  }
832 
833  const agxCollide::GeometryContactPtrVector& getContacts() const { return *m_contacts; }
834 
835  protected:
836  ContactsProxy() : RenderProxy( PRIMITIVE_CONTACTS ), m_contacts(nullptr), m_scale(1) {}
837 
838  virtual ~ContactsProxy() {}
840  float m_scale;
841  };
842 
847  {
848  public:
850 
851  public:
853  : RenderProxy( PRIMITIVE_SPHERE ), m_bodies(), m_scale( 1.f ) {}
854 
855  void set( const agx::RigidBodyPtrSetVector* enabledBodies, float scale )
856  {
857  m_bodies.clear();
858  if ( enabledBodies != nullptr ) {
859  m_bodies.reserve( enabledBodies->size() );
860  for ( agx::UInt i = 0; i < enabledBodies->size(); ++i ) {
861  const agx::RigidBody* rb = enabledBodies->at( i );
862  if ( RenderProxy::shouldRender( rb ) )
863  m_bodies.push_back( rb );
864  }
865  }
866  m_scale = scale;
867  callOnChange( SHAPE );
868  }
869 
870  protected:
872 
873  protected:
875  float m_scale;
876  };
877 
879  {
880  public:
881  struct SegmentDef
882  {
883  SegmentDef( const agx::Vec3& sp, const agx::Vec3& ep, float r )
884  : startPoint( sp ), endPoint( ep ), radius( r ) {}
885 
886  const SegmentDef* operator->() const { return this; }
887 
888  agx::AffineMatrix4x4 getTransform() const;
889  agx::Vec3f getScale() const;
890 
893  float radius;
894  };
895 
896  struct SphereDef
897  {
898  SphereDef( const agx::Vec3& p )
899  : point( p ) {}
900 
901  const SphereDef* operator->() const { return this; }
902  agx::AffineMatrix4x4 getTransform() const;
903 
905  };
906 
909 
910  public:
911  WireRenderProxy( float radius, const agx::Vec3& color );
912 
916  virtual void onAddNotification() {}
917 
921  virtual void onRemoveNotification() {}
922 
926  void prepare( agx::UInt numSegmentEstimate, agx::UInt numEdgesEstimate, agx::UInt numNodesEstimate );
927 
931  void commit();
932 
936  void addSegment( const agx::Vec3& startPoint, const agx::Vec3& endPoint, const agx::Vec3& prevStartPoint, const agx::Vec3& prevEndPoint );
937 
941  void addSegment( const agx::Vec3& startPoint, const agx::Vec3& endPoint, float radius, const agx::Vec3& color, agxRender::RenderManager* manager ) const;
942 
946  void addEdge( const agx::Vec3& startPoint, const agx::Vec3& endPoint );
947 
951  void addNode( const agx::Vec3& point );
952 
956  void addNode( const agx::Vec3& point, float radius, const agx::Vec3& color, agxRender::RenderManager* manager ) const;
957 
958  protected:
959  virtual ~WireRenderProxy() {}
960 
961  protected:
962  float m_radius;
966  };
967 
969 
970  // -------- Implementation ----------------
971 
972  inline PrimitiveType RenderProxy::getType() const { return m_type; }
973 
977  }
979  return m_transform;
980  }
981 
982  inline void RenderProxy::setColor( const agx::Vec3& color ) {
983  if (!agx::equivalent(m_color, color)) {
984  m_color = color;
985  callOnChange( COLOR );
986  }
987  }
988 
990  return m_color;
991  }
992 
993  inline void RenderProxy::setAlpha( float alpha ) {
994 
995  if (!agx::equivalent(m_alpha, alpha)) {
996  m_alpha = alpha;
997  callOnChange( ALPHA );
998  }
999  }
1000 
1001  inline float RenderProxy::getAlpha() const {
1002  return m_alpha;
1003  }
1004 
1006  m_modifiedCount = c;
1007  }
1008 
1010  return m_modifiedCount;
1011  }
1012 
1013  inline void RenderProxy::setShape( agxCollide::Shape* shape, const agxCollide::Geometry *geometry ) {
1014  m_shape = shape;
1015  m_geometry = geometry;
1017  //callOnChange( SHAPE );
1018  }
1019 
1021  return m_shape;
1022  }
1023 
1025  return m_geometry;
1026  }
1027 
1028  inline void RenderProxy::setEnable( bool flag ) {
1029  if (m_enable != flag)
1030  {
1031  m_enable = flag;
1032  callOnChange( ENABLE );
1033  }
1034  }
1035 
1036  inline bool RenderProxy::getEnable() const {
1037  return m_enable;
1038  }
1039 
1041  if ( mode != m_renderMode ) {
1042  m_renderMode = ( RenderMode )mode;
1044  }
1045  }
1046 
1048  return ( RenderMode )m_renderMode;
1049  }
1050 
1051  inline void HeightFieldProxy::setHeights(const agx::Vec2iVector& modifiedIndices, const agx::RealVector& heights)
1052  {
1053  agxAssert(modifiedIndices.size() == heights.size() );
1054 
1055  set( modifiedIndices, heights );
1056 
1057  // Sync modified count
1059  }
1060 
1062  {
1064  }
1065 
1067  {
1068  return agx::Vec3f( radius, radius, (float)startPoint.distance( endPoint ) );
1069  }
1070 
1072  {
1073  return agx::AffineMatrix4x4::translate( point );
1074  }
1075 }
1076 
1077 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
A box shape for geometric intersection tests.
Definition: Box.h:33
Implements a Capsule shape for geometric intersection tests.
Definition: Capsule.h:35
A right circular cone shape for geometric intersection tests.
Definition: Cone.h:49
A cylinder shape for geometric intersection tests.
Definition: Cylinder.h:37
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
A HeightField is a collision shape that can be created from a grid structure, like an image.
A right circular hollow cone shape for geometric intersection tests.
Definition: HollowCone.h:46
A hollow cylinder shape for geometric intersection tests.
A line shape for intersection tests, mostly for depth sensing and picking.
Base class for a shape.
Definition: Shape.h:54
A sphere class for geometric intersection tests.
Definition: Sphere.h:32
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:43
Internal class used by agxWire::Wire.
Definition: WireShape.h:45
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Abstract representation of a data buffer.
Definition: Buffer.h:56
Abstract representation of a value.
Definition: Value.h:43
Subclass that implements a BoxProxy.
const agxCollide::Box * getCastShape() const
BoxProxy(const agx::Vec3 &halfExtents)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void set(const agx::Vec3 &halfExtents)
Set the size of the box, will trigger onChange(SHAPE)
agx::Vec3 getHalfExtents() const
Subclass that implements a CapsuleProxy.
CapsuleProxy(float radius, float height)
const agxCollide::Capsule * getCastShape() const
CapsuleProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
void set(float radius, float height)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void set(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
Subclass that implements a ConeProxy.
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void set(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
void set(float radius, float height)
ConeProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
ConeProxy(float radius, float height)
const agxCollide::Cone * getCastShape() const
Class holding contacts that makes it possible to batch render these objects.
const agxCollide::GeometryContactPtrVector * m_contacts
void set(const agxCollide::GeometryContactPtrVector &contacts, float scale)
const agxCollide::GeometryContactPtrVector & getContacts() const
ContactsProxy(const agxCollide::GeometryContactPtrVector &contacts)
Subclass that implements a CylinderProxy.
CylinderProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
void set(const agx::Vec3 &begin, const agx::Vec3 &end, float radius)
void set(float radius, float height)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
CylinderProxy(float radius, float height)
const agxCollide::Cylinder * getCastShape() const
Subclass that implements a HeightfieldProxy.
void setHeights(const agx::Vec2iVector &modifiedIndices, const agx::RealVector &heights)
Set specified heights of a Heightfield.
HeightFieldProxy & operator=(const HeightFieldProxy &)
virtual void set(const agx::Vec2iVector &modifiedIndices, const agx::RealVector &heights)=0
Override this method to support changing a selection of indices in the heightfield.
HeightFieldProxy(agxCollide::HeightField *hf)
const agxCollide::HeightField * getCastShape() const
virtual ~HeightFieldProxy()
Destructor.
Subclass that implements a CylinderProxy.
void set(float radius, float height, float thickness)
HollowCylinderProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float radius, float thickness)
HollowCylinderProxy(float radius, float height, float thickness)
void set(const agx::Vec3 &begin, const agx::Vec3 &end, float radius, float thickness)
const agxCollide::HollowCylinder * getCastShape() const
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
Subclass that implements a HollowTruncatedConeProxy.
HollowTruncatedConeProxy(float topRadius, float bottomRadius, float height, float thickness)
void set(const agx::Vec3 &top, const agx::Vec3 &bottom, float topRadius, float bottomRadius, float thickness)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void set(float topRadius, float bottomRadius, float height, float thickness)
HollowTruncatedConeProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float topRadius, float bottomRadius, float thickness)
const agxCollide::HollowCone * getCastShape() const
Subclass that implements a LineProxy.
const agxCollide::Line * getCastShape() const
LineProxy(const agx::Vec3 &p1, const agx::Vec3 &p2)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void set(const agx::Vec3 &p1, const agx::Vec3 &p2)
Subclass that implements a PlaneProxy.
const agxCollide::Plane * getCastShape() const
agx::Real getDistance() const
void set(const agx::Vec3 &normal, agx::Real distance)
PlaneProxy(const agx::Vec3 &normal, agx::Real distance)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
Abstract base class which encapsulated information for rendering a specific shape.
virtual float getAlpha() const
virtual void setAlpha(float alpha)
Set the alpha value of this proxy.
const agxCollide::Geometry * getGeometry() const
virtual agx::Vec3 getColor() const
void setModifiedCount(agx::UInt32 c)
agx::UInt32 getModifiedCount() const
This value tells us that if the proxy is synchronized with the associated shape.
virtual ~RenderProxy()
Destructor.
void setEnable(bool flag)
Toggle this proxy for rendering on/off.
virtual void onChange(EventType)
Pure virtual method that should response on the different events.
RenderMode getRenderMode() const
agx::AffineMatrix4x4 m_transform
virtual void updateShape()
Called when a Shape has been changed (for example radius on a sphere is changed).
virtual void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void setShape(agxCollide::Shape *shape, const agxCollide::Geometry *geometry)
Set the shape for this proxy.
void callOnChange(EventType type)
Explicitly fires event of type.
virtual void reset()
Will reset color, alpha and enabled state back to default state (as when initially created).
virtual void setTransform(const agx::AffineMatrix4x4 &transform)
Set the transform of this RenderProxy, if overridden, set the m_transform and call onUpdate(TRANSFORM...
virtual void setColor(const agx::Vec3 &color)
Set the color of this proxy.
const agx::AffineMatrix4x4 & getTransform() const
PrimitiveType getType() const
const agxCollide::Shape * getShape() const
bool compare() const
Compare the modified count with its associated shape.
static agx::Bool shouldRender(const agx::RigidBody *rb)
EventType
Enum for specifying a type of event which might change a RenderProxy.
@ COLOR
The color value for a proxy is updated.
@ ENABLE
A RenderProxy is enabled/disabled.
@ REMOVE
The Shape has been removed from space, need to be removed from rendering.
@ RENDERMODE
The RenderMode has been changed.
@ ALPHA
The alpha value for a proxy is updated.
@ TRANSFORM
The transformation for a proxy is updated.
@ SHAPE
The Shape has been modified a rebuild is needed.
agx::observer_ptr< agxCollide::Shape > m_shape
RenderProxy(PrimitiveType type, agxCollide::Shape *shape=nullptr)
Constructor.
void setRenderMode(RenderMode mode)
Set the render mode for this Proxy.
Class holding rigid bodies that makes it possible to batch render these objects.
agx::Vector< const agx::RigidBody * > Container
void set(const agx::RigidBodyPtrSetVector *enabledBodies, float scale)
agxRender::RigidBodyBatchRenderProxy::Container m_bodies
Subclass that implements a SphereProxy.
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
const agxCollide::Sphere * getCastShape() const
SphereProxy(float radius)
Subclass that implements a TextProxy.
TextProxy(const agx::String &text, const agx::Vec3 &pos)
void set(const agx::String &text, const agx::Vec3 &pos)
agx::Vec3 getPosition() const
agx::String getText() const
Subclass that implements a TrimeshProxy.
void set(agxCollide::Trimesh *mesh)
const agxCollide::Trimesh * getCastShape() const
TrimeshProxy(agxCollide::Trimesh *mesh)
TrimeshProxy & operator=(const TrimeshProxy &)
Subclass that implements a TruncatedConeProxy.
TruncatedConeProxy(const agx::Vec3 &begin, const agx::Vec3 &end, float topRadius, float bottomRadius)
TruncatedConeProxy(float topRadius, float bottomRadius, float height)
const agxCollide::Cone * getCastShape() const
void set(const agx::Vec3 &top, const agx::Vec3 &bottom, float topRadius, float bottomRadius)
void set(float topRadius, float bottomRadius, float height)
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
void addNode(const agx::Vec3 &point)
Node with default color (lumped node).
virtual void onAddNotification()
Called when the wire is added to the simulation.
agx::VectorPOD< SphereDef > SphereDefContainer
agx::VectorPOD< SegmentDef > SegmentDefContainer
void commit()
Commit the current state to the renderer.
void addSegment(const agx::Vec3 &startPoint, const agx::Vec3 &endPoint, const agx::Vec3 &prevStartPoint, const agx::Vec3 &prevEndPoint)
Add segment with global radius and color.
void addSegment(const agx::Vec3 &startPoint, const agx::Vec3 &endPoint, float radius, const agx::Vec3 &color, agxRender::RenderManager *manager) const
Slow, non-batch-rendered, segment.
void addNode(const agx::Vec3 &point, float radius, const agx::Vec3 &color, agxRender::RenderManager *manager) const
Node with different color and/or size.
void prepare(agx::UInt numSegmentEstimate, agx::UInt numEdgesEstimate, agx::UInt numNodesEstimate)
Prepare buffers.
void addEdge(const agx::Vec3 &startPoint, const agx::Vec3 &endPoint)
Edges are always red and same radius as others.
virtual void onRemoveNotification()
Called when the wire is removed from the simulation.
WireRenderProxy(float radius, const agx::Vec3 &color)
Subclass that implements a WireShapeProxy.
void set(float radius, float height, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1)
void set(float radius, float height)
void set(const agx::Vec3 &begin, const agx::Vec3 &end, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1, float radius)
agx::Vec3 getPreviousEndPoint1() const
agx::Vec3 getPreviousEndPoint0() const
const agxCollide::WireShape * getCastShape() const
void synchronizeParameters()
This method should be implemented so that it extracts size parameters from an associated shape and st...
WireShapeProxy(const agx::Vec3 &begin, const agx::Vec3 &end, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1, float radius)
WireShapeProxy(float radius, float height, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1)
static AffineMatrix4x4T< Real > rotate(const Vec3T< Real > &from, const Vec3T< Real > &to)
Return a matrix which rotate a vector from from to to.
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
size_t size() const
Definition: Container.h:134
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
size_t size() const
Return the number of inserted elements.
Definition: SetVector.h:114
const DataT & at(size_t index) const
Access an element in the vector using an index.
Definition: SetVector.h:484
static Vec3T Z_AXIS()
Definition: Vec3Template.h:789
Vector containing 'raw' data.
Definition: agx/Vector.h:246
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define agxAssert(expr)
Definition: debug.h:143
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGXCORE_EXPORT Type * getType(const agx::String &name)
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
AGXOSG_EXPORT void setAlpha(osg::Node *node, float alpha)
Set the alpha part of the material for a node.
Namespace containing classes for handling debug rendering of collision geometries,...
Definition: Constraint.h:36
agx::ref_ptr< WireRenderProxy > WireRenderProxyRef
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
int32_t Int32
Definition: Integer.h:45
uint32_t UInt32
Definition: Integer.h:40
PlaneT< agx::Real > Plane
Definition: agx/Plane.h:121
bool Bool
Definition: Integer.h:48
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
LineT< Vec3 > Line
Definition: agx/Line.h:39
Vec3T< Real32 > Vec3f
Definition: agx/Vec3.h:39
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)
SegmentDef(const agx::Vec3 &sp, const agx::Vec3 &ep, float r)
agx::AffineMatrix4x4 getTransform() const