AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxOSG::WireRenderProxy Class Reference

#include <RenderProxy.h>

+ Inheritance diagram for agxOSG::WireRenderProxy:

Public Types

enum  EventType {
  ENABLE, TRANSFORM, ALPHA, COLOR,
  SHAPE, REMOVE, RENDERMODE
}
 Enum for specifying a type of event which might change a RenderProxy. More...
 
enum  RenderMode { NOT_SET = 0x0, SOLID = 0x1, WIREFRAME = 0x2 }
 
typedef agx::VectorPOD
< SegmentDef > 
SegmentDefContainer
 
typedef agx::VectorPOD< SphereDef > SphereDefContainer
 

Public Member Functions

 WireRenderProxy (float radius, const agx::Vec3 &color, osg::Geode *segmentGeode, osg::Geode *edgeGeode, osg::Geode *nodeGeode, agxOSG::RenderProxyFactory *factory)
 
void addEdge (const agx::Vec3 &startPoint, const agx::Vec3 &endPoint)
 Edges are always red and same radius as others. More...
 
void addNode (const agx::Vec3 &point)
 Node with default color (lumped node). More...
 
void addNode (const agx::Vec3 &point, float radius, const agx::Vec3 &color, agxRender::RenderManager *manager) const
 Node with different color and/or size. More...
 
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. More...
 
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. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
void callOnChange (EventType type)
 Explicitly fires event of type. More...
 
void commit ()
 Commit the current state to the renderer. More...
 
bool compare () const
 Compare the modified count with its associated shape. More...
 
virtual float getAlpha () const
 
virtual agx::Vec3 getColor () const
 
osg::MatrixTransform * getEdgeTransform ()
 
bool getEnable () const
 
const agxCollide::Geometry * getGeometry () const
 
agx::UInt32 getModifiedCount () const
 This value tells us that if the proxy is synchronized with the associated shape. More...
 
int getReferenceCount () const
 
RenderMode getRenderMode () const
 
osg::MatrixTransform * getSegmentTransform ()
 
const agxCollide::Shape * getShape () const
 
osg::MatrixTransform * getSphereTransform ()
 
const agx::AffineMatrix4x4 & getTransform () const
 
PrimitiveType getType () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
bool isEnabled () const
 
void prepare (agx::UInt numSegmentEstimate, agx::UInt numEdgesEstimate, agx::UInt numNodesEstimate)
 Prepare buffers. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
virtual void setAlpha (float alpha)
 Set the alpha value of this proxy. More...
 
virtual void setColor (const agx::Vec3 &color)
 Set the color of this proxy. More...
 
void setEnable (bool flag)
 Toggle this proxy for rendering on/off. More...
 
void setRenderMode (RenderMode mode)
 Set the render mode for this Proxy. More...
 
virtual void setTransform (const agx::AffineMatrix4x4 &transform)
 Set the transform of this RenderProxy, if overridden, set the m_transform and call onUpdate(TRANSFORM) More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
virtual void updateShape ()
 Called when a Shape has been changed (for example radius on a sphere is changed). More...
 

Static Public Member Functions

static agx::Bool shouldRender (const agx::RigidBody *rb)
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~WireRenderProxy ()
 
 ADD_COMMON_METHODS ()
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
virtual void onAddNotification () override
 Called when the wire is added to the simulation. More...
 
virtual void onChange (EventType)
 Pure virtual method that should response on the different events. More...
 
virtual void onRemoveNotification () override
 Called when the wire is removed from the simulation. More...
 
void onRemoveOSG ()
 
virtual void reset () override
 Will reset color, alpha and enabled state back to default state (as when initially created). More...
 
void setAlphaOSG (float transparency)
 
void setColorOSG (const agx::Vec3 &color, float alpha)
 
void setEnableOSG (bool flag)
 
void setModifiedCount (agx::UInt32 c)
 
void setRenderModeOSG (agxRender::RenderProxy::RenderMode mode)
 
void setShape (agxCollide::Shape *shape, const agxCollide::Geometry *geometry)
 Set the shape for this proxy. More...
 
void setTransformOSG (const agx::AffineMatrix4x4 &transform)
 
virtual void synchronizeParameters ()
 This method should be implemented so that it extracts size parameters from an associated shape and store it in the Proxy parameters (radius/length etc). More...
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

ContainerShapeBatchRenderer
< agxRender::WireRenderProxy::SegmentDefContainer,
osg::MatrixTransform > 
m_edgeBatch
 
SegmentDefContainer m_edges
 
Mutex m_mutex
 
SphereDefContainer m_nodes
 
ObserverContainer m_observers
 
float m_radius
 
AtomicValue m_refCount
 
ContainerShapeBatchRenderer
< agxRender::WireRenderProxy::SegmentDefContainer,
osg::MatrixTransform > 
m_segmentBatch
 
SegmentDefContainer m_segments
 
agx::observer_ptr
< agxCollide::Shape > 
m_shape
 
ContainerShapeBatchRenderer
< agxRender::WireRenderProxy::SphereDefContainer,
osg::MatrixTransform > 
m_sphereBatch
 
agx::AffineMatrix4x4 m_transform
 

Detailed Description

Definition at line 817 of file agxOSG/RenderProxy.h.

Member Typedef Documentation

Member Enumeration Documentation

Enum for specifying a type of event which might change a RenderProxy.

Enumerator
ENABLE 

A RenderProxy is enabled/disabled.

TRANSFORM 

The transformation for a proxy is updated.

ALPHA 

The alpha value for a proxy is updated.

COLOR 

The color value for a proxy is updated.

SHAPE 

The Shape has been modified a rebuild is needed.

REMOVE 

The Shape has been removed from space, need to be removed from rendering.

RENDERMODE 

The RenderMode has been changed.

Definition at line 81 of file agxRender/RenderProxy.h.

Enumerator
NOT_SET 
SOLID 
WIREFRAME 

Definition at line 91 of file agxRender/RenderProxy.h.

Constructor & Destructor Documentation

agxOSG::WireRenderProxy::WireRenderProxy ( float  radius,
const agx::Vec3 &  color,
osg::Geode *  segmentGeode,
osg::Geode *  edgeGeode,
osg::Geode *  nodeGeode,
agxOSG::RenderProxyFactory *  factory 
)
virtual agxOSG::WireRenderProxy::~WireRenderProxy ( )
protectedvirtual

Reimplemented from agxRender::WireRenderProxy.

Member Function Documentation

agxOSG::WireRenderProxy::ADD_COMMON_METHODS ( )
protected
void agxRender::WireRenderProxy::addEdge ( const agx::Vec3 &  startPoint,
const agx::Vec3 &  endPoint 
)
inherited

Edges are always red and same radius as others.

void agxRender::WireRenderProxy::addNode ( const agx::Vec3 &  point)
inherited

Node with default color (lumped node).

void agxRender::WireRenderProxy::addNode ( const agx::Vec3 &  point,
float  radius,
const agx::Vec3 &  color,
agxRender::RenderManager *  manager 
) const
inherited

Node with different color and/or size.

void agxRender::WireRenderProxy::addSegment ( const agx::Vec3 &  startPoint,
const agx::Vec3 &  endPoint,
const agx::Vec3 &  prevStartPoint,
const agx::Vec3 &  prevEndPoint 
)
inherited

Add segment with global radius and color.

void agxRender::WireRenderProxy::addSegment ( const agx::Vec3 &  startPoint,
const agx::Vec3 &  endPoint,
float  radius,
const agx::Vec3 &  color,
agxRender::RenderManager *  manager 
) const
inherited

Slow, non-batch-rendered, segment.

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agxRender::RenderProxy::callOnChange ( EventType  type)
inherited

Explicitly fires event of type.

Parameters
type- type of event to fire to this render proxy

Referenced by agxRender::RenderProxy::setAlpha(), agxRender::RenderProxy::setColor(), agxRender::RenderProxy::setEnable(), agxRender::RenderProxy::setRenderMode(), and agxRender::RenderProxy::setTransform().

void agxRender::WireRenderProxy::commit ( )
inherited

Commit the current state to the renderer.

bool agxRender::RenderProxy::compare ( ) const
inherited

Compare the modified count with its associated shape.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
float agxRender::RenderProxy::getAlpha ( ) const
inlinevirtualinherited
Returns
the current alpha value for this proxy

Definition at line 1001 of file agxRender/RenderProxy.h.

agx::Vec3 agxRender::RenderProxy::getColor ( ) const
inlinevirtualinherited
Returns
the current color

Definition at line 989 of file agxRender/RenderProxy.h.

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
osg::MatrixTransform* agxOSG::WireRenderProxy::getEdgeTransform ( )
bool agxRender::RenderProxy::getEnable ( ) const
inlineinherited
Returns
true if this proxy is enabled

Definition at line 1036 of file agxRender/RenderProxy.h.

const agxCollide::Geometry * agxRender::RenderProxy::getGeometry ( ) const
inlineinherited

Definition at line 1024 of file agxRender/RenderProxy.h.

agx::UInt32 agxRender::RenderProxy::getModifiedCount ( ) const
inlineinherited

This value tells us that if the proxy is synchronized with the associated shape.

When a shape change any of its attributes, it will increment its own number. If it does not match this, it will trigger onChange(SHAPE).

Returns
the current modified count for this Proxy.

Definition at line 1009 of file agxRender/RenderProxy.h.

Referenced by agxRender::HeightFieldProxy::setHeights().

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
RenderProxy::RenderMode agxRender::RenderProxy::getRenderMode ( ) const
inlineinherited
Returns
the current render mode for this Proxy

Definition at line 1047 of file agxRender/RenderProxy.h.

osg::MatrixTransform* agxOSG::WireRenderProxy::getSegmentTransform ( )
const agxCollide::Shape * agxRender::RenderProxy::getShape ( ) const
inlineinherited
osg::MatrixTransform* agxOSG::WireRenderProxy::getSphereTransform ( )
const agx::AffineMatrix4x4 & agxRender::RenderProxy::getTransform ( ) const
inlineinherited
Returns
the current transform for this proxy

Definition at line 978 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::m_transform.

PrimitiveType agxRender::RenderProxy::getType ( ) const
inlineinherited
Returns
the type of this RenderProxy

Definition at line 972 of file agxRender/RenderProxy.h.

template<typename T >
bool agx::Referenced::is ( ) const
inherited
bool agxRender::RenderProxy::isEnabled ( ) const
inlineinherited
Returns
true if this proxy is enabled

Definition at line 165 of file agxRender/RenderProxy.h.

virtual void agxOSG::WireRenderProxy::onAddNotification ( )
overrideprotectedvirtual

Called when the wire is added to the simulation.

Reimplemented from agxRender::WireRenderProxy.

virtual void agxRender::RenderProxy::onChange ( EventType  )
inlineprotectedvirtualinherited

Pure virtual method that should response on the different events.

This method is (indirectly via callOnChange) called from most set* methods. Should really never be called direct from anywhere else but from callOnChange.

Definition at line 195 of file agxRender/RenderProxy.h.

virtual void agxOSG::WireRenderProxy::onRemoveNotification ( )
overrideprotectedvirtual

Called when the wire is removed from the simulation.

Reimplemented from agxRender::WireRenderProxy.

void agxOSG::WireRenderProxy::onRemoveOSG ( )
protected
void agxRender::WireRenderProxy::prepare ( agx::UInt  numSegmentEstimate,
agx::UInt  numEdgesEstimate,
agx::UInt  numNodesEstimate 
)
inherited

Prepare buffers.

Will clear previous data.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

virtual void agxOSG::WireRenderProxy::reset ( )
inlineoverrideprotectedvirtual

Will reset color, alpha and enabled state back to default state (as when initially created).

Reimplemented from agxRender::RenderProxy.

Definition at line 841 of file agxOSG/RenderProxy.h.

void agxRender::RenderProxy::setAlpha ( float  alpha)
inlinevirtualinherited

Set the alpha value of this proxy.

If overridden, store color in m_alpha and call onUpdate(ALPHA)

Definition at line 993 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::ALPHA, agxRender::RenderProxy::callOnChange(), and agx::equivalent().

void agxOSG::WireRenderProxy::setAlphaOSG ( float  transparency)
protected
void agxRender::RenderProxy::setColor ( const agx::Vec3 &  color)
inlinevirtualinherited

Set the color of this proxy.

If overridden, store color in m_color and call onUpdate(COLOR)

Definition at line 982 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::callOnChange(), agxRender::RenderProxy::COLOR, and agx::equivalent().

void agxOSG::WireRenderProxy::setColorOSG ( const agx::Vec3 &  color,
float  alpha 
)
protected
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxRender::RenderProxy::setEnable ( bool  flag)
inlineinherited

Toggle this proxy for rendering on/off.

Will trigger onUpdate(ENABLE)

Definition at line 1028 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::callOnChange(), and agxRender::RenderProxy::ENABLE.

void agxOSG::WireRenderProxy::setEnableOSG ( bool  flag)
protected
void agxRender::RenderProxy::setModifiedCount ( agx::UInt32  c)
inlineprotectedinherited
void agxRender::RenderProxy::setRenderMode ( RenderProxy::RenderMode  mode)
inlineinherited

Set the render mode for this Proxy.

Will trigger onUpdate(RENDERMODE)

Definition at line 1040 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::callOnChange(), and agxRender::RenderProxy::RENDERMODE.

void agxOSG::WireRenderProxy::setRenderModeOSG ( agxRender::RenderProxy::RenderMode  mode)
protected
void agxRender::RenderProxy::setShape ( agxCollide::Shape *  shape,
const agxCollide::Geometry *  geometry 
)
inlineprotectedinherited

Set the shape for this proxy.

Definition at line 1013 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::m_shape, and agxRender::RenderProxy::setModifiedCount().

void agxRender::RenderProxy::setTransform ( const agx::AffineMatrix4x4 &  transform)
inlinevirtualinherited

Set the transform of this RenderProxy, if overridden, set the m_transform and call onUpdate(TRANSFORM)

Reimplemented in agxOSG::TextProxy.

Definition at line 974 of file agxRender/RenderProxy.h.

References agxRender::RenderProxy::callOnChange(), agxRender::RenderProxy::m_transform, agxData::transform(), and agxRender::RenderProxy::TRANSFORM.

Referenced by agxOSG::RigidBodyBatchRenderProxy< ContainerType, TransformType >::ADD_COMMON_METHODS().

void agxOSG::WireRenderProxy::setTransformOSG ( const agx::AffineMatrix4x4 &  transform)
protected
static agx::Bool agxRender::RenderProxy::shouldRender ( const agx::RigidBody *  rb)
staticinherited
Returns
true if the rigid body should be rendered - otherwise false

Referenced by agxRender::RigidBodyBatchRenderProxy::set().

virtual void agxRender::RenderProxy::synchronizeParameters ( )
inlineprotectedvirtualinherited

This method should be implemented so that it extracts size parameters from an associated shape and store it in the Proxy parameters (radius/length etc).

Reimplemented in agxRender::BoxProxy, agxRender::WireShapeProxy, agxRender::CapsuleProxy, agxRender::HollowTruncatedConeProxy, agxRender::TruncatedConeProxy, agxRender::ConeProxy, agxRender::HollowCylinderProxy, agxRender::CylinderProxy, agxRender::LineProxy, agxRender::SphereProxy, and agxRender::PlaneProxy.

Definition at line 188 of file agxRender/RenderProxy.h.

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

virtual void agxRender::RenderProxy::updateShape ( )
inlinevirtualinherited

Called when a Shape has been changed (for example radius on a sphere is changed).

Definition at line 128 of file agxRender/RenderProxy.h.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > agxOSG::WireRenderProxy::m_edgeBatch
protected

Definition at line 848 of file agxOSG/RenderProxy.h.

SegmentDefContainer agxRender::WireRenderProxy::m_edges
protectedinherited

Definition at line 964 of file agxRender/RenderProxy.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

SphereDefContainer agxRender::WireRenderProxy::m_nodes
protectedinherited

Definition at line 965 of file agxRender/RenderProxy.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

float agxRender::WireRenderProxy::m_radius
protectedinherited

Definition at line 962 of file agxRender/RenderProxy.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SegmentDefContainer, osg::MatrixTransform > agxOSG::WireRenderProxy::m_segmentBatch
protected

Definition at line 847 of file agxOSG/RenderProxy.h.

SegmentDefContainer agxRender::WireRenderProxy::m_segments
protectedinherited

Definition at line 963 of file agxRender/RenderProxy.h.

agx::observer_ptr<agxCollide::Shape> agxRender::RenderProxy::m_shape
protectedinherited
ContainerShapeBatchRenderer< agxRender::WireRenderProxy::SphereDefContainer, osg::MatrixTransform > agxOSG::WireRenderProxy::m_sphereBatch
protected

Definition at line 849 of file agxOSG/RenderProxy.h.

agx::AffineMatrix4x4 agxRender::RenderProxy::m_transform
protectedinherited

The documentation for this class was generated from the following file: