//---------------------------------------------------------------------
	TangentSpaceCalc::Result TangentSpaceCalc::build(
		VertexElementSemantic targetSemantic,
		unsigned short sourceTexCoordSet, unsigned short index)
	{
		Result res;

		// Pull out all the vertex components we'll need
		populateVertexArray(sourceTexCoordSet);

		// Now process the faces and calculate / add their contributions
		processFaces(res);

		// Now normalise & orthogonalise
		normaliseVertices();

		// Create new final geometry
		// First extend existing buffers to cope with new vertices
		extendBuffers(res.vertexSplits);

		// Alter indexes
		remapIndexes(res);

		// Create / identify target & write tangents
		insertTangents(res, targetSemantic, sourceTexCoordSet, index);

		return res;


	}
Esempio n. 2
0
void LookAlikeMainPrivate::onMultiSelectionDone(QList<QUrl> urlList)
{
    m_facesToProcess = urlList;
    m_progress = new MProgressIndicator(0, MProgressIndicator::barType);
    m_progress->setStyleName(("CommonProgressBarInverted"));
    m_progress->setRange(0, urlList.size());
    m_progressDialog = new MDialog();
    m_progressDialog->setCentralWidget(m_progress);
    m_progressDialog->appear(MSceneWindow::DestroyWhenDone);

    connect(m_progressDialog, SIGNAL(appeared()),
            this, SLOT(processFaces()),
            Qt::QueuedConnection);
    connect(m_progress, SIGNAL(valueChanged(int)),
            this, SLOT(processFaces()),
            Qt::QueuedConnection);
    connect(m_progressDialog, SIGNAL(rejected()),
            this, SLOT(onProgressDialogRejected()));
}
Esempio n. 3
0
	INT32 TriangleClipperBase::clipByPlane(const Plane& plane)
	{
		int state = processVertices(plane);

		if (state == 1)
			return +1; // Nothing is clipped
		else if (state == -1)
			return -1; // Everything is clipped

		processEdges();
		processFaces();

		return 0;
	}
void KinectHDFaceGrabber::renderColorFrameAndProcessFaces()
{

    HRESULT hr;
    hr = m_pDrawDataStreams->beginDrawing();

    if (SUCCEEDED(hr))
    {
        // Make sure we've received valid color data
		if ((m_colorWidth > 0 ) && (m_colorHeight > 0))
        {
            // Draw the data with Direct2D
            hr = m_pDrawDataStreams->drawBackground(reinterpret_cast<BYTE*>(m_colorBuffer.data()), m_colorWidth * m_colorHeight* sizeof(RGBQUAD));

			/*
			// View Depth Sensor Output
			std::vector<RGBQUAD> depth(1920 * 1080);
			int row;
			int col;
			int value;

			for (int i = 0; i < (1920 * 1080); i++)
			{
				col = i % 1920;
				row = (i - col) / 1920;
				value = static_cast<UINT8>((m_depthBuffer[((row % m_depthHeight) * m_depthWidth + (col % m_depthWidth))] / 30) % 256);
				depth[i].rgbRed = value;
				depth[i].rgbGreen = value;
				depth[i].rgbBlue = value;
			}
			hr = m_pDrawDataStreams->drawBackground(reinterpret_cast<BYTE*>(depth.data()), m_colorWidth * m_colorHeight* sizeof(RGBQUAD));
			*/
        }
        else
        {
            // Recieved invalid data, stop drawing
            hr = E_INVALIDARG;
        }

        if (SUCCEEDED(hr))
        {
            // begin processing the face frames
			processFaces();
        }

        m_pDrawDataStreams->endDrawing();
    }
}
Esempio n. 5
0
ClipMesh::Result ClipMesh::clip( const Plane& clipPlane ) {
	const Result result = processVertices(clipPlane);

	// no more processing required if the mesh isn't clipped
	if( result != Result::Dissected ) {
		return result;
	}

	processEdges();
	if( !processFaces(clipPlane) ) {
		//printf("Error: Failed to process faces.\n");
		return Result::Visible;
	}

	return Result::Dissected;
}
Esempio n. 6
0
	//---------------------------------------------------------------------
	TangentSpaceCalc::Result TangentSpaceCalc::build(
		VertexElementSemantic targetSemantic,
		unsigned short sourceTexCoordSet, unsigned short index)
	{
		if (index == 0 && targetSemantic == VES_TEXTURE_COORDINATES)
		{
			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
				"Destination texture coordinate set must be greater than 0",
				"TangentSpaceCalc::build");
		}

		Result res;

		// Pull out all the vertex components we'll need
		populateVertexArray(sourceTexCoordSet);

		// Now process the faces and calculate / add their contributions
		processFaces(res);

		// Now normalise & orthogonalise
		normaliseVertices();

		// Create new final geometry
		// First extend existing buffers to cope with new vertices
		extendBuffers(res.vertexSplits);

		// Alter indexes
		remapIndexes(res);

		// Create / identify target & write tangents
		insertTangents(res, targetSemantic, sourceTexCoordSet, index);

		return res;


	}
Mesh* ObjToMesh::convert(ObjLoader::ObjFileInfo *objFile) {
	/*
	Log::info("Faces");
	for (int i = 0; i < 40; i++) {
		ObjLoader::Face3v f = objFile->namedObjects[1]->faces.faces[i];
		cout << "[" << f.v[0] << ", " << f.v[1] << ", " << f.v[2] << "]";
		cout << "[" << f.vn[0] << ", " << f.vn[1] << ", " << f.vn[2] << "]";
		cout << "[" << f.vt[0] << ", " << f.vt[1] << ", " << f.vt[2] << "]" << endl;
	}
	/*
	Log::info("NORMALES");
	for (int i = 0; i < 40; i++) {
		Normal v = objFile->vn.normals[i];
		cout << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]" << endl;
	}
	Log::info("TEX-VERTICES");
	for (int i = 0; i < 40; i++) {
		TexVertex v = objFile->vt.texVertices[i];
		cout << "[" << v[0] << ", " << v[1] << "]" << endl;
	}

	*/

	typedef vector<ObjLoader::NamedObject*>::iterator NamedObjIt;
	typedef vector<ObjLoader::ObjectGroup*>::iterator ObjGroupIt;
	vector<ObjLoader::NamedObject*> objs = objFile->namedObjects;

	vector<Mesh::PerVertex*> vertexBufferData;
	vector<Mesh::PerDraw*> elementBufferData;
	vector<GLuint> currIndexes;
	
	GLuint currentIndex = 0;
	GLint lastMaterial = -1;

	for (NamedObjIt o = objs.begin(); o != objs.end(); ++o) {
		ObjLoader::Faces3v faces = (*o)->faces;
		processFaces(faces, *objFile, vertexBufferData, elementBufferData, 
			lastMaterial, currIndexes, currentIndex, (*o)->name);
		closeIndexBuffer(lastMaterial, *objFile, currIndexes, elementBufferData, (*o)->name);

		for (ObjGroupIt g = (*o)->groups.begin(); g != (*o)->groups.end(); ++g) {
			ObjLoader::Faces3v faces = (*g)->faces;
			processFaces(faces, *objFile, vertexBufferData, elementBufferData, 
				lastMaterial, currIndexes, currentIndex, (*o)->name);
			closeIndexBuffer(lastMaterial, *objFile, currIndexes, elementBufferData, (*g)->name);
		}
	}

	GLuint vCount = vertexBufferData.size();
	GLuint eCount = elementBufferData.size();
	Mesh::PerVertex* vertexBufferDataArray = new Mesh::PerVertex[vCount];
	Mesh::PerDraw* elementBufferDataArray = new Mesh::PerDraw[eCount];
	GLuint i = 0;
	for (vector<Mesh::PerVertex*>::iterator perV = vertexBufferData.begin(); perV != vertexBufferData.end(); ++perV) {
		vertexBufferDataArray[i++] = **perV;
	}
	i = 0;
	for (vector<Mesh::PerDraw*>::iterator perD = elementBufferData.begin(); perD != elementBufferData.end(); ++perD) {
		elementBufferDataArray[i++] = **perD;
	}

	return new Mesh(vertexBufferDataArray, vCount, elementBufferDataArray, eCount);
}