void Creature::draw(const ofCamera& cam)
 {
     ofPushMatrix();
     if (cam.getPosition().z - getPosition().z > Creature::fogEnd)
     {
         ofTranslate(0, 0, Creature::fogEnd * floor((cam.getPosition().z - getPosition().z) / Creature::fogEnd));
     }
     else if (getPosition().z > cam.getPosition().z)
     {
         ofTranslate(0, 0, -Creature::fogEnd * ceil((getPosition().z - cam.getPosition().z) / Creature::fogEnd));
     }
     ofMultMatrix(getGlobalTransformMatrix());
     customDraw();
     ofPopMatrix();
 }
 void MarineSnow::draw(const ofCamera& cam)
 {
     // putting this here otherwise isn't working in VSE
     tex.bind();
     glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
     tex.unbind();
     
     ofPushStyle();
     glPushAttrib(GL_ENABLE_BIT);
     glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     glEnable(GL_POINT_SPRITE);
     ofEnableAlphaBlending();
     shader.begin();
     shader.setUniform1f("innerFogStart", innerFogStart);
     shader.setUniform1f("innerFogEnd", innerFogEnd);
     shader.setUniform1f("fogStart", fogStart);
     shader.setUniform1f("fogEnd", fogEnd);
     shader.setUniform1f("nearClip", cam.getNearClip());
     shader.setUniform1f("camZ", cam.getPosition().z);
     shader.setUniform1f("time", ofGetElapsedTimef());
     shader.setUniform1f("yMin", yMin);
     shader.setUniform1f("yRange", yMax - yMin);
     shader.setUniformTexture("tex", tex, 1);
     mesh.draw();
     shader.end();
     glPopAttrib();
     ofPopStyle();
 }
Exemplo n.º 3
0
void ParticleSystem::depthSort(ofCamera& cam)
{
        /* depth sorting */
	list< pair<int, float> > depthList;

	// put indexed points and z-values into the list
	for(unsigned int i = 0; i < particles.size(); i++) {
		depthList.push_back( make_pair(i, ofVec3f(particles[i].pos - cam.getPosition()).length() ));
	}

	// sort the list
	depthList.sort(DepthSortPredicate);

	std::list<pair<int, float> >::iterator it;
	int j = 0;
    for(it = depthList.begin(); it != depthList.end(); it++) {

	int i = it->first;
        billboards.getVertices()[j] = particles[i].pos;
        billboards.getColors()[j] = particles[i].colour;
        billboards.setNormal(j,ofVec3f(particles[i].scale,spriteSheetWidth,particles[i].spriteCount));
        rotations[j] = particles[i].rotation;

        if(particles[i].animSpeed > 0) {
            if((int)particles[i].age % particles[i].animSpeed == 0) particles[i].spriteCount++;
            if(particles[i].spriteCount >= totalSprites) particles[i].spriteCount = 0;
        }

		j++;
	}

}