CST8234 Assignment 2 Particle system solved

$24.99

Original Work ?

Download Details:

  • Name: Assignment_2-3.zip
  • Type: zip
  • Size: 192.48 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

struct particle { Color4 color; Point3D pos; Vector3D dir; Vector3D spd; int lifespan; int size; struct particle* next; };
6
color, Color4,,-.,-#’!’/)!’ !0 .$)!’’!’’!’)!’%! .*$%)!’*. ’!’#+.!
struct color { float r; float g; float b; float a; }; typedef struct color Color4;
pos, Point3D,1!dirspd .!2. .$’!’)!’’!’%/.”3!4 .&5#$&!’&!’&!’%! #!
struct vector { float x; float y; float z; }; typedef struct vector Point3D; typedef struct vector Vector3D; !”#$”%

/********************************************************************* /* FUNCTION : particle_init /* PURPOSE : initialize the properties of a single particle /* INPUT : pointer to the particle structure to be initialized /* OUTPUT : returns ­1 on error, 0 on success /* NOTES : *********************************************************************/ int particle_init(struct particle* p);
/********************************************************************* /* FUNCTION : particle_add /* PURPOSE : add a particle to the dynamic particle linked list /* INPUT : struct particle *head. Head of the particle list /* OUTPUT : returns ­1 on error, 0 on success /* NOTES : Calls particle_init() ********************************************************************/ int particle_add( struct particle **head);
6
/********************************************************************* /* FUNCTION : particle_remove /* PURPOSE : remove a specific particle from the dynamic particle linked list /* INPUT : pointer to the particle to remove /* OUTPUT : returns ­1 on error, 0 on success /* NOTES : Particle can be situated in any place in the list. /* Usually deleted because the lifespan ran out ********************************************************************/ int particle_remove(struct particle* p);
/********************************************************************* /* FUNCTION : particle_destroy /* PURPOSE : free memory used by the dynamic particle linked list /* INPUT : struct particle **head. Head of the particle list /* OUTPUT : returns ­1 on error, the number of particles destroyed on success /* NOTES : removes all particles from the list Calls particle_remove() ********************************************************************/ int particle_destroy( struct particle **head );
/******************************************************************** /* FUNCTION : particle_update /* PURPOSE : update the particles properties to be rendered in the next frame /* INPUT : struct particle **head. Head of the particle list /* OUTPUT : returns ­1 on error, 0 on success /* NOTES : Creativity and more creativity here for you !!! ******************************************************************** / int particle_update(struct particle **head );
& 67#. 8+ .#.
p­life_span ­= DELTA_LIFE_SPAN;
# !0 .$ %
.#
particle­pos += particle­pos + (particle­speed * particle­direction )
../!
Particle­posi += particle­pos + particle­( 31 feet / sec ) * ( 0, ­1, 0 );
.#+,#/ !