void draw(float u) { glLoadIdentity(); glLoadMatrixf(glm::value_ptr(camera.getViewMatrix(u))); glColor3f(0.5f, 0.5f, 0.5f); glDisable(GL_TEXTURE_2D); physics.applyVoxelGridConstraint(&voxelGrid); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, circleTexture); glColor3f(0.75f, 0.75f, 0.75f); for(Physics::Particles::iterator iter = physics.particles.begin(); iter != physics.particles.end(); ++iter) { Particle *p = *iter; glm::vec3 pos = lerp(u, p->x, p->x + p->v * PHYSICS_DT); glBindTexture(GL_TEXTURE_2D, particleTextures[p->type]); drawBillboard(camera.position, pos, AABB().include(glm::vec2(0.0f,0.0f)).expand(p->r)); } voxelGrid.draw(); glm::vec3 direction = camera.getDirection(); glm::ivec3 result; glBindTexture(GL_TEXTURE_2D, circleTexture); glm::ivec3 result_face; float d = voxelGrid.intersectRay(camera.position, direction, result, result_face); if(d > 0.0f) { drawBillboard(camera.position, camera.position + direction * d, AABB().include(glm::vec2(0.0f,0.0f)).expand(0.03f)); } }
void BillboardLayer::draw(bool deactiveBlendMode) { if(useShader&&!deactiveBlendMode) billboardShader.begin(); if(useAddBlendMode&&!deactiveBlendMode) ofEnableBlendMode(OF_BLENDMODE_ADD); ofEnablePointSprites(); // not needed for GL3/4 texture.getTexture().bind(); ofPushMatrix(); ofTranslate(0, 0, posZ); drawBillboard(); ofPopMatrix(); texture.getTexture().unbind(); ofDisablePointSprites(); // not needed for GL3/4 if(useAddBlendMode&&!deactiveBlendMode) ofDisableBlendMode(); if(useShader&&!deactiveBlendMode) billboardShader.end(); }