Ejemplo n.º 1
0
	void Cloud::Draw()
	{
		ofSetColor(color_.r, color_.g, color_.b,color_.a);
		if(enable_)
		{
			switch (flower_state_)
			{
			case GROWING:
			case DISAPPEARING:
			case WAITING:
				drawFaces();
				break;
			case FALLING:

				drawFaces();
				ofDisableLighting();
				ofEnableAlphaBlending();
				rain_emitter_.draw(0,0);
				ofEnableLighting();
				break;
			case HOLDING:
				break;
			}
		}
	}
Ejemplo n.º 2
0
// Renders the requested list of faces
// Normal faces are rendered with vertex arrays and multitexturing. The first TMU handles the 
// lightmap, while the second TMU handles the surface texture itself.
int GLDriver::drawGeometryList(GeometryList* l)
{
	Assert(l != NULL);
	if(lastTime == 0)
		lastTime = timeGetTime();
	renderTime = timeGetTime();
	qmap = l->mapData;

	ShaderUtils::renderTime = renderTime;
	ShaderUtils::qmap = qmap;
	ShaderUtils::textureFactory = textureFactory;
	qsort(l->faces, l->faceCount, sizeof(int), TransSort);

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glDisable(GL_TEXTURE_2D);

	glClientActiveTextureARB(GL_TEXTURE1_ARB);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glClientActiveTextureARB(GL_TEXTURE0_ARB);

	glDepthFunc(GL_LEQUAL);

	float timeDiff = renderTime - lastTime;
    drawSky(l, timeDiff);
    drawFaces(l, timeDiff);
    drawMeshes(l, timeDiff);
    drawPatches(l);
    //drawFog(l);

	lastTime = renderTime;
	return 0;
}
Ejemplo n.º 3
0
void Mesh::drawMesh() {
	sumAngle = this->rotatedAngle.x + this->rotatedAngle.y
			+ this->rotatedAngle.z;
	if (sumAngle > 90) {
		if (this->rotatedAngle.x > 0)
			calculateRotateMesh(1);
		if (this->rotatedAngle.y > 0)
			calculateRotateMesh(2);
		if (this->rotatedAngle.z > 0)
			calculateRotateMesh(3);
		this->rotatedAngle.x = 0;
		this->rotatedAngle.y = 0;
		this->rotatedAngle.z = 0;
	}
	if (sumAngle > 0) {
		glPushMatrix();

		glRotated(this->rotatedAngle.x, 1, 0, 0);
		glRotated(this->rotatedAngle.y, 0, 1, 0);
		glRotated(this->rotatedAngle.z, 0, 0, 1);

		if (this->rotatedAngle.x > 0)
			this->rotatedAngle.x += addAngle;
		if (this->rotatedAngle.y > 0)
			this->rotatedAngle.y += addAngle;
		if (this->rotatedAngle.z > 0)
			this->rotatedAngle.z += addAngle;
		this->drawFaces();
		glPopMatrix();
	} else
		drawFaces();
}
void Mesh :: drawOpenGL()
{ 
  tellMaterialsGL(); 	
  glPushMatrix();
  glMultMatrixf(transf.m);

  switch (mode) {
  case MODE_WIRE:
    drawEdges();
    break;
  case MODE_SOLID:
    drawFaces();	
    break;
  default:
    drawFaces();	
    drawEdges();
    break;
  }

  glPopMatrix();
} 
Ejemplo n.º 5
0
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    double aspect = (double)viewport[2] / (double)viewport[3];
    gluPerspective(fovy, aspect, clipNear, clipFar);
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    gluLookAt(0, 0, z, x, y, 0, 0, 1, 0);
    
    if (success) {
        drawFaces();
        
        if (drawAABB) {
            Eigen::Vector3d max = boundingBox.max;
            Eigen::Vector3d min = boundingBox.min;
            Eigen::Vector3d extent = boundingBox.extent;
            
            Eigen::Vector3d b2(min.x() + extent.x(), min.y(), min.z());
            Eigen::Vector3d b3(min.x() + extent.x(), min.y() + extent.y(), min.z());
            Eigen::Vector3d b4(min.x(), min.y() + extent.y(), min.z());
            Eigen::Vector3d b5(max.x() - extent.x(), max.y() - extent.y(), max.z());
            Eigen::Vector3d b6(max.x(), max.y() - extent.y(), max.z());
            Eigen::Vector3d b8(max.x() - extent.x(), max.y(), max.z());
            
            drawBox(min, b2, b3, b4, b5, b6, max, b8);
            
        } else {
            std::vector<Eigen::Vector3d> orientedPoints = boundingBox.orientedPoints;
            
            Eigen::Vector3d b1 = orientedPoints[0] + orientedPoints[2] + orientedPoints[4];
            Eigen::Vector3d b2 = orientedPoints[1] + orientedPoints[2] + orientedPoints[4];
            Eigen::Vector3d b3 = orientedPoints[1] + orientedPoints[2] + orientedPoints[5];
            Eigen::Vector3d b4 = orientedPoints[0] + orientedPoints[2] + orientedPoints[5];
            Eigen::Vector3d b5 = orientedPoints[0] + orientedPoints[3] + orientedPoints[4];
            Eigen::Vector3d b6 = orientedPoints[1] + orientedPoints[3] + orientedPoints[4];
            Eigen::Vector3d b8 = orientedPoints[0] + orientedPoints[3] + orientedPoints[5];
            Eigen::Vector3d b7 = orientedPoints[1] + orientedPoints[3] + orientedPoints[5];
            
            drawBox(b1, b2, b3, b4, b5, b6, b7, b8);
        }
    }
    
    glutSwapBuffers();
}
Ejemplo n.º 6
0
void poShape3D::draw()
{
	po::setColor(fillColor, appliedAlpha());
	
	if(callListID != -1)
		glCallList(callListID);
	else if ( enableFill )
		drawFaces();
	else if ( strokeWidth != 0 )
		drawWireframe();
	else if ( enablePoints )
		drawVertices();
}
Ejemplo n.º 7
0
void Mesh::drawOpenGL()
{
	tellMaterialsGL();
	glPushMatrix();
	if (usesTexture)
	{
		if (!textureLoaded)
		{
			cout << " \n TextureFileName = " << texturefile << endl;
		setTexture(loadTexture(texturefile));
		}
			
		glBindTexture(GL_TEXTURE_2D, texture);
		glEnable(GL_TEXTURE_2D);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	}
	glMultMatrixf(transf.m);
	switch (mode) {
	case MODE_WIRE:
		drawEdges();
		break;
	case MODE_SOLID:
		drawFaces();
		break;
	default:
		drawFaces();
		drawEdges();
		break;
	}
	
	glPopMatrix();
}
Ejemplo n.º 8
0
void Viewer::cb_redraw()
{
	// Draw the faces with SSAO and everything else
	if (m_useSSAO && m_drawFaces)
	{
		CGoGNGLuint SSAOTexture = computeSSAO();
		
		// Get and draw only SSAO results
		if (m_displayOnlySSAO)
			Utils::TextureSticker::StickTextureOnWholeScreen(SSAOTexture);
		// Use SSAO results with regular rendering
		else
		{
			// Render color and depth
			m_finalRenderFbo->Bind();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			{
				// Simply render faces color and depth
				drawFaces();
			}
			m_finalRenderFbo->Unbind();
		
			// Merge color and SSAO
			m_colorAndSSAOMergeFbo->Bind();
			glClear(GL_COLOR_BUFFER_BIT);
			{
				// Send textures to multiply shader
				m_multTexturesShader->bind();
				m_multTexturesShader->setTexture1Unit(GL_TEXTURE0);
				m_multTexturesShader->activeTexture1(m_finalRenderFbo->GetColorTexId(0));
				m_multTexturesShader->setTexture2Unit(GL_TEXTURE1);
				m_multTexturesShader->activeTexture2(SSAOTexture);
				m_multTexturesShader->unbind();
			
				// Multiply textures together
				Utils::TextureSticker::DrawFullscreenQuadWithShader(m_multTexturesShader);
			}
			m_colorAndSSAOMergeFbo->Unbind();
			
			// Get and draw color texture from merged SSAO and color Fbo into final render Fbo (we need to use the depth information to display everything else)
			m_finalRenderFbo->Bind();
			glClear(GL_COLOR_BUFFER_BIT);
			{
				// Simply stick result texture on screen
				Utils::TextureSticker::StickTextureOnWholeScreen(m_colorAndSSAOMergeFbo->GetColorTexId(0));
				
				// Now that we have depth *and* SSAO information, display everything else
				if(m_drawVertices)
					drawVertices();
				if(m_drawEdges)
					drawEdges();
				if(m_drawTopo)
					drawTopo();
				if(m_drawNormals)
					drawNormals();
			}
			m_finalRenderFbo->Unbind();
			
			// Stick final render in main framebuffer
			Utils::TextureSticker::StickTextureOnWholeScreen(m_finalRenderFbo->GetColorTexId(0));
		}
	}
	// Draw everything without SSAO
	else
	{
		if (m_drawFaces)
			drawFaces();
		if(m_drawVertices)
			drawVertices();
		if(m_drawEdges)
			drawEdges();
		if(m_drawTopo)
			drawTopo();
		if(m_drawNormals)
			drawNormals();
	}
	
	// Check for OpenGL errors
	GLenum glError = glGetError();
	if (glError != GL_NO_ERROR)
		std::cout << "GL error : " << gluErrorString(glError) << std::endl;
}
Ejemplo n.º 9
0
CGoGNGLuint Viewer::computeSSAO()
{
	// Render in positions and normals Fbo
	m_positionsAndNormalsFbo->Bind();
	m_positionsAndNormalsFbo->EnableColorAttachments();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	{
		// Render faces color, normals and depth
		int oldRenderStyle = m_renderStyle;
		m_renderStyle = POSITIONS_AND_NORMALS;
		drawFaces();
		m_renderStyle = oldRenderStyle;
	}
	m_positionsAndNormalsFbo->Unbind();
		
	// Render in SSAO Fbo
	m_SSAOFbo->Bind();
	glClear(GL_COLOR_BUFFER_BIT);
	{
		// Send textures to SSAO shader
		m_computeSSAOShader->bind();
		m_computeSSAOShader->setPositionTextureUnit(GL_TEXTURE0);
		m_computeSSAOShader->activePositionTexture(m_positionsAndNormalsFbo->GetColorTexId(0));
		m_computeSSAOShader->setNormalTextureUnit(GL_TEXTURE1);
		m_computeSSAOShader->activeNormalTexture(m_positionsAndNormalsFbo->GetColorTexId(1));
		m_computeSSAOShader->setDepthTextureUnit(GL_TEXTURE2);
		m_computeSSAOShader->activeDepthTexture(m_positionsAndNormalsFbo->GetDepthTexId());
		m_computeSSAOShader->unbind();
			
		// Render SSAO texture
		Utils::TextureSticker::DrawFullscreenQuadWithShader(m_computeSSAOShader);
	}
	m_SSAOFbo->Unbind();
	
	// Blur SSAO texture horizontaly
	m_SSAOFirstBlurPassFbo->Bind();
	glClear(GL_COLOR_BUFFER_BIT);
	{
		// Send textures and blur size to blur shader
		m_textureBlurHShader->bind();
		m_textureBlurHShader->setTextureUnit(GL_TEXTURE0);
		m_textureBlurHShader->activeTexture(m_SSAOFbo->GetColorTexId(0));
		m_textureBlurHShader->setBlurSize(1.0/1024.0);
		m_textureBlurHShader->unbind();
		
		// Render blurred SSAO texture
		Utils::TextureSticker::DrawFullscreenQuadWithShader(m_textureBlurHShader);
	}
	m_SSAOFirstBlurPassFbo->Unbind();
	
	// Blur SSAO texture verticaly
	m_SSAOSecondBlurPassFbo->Bind();
	glClear(GL_COLOR_BUFFER_BIT);
	{
		// Send textures and blur size to blur shader
		m_textureBlurVShader->bind();
		m_textureBlurVShader->setTextureUnit(GL_TEXTURE0);
		m_textureBlurVShader->activeTexture(m_SSAOFirstBlurPassFbo->GetColorTexId(0));
		m_textureBlurVShader->setBlurSize(1.0/1024.0);
		m_textureBlurVShader->unbind();
		
		// Render blurred SSAO texture
		Utils::TextureSticker::DrawFullscreenQuadWithShader(m_textureBlurVShader);
	}
	m_SSAOSecondBlurPassFbo->Unbind();
	
	return m_SSAOSecondBlurPassFbo->GetColorTexId(0);
}
Ejemplo n.º 10
0
	//----------
	void Device::drawWorld() {
		auto colorSource = this->getColorSource();
		auto depthSource = this->getDepthSource();
		auto bodySource = this->getBodySource();

		if (!depthSource) {
			ofLogError("ofxKinectForWindows2::Device::drawPrettyMesh") << "No depth source initialised";
			return;
		}
		
		//point cloud
		{
			//setup some point cloud properties for kicks
			bool usePointSize = true;

#if OF_VERSION_MAJOR > 0 || OF_VERSION_MINOR >= 10
			auto mainWindow = std::static_pointer_cast<ofAppGLFWWindow>(ofGetCurrentWindow());
			usePointSize = mainWindow ? mainWindow->getSettings().glVersionMajor <= 2 : false;
#endif

			usePointSize = false;

			if (usePointSize) {
				glPushAttrib(GL_POINT_BIT);
				glPointSize(5.0f);
				glEnable(GL_POINT_SMOOTH);
			}

			ofPushStyle();

			bool useColor = colorSource.get();
			if (useColor) {
				useColor &= colorSource->getTexture().isAllocated();
			}

			if (useColor) {
				//bind kinect color camera texture and draw mesh from depth (which has texture coordinates)
				colorSource->getTexture().bind();
			}

			auto opts = Source::Depth::PointCloudOptions(true, Source::Depth::PointCloudOptions::TextureCoordinates::ColorCamera);
			auto mesh = depthSource->getMesh(opts);

			//draw point cloud
			mesh.drawVertices();

			//draw triangles
			ofSetColor(255, 150);
			mesh.drawWireframe();

			//draw fills faded
			ofSetColor(255, 50);
			mesh.drawFaces();

			if (useColor) {
				//unbind colour camera
				colorSource->getTexture().unbind();
			}

			ofPopStyle();

			//clear the point cloud drawing attributes
			if (usePointSize) {
				glPopAttrib();
			}
		}
		
		//bodies and floor
		if (bodySource) {
			bodySource->drawWorld();

			ofPushMatrix();
			ofRotateDeg(90, 0, 0, 1);
			ofMultMatrix(bodySource->getFloorTransform());
			ofDrawGridPlane(5.0f);
			ofPopMatrix();
		}

		//draw the view cones of depth and colour cameras
		ofPushStyle();
		ofNoFill();
		ofSetLineWidth(2.0f);
		ofSetColor(100, 200, 100);
		depthSource->drawFrustum();
		if (colorSource) {
			ofSetColor(200, 100, 100);
			colorSource->drawFrustum();
		}
		ofPopStyle();
	}
Ejemplo n.º 11
0
char operateImage(Userdata *userdata) {
	if (!userdata) {
		return 0;
	}

	IplImage *image1 = userdata->input[0];
	IplImage *image2 = userdata->input[1];
	IplImage *imageOut = userdata->output[0];
	IplImage *imageOut2 = userdata->output[1];

	static int color_mode = 4;
	static int smooth_mode = 0;
	static int otsu_mode = 0;
	static int close_mode = 0;
	static int canny_mode = 0;
	static int contour_mode = 0;
	static int hsv_mode = 0;
	static int save_img = 0;
	static int history_mode = 0;

	int key = userdata->key;
	switch (key) {
	case 'g':
		color_mode++;
		color_mode %= 5;
		break;
	case 's':
		smooth_mode = !smooth_mode;
		break;
	case 'o':
		otsu_mode = !otsu_mode;
		break;
	case 'e':
		close_mode = !close_mode;
		break;
	case 'c':
		canny_mode = !canny_mode;
		break;
	case 'b':
		contour_mode = !contour_mode;
		break;
	case 'h':
		hsv_mode = !hsv_mode;
		break;
	case 'H':
		history_mode = !history_mode;
		break;
	case 'S':
		save_img = 1;
		break;
	default:
		//cout << key << "\n";
		break;
	}

	int value = userdata->value;
	int kernelSize = userdata->kernelSize;
	kernelSize += 1 - (kernelSize % 2);
	int lowThreshold = userdata->lowThreshold;
	int highThreshold = userdata->highThreshold;
	CvScalar minScalar = cvScalar(userdata->minScalar0, userdata->minScalar1, userdata->minScalar2);
	CvScalar maxScalar = cvScalar(userdata->maxScalar0, userdata->maxScalar1, userdata->maxScalar2);

	static IplImage *tmp1d = cvCreateImage(cvGetSize(image1), IPL_DEPTH_8U, 1);
	static IplImage *tmp3d = cvCreateImage(cvGetSize(image1), IPL_DEPTH_8U, 3);
	cvCopy(image1, tmp3d, NULL);

	filterByHSV(tmp3d, minScalar, maxScalar, tmp3d);
	
	static int tick = 0;
	static CvRect face = cvRect(0,0,1,1);
	if ((tick %= 10) == 0) {
		//userdata->timestep = 100;
		double scale = 4;
		CvRect *faces = NULL;
		double t = 0;
		int facesCount = findFaces(tmp3d, &faces, scale, &t);
		face = (facesCount != 0) ? faces[0] : face;
		free(faces);
		//printf("%d face(s) detected in %g ms :: 1st face at {%d,%d,%d,%d}", facesCount, t, face.x, face.y, face.width, face.height);
		drawFaces(tmp3d, 1, &face);
	}
	tick++;

	//face extraction
	IplImage *subimage = createSubArray(tmp3d, face);
	cvNamedWindow(CONTROL_WINDOW  "face", 0);
	cvResizeWindow(CONTROL_WINDOW "face", subimage->width, subimage->height);
	cvShowImage(CONTROL_WINDOW    "face", subimage);

	//face histogram
	IplImage *subimage2 = cvCloneImage(subimage);
	cvCvtColor(subimage2, subimage2, CV_BGR2HSV);
	size_t binsCount = 0;
	size_t *bins = NULL;
	//printf("%d (%p)", binsCount, &bins);
	size_t ret = calcularHistograma(subimage2, &binsCount, &bins);
	//printf(" ret=%d %d (%p)", ret, binsCount, bins);
	CvScalar maxValues;
	if (bins) {
		for (size_t i = 0; i < binsCount; i++) {
			size_t idx = 0;
			for (size_t j = 0; j < 256; j++) {
				if (bins[i * 256 + j] > bins[idx]) {
					idx = j;
				}
			}
			maxValues.val[i] = idx;
		}
		free(bins);
	}
#if 0
	if (subimage->width > 10 && subimage->height > 10)
	graficarHistograma(subimage, binsCount, bins);
	cvNamedWindow(CONTROL_WINDOW  "42", 0);
	cvResizeWindow(CONTROL_WINDOW "42", subimage->width, subimage->height);
	cvShowImage(CONTROL_WINDOW    "42", subimage);
#endif

#if 0
	int minH = (int)maxValues.val[0] - 20;
	int maxH = (int)maxValues.val[0] + 20;
	int minS = (int)maxValues.val[1] - 20;
	int maxS = (int)maxValues.val[1] + 20;
	int minV = (int)maxValues.val[2] - 20;
	int maxV = (int)maxValues.val[2] + 20;

	minH = minH < 0 ? 180 - minH : minH;
	maxH = maxH > 180 ? maxH - 180 : maxH;

	printf("%d,%d,%d %d,%d,%d", minH, minS, minV, maxH, maxS, maxV);

	filterByHSV(subimage2, cvScalar(minH, minS, minV, 0), cvScalar(maxH, maxS, maxV, 0), subimage2);
	filterByHSV(subimage2, minScalar, maxScalar, subimage2);
	cvCvtColor(subimage2, subimage2, CV_HSV2BGR);

	cvNamedWindow(CONTROL_WINDOW "41", 0);
	cvResizeWindow(CONTROL_WINDOW "41", subimage2->width, subimage2->height);
	cvShowImage(CONTROL_WINDOW "41", subimage2);
#endif

	cvReleaseImage(&subimage);
	cvReleaseImage(&subimage2);
	
	cvCopy(image1, image2, NULL);
	cvCopy(imageOut, imageOut2, NULL);
	cvCopy(tmp3d, imageOut, NULL);

	//cvReleaseImage(&tmp1d);
	//cvReleaseImage(&tmp3d);

	//afterProcess(userdata);

	printf("\r");
	return 0;
}
Ejemplo n.º 12
0
void Cube::render(FrameBuffer* fb,DepthBuffer* db,VertexShader vs,FragmentShader fs,int cullFlag) {
	drawFaces(fb,db,vs,fs,cullFlag,verts,faceNum);
}
Ejemplo n.º 13
0
//--------------------------------------------------------------
void testApp::draw(){

    ofClear(0);
    
    opticalFlow.setSource(cameraFbo.getTextureReference());
    opticalFlow.update(deltaTime);
    
    velocityMask.setDensity(cameraFbo.getTextureReference());
    velocityMask.setVelocity(opticalFlow.getOpticalFlow());
    velocityMask.update();
    
    
    fluid.addVelocity(opticalFlow.getOpticalFlowDecay());
    fluid.addDensity(velocityMask.getColorMask());
    fluid.addTemperature(velocityMask.getLuminanceMask());
    
    
	for (int i=0; i<numDrawForces; i++) {
		flexDrawForces[i].update();
		if (flexDrawForces[i].didChange()) {
			// if a force is constant multiply by deltaTime
			float strength = flexDrawForces[i].getStrength();
			if (!flexDrawForces[i].getIsTemporary())
				strength *=deltaTime;
			switch (flexDrawForces[i].getType()) {
				case flowTools::FT_DENSITY:
					fluid.addDensity(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_VELOCITY:
					fluid.addVelocity(flexDrawForces[i].getTextureReference(), strength);
					particleFlow.addFlowVelocity(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_TEMPERATURE:
					fluid.addTemperature(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_PRESSURE:
					fluid.addPressure(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_OBSTACLE:
					fluid.addTempObstacle(flexDrawForces[i].getTextureReference());
				default:
					break;
			}
		}
	}
	
    fluid.update();
    
	if (particleFlow.isActive()) {
		particleFlow.setSpeed(fluid.getSpeed());
		particleFlow.setCellSize(fluid.getCellSize());
		particleFlow.addFlowVelocity(opticalFlow.getOpticalFlow());
		particleFlow.addFluidVelocity(fluid.getVelocity());
		particleFlow.setObstacle(fluid.getObstacle());
	}
	particleFlow.update();
	
	int windowWidth = ofGetWindowWidth();
	int windowHeight = ofGetWindowHeight();
	
    ofClear(0,0);
    
    switch(visualisationMode.get()) {
            
        case 0: // Source
			cameraFbo.draw(0,0, windowWidth, windowHeight);
			break;
            
        case 1: // Fluid Composite

            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            
            cameraFbo.end();
            cameraFbo.draw(0,0, windowWidth, windowHeight);
            
            ofEnableBlendMode(blendMode);
			fluid.draw(0, 0,windowWidth, windowHeight);
			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            if (showLogo) {
				theImage.draw(0, 0,windowWidth, windowHeight);
			}
            ofPopStyle();
			break;
            
        case 2: // Fluid Color
            
            //----------------------
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            
            //----------------------
            ofEnableBlendMode(blendMode);
			fluid.draw(0, 0, windowWidth, windowHeight);

			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            
            ofPopStyle();
			break;
            
        case 3: // velocityMask
            
            //----------------------
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            ofBackground(255);
            ofEnableBlendMode(blendMode);
            velocityMask.draw(0, 0, windowWidth, windowHeight);
			fluid.draw(0, 0, windowWidth, windowHeight);
            if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            if (showLogo) {
				ofEnableBlendMode(OF_BLENDMODE_ADD);
				theImage.draw(0,0,windowWidth, windowHeight);
			}


            ofPopStyle();
            break;
            
        case 4: // CLOUD
            
            ofPushStyle();
            
            ofEnableBlendMode(blendMode);
            
            
            easyCam.begin();
            drawPointCloud();
            easyCam.end();
            cameraFbo.begin();
            particleFlow.draw(0, 0, windowWidth, windowHeight);
     
            cameraFbo.end();
            ofPopStyle();
            break;
            
            
        case 5: // LINES
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			ofPushStyle();
			ofEnableBlendMode(blendMode);
            
            easyCam.begin();
            drawLines();
            easyCam.end();
            
            ofPopStyle();
            break;
            
        case 6: // FACES
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			ofPushStyle();
			ofEnableBlendMode(blendMode);
            
            easyCam.begin();
            drawFaces();
            easyCam.end();
            
            ofPopStyle();
            break;

        case 7: //
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            ofBackground(220,200,100,60);
                        ofColor(188,10,10);
            ofEnableBlendMode(blendMode);
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);

            if (showLogo) {
				ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
				ofSetColor(255,255,255,200);
				theImage.draw(0,0,windowWidth, windowHeight);
			}
           
            ofPopStyle();
            break;
  }

    if (toggleGuiDraw) {
		guiFPS = ofGetFrameRate();
		if (visualisationMode.get() >= numVisualisationModes)
			visualisationMode.set(numVisualisationModes-1);
		visualisationName.set(visualisationModeTitles[visualisationMode.get()]);
		gui.draw();
	}
    
    drawtheMidi();
    
}