21#if AGX_USE_AGXSENSOR()
28 #include <osg/Geometry>
29 #include <osg/MatrixTransform>
30 #include <osg/PrimitiveSet>
36#if AGX_USE_AGXSENSOR()
75 using ColorFunc = std::function<osg::Vec4(
float intensity)>;
89 } interpolationFunctionValues;
92 class LidarObserverHolder;
148 const std::vector<LidarOutputRendererLegendPoint>& legend,
float exponent);
198 struct HitOutput :
agx::Vec4f
200 using agx::Vec4f::Vec4f;
202 agx::Vec3f position()
const {
return {x(), y(), z()}; }
204 osg::Vec3 osgPosition()
const {
return {x(), y(), z()}; }
209 return {q.
x(), q.
y(), q.
z(), q.
w()};
212 float intensity()
const {
return w(); }
217 struct FrameCallback : osg::NodeCallback
219 virtual void operator()(osg::Node* node, osg::NodeVisitor* )
override
221 dynamic_cast<LidarOutputRenderer*
>(node)->onPreRender();
225 struct CloudRenderData
227 CloudRenderData(
size_t maxNumPoints);
228 GeometryRef createGeometry(osg::PrimitiveSet::Mode renderMode);
229 osg::StateSet* getCommonStateSet();
233 size_t newCount,
const HitOutput* newPoints,
float lifetime,
const agx::Quat32& rotationToWorldF,
234 const IntensityState& intensityState);
235 void updatePrimitiveCount(
size_t primitiveCount);
240 FloatArrayRef lifetimes;
241 Vec3ArrayRef vertices;
242 ColorArrayRef colors;
243 Vec4ArrayRef zToNormals;
246 struct GeometryShaderData
249 ProgramRef rayProgram;
253 ProgramRef pointsProgram;
254 UniformRef hitPointScale;
258 static size_t determinePointBufferCount(
const agxSensor::Lidar* lidar,
float hitPointLifetime);
261 friend FrameCallback;
263 void synchronizeTransform();
264 ProgramRef createShader(
const agx::String& filename);
266 void initializeOutputCloudGeometryShader(
bool renderRays);
270 LidarObserverHolder* m_lidarObserver;
271 CloudRenderData m_cloudRenderData;
272 GeometryShaderData m_geometryShaderData;
273 IntensityState m_intensityState;
275 float m_hitPointLifetime;
Lidar point cloud renderer.
osg::ref_ptr< osg::Vec4Array > Vec4ArrayRef
void setIntensityColorFunction(IntensityState::ColorFunc colorFunc)
Set custom color function of the hits.
void setIntensityScale(float intensityScale)
Set scale of the output intensity of the lidar.
void setHitPointLifetime(float hitPointLifetime)
Set how long the lidar points should remain rendered for.
osg::ref_ptr< osg::Uniform > UniformRef
void setIntensityColorFunctionFromLegend(const std::vector< LidarOutputRendererLegendPoint > &legend, float exponent)
Set lidar point color intensity function based on the given color interpolation legend.
float getIntensityScale() const
void setIntensityColorFunctionFromInterpolation(osg::Vec4 low, osg::Vec4 high, float exponent)
Set lidar point color intensity function based on an interpolation of the intensity,...
float getHitPointScale() const
osg::ref_ptr< osg::Vec4Array > ColorArrayRef
LidarOutputRenderer(const agxSensor::Lidar *lidar, bool renderRays=false)
Construct given lidar and option to render the lidar rays (default: false).
osg::ref_ptr< osg::FloatArray > FloatArrayRef
void setHitPointScale(float scale)
Set scale of the circle representing a hit.
osg::ref_ptr< osg::Vec3Array > Vec3ArrayRef
void setIntensityColorFunctionFromMode(IntensityState::Mode mode)
Set lidar point color intensity function from the given mode of how the intensity of a hit is visuali...
osg::ref_ptr< osg::Program > ProgramRef
float getHitPointLifetime() const
osg::ref_ptr< osg::Geode > GeodeRef
void setHitPointsAlwaysOnTop(bool alwaysOnTop)
Set if the lidar hit points should always be drawn over all other geometry (disabling depth testing).
bool isAlwaysRenderedOnTop() const
IntensityState::ColorFunc getIntensityColorFunction() const
osg::ref_ptr< osg::Geometry > GeometryRef
Lidar instance class defined by a frame/transform and a model.
The object holding quaternions and providing operations on these.
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
agx::ref_ptr< Geometry > GeometryRef
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
osg::ref_ptr< LidarOutputRenderer > LidarOutputRendererRef
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Reference color point for lidar hit points when using a color legend.
LidarOutputRendererLegendPoint()
LidarOutputRendererLegendPoint(float intensity, osg::Vec4 color)
@ COLOR_A
Color alpha - hit points with intensity as transparency.
@ COLOR_RG
Color red (low intensity) -> green (high intensity).
std::vector< LidarOutputRendererLegendPoint > colorLegend
std::function< osg::Vec4(float intensity)> ColorFunc