UFO: Alien Invasion
Loading...
Searching...
No Matches
Weather Class Reference

#include <r_weather.h>

Collaboration diagram for Weather:
Collaboration graph

Data Structures

struct  particle

Public Types

enum  weatherTypes {
  WEATHER_CLEAN , WEATHER_RAIN , WEATHER_SNOW , WEATHER_SANDSTORM ,
  WEATHER_MAX
}

Public Member Functions

 Weather (void)
 make a default (clean) weather
 Weather (weatherTypes weather)
 make a weather of given type
virtual ~Weather ()
void setDefaults (void)
 Sets clean weather, but generate some parameters usable for easily changing it into the worse varieties.
void changeTo (weatherTypes weather)
 changes to weather of given type; parameters are randomized
void clearParticles (void)
 Just a shared methods for ctors to initialize the weather.
void update (int milliseconds)
 Updates weather for the time passed; handles particle creation/removal automatically.
void render (void)
 Draws weather effects.

Data Fields

weatherTypes weatherType
float weatherStrength
float windStrength
float windDirection
float windTurbulence
float fallingSpeed
int splashTime
float splashSize

Protected Attributes

float smearLength
float particleSize
vec4_t color
particle particles [MAX_PARTICLES]

Static Protected Attributes

static const size_t MAX_PARTICLES = 8192

Detailed Description

Definition at line 29 of file r_weather.h.

Member Enumeration Documentation

◆ weatherTypes

Enumerator
WEATHER_CLEAN 
WEATHER_RAIN 
WEATHER_SNOW 
WEATHER_SANDSTORM 
WEATHER_MAX 

Definition at line 32 of file r_weather.h.

Constructor & Destructor Documentation

◆ Weather() [1/2]

Weather::Weather ( void )

make a default (clean) weather

< final particle size

Definition at line 142 of file r_weather.cpp.

References clearParticles(), and setDefaults().

◆ Weather() [2/2]

Weather::Weather ( weatherTypes weather)

make a weather of given type

Definition at line 151 of file r_weather.cpp.

References changeTo(), and clearParticles().

◆ ~Weather()

Weather::~Weather ( )
virtual

Definition at line 157 of file r_weather.cpp.

Member Function Documentation

◆ changeTo()

void Weather::changeTo ( weatherTypes weather)

changes to weather of given type; parameters are randomized

Definition at line 91 of file r_weather.cpp.

References color, fallingSpeed, frand(), particleSize, setDefaults(), smearLength, splashSize, splashTime, WEATHER_RAIN, WEATHER_SANDSTORM, WEATHER_SNOW, weatherStrength, weatherType, windStrength, and windTurbulence.

Referenced by Weather().

◆ clearParticles()

void Weather::clearParticles ( void )

Just a shared methods for ctors to initialize the weather.

Definition at line 132 of file r_weather.cpp.

References i, MAX_PARTICLES, and particles.

Referenced by Weather(), and Weather().

◆ render()

void Weather::render ( void )

Draws weather effects.

Todo
shadowcasting at least for the sunlight
Todo
proper color to brightness mapping
Todo
alpha decay
Todo
make a proper projection instead of this hack
Todo
should use proper velocity vector ... or maybe not
Todo
actually rotate billboard in the correct position

Definition at line 257 of file r_weather.cpp.

References color, Cvar_GetInteger(), glBindTexture(), i, MAX_PARTICLES, particles, particleSize, R_BindArray(), R_Color(), R_EnableBlend(), R_ResetArrayState(), refdef, smearLength, splashSize, splashTime, Weather::particle::ttl, VectorLength(), Weather::particle::vz, wpTexture(), Weather::particle::x, Weather::particle::y, and Weather::particle::z.

◆ setDefaults()

void Weather::setDefaults ( void )

Sets clean weather, but generate some parameters usable for easily changing it into the worse varieties.

Definition at line 71 of file r_weather.cpp.

References color, fallingSpeed, frand(), M_PI_2, particleSize, smearLength, splashSize, splashTime, WEATHER_CLEAN, weatherStrength, weatherType, windDirection, windStrength, and windTurbulence.

Referenced by changeTo(), and Weather().

◆ update()

void Weather::update ( int milliseconds)

Updates weather for the time passed; handles particle creation/removal automatically.

Todo
creates vanishing-before-impact particles at low framerates – should improve that somehow
Todo

< extents of zone in which weather particles will be rendered

Todo
proper code for physics

Definition at line 164 of file r_weather.cpp.

References cl, CL_Trace(), Com_Printf(), crand(), Cvar_GetInteger(), AABB::EMPTY, AABB::expandXY(), fallingSpeed, trace_t::fraction, frand(), AABB::getMaxX(), AABB::getMaxY(), AABB::getMaxZ(), AABB::getMinX(), AABB::getMinY(), AABB::getMinZ(), i, MASK_SOLID, MAX_PARTICLES, AABB::maxs, particles, splashTime, Line::start, Line::stop, Weather::particle::timeout, Weather::particle::ttl, VectorSet, Weather::particle::vx, Weather::particle::vy, Weather::particle::vz, weatherStrength, windDirection, windStrength, windTurbulence, Weather::particle::x, Weather::particle::y, and Weather::particle::z.

Field Documentation

◆ color

vec4_t Weather::color
protected

< how much to scale from default

Definition at line 58 of file r_weather.h.

Referenced by changeTo(), render(), and setDefaults().

◆ fallingSpeed

float Weather::fallingSpeed

< variety of wind strength and direction in units per second

Definition at line 38 of file r_weather.h.

Referenced by changeTo(), setDefaults(), and update().

◆ MAX_PARTICLES

const size_t Weather::MAX_PARTICLES = 8192
staticprotected

Definition at line 54 of file r_weather.h.

Referenced by clearParticles(), render(), and update().

◆ particles

particle Weather::particles[MAX_PARTICLES]
protected

Definition at line 67 of file r_weather.h.

Referenced by clearParticles(), render(), and update().

◆ particleSize

float Weather::particleSize
protected

< how much particle is motion-blurred, in seconds

Definition at line 56 of file r_weather.h.

Referenced by changeTo(), render(), and setDefaults().

◆ smearLength

float Weather::smearLength
protected

< particle array size, must be a power of two

Definition at line 55 of file r_weather.h.

Referenced by changeTo(), render(), and setDefaults().

◆ splashSize

float Weather::splashSize

< how long splash effect is being played, in milliseconds

Definition at line 41 of file r_weather.h.

Referenced by changeTo(), render(), and setDefaults().

◆ splashTime

int Weather::splashTime

< how fast particles fall

Definition at line 40 of file r_weather.h.

Referenced by changeTo(), render(), setDefaults(), and update().

◆ weatherStrength

float Weather::weatherStrength

Definition at line 34 of file r_weather.h.

Referenced by changeTo(), setDefaults(), and update().

◆ weatherType

weatherTypes Weather::weatherType

Definition at line 33 of file r_weather.h.

Referenced by changeTo(), and setDefaults().

◆ windDirection

float Weather::windDirection

< units/sec

Definition at line 36 of file r_weather.h.

Referenced by setDefaults(), and update().

◆ windStrength

float Weather::windStrength

< 0 to 1, amount of particles generated, 1 is the maximum possible

Definition at line 35 of file r_weather.h.

Referenced by changeTo(), setDefaults(), and update().

◆ windTurbulence

float Weather::windTurbulence

< in radians, 0 is due east

Definition at line 37 of file r_weather.h.

Referenced by changeTo(), setDefaults(), and update().


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