AvogadroLibs 2.0.0
Loading...
Searching...
No Matches
WideLineGeometry Class Reference

Renders line segments as camera-facing quads for wide line support. More...

#include <widelinegeometry.h>

Inheritance diagram for WideLineGeometry:
Drawable

Classes

struct  PackedVertex

Public Member Functions

 WideLineGeometry (const WideLineGeometry &other)
WideLineGeometry & operator= (WideLineGeometry)
void accept (Visitor &) override
void render (const Camera &camera) override
 Render the wide line geometry.
void clear () override
void addLine (const Vector3f &start, const Vector3f &end, const Vector3ub &colorStart, const Vector3ub &colorEnd, float lineWidth)
void addLine (const Vector3f &start, const Vector3f &end, const Vector3ub &color, float lineWidth)
void addLineStrip (const Core::Array< Vector3f > &vertices, const Vector3ub &color, float lineWidth)
void addLineStrip (const Core::Array< Vector3f > &vertices, const Core::Array< Vector3ub > &colors, float lineWidth)
void addDashedLine (const Vector3f &start, const Vector3f &end, const Vector3ub &color, float lineWidth, int dashCount)
void reserve (size_t lineCount)
const std::vector< PackedVertex > & vertices () const
size_t lineCount () const
void setColor (const Vector3ub &c)
Vector3ub color () const
void setOpacity (unsigned char opacity_)
unsigned char opacity () const
Public Member Functions inherited from Drawable
 Drawable (const Drawable &other)
Drawable & operator= (Drawable)
const GeometryNode * parent () const
 Get a pointer to the drawable object's parent.
GeometryNode * parent ()
void setVisible (bool visibility)
 Set the visibility of the drawable object.
bool isVisible () const
 Get the current visibility of the drawable.
Identifieridentifier ()
const Identifieridentifier () const
virtual std::multimap< float, Identifierhits (const Vector3f &rayOrigin, const Vector3f &rayEnd, const Vector3f &rayDirection) const
virtual Core::Array< IdentifierareaHits (const Frustrum &f) const
void setRenderPass (RenderPass pass)
RenderPass renderPass () const

Static Public Attributes

static constexpr float lineWidthScale = 0.035f

Additional Inherited Members

Protected Member Functions inherited from Drawable
void setParent (GeometryNode *parent)
 Set the parent node for the node.
Protected Attributes inherited from Drawable
GeometryNode * m_parent
bool m_visible
RenderPass m_renderPass
Identifier m_identifier

Detailed Description

<avogadro/rendering/widelinegeometry.h>

OpenGL 4.0 Core Profile does not guarantee glLineWidth() > 1.0. This class renders each line segment as a quad (two triangles) whose width is computed in the vertex shader, producing correct wide lines on all platforms.

Supports both solid and dashed lines. Dashing is implemented in the fragment shader using a per-vertex lineParam attribute — no extra geometry is needed.

Width is specified in world-space units.

Member Function Documentation

◆ accept()

void accept ( Visitor & )
overridevirtual

Accept a visit from our friendly visitor.

Reimplemented from Drawable.

◆ render()

void render ( const Camera & camera)
overridevirtual
Parameters
cameraThe current camera to be used for rendering.

Reimplemented from Drawable.

◆ clear()

void clear ( )
overridevirtual

Clear the contents of the node.

Reimplemented from Drawable.

◆ addLine() [1/2]

void addLine ( const Vector3f & start,
const Vector3f & end,
const Vector3ub & colorStart,
const Vector3ub & colorEnd,
float lineWidth )

Add a single solid line segment.

Parameters
startStart position of the line segment.
endEnd position of the line segment.
colorStartColor at the start.
colorEndColor at the end.
lineWidthWidth of the line in world-space units.

◆ addLine() [2/2]

void addLine ( const Vector3f & start,
const Vector3f & end,
const Vector3ub & color,
float lineWidth )

Add a single solid line segment with a uniform color.

◆ addLineStrip() [1/2]

void addLineStrip ( const Core::Array< Vector3f > & vertices,
const Vector3ub & color,
float lineWidth )

Add a connected strip of line segments from consecutive vertices. Each adjacent pair of vertices becomes one line segment.

Parameters
verticesThe vertices forming the line strip.
colorUniform color for the strip.
lineWidthWidth of the lines in world-space units.

◆ addLineStrip() [2/2]

void addLineStrip ( const Core::Array< Vector3f > & vertices,
const Core::Array< Vector3ub > & colors,
float lineWidth )

Add a connected strip with per-vertex colors.

◆ addDashedLine()

void addDashedLine ( const Vector3f & start,
const Vector3f & end,
const Vector3ub & color,
float lineWidth,
int dashCount )

Add a dashed line segment.

Parameters
startStart position.
endEnd position.
colorLine color.
lineWidthWidth in world-space units.
dashCountNumber of dashes.

◆ setColor()

void setColor ( const Vector3ub & c)

The default color of the lines.

◆ color()

Vector3ub color ( ) const

The default color of the lines.

◆ setOpacity()

void setOpacity ( unsigned char opacity_)

The default opacity of the lines.

◆ opacity()

unsigned char opacity ( ) const

The default opacity of the lines.

◆ reserve()

void reserve ( size_t lineCount)

Reserve space for the given number of line segments. Each segment uses 4 vertices and 6 indices.

◆ vertices()

const std::vector< PackedVertex > & vertices ( ) const

The vertex array (for geometry bounds computation).

◆ lineCount()

size_t lineCount ( ) const

The number of line segments.

Member Data Documentation

◆ lineWidthScale

float lineWidthScale = 0.035f
staticconstexpr

Scale factor converting legacy pixel-based widths to world-space units.


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