Автоматизированное редактирование частиц в компьютерной графике

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

icleSystem();

}

delete tmp_ps_ptr;

 

0&&selected_system_layer 0 && selected_system_layer < 0)

selectedSystemLayer = 0;

else

selectedSystemLayer = selected_system_layer;

 

//remove all old-created and add new

::iteratoriter=all_ps.begin();">vector::iterator iter = all_ps.begin();

while(iter != all_ps.end())

{

delete((ParticleSystem*)*iter);

++iter;

}

all_ps.clear();

tmp_all_ps.swap(all_ps);

workMode = ParticleSystemChainWorkMode_STATIC;

return true;

}

 

//ParticleSystem.cpp (эмиттер)

#include "ParticleSystem.h"

#include "MYSpinCtrld.h"

 

#define PS_BOUNDED_RECT_COLOR wxColour(150, 150, 150, 255)

 

//XML elements attributes of PSs

#define TEXTURE_ATTR "texture_file_name"

#define LIFE_TIME_ATTR "life_time"

#define APPEAR_DELAY_ATTR "appear_delay"

#define PARTICLE_SPEED_X_ATTR "particle_speed_x"

#define PARTICLE_SPEED_Y_ATTR "particle_speed_y"

#define GRAVITY_X_ATTR "gravity_x"

#define GRAVITY_Y_ATTR "gravity_y"

#define MAX_COUNT_ATTR "max_count"

#define START_COUNT_ATTR "start_count"

#define APPEAR_BOX_W_ATTR "appear_box_w"

#define APPEAR_BOX_H_ATTR "appear_box_h"

#define RED_BEGIN_ATTR "red_begin"

#define RED_END_ATTR "red_end"

#define GREEN_BEGIN_ATTR "green_begin"

#define GREEN_END_ATTR "green_end"

#define BLUE_BEGIN_ATTR "blue_begin"

#define BLUE_END_ATTR "blue_end"

#define ALPHA_BEGIN_ATTR "alpha_begin"

#define ALPHA_END_ATTR "alpha_end"

#define SCALE_BEGIN_W_ATTR "scale_begin_w"

#define SCALE_BEGIN_H_ATTR "scale_begin_h"

#define SCALE_END_W_ATTR "scale_end_w"

#define SCALE_END_H_ATTR "scale_end_h"

#define DISPERSION_X_ATTR "dispersion_x"

#define DISPERSION_Y_ATTR "dispersion_y"

#define PS_X_ATTR "ps_x"

#define PS_Y_ATTR "ps_y"

#define PS_SPEED_X_ATTR "ps_speed_x"

#define PS_SPEED_Y_ATTR "ps_speed_y"

#define START_DELAY_ATTR "start_delay"

#define STOP_DELAY_ATTR "stop_delay"

#define ROTATE_ATTR "rotate"

 

 

//ctors, destructors, ...

ParticleSystem::ParticleSystem()

{

data.pLifeTime= 1.0;

data.pMaxCount = EXPL_MAX;

data.pCountOnStart = 1;

data.pGravityX = data.pGravityY = 0.0;

 

//p.speed, dispersion page

data.pMoveSpeedX = 0.0;

data.pMoveSpeedY = 0.0;

data.pKFDispersionX = 0.0;

data.pKFDispersionY = 0.0;

 

//p.scale page

data.pKFScaleBeginW = 1.0;

data.pKFScaleBeginH = 1.0;

data.pKFScaleEndW = 1.0;

data.pKFScaleEndH = 1.0;

 

//p.color page

data.pRedBegin = 1.0;

data.pGreenBegin = 1.0;

data.pBlueBegin = 1.0;

data.pAlphaBegin = 1.0;

data.pRedEnd = 1.0;

data.pGreenEnd = 1.0;

data.pBlueEnd = 1.0;

data.pAlphaEnd = 1.0;

 

//rotate

data.pAngleRotate = 0.0;

 

//start in, stop in page

data.startDelay = 0.0;

data.stopDelay = 1800.0;

data.pAppearDelay = 0.0;

 

//PS settings page

MYSize2D sz = {100.0,100.0};

data.pAppearBoxSize = sz;

 

data.speedChangeX = 0;

data.speedChangeY = 0;

 

data.initialX = currentX = BOUND_DIMENSION;

data.initialY = currentY = BOUND_DIMENSION;

 

boundedRectColor = PS_BOUNDED_RECT_COLOR;

 

particleTexPtr = NULL;

setDefaultParticleTex();

 

isRunb = false;

isFinishedb = false;

 

viewMatrixCache = (GLdouble*)malloc(sizeof(GLdouble) * 16);

assert(viewMatrixCache != NULL);

}

 

ParticleSystem::~ParticleSystem()

{

free(viewMatrixCache);

if(particleTexPtr)

delete particleTexPtr;

}

 

int ParticleSystem::setParticleTex(const wxString &texture_path)

{

MYTexture* tmp_tex = new MYTexture(texture_path);

int res = tmp_tex->getState();

if(res != TEX_OK)

{

delete tmp_tex;

return res;

}

 

if(particleTexPtr)

delete particleTexPtr;

particleTexPtr = tmp_tex;

data.particleTexFileName = texture_path;

MYTexCoordPoint *ptrTex = texCoord;

for(int i = 0; i < EXPL_MAX; i++)

{

ptrTex->x = 0.0; ptrTex->y = 0.0;

ptrTex++;

ptrTex->x = particleTexPtr->getMaxS(); ptrTex->y = 0.0;

ptrTex++;

ptrTex->x = particleTexPtr->getMaxS(); ptrTex->y = particleTexPtr->getMaxT();

ptrTex++;

 

ptrTex->x = 0.0; ptrTex->y = 0.0;

ptrTex++;

ptrTex->x = particleTexPtr->getMaxS(); ptrTex->y = particleTexPtr->getMaxT();

ptrTex++;

ptrTex->x = 0.0; ptrTex->y = particleTexPtr->getMaxT();

ptrTex++;

}

return TEX_OK;

}

 

void ParticleSystem::setDefaultParticleTex()

{

if(particleTexPtr)

delete particleTexPtr;

GLubyte *buffer = new GLubyte[8 * 8 * 4];

memset(buffer, 255, 8*8*4);//white colour

particleTexPtr = new MYTexture(32,16711680/*third byte pattern*/,65280/*second byte pattern*/,255/*first byte pattern*/

,8,8,buffer);

delete[] buffer;

data.particleTexFileName = wxString("");

}

 

double ParticleSystem::getX() const

{

return currentX;

}

 

double ParticleSystem::getY() const

{

return currentY;

}

 

void ParticleSystem::setX(double x)

{

data.initialX = currentX = x;

}

 

void ParticleSystem::setY(double y)

{

data.initialY = currentY = y;

}

 

double ParticleSystem::getSpeedChangeX() const

{

return data.speedChangeX;

}

 

double ParticleSystem::getSpeedChangeY() const

{

return data.speedChangeY;

}

 

void ParticleSystem::setSpeedChangeX(double speed)

{

data.speedChangeX = speed;

}

 

void ParticleSystem::setSpeedChangeY(double speed)

{

data.speedChangeY = speed;

}

 

double ParticleSystem::getStopDelay() const

{

return data.stopDelay;

}

 

double ParticleSystem::getStartDelay() const

{

return data.startDelay;

}

 

void ParticleSystem::setStopDelay(double time)

{

data.stopDelay = time;

}

 

void ParticleSystem::setStartDelay(double time)

{

data.startDelay = time;

}

 

double ParticleSystem::getLifeTime() const

{

return data.pLifeTime;

}

 

void ParticleSystem::setLifeTime(double time)

{

data.pLifeTime = time;

}

 

double ParticleSystem::getParticleAppearDelay() const

{

return data.pAppearDelay;

}

 

void ParticleSystem::setParticleAppearDelay(double time)

{

data.pAppearDelay = time;

}

 

double ParticleSystem::getMoveSpeedX() const

{

return data.pMoveSpeedX;

}

 

double ParticleSystem::getMoveSpeedY() const

{

return data.pMoveSpeedY;

}

 

void ParticleSystem::setMoveSpeedX(double speed)

{

data.pMoveSpeedX = speed;

}

 

void ParticleSystem::setMoveSpeedY(double speed)

{

data.pMoveSpeedY = speed;

}

 

double ParticleSystem::getGravityX() const

{

return data.pGravityX;

}

 

double ParticleSystem::getGravityY() const

{

return data.pGravityY;

}

 

void ParticleSystem::setGravityX(double gravity)

{

data.pGravityX = gravity;

}

 

void ParticleSystem::setGravityY(double gravity)

{

data.pGravityY = gravity;

}

 

int ParticleSystem::getMaxCount() const

{

return data.pMaxCount;

}

 

void ParticleSystem::setMaxCount(int count)

{

data.pMaxCount = count;

data.pMaxCount)">if(data.pCountOnStart > data.pMaxCount)

data.pCountOnStart = data.pMaxCount;

}

 

int ParticleSystem::getCountOnStart() const

{

return data.pCountOnStart;