group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
TeslaBeamEffect Class Reference

Sustained curved energy-arc beams, keyed by owner entity id. More...

#include <TeslaBeamEffect.hpp>

Collaboration diagram for TeslaBeamEffect:
[legend]

Classes

struct  Branch
 One forked branch diverging from the main arc. More...
struct  Beam
 State for a single sustained, curved beam. More...

Public Member Functions

void drive (uint32_t key, glm::vec3 origin, glm::vec3 target)
 Refresh (or start) the beam owned by key for this frame.
void update (float dt, glm::vec3 camForward)
 Advance animation, age out undriven beams, and rebuild arc verts.
const ArcVertexarcData () const
 Arc vertex array for GPU upload (nullptr if empty).
uint32_t arcCount () const
 Number of arc vertices generated this frame.
uint32_t activeBeamCount () const
 Number of beams currently alive.

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_.
BeamfindOrAllocBeam (uint32_t key)

Static Private Member Functions

static glm::vec3 evalBezier (glm::vec3 p0, glm::vec3 p1, glm::vec3 p2, glm::vec3 p3, float t)
static glm::vec3 evalBezierTangent (glm::vec3 p0, glm::vec3 p1, glm::vec3 p2, glm::vec3 p3, float t)
static void rerandomizeBranches (Beam &beam)

Private Attributes

Beam beams_ [k_maxBeams] {}
std::vector< ArcVertexarcVerts_

Static Private Attributes

static constexpr int k_maxBeams = 4
static constexpr int k_bezierSegs = 28
 Samples along the main arc.
static constexpr int k_branchSegs = 6
 Samples along each branch.
static constexpr int k_maxBranches = 3
static constexpr float k_fadeTime = 0.08f
 Fade in/out window (s).
static constexpr float k_keepAlive = 0.06f
 Grace before an undriven beam starts fading.
static constexpr float k_bowFrac = 0.16f
 Spine sag as a fraction of beam length.
static constexpr float k_branchRetime = 0.05f
 Branch re-randomise interval (s).

Detailed Description

Sustained curved energy-arc beams, keyed by owner entity id.

Member Function Documentation

◆ activeBeamCount()

uint32_t TeslaBeamEffect::activeBeamCount ( ) const
nodiscard

Number of beams currently alive.

◆ appendArcStrip()

void TeslaBeamEffect::appendArcStrip ( const std::vector< glm::vec3 > & pts,
float radius,
glm::vec4 color,
glm::vec3 camForward )
private

Append a camera-facing triangle-strip ribbon to arcVerts_.

Here is the caller graph for this function:

◆ arcCount()

uint32_t TeslaBeamEffect::arcCount ( ) const
inlinenodiscard

Number of arc vertices generated this frame.

◆ arcData()

const ArcVertex * TeslaBeamEffect::arcData ( ) const
inlinenodiscard

Arc vertex array for GPU upload (nullptr if empty).

◆ drive()

void TeslaBeamEffect::drive ( uint32_t key,
glm::vec3 origin,
glm::vec3 target )

Refresh (or start) the beam owned by key for this frame.

Call once per frame for every entity whose Tesla beam is firing. The beam stays alive as long as it keeps being driven; stop calling drive() and it fades out over k_fadeTime.

Parameters
keyStable owner id (entity handle as integer).
originWorld-space beam start (muzzle / eye).
targetWorld-space beam end (the locked target, or a forward point).
Here is the call graph for this function:

◆ evalBezier()

glm::vec3 TeslaBeamEffect::evalBezier ( glm::vec3 p0,
glm::vec3 p1,
glm::vec3 p2,
glm::vec3 p3,
float t )
staticprivate
Here is the caller graph for this function:

◆ evalBezierTangent()

glm::vec3 TeslaBeamEffect::evalBezierTangent ( glm::vec3 p0,
glm::vec3 p1,
glm::vec3 p2,
glm::vec3 p3,
float t )
staticprivate
Here is the caller graph for this function:

◆ findOrAllocBeam()

TeslaBeamEffect::Beam * TeslaBeamEffect::findOrAllocBeam ( uint32_t key)
private
Here is the caller graph for this function:

◆ rerandomizeBranches()

void TeslaBeamEffect::rerandomizeBranches ( Beam & beam)
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void TeslaBeamEffect::update ( float dt,
glm::vec3 camForward )

Advance animation, age out undriven beams, and rebuild arc verts.

Parameters
dtFrame delta time in seconds.
camForwardCamera forward vector for billboard orientation.
Here is the call graph for this function:

Member Data Documentation

◆ arcVerts_

std::vector<ArcVertex> TeslaBeamEffect::arcVerts_
private

◆ beams_

Beam TeslaBeamEffect::beams_[k_maxBeams] {}
private

◆ k_bezierSegs

int TeslaBeamEffect::k_bezierSegs = 28
staticconstexprprivate

Samples along the main arc.

◆ k_bowFrac

float TeslaBeamEffect::k_bowFrac = 0.16f
staticconstexprprivate

Spine sag as a fraction of beam length.

◆ k_branchRetime

float TeslaBeamEffect::k_branchRetime = 0.05f
staticconstexprprivate

Branch re-randomise interval (s).

◆ k_branchSegs

int TeslaBeamEffect::k_branchSegs = 6
staticconstexprprivate

Samples along each branch.

◆ k_fadeTime

float TeslaBeamEffect::k_fadeTime = 0.08f
staticconstexprprivate

Fade in/out window (s).

◆ k_keepAlive

float TeslaBeamEffect::k_keepAlive = 0.06f
staticconstexprprivate

Grace before an undriven beam starts fading.

◆ k_maxBeams

int TeslaBeamEffect::k_maxBeams = 4
staticconstexprprivate

◆ k_maxBranches

int TeslaBeamEffect::k_maxBranches = 3
staticconstexprprivate

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