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

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

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

}

 

void ParticleSystem::setCountOnStart(int count)

{

data.pCountOnStart = count;

}

 

MYSize2D ParticleSystem::getAppearBoxSize() const

{

return data.pAppearBoxSize;

}

 

void ParticleSystem::setAppearBoxSize(MYSize2D box)

{

data.pAppearBoxSize = box;

}

 

double ParticleSystem::getRedBegin() const

{

return data.pRedBegin;

}

 

double ParticleSystem::getGreenBegin() const

{

return data.pGreenBegin;

}

 

double ParticleSystem::getBlueBegin() const

{

return data.pBlueBegin;

}

 

double ParticleSystem::getAlphaBegin() const

{

return data.pAlphaBegin;

}

 

void ParticleSystem::setRedBegin(double red)

{

data.pRedBegin = red;

}

 

void ParticleSystem::setGreenBegin(double green)

{

data.pGreenBegin = green;

}

 

void ParticleSystem::setBlueBegin(double blue)

{

data.pBlueBegin = blue;

}

 

void ParticleSystem::setAlphaBegin(double alpha)

{

data.pAlphaBegin = alpha;

}

 

double ParticleSystem::getRedEnd() const

{

return data.pRedEnd;

}

 

double ParticleSystem::getGreenEnd() const

{

return data.pGreenEnd;

}

 

double ParticleSystem::getBlueEnd() const

{

return data.pBlueEnd;

}

 

double ParticleSystem::getAlphaEnd() const

{

return data.pAlphaEnd;

}

 

void ParticleSystem::setRedEnd(double red)

{

data.pRedEnd = red;

}

 

void ParticleSystem::setGreenEnd(double green)

{

data.pGreenEnd = green;

}

 

void ParticleSystem::setBlueEnd(double blue)

{

data.pBlueEnd = blue;

}

 

void ParticleSystem::setAlphaEnd(double alpha)

{

data.pAlphaEnd = alpha;

}

 

double ParticleSystem::getRotateAngle() const

{

return data.pAngleRotate;

}

 

void ParticleSystem::setRotateAngle(double angle)

{

data.pAngleRotate = angle;

}

 

double ParticleSystem::getKFScaleBeginW() const

{

return data.pKFScaleBeginW;

}

 

double ParticleSystem::getKFScaleBeginH() const

{

return data.pKFScaleBeginH;

}

 

void ParticleSystem::setKFScaleBeginW(double scale)

{

data.pKFScaleBeginW = scale;

}

 

void ParticleSystem::setKFScaleBeginH(double scale)

{

data.pKFScaleBeginH = scale;

}

 

double ParticleSystem::getKFScaleEndW() const

{

return data.pKFScaleEndW;

}

 

double ParticleSystem::getKFScaleEndH() const

{

return data.pKFScaleEndH;

}

 

void ParticleSystem::setKFScaleEndW(double scale)

{

data.pKFScaleEndW = scale;

}

 

void ParticleSystem::setKFScaleEndH(double scale)

{

data.pKFScaleEndH = scale;

}

 

double ParticleSystem::getKFDispersionX() const

{

return data.pKFDispersionX;

}

 

double ParticleSystem::getKFDispersionY() const

{

return data.pKFDispersionY;

}

 

void ParticleSystem::setKFDispersionX(double disp)

{

data.pKFDispersionX = disp;

}

 

void ParticleSystem::setKFDispersionY(double disp)

{

data.pKFDispersionY = disp;

}

 

wxString ParticleSystem::getParticleTexFileName() const

{

return data.particleTexFileName;

}

 

void ParticleSystem::copyDataFromParticleSystem(ParticleSystem* sys_from)

{

if(!sys_from)

return;

 

data.pLifeTime;">data.pLifeTime = sys_from->data.pLifeTime;

data.pMaxCount;">data.pMaxCount = sys_from->data.pMaxCount;

data.pCountOnStart;">data.pCountOnStart = sys_from->data.pCountOnStart;

data.pGravityX;">data.pGravityX = sys_from->data.pGravityX;

data.pGravityY;">data.pGravityY = sys_from->data.pGravityY;

 

//p.speed, dispersion page

data.pMoveSpeedX;">data.pMoveSpeedX = sys_from->data.pMoveSpeedX;

data.pMoveSpeedY;">data.pMoveSpeedY = sys_from->data.pMoveSpeedY;

data.pKFDispersionX;">data.pKFDispersionX = sys_from->data.pKFDispersionX;

data.pKFDispersionY;">data.pKFDispersionY = sys_from->data.pKFDispersionY;

 

//p.scale page

data.pKFScaleBeginW;">data.pKFScaleBeginW = sys_from->data.pKFScaleBeginW;

data.pKFScaleBeginH;">data.pKFScaleBeginH = sys_from->data.pKFScaleBeginH;

data.pKFScaleEndW;">data.pKFScaleEndW = sys_from->data.pKFScaleEndW;

data.pKFScaleEndH;">data.pKFScaleEndH = sys_from->data.pKFScaleEndH;

 

//p.color page

data.pRedBegin;">data.pRedBegin = sys_from->data.pRedBegin;

data.pGreenBegin;">data.pGreenBegin = sys_from->data.pGreenBegin;

data.pBlueBegin;">data.pBlueBegin = sys_from->data.pBlueBegin;

data.pAlphaBegin;">data.pAlphaBegin = sys_from->data.pAlphaBegin;

data.pRedEnd;">data.pRedEnd = sys_from->data.pRedEnd;

data.pGreenEnd;">data.pGreenEnd = sys_from->data.pGreenEnd;

data.pBlueEnd;">data.pBlueEnd = sys_from->data.pBlueEnd;

data.pAlphaEnd;">data.pAlphaEnd = sys_from->data.pAlphaEnd;

 

//rotate

data.pAngleRotate;">data.pAngleRotate = sys_from->data.pAngleRotate;

 

//start in, stop in page

data.startDelay;">data.startDelay = sys_from->data.startDelay;

data.stopDelay;">data.stopDelay = sys_from->data.stopDelay;

data.pAppearDelay;">data.pAppearDelay = sys_from->data.pAppearDelay;

 

//PS settings page

data.pAppearBoxSize;">data.pAppearBoxSize = sys_from->data.pAppearBoxSize;

 

data.speedChangeX;">data.speedChangeX = sys_from->data.speedChangeX;

data.speedChangeY;">data.speedChangeY = sys_from->data.speedChangeY;

 

data.initialX);">setX(sys_from->data.initialX);

data.initialY);">setY(sys_from->data.initialY);

 

data.particleTexFileName=="")">if(sys_from->data.particleTexFileName == "")

setDefaultParticleTex();

else

data.particleTexFileName);">setParticleTex(sys_from->data.particleTexFileName);

}

 

bool ParticleSystem::isRun() const

{

return isRunb;

}

 

bool ParticleSystem::isFinished() const

{

return isFinishedb;

}

 

void ParticleSystem::start()

{

isRunb = true;

isFinishedb = false;

restart();

}

 

void ParticleSystem::stop()

{

isRunb = false;

}

 

void ParticleSystem::stopExtra()

{

isRunb = false;

finish();

}

 

void ParticleSystem::finish()

{

isFinishedb = true;

currentX = data.initialX;

currentY = data.initialY;

}

 

void ParticleSystem::restart()

{

startInTime = data.startDelay;

stopInTime = data.stopDelay;

timeForNextParticle = data.pAppearDelay;

int count = data.pCountOnStart;

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

{

if (count > 0)

{

initParticleAtIndex(i);

count--;

}

else

{

pTM[i] = 0;

}

}

}

 

void ParticleSystem::initParticleAtIndex(int i)

{

assert(i >= 0 && i < EXPL_MAX);

 

pTM[i] = data.pLifeTime;

 

pX[i] = fmod(rand(), data.pAppearBoxSize.width);

pY[i] = fmod(rand(), data.pAppearBoxSize.height);

 

double speedDeltaX = fmod(rand(), data.pKFDispersionX * 2 + 1) - data.pKFDispersionX;

pDx[i] = data.pMoveSpeedX + speedDeltaX;

 

double speedDeltaY = fmod(rand(), data.pKFDispersionY * 2 + 1) - data.pKFDispersionY;

pDy[i] = data.pMoveSpeedY + speedDeltaY;

}

 

void ParticleSystem::drawBound()

{

double appear_w = data.pAppearBoxSize.width;

double appear_h = data.pAppearBoxSize.height;

 

//draw bound itself

glColor4d(boundColor.Red()/255.0, boundColor.Green()/255.0, boundColor.Blue()/255.0, boundColor.Alpha()/255.0);

glBegin(GL_POLYGON);

glVertex2d(currentX - BOUND_DIMENSION, currentY - BOUND_DIMENSION);

glVertex2d(currentX + appear_w + BOUND_DIMENSION, currentY - BOUND_DIMENSION);

glVertex2d(currentX + appear_w + BOUND_DIMENSION, currentY + appear_h + BOUND_DIMENSION);