162 lines
No EOL
3.5 KiB
C++
162 lines
No EOL
3.5 KiB
C++
|
|
#ifndef ___PARTICULES_H___
|
|
#define ___PARTICULES_H___
|
|
|
|
#define MAX_FORCES 20
|
|
#define TEXTURE_INCREMENTAL 1<<0
|
|
#define TEXTURE_RANDOM 1<<1
|
|
|
|
typedef struct
|
|
{
|
|
char alive;
|
|
int life;
|
|
int collide;
|
|
|
|
DWORD creationTime;
|
|
u32 RGBA;
|
|
Vector coords;
|
|
Vector speed; // pixels per second
|
|
|
|
Vector coordsDest;
|
|
Vector speedDest;
|
|
|
|
float scaleFactor;
|
|
float width; // width or width/2
|
|
float height; // height or height/2
|
|
float rotAngle; // angle in degrees
|
|
int textureIdx; // IN GRID !!
|
|
int textureIdxBase; // IN GRID !!
|
|
|
|
char * luaCollideCallBack;
|
|
} Particules;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
Vector Gravity;
|
|
float Frictions; // ration per millisecond
|
|
|
|
Vector WindDirection;
|
|
float WindForce;
|
|
|
|
float RotationSpeed;
|
|
float RotationRand;
|
|
float RotationInit;
|
|
float RotationInit2;
|
|
|
|
int GrowFor;
|
|
float GrowForInit;
|
|
float GrowForEnd;
|
|
float GrowForRand;
|
|
|
|
int FadeFor;
|
|
float FadeForInit;
|
|
float FadeForEnd;
|
|
float FadeForRand;
|
|
|
|
int GrowForColor;
|
|
u32 GrowForColorInit;
|
|
u32 GrowForColorEnd;
|
|
|
|
int FadeForColor;
|
|
u32 FadeForColorInit;
|
|
u32 FadeForColorEnd;
|
|
|
|
u32 AnimSpeed;
|
|
BOOL AnimRepeat;
|
|
u32 AnimInit;
|
|
|
|
float collisionFriction;
|
|
float collisionRandAngle;
|
|
} Forces;
|
|
|
|
|
|
class PGENERATOR_OBJ
|
|
{
|
|
public:
|
|
BOOL alive;
|
|
BOOL Collision;
|
|
UnicID ThisID;
|
|
// Code For .MAT in Particles, ABONDONNED
|
|
//_3D_Material *MaterialPtr;
|
|
|
|
char Name[MAX_PATH];
|
|
char GeneratorName[MAX_PATH];
|
|
char MediaName[MAX_PATH];
|
|
char SceneName[MAX_PATH];
|
|
char ObjectName[MAX_PATH];
|
|
|
|
SIZE TextureGrid;
|
|
int TextureIdx;
|
|
|
|
u32 nbInGrid;
|
|
u16 BlendMode;
|
|
int AlphaThreshold;
|
|
|
|
DWORD curTime;
|
|
DWORD pgTime;
|
|
DWORD pgTimeUnused;
|
|
|
|
u32 options;////
|
|
|
|
Particules *particulesTab;
|
|
int maxParticules;
|
|
int nbParticules;
|
|
int curParticule;
|
|
|
|
int particuleRepeat;
|
|
int particuleLife;
|
|
float particuleLifeRand;
|
|
|
|
float genSpeed; // in particules per second
|
|
float genSpeedRand;
|
|
float genAngleAllowed;
|
|
float genPower;
|
|
float genPowerRand;
|
|
int genNumber;
|
|
float genWidth; // width or width/2
|
|
float genHeight; // height or height/2
|
|
float genSizeRand;
|
|
|
|
Forces forces;
|
|
PGENERATOR_OBJ *particuleSonPtr;
|
|
char son[MAX_PATH];
|
|
int sonMode;
|
|
|
|
Vector Origin;
|
|
Vector Direction;
|
|
Vector *OriginList;
|
|
Vector *DirectionList;
|
|
|
|
char MassTextureName[MAX_PATH];
|
|
int MeshFaces;
|
|
float MeshSurface;
|
|
float *MeshSurfaceList;
|
|
|
|
public:
|
|
PGENERATOR_OBJ() {memset(this, 0, sizeof(*this)); TextureGrid.cx = TextureGrid.cy = 1; alive=true;};
|
|
~PGENERATOR_OBJ() {
|
|
for (int i=0; i<nbParticules; i++)
|
|
if (particulesTab[i].luaCollideCallBack)
|
|
CC_free(particulesTab[i].luaCollideCallBack);
|
|
if (particulesTab) {CC_free(particulesTab); particulesTab = NULL;}
|
|
if (OriginList) {CC_free(OriginList); OriginList = NULL;}
|
|
if (DirectionList) {CC_free(DirectionList); DirectionList = NULL;}
|
|
if (MeshSurfaceList){CC_free(MeshSurfaceList); MeshSurfaceList = NULL;}
|
|
};
|
|
|
|
void Init();
|
|
void Process(int elapsedTime);
|
|
|
|
int GenerateSingle(Vector center, Vector direction, int elapsedTime);
|
|
void GenerateFix(int nbPToMake, int life);
|
|
void GenerateDyn(int elapsedTime);
|
|
|
|
BOOL ProcessParticule(int time, Particules *particulePtr);
|
|
void ProcessParticuleSon(Particules *particulePtr);
|
|
};
|
|
|
|
float GetMeshSurface(Mesh *mesh, MATRIX *global, float *surfaceList, MAP *massTexture);
|
|
int GetPointRepartition(Vector *points, Vector *normals, Vector *ulist, Vector *uvlist, int number, Mesh *mesh, MATRIX *global, float density, float *surfaceList, MAP *massTexture, int initFace = 0, int initRand = 0, u32 seed = -1);
|
|
|
|
#endif |