Beispiel #1
0
//////////////////////////////////////////////////////////////////////////
// addVertexShared
BcU32 MdlMesh::addVertexShared( const MdlVertex& Vertex )
{
	// Go through all our vertices, and if we find a matching one,
	// return the index to it, else just add this vert and return
	// the index to it.
	BcU32 iVertex = 0;
	BcBool bFoundVertex = BcFalse;

	for( BcU32 i = 0; i < aVertices_.size(); ++i )
	{
		// If we find the vertex, we can bail.
		if( compareVertices( Vertex, aVertices_[ i ] ) )
		{
			iVertex = i;
			bFoundVertex = BcTrue;
			break;
		}
	}

	// If we didn't find a vertex then add it.
	if( bFoundVertex == BcFalse )
	{
		addVertex( Vertex );
		iVertex = BcU32( aVertices_.size() ) - 1;
	}

	return iVertex;
}
Beispiel #2
0
	void fillIndices(dae_reader_t *reader, uint32_t geometryID, vector<float>& rawData)
	{
		geometry_t *geometry = &reader->geometry[geometryID];
		elements_t elements = getElementOffsets(geometry);
		int totalTrianglesSize = getTrianglesSize(geometry);
		vector<uint32_t>& indices = geometry->indices;
		int elementSize = getElementSize(reader);

		indices.resize(totalTrianglesSize / elements.elementsCount);
		memset(indices.data(), 0xFF, indices.size() * sizeof(uint32_t));

		int baseIdx = 0;

		for (uint32_t i = 0; i < geometryID; i++)
		{
			baseIdx += reader->geometry[i].maxIndex;
		}

		int idx = geometryID == 0 ? 0 : baseIdx + 1;

		for (uint32_t i = 0; i < indices.size(); i++)
		{
			if (indices[i] != -1) continue;

			indices[i] = idx;
			addVertex(rawData, geometry->bufferData, i*elementSize, elementSize);

			for (uint32_t j = i + 1; j < indices.size(); j++)
			{
				if (!compareVertices(rawData, i, j, elementSize))
				{
					indices[j] = idx;
				}
			}

			idx++;
		}

		geometry->maxIndex = idx - baseIdx - 1;
	}
Beispiel #3
0
//////////////////////////////////////////////////////////////////////////
// addVertexShared
BcU32 MdlMesh::addVertexShared( const MdlVertex& Vertex )
{
	// Go through all our vertices, and if we find a matching one,
	// return the index to it, else just add this vert and return
	// the index to it.
	BcU32 iVertex = BcErrorCode;

	std::map< BcU32, BcU32 >::iterator VertexIt = aVertexHashes_.find( BcHash::GenerateCRC32( &Vertex, sizeof( Vertex ) ) );
	if( VertexIt != aVertexHashes_.end() )
	{
		iVertex = VertexIt->second;
		BcAssert( compareVertices( Vertex, aVertices_[ iVertex ] ) );
	}

	// If we didn't find a vertex then add it.
	if( iVertex == BcErrorCode )
	{
		iVertex = addVertex( Vertex );
	}

	return iVertex;
}