Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
GRAPHICS: 3D particles utilities

Data Structures

struct  PARTICLE
 Structure of a single particle. More...
 
struct  PARTICLE_SYSTEM
 Structure of a particle system. More...
 

Macros

#define BITMAP_PART   8
 bitmap particle
 
#define CIRCLE_PART   6
 circle particle
 
#define FIRE_PART   4
 fire particle
 
#define NORMAL_PART   0
 classic moving particle
 
#define PIXEL_PART   7
 pixel particle
 
#define SINUS_PART   1
 sinus based moving particle
 
#define SNOW_PART   3
 snow particle
 
#define STAR_PART   5
 star particle
 
#define TEXT_PART   9
 bitmap particle
 
#define TRANS_PART   2
 transparent particle
 

Functions

int add_particle (PARTICLE_SYSTEM *psys, int spr, int mode, int lifetime, int size, ALLEGRO_COLOR color, PHYSICS object)
 add a particle to a particle system
 
int add_particle_ex (PARTICLE_SYSTEM *psys, int spr, int mode, int off_x, int off_y, int lifetime, int size, ALLEGRO_COLOR color, double vx, double vy, double vz, double ax, double ay, double az)
 add a particle to a particle system, all in line version (you have to set the PHYSICS object parameter in the function parameter instead of providing a PHYSICS object)
 
int draw_particle (PARTICLE_SYSTEM *psys, double xpos, double ypos, int w, int h, double range)
 draw particles of a particle system
 
int free_particle_system (PARTICLE_SYSTEM **psys)
 destroy and free a particle system
 
int init_particle_system (PARTICLE_SYSTEM **psys, int max, double x, double y, double z, int max_sprites)
 initialize a particle system
 
int manage_particle (PARTICLE_SYSTEM *psys)
 update particles positions usting particle system internal timer
 
int manage_particle_ex (PARTICLE_SYSTEM *psys, double delta_t)
 update particles positions usting provided delta time
 
int move_particles (PARTICLE_SYSTEM *psys, double vx, double vy, double vz)
 draw particles of a particle system
 

Detailed Description


Data Structure Documentation

◆ PARTICLE

struct PARTICLE

Structure of a single particle.

Definition at line 57 of file n_particles.h.

+ Collaboration diagram for PARTICLE:
Data Fields
ALLEGRO_COLOR color color of the particle
int lifetime lifetime
int mode particle mode: NORMAL_PART,SINUS_PART,PIXEL_PART
PHYSICS object particle physical properties
int size size of particle
int spr_id sprite id in library

◆ PARTICLE_SYSTEM

struct PARTICLE_SYSTEM

Structure of a particle system.

Examples
ex_gui_particles.c.

Definition at line 77 of file n_particles.h.

+ Collaboration diagram for PARTICLE_SYSTEM:
Data Fields
LIST * list list of PARTICLE pointers
int max_sprites size of the picture library
VECTOR3D source Coordinate of emitting point.
ALLEGRO_BITMAP ** sprites Library of picture for the particles.
N_TIME timer Internal: particle system timer.

Macro Definition Documentation

◆ BITMAP_PART

#define BITMAP_PART   8

bitmap particle

Definition at line 51 of file n_particles.h.

◆ CIRCLE_PART

#define CIRCLE_PART   6

circle particle

Definition at line 47 of file n_particles.h.

◆ FIRE_PART

#define FIRE_PART   4

fire particle

Definition at line 43 of file n_particles.h.

◆ NORMAL_PART

#define NORMAL_PART   0

classic moving particle

Definition at line 35 of file n_particles.h.

◆ PIXEL_PART

#define PIXEL_PART   7

pixel particle

Examples
ex_gui_particles.c.

Definition at line 49 of file n_particles.h.

◆ SINUS_PART

#define SINUS_PART   1

sinus based moving particle

Definition at line 37 of file n_particles.h.

◆ SNOW_PART

#define SNOW_PART   3

snow particle

Definition at line 41 of file n_particles.h.

◆ STAR_PART

#define STAR_PART   5

star particle

Definition at line 45 of file n_particles.h.

◆ TEXT_PART

#define TEXT_PART   9

bitmap particle

Definition at line 53 of file n_particles.h.

◆ TRANS_PART

#define TRANS_PART   2

transparent particle

Definition at line 39 of file n_particles.h.

Function Documentation

◆ add_particle()

int add_particle ( PARTICLE_SYSTEM psys,
int  spr,
int  mode,
int  lifetime,
int  size,
ALLEGRO_COLOR  color,
PHYSICS  object 
)

add a particle to a particle system

Parameters
psystargeted particle system
sprsprite id of the particle, if any. Set to negative if there is no sprite for the particle
modeparticle mode, NORMAL_PART:if sprite id then use sprite, else draw a pixel,SINUS_PART: snow moving effect,PIXEL_PART: rectfill with size
lifetimeduration of the particle in msecs
sizesize of the particle, in pixels
colorcolor of the particle
objectPHYSICS object in which you set the particle initial position, speed, acceleration, rotation
Returns
TRUE or FALSE

Definition at line 59 of file n_particles.c.

References __n_assert, list_push(), and Malloc.

Referenced by add_particle_ex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_particle_ex()

int add_particle_ex ( PARTICLE_SYSTEM psys,
int  spr,
int  mode,
int  off_x,
int  off_y,
int  lifetime,
int  size,
ALLEGRO_COLOR  color,
double  vx,
double  vy,
double  vz,
double  ax,
double  ay,
double  az 
)

add a particle to a particle system, all in line version (you have to set the PHYSICS object parameter in the function parameter instead of providing a PHYSICS object)

Parameters
psystargeted particle system
sprsprite id of the particle, if any. Set to negative if there is no sprite for the particle
modeparticle mode, NORMAL_PART:if sprite id then use sprite, else draw a pixel,SINUS_PART: snow moving effect,PIXEL_PART: rectfill with size
off_xx offset from particle source x position
off_yy offset from particle source x position
lifetimeduration of the particle in msecs
sizesize of the particle, in pixels
colorcolor of the particle
vxx speed of the particle
vyvy speed of the particle
vzsvz peed of the particle
axx acceleration of the particle
ayy acceleration of the particle
azz acceleration of the particle
Returns
TRUE or FALSE

Definition at line 109 of file n_particles.c.

References add_particle(), and VECTOR3D_SET.

+ Here is the call graph for this function:

◆ draw_particle()

int draw_particle ( PARTICLE_SYSTEM psys,
double  xpos,
double  ypos,
int  w,
int  h,
double  range 
)

draw particles of a particle system

Parameters
psysthe targeted particle system
xposcamera x position
yposcamera y position
wwidth of the current display
hheight of the current display
rangedisplay border tolerance, if( ( x < -range ) || ( x > ( w + range ) ) || ( y< -range ) || ( y > ( h + range ) ) ) next ;
Returns
TRUE or FALSE

Definition at line 193 of file n_particles.c.

References __n_assert, NORMAL_PART, PIXEL_PART, and SINUS_PART.

◆ free_particle_system()

int free_particle_system ( PARTICLE_SYSTEM **  psys)

destroy and free a particle system

Parameters
psysa pointer to the particle system to destroy
Returns
TRUE or FALSE

Definition at line 279 of file n_particles.c.

References __n_assert, Free, and remove_list_node.

◆ init_particle_system()

int init_particle_system ( PARTICLE_SYSTEM **  psys,
int  max,
double  x,
double  y,
double  z,
int  max_sprites 
)

initialize a particle system

Parameters
psysa pointer to a NULL initialized PARTICLE_SYSTEM pointer
maxmaximum number of particles in the system. Set to zero or negative to disable the limitation
xx position of the emitter
yy position of the emitter
zz position of the emitter
max_spritesmaximum number of sprites used in the system. Set to zero or negative if there are no sprites used.
Returns
TRUE or FALSE

Definition at line 24 of file n_particles.c.

References __n_assert, LOG_ERR, Malloc, n_log, new_generic_list(), and start_HiTimer().

+ Here is the call graph for this function:

◆ manage_particle()

int manage_particle ( PARTICLE_SYSTEM psys)

update particles positions usting particle system internal timer

Parameters
psysthe targeted particle system
Returns
TRUE or FALSE

Definition at line 173 of file n_particles.c.

References __n_assert, get_usec(), and manage_particle_ex().

+ Here is the call graph for this function:

◆ manage_particle_ex()

int manage_particle_ex ( PARTICLE_SYSTEM psys,
double  delta_t 
)

update particles positions usting provided delta time

Parameters
psysthe targeted particle system
delta_tdelta time to use, in msecs
Returns
TRUE or FALSE

Definition at line 132 of file n_particles.c.

References __n_assert, Free, remove_list_node, and update_physics_position().

Referenced by manage_particle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move_particles()

int move_particles ( PARTICLE_SYSTEM psys,
double  vx,
double  vy,
double  vz 
)

draw particles of a particle system

Parameters
psysthe targeted particle system
vxx move
vyy move
vzz move
Returns
TRUE or FALSE

Definition at line 304 of file n_particles.c.

References __n_assert.