|
group2 0.1.0
CSE 125 Group 2
|
Hitscan energy beam using fBm (fractional Brownian motion) path deviation. More...
#include <HitscanEffect.hpp>
Classes | |
| struct | Branch |
| A single forked branch diverging from the main arc. More... | |
| struct | ReturnStroke |
| A scheduled return stroke that re-randomises the arc path. More... | |
| struct | BezierBeam |
| State for a single active Bezier-spine beam. More... | |
Public Member Functions | |
| void | update (float dt, glm::vec3 camForward) |
| Update all active beams, rebuilding arc vertex data each frame. | |
| void | spawn (glm::vec3 origin, glm::vec3 hitPos, WeaponType wt, glm::vec3 camForward) |
| Fire a beam. | |
| const ArcVertex * | arcData () const |
| Get pointer to the arc vertex array for GPU upload. | |
| uint32_t | arcCount () const |
| Get the number of arc vertices currently generated. | |
| uint32_t | activeBeamCount () const |
| Get the number of active beams. | |
| const HitscanBeam * | beamData () const |
| uint32_t | beamCount () const |
Private Member Functions | |
| void | appendArcStrip (const std::vector< glm::vec3 > &pts, float radius, glm::vec4 color, glm::vec3 camForward) |
| Append a camera-facing triangle-strip ribbon to arcVerts_. | |
Static Private Member Functions | |
| static glm::vec3 | evalBezier (glm::vec3 p0, glm::vec3 p1, glm::vec3 p2, glm::vec3 p3, float t) |
| Evaluate a cubic Bezier curve at parameter t. | |
| static glm::vec3 | evalBezierTangent (glm::vec3 p0, glm::vec3 p1, glm::vec3 p2, glm::vec3 p3, float t) |
| Evaluate the tangent of a cubic Bezier curve at parameter t. | |
| static void | randomizeCP (glm::vec3 origin, glm::vec3 hitPos, glm::vec3 camForward, glm::vec3 &cp1, glm::vec3 &cp2) |
| Randomize Bezier control points for a new arc shape. | |
| static void | rerandomizeBranches (BezierBeam &beam, glm::vec3 camForward) |
| Re-randomize all branch parameters on a beam for flicker. | |
Private Attributes | |
| BezierBeam | beams_ [k_maxBeams] {} |
| std::vector< ArcVertex > | arcVerts_ |
Static Private Attributes | |
| static constexpr int | k_maxBeams = 4 |
| static constexpr int | k_bezierSegs = 32 |
| Samples along main arc. | |
| static constexpr int | k_branchSegs = 7 |
| Samples along each branch. | |
| static constexpr int | k_maxBranches = 5 |
| static constexpr float | k_beamLifetime = 0.22f |
| static constexpr float | k_interpDuration = 0.08f |
| Bezier morph time (s). | |
Hitscan energy beam using fBm (fractional Brownian motion) path deviation.
Signal chain per frame: t [0,1] along Bezier spine -> optional domain warp -> 4-octave fBm (lacunarity~3, persistence~0.4) -> multiply by sin(t*pi) envelope (pinned at both endpoints) -> scale by baseAmplitude (16 % of beam length) -> apply perpendicular to Bezier tangent
Rendering: three concentric triangle-strip layers per arc (outer bloom halo, inner glow channel, white-hot core) rendered with additive blending, giving an HDR-like look without a post-process pass.
Temporal behaviour:
|
nodiscard |
Get the number of active beams.
|
private |
Append a camera-facing triangle-strip ribbon to arcVerts_.
| pts | Sampled points along the arc segment. |
| radius | Half-width of the ribbon strip. |
| color | RGBA color for all vertices in this strip. |
| camForward | Camera forward vector for billboard orientation. |
|
inlinenodiscard |
Get the number of arc vertices currently generated.
|
inlinenodiscard |
Get pointer to the arc vertex array for GPU upload.
|
inlinenodiscard |
|
inlinenodiscard |
|
staticprivate |
Evaluate a cubic Bezier curve at parameter t.
|
staticprivate |
Evaluate the tangent of a cubic Bezier curve at parameter t.
|
staticprivate |
Randomize Bezier control points for a new arc shape.
|
staticprivate |
Re-randomize all branch parameters on a beam for flicker.
| void HitscanEffect::spawn | ( | glm::vec3 | origin, |
| glm::vec3 | hitPos, | ||
| WeaponType | wt, | ||
| glm::vec3 | camForward ) |
Fire a beam.
Consecutive shots on the same slot produce a smooth morph.
| origin | World-space beam start position. |
| hitPos | World-space beam end position. |
| wt | Weapon type (reserved for future per-weapon tuning). |
| camForward | Camera forward vector for control-point placement. |
| void HitscanEffect::update | ( | float | dt, |
| glm::vec3 | camForward ) |
Update all active beams, rebuilding arc vertex data each frame.
| dt | Frame delta time in seconds. |
| camForward | Camera forward vector for billboard orientation. |
|
private |
|
private |
|
staticconstexprprivate |
|
staticconstexprprivate |
Samples along main arc.
|
staticconstexprprivate |
Samples along each branch.
|
staticconstexprprivate |
Bezier morph time (s).
|
staticconstexprprivate |
|
staticconstexprprivate |