tmp_rect.SetHeight(MIN_RUN_PSCHAIN_ITEM_DIMENSION);
}
else
tmp_rect = wxRect(appear_box_position.x - BOUND_DIMENSION, appear_box_position.y - BOUND_DIMENSION,
appear_box_size.width + BOUND_DIMENSION * 2, appear_box_size.height + BOUND_DIMENSION * 2);
if(point.x >= tmp_rect.x && point.x < (tmp_rect.x + tmp_rect.width) &&
point.y >= tmp_rect.y && point.y < (tmp_rect.y + tmp_rect.height) )
{
res.psLayer = (int)i;
system_rect = tmp_rect;
break;
if( res.psLayer == -1/*no selected ps*/ || chain_is_run )
return res;
//selecting system has been finded, and <!chainIsRun> - maybe we touched on some ps's bottom(-s)
if( (point.x >= system_rect.x) && (point.x < system_rect.x + BOUND_DIMENSION) )
res.isLeft = true;
if( (point.x < system_rect.x + system_rect.width) && (point.x >= system_rect.x + system_rect.width - BOUND_DIMENSION) )
res.isRight = true;
if( (point.y >= system_rect.y) && (point.y < system_rect.y + BOUND_DIMENSION) )
res.isTop = true;
if( (point.y < system_rect.y + system_rect.height) && (point.y >= system_rect.y + system_rect.height - BOUND_DIMENSION) )
res.isBottom = true;
void ParticleSystemChain::ChooseSystemAtLayer(int layer)
if( (layer < 0)
int ParticleSystemChain::GetChoosedSystemLayer() const
return choosedSystemLayer;
void ParticleSystemChain::SelectSystemAtLayer(int layer)
int ParticleSystemChain::GetSelectedSystemLayer() const
return selectedSystemLayer;
ParticleSystemChainWorkMode ParticleSystemChain::GetWorkMode() const
return workMode;
void ParticleSystemChain::SetWorkMode(ParticleSystemChainWorkMode mode)
vector<ParticleSystem*>::iterator begin_iter = all_ps.begin();
vector<ParticleSystem*>::iterator end_iter = all_ps.end();
vector<ParticleSystem*>::iterator iter = begin_iter;
if(mode == ParticleSystemChainWorkMode_PLAYBACK || mode == ParticleSystemChainWorkMode_PLAYBACK_LOOP)
while(iter != end_iter)
(*iter)->start();
++iter;
timer.reset();
else//if(mode == ParticleSystemChainWorkMode_STATIC)
(*iter)->stopExtra();
workMode = mode;
void ParticleSystemChain::CallbackSystems()
if(workMode == ParticleSystemChainWorkMode_STATIC)
return;
double sec_interval = timer.getMilliseconds() / 1000.0;
vector<ParticleSystem*>::iterator iter = all_ps.begin();
bool chain_is_run = false;
while(iter != all_ps.end())
(*iter)->callback(sec_interval);
if(!(*iter)->isFinished())
chain_is_run = true;
if(chain_is_run)
//!chain_is_run
if(workMode == ParticleSystemChainWorkMode_PLAYBACK)
SetWorkMode(ParticleSystemChainWorkMode_STATIC);
else// if(workMode == ParticleSystemChainWorkMode_PLAYBACK_LOOP)
SetWorkMode(ParticleSystemChainWorkMode_PLAYBACK_LOOP);//just restart
void ParticleSystemChain::DrawSystems()
if(workMode != ParticleSystemChainWorkMode_STATIC)
glEnable(GL_BLEND);
glBlendFunc(blendModeSrc, blendModeDst);
(*iter)->draw();
glDisable(GL_BLEND);
int i = 0;
ParticleSystem* curr_ps = (*iter);
if(i == selectedSystemLayer)
curr_ps->setBoundColor(PSBOUND_SELECTED_COLOR);
else if(i == choosedSystemLayer)
curr_ps->setBoundColor(PSBOUNS_CHOOSED_COLOR);
curr_ps->setBoundColor(PSBOUND_COLOR);
curr_ps->drawBound();
++iter, ++i;
int ParticleSystemChain::GetBlendModeSrc() const
return blendModeSrc;
int ParticleSystemChain::GetBlendModeDst() const
return blendModeDst;
void ParticleSystemChain::SetBlendModeSrc(int mode)
blendModeSrc = mode;
void ParticleSystemChain::SetBlendModeDst(int mode)
blendModeDst = mode;
ParticleSystem* ParticleSystemChain::GetSystemAtLayer(int layer)
return NULL;
MYRect ParticleSystemChain::GetInitialSystemsRect(unsigned int *systems_counter) const//systems bound rect on gl
*systems_counter = (unsigned int)all_ps.size();
double min_x = 0.0;
double min_y = 0.0;
double max_x = 0.0;
double max_y = 0.0;
vector<ParticleSystem*>::const_iterator begin_iter = all_ps.begin();
vector<ParticleSystem*>::const_iterator end_iter = all_ps.end();
vector<ParticleSystem*>::const_iterator iter = begin_iter;
max_x < new_max)
MYPoint2D pos = MYPoint2DMake(min_x, min_y);
MYSize2D sz = MYSize2DMake(max_x - min_x, max_y - min_y);
return(MYRectMake(pos,sz));
int ParticleSystemChain::GetNumofSystems() const
return (int)all_ps.size();
//internals
ParticleSystemChain::ParticleSystemChain()
workMode = DEFAULT_PARTICLE_SYSTEM_CHAIN_WORK_MODE;
blendModeSrc = GL_ONE;
blendModeDst = GL_ONE_MINUS_SRC_ALPHA;
selectedSystemLayer = choosedSystemLayer = -1;
ParticleSystemChain::~ParticleSystemChain()
RemoveAll();
bool ParticleSystemChain::saveSystems(TiXmlElement* root) const
TiXmlElement tmp("SYSTEMS_DATA");
TiXmlElement *sys_data = (TiXmlElement*)root->InsertEndChild(tmp);
if(!sys_data)
return false;
sys_data->SetAttribute(ITEM_SELECTED, selectedSystemLayer);
if(all_ps.size() == 0)
return true;
vector<ParticleSystem*>::const_iterator iter = all_ps.end();
do
--iter;
if(!(*iter)->save(root))
while(iter != all_ps.begin());
bool ParticleSystemChain::loadSystems(TiXmlElement* root)
TiXmlElement *systems_data_ptr = (TiXmlElement*)root->FirstChild("SYSTEMS_DATA");
int selected_system_layer = -1;
if(systems_data_ptr)//new format file (ver. above 1.0)
systems_data_ptr->Attribute(ITEM_SELECTED, &selected_system_layer);
vector<ParticleSystem*> tmp_all_ps;
ParticleSystem *tmp_ps_ptr = new ParticleSystem();
while(bool is_success = tmp_ps_ptr->load(root))
tmp_all_ps.insert(tmp_all_ps.begin(), tmp_ps_ptr);
tmp_ps_ptr = new ParticleSystem();
delete tmp_ps_ptr;
if(tmp_all_ps.size() > 0 && selected_system_layer < 0)
selectedSystemLayer = 0;
selectedSystemLayer = selected_system_layer;
//remove all old-created and add new
delete((ParticleSystem*)*iter);
all_ps.clear();
tmp_all_ps.swap(all_ps);
workMode = ParticleSystemChainWorkMode_STATIC;
//ParticleSystem.cpp (эмиттер)
#include "ParticleSystem.h"
#include "MYSpinCtrld.h"
#define PS_BOUNDED_RECT_COLOR wxColour(150, 150, 150, 255)
//XML element's attributes of PSs
Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14