LaVectorDouble TrainingImageDatabase::outputVector(std::size_t sample) const
{
	if (m_samples[sample].info != 0) {
		calcVectors(sample);
	}
	return m_samples[sample].output;
}
LaVectorDouble TrainingImageDatabase::inputVector(std::size_t sample) const
{
	if (!m_workingImage.isNull()) {
		m_workingImage = QImage();
	}
	if (m_samples[sample].info != 0) {
		calcVectors(sample);
	}
	return m_samples[sample].input;
}
Example #3
0
void GmlModel::calcModelData()
{
	
	myData.clear();
	
	for( int i = 0; i < myStrokes.size(); i++)
	{
		modelData m;
		myData.push_back(m);
	}
	
	calcMaxLen();		// calculate min and max values for rendering nicely
	calcVectors();		// calculate normal vectors from one point to next	
	calcRadius();		// calculate radius at each point
	calcRPoints();		// calculate points defining a circle at each point, rotate in direction of next to create extrusion
	calcEndPoints();
	calcTriangles();
}
void VHParticlesRender::draw(){

	if (pSys->nParts == -1)
		return;

	if(displayMode == SHADOWED_SPRITES) {

			calcVectors();
			cu::float3 halfVec = cu::make_float3(halfVector.x,halfVector.y,halfVector.z); 

			calcDepthCu(pSys->dev_pos, pSys->dev_keys, pSys->dev_indices, halfVec, pSys->nParts);

			if (sortParts)
				cudppSort(m_sortHandle, pSys->dev_keys, pSys->dev_indices, 32, pSys->nParts);
	}

	if((displayMode == SPRITES || displayMode == POINTS) && sortParts) {

		glGetFloatv(GL_MODELVIEW_MATRIX, (float *) modelView.get_value());
		 viewVector = -vec3f(modelView.get_row(2));

		cu::float3 viewVec = cu::make_float3(viewVector.x, viewVector.y, viewVector.y);
		//printf("view vec : %f, %f, %f \n", viewVector.x, viewVector.y, viewVector.z);
		calcDepthCu(pSys->dev_pos, pSys->dev_keys, pSys->dev_indices, viewVec, pSys->nParts);

		cudppSort(m_sortHandle, pSys->dev_keys, pSys->dev_indices, 32, pSys->nParts);


	}

	pSys->posVbo->map();
	pSys->colourVbo->map();
	pSys->indexVbo->map();

	pSys->updateVBOs();

	pSys->posVbo->unmap();
	pSys->colourVbo->unmap();
	pSys->indexVbo->unmap();

	switch (displayMode) {

		case POINTS:

			glPointSize(pointSize);

			glDisable(GL_DEPTH_TEST);

			glEnable(GL_BLEND);

			pSys->posVbo->bind();
			glVertexPointer(3, GL_FLOAT, 0, 0);
			glEnableClientState(GL_VERTEX_ARRAY);

			pSys->colourVbo->bind();
			glColorPointer(4, GL_FLOAT, 0, 0);
			glEnableClientState(GL_COLOR_ARRAY);

			if (blendingMode == ADD) {
				glBlendFunc( GL_SRC_ALPHA, GL_ONE );
				glDrawArrays(GL_POINTS, 0, pSys->nParts);
			} else {
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				if(sortParts){
					pSys->indexVbo->bind();
					glDrawElements(GL_POINTS, pSys->nParts, GL_UNSIGNED_INT, 0);
					pSys->indexVbo->unbind();
				} else {
					glDrawArrays(GL_POINTS, 0, pSys->nParts);
				}
			}


			pSys->posVbo->unbind();

			glDisableClientState(GL_VERTEX_ARRAY);
			glDisableClientState(GL_COLOR_ARRAY);

			glDisable(GL_BLEND);

			break;

		case LINES:

			glDisable(GL_DEPTH_TEST);

			glEnable(GL_BLEND);
			glBlendFunc( GL_SRC_ALPHA, GL_ONE );

			pSys->posVbo->bind();
			glVertexPointer(3, GL_FLOAT, 0, 0);
			glEnableClientState(GL_VERTEX_ARRAY);

			pSys->colourVbo->bind();
			glColorPointer(4, GL_FLOAT, 0, 0);
			glEnableClientState(GL_COLOR_ARRAY);

			glLineWidth(lineWidth);
			for (int i = 0; i<pSys->nLeadParts; i++) {
				glDrawArrays(GL_LINE_STRIP, i*pSys->trailLength, pSys->trailLength);
			}

			pSys->posVbo->unbind();

			glDisableClientState(GL_VERTEX_ARRAY);
			glDisableClientState(GL_COLOR_ARRAY);

			glDisable(GL_BLEND);

			break;

		case SPRITES:


			glDisable(GL_DEPTH_TEST);

			glEnable(GL_TEXTURE_2D);

			glEnable(GL_BLEND);
			glBlendFunc( GL_SRC_ALPHA, GL_ONE );

			pSys->posVbo->bind();
			glVertexPointer(3, GL_FLOAT, 0, 0);
			glEnableClientState(GL_VERTEX_ARRAY);

			pSys->colourVbo->bind();
			glColorPointer(4, GL_FLOAT, 0, 0);
			glEnableClientState(GL_COLOR_ARRAY);

			simpleSpriteProg->enable();
			simpleSpriteProg->setUniform1f("pointRadius",pointSize);
			simpleSpriteProg->bindTexture("sDiffuseMap",TextureManager::Inst()->m_texID[id1],GL_TEXTURE_2D,0);

			if (blendingMode == ADD) {
				glBlendFunc( GL_SRC_ALPHA, GL_ONE );
				glDrawArrays(GL_POINTS, 0, pSys->nParts);
			} else {
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				if(sortParts){
					pSys->indexVbo->bind();
					glDrawElements(GL_POINTS, pSys->nParts, GL_UNSIGNED_INT, 0);
					pSys->indexVbo->unbind();
				} else {
					glDrawArrays(GL_POINTS, 0, pSys->nParts);
				}
			}

			simpleSpriteProg->disable();

			pSys->posVbo->unbind();

			glDisableClientState(GL_VERTEX_ARRAY);
			glDisableClientState(GL_COLOR_ARRAY);

			glDisable(GL_BLEND);

			glDisable(GL_TEXTURE_2D);

			break;

		case SHADOWED_SPRITES :

			GLfloat currentViewport[4];
			glGetFloatv(GL_VIEWPORT, currentViewport);

			if(width != currentViewport[2] || height != currentViewport[3])
				initFbos(currentViewport[2],currentViewport[3], false);

			drawSlices();

			//glutReportErrors();

			Fbo::unbind();


			glViewport(0, 0, width, height);
			glDisable(GL_DEPTH_TEST);
			glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
			glEnable(GL_BLEND);

			int mm;
			glGetIntegerv ( GL_MATRIX_MODE, &mm );

			displayTexProg->enable();
			displayTexProg->bindTexture("tex", imageTex, GL_TEXTURE_2D, 0);
		    
			drawQuad();

			displayTexProg->disable();

			if(displayLightBuffer) {

				displayTexProg->bindTexture("tex", lightTex[srcLightTexture], GL_TEXTURE_2D, 0);
				glViewport(0, 0, lightBufferSize, lightBufferSize);
				drawQuad();
				displayTexProg->disable();
			}

			//calcVectors();

			glViewport(0, 0, width, height);

 			if (displayVectors) {
				debugVectors();
			}

			glutReportErrors();

			break;

	}

}