示例#1
0
文件: GemBase.cpp 项目: megrimm/Gem
/////////////////////////////////////////////////////////
// renderMess
//
/////////////////////////////////////////////////////////
void GemBase :: gem_renderMess(GemCache* cache, GemState*state)
{
  m_cache=cache;
  if(m_cache && m_cache->m_magic!=GEMCACHE_MAGIC) {
    m_cache=NULL;
  }
  if(INIT==m_state) {
    if(isRunnable()) {
      m_state=ENABLED;
    } else {
      m_state=DISABLED;
    }
  }
  if(MODIFIED==m_state) {
    stopRendering();
    m_state=ENABLED;
  }
  if(ENABLED==m_state) {
    startRendering();
    m_state=RENDERING;
  }
  if(RENDERING==m_state) {
    gem_amRendering=true;
    if(state) {
      render(state);
    }
    continueRender(state);
    if(state) {
      postrender(state);
    }
  }
  m_modified=false;
}
示例#2
0
void Client::updated() {
	stillAlive();
	// get the information in statusBuffer
	statusBuffer = client->status();
	// and deal with what it says
	if(statusBuffer.section("?", 0, 0) == "ERROR") {
		if (statusBuffer.section("?", 1, 1) == "FATAL") {
			emit disconnect(statusBuffer.section("?", 2, 2), thread);
		}
		else if (statusBuffer.section("?", 1, 1) == "RECOVERABLE") {
			emit couldntConnect(statusBuffer.section("?", 2, 2), thread);
		}
		else
			emit jobFailed("Bad plugin error string.", thread);
	}
	else if (statusBuffer.section("?", 0, 0) == "PROGRESS") {
		// here is the status update code
		emit changed(statusBuffer.section("?", 1, 1), thread, statusBuffer.section("?", 2, 2).toInt());
	}
	else if (statusBuffer.section("?", 0, 0) == "CONNECTED") {
		// yay!  It connected... now get to it, slacker
		emit connected(statusBuffer.section("?", 1, 1), thread);
	}
	else if (statusBuffer.section("?", 0, 0) == "RESULT") {
		if (statusBuffer.section("?", 1, 1) == "TRUE") {
			if (!Loaded) {
				Loaded = true;
				emit continueRender("Loaded file successfully", thread);
			}
		}
		else
			// emit to say that the result was bad
			emit jobFailed("Job Failed", thread);
	}
	else if (statusBuffer.section("?", 0, 0) == "ECHO") {
		emit echo(statusBuffer.section("?",1,-1), thread);
	}
	else if (statusBuffer.section("?", 0, 0) == "OUTPUT") {
		// can change later to check for successful creation of filename
		emit echo(statusBuffer.section("?", 1, 1), thread);
		emit jobDone("Job finished", thread);
	}
	else
		emit echo(statusBuffer, thread);
}
示例#3
0
/////////////////////////////////////////////////////////
// renderParticles
//
/////////////////////////////////////////////////////////
void part_render :: renderParticles(GemState *state)
{
  if (m_tickTime > 0.f)    {
    pMove();
  }
  //	pDrawGroupp();
  int cnt = pGetGroupCount();
  if(cnt < 1)return;
  if (cnt>m_number){
    if(m_colors)delete[]m_colors;
    if(m_sizes) delete[]m_sizes;
    if(m_pos)   delete[]m_pos;
    m_number = cnt;

    m_colors = new GLfloat[m_number * 4];
    m_sizes  = new GLfloat[m_number * 3];
    m_pos    = new GLfloat[m_number * 3];
  }
  GLfloat *position = m_pos;
  GLfloat *color = m_colorize ?  m_colors : NULL;
  GLfloat *size = m_sizing ? m_sizes : NULL;
  pGetParticles(0, cnt, position, color, NULL, size);
  for(int i = 0; i < cnt; i++)	{
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glTranslatef(position[0], position[1], position[2]);
    position+=3;
    if(color!=NULL){
      glColor4fv((GLfloat *)&color[i*4]);
      //post("%d color: %f %f %f", i, color[0], color[1], color[2], color[3]);
    }
    if(size!=NULL){
      glScalef(size[0], size[1], size[2]);
      //      post("%d size: %f %f %f", i, size[0], size[1], size[2]);
      size+=3;
    }
    if(i<(cnt-1)){
      continueRender(state);
      glMatrixMode(GL_MODELVIEW);
      glPopMatrix();
    }
  }
}