示例#1
0
void G3D::readSoA(AbstractReader& reader, G3D::GeometrySoA& geometry) {
    if (reader.isOpen()) {
        geometry.info = readHeader(reader);
        if (geometry.info.numberVertices == 0)
            return;
        if (geometry.info.vertexType == SoA)
            readContent(reader, geometry);
        else if (geometry.info.vertexType == AoS) {
            geometry.info.vertexType = SoA;
            geometry.indices = readIndices(reader, geometry.info);
            std::vector<float> vertices = readVertices(reader, geometry.info);
            geometry.vertexAttributes = convertVertices(vertices, geometry.info);
        }
    }
}
示例#2
0
void G3D::readAoS(AbstractReader& reader, G3D::GeometryAoS& geometry) {
    if (reader.isOpen()) {
        geometry.info = readHeader(reader);
        if (geometry.info.numberVertices == 0)
            return;
        if (geometry.info.vertexType == AoS)
            readContent(reader, geometry);
        else if (geometry.info.vertexType == SoA) {
            geometry.info.vertexType = AoS;
            geometry.indices = readIndices(reader, geometry.info);
            auto vertexAttributes = readVertexAttributes(reader, geometry.info);
            geometry.vertices = convertVertices(vertexAttributes, geometry.info);
        }
    }
}
示例#3
0
void GFF3Struct::readFields(Common::SeekableReadStream &data, uint32 index, uint32 count) {
	// Sanity check
	if (index > _parent->_header.fieldIndicesCount)
		throw Common::Exception("GFF3: Field indices index out of range (%d/%d)",
		                        index , _parent->_header.fieldIndicesCount);

	// Seek
	data.seek(_parent->_header.fieldIndicesOffset + index);

	// Read the field indices
	std::vector<uint32> indices;
	readIndices(data, indices, count);

	// Read the fields
	for (std::vector<uint32>::const_iterator i = indices.begin(); i != indices.end(); ++i)
		readField(data, *i);
}
示例#4
0
文件: G3D.cpp 项目: BlueBrain/TuvokIO
void G3D::read(const std::string & file, GeometrySoA * const geometry)
{
	std::fstream fs;
	fs.open(file.c_str(), std::fstream::in | std::fstream::binary);

	if (fs.is_open())
	{
		readHeader(fs, geometry->info);
		if (geometry->info.vertexType == SoA) readContent(fs, *geometry);
		else if (geometry->info.vertexType == AoS)
		{
			geometry->info.vertexType = SoA;
			readIndices(fs, geometry->indices, geometry->info);
			float * vertices = NULL;
			readVertices(fs, vertices, geometry->info);
			convertVertices(vertices, geometry->vertexAttributes, geometry->info);
			cleanVertices(vertices);
		}
		fs.close();
	}
}
reflectionAnalysis2DLS::reflectionAnalysis2DLS
(
    const Time& rT,
    const dictionary& actionProp,
    const word& action
)
:
    postProcessingWaves( rT, actionProp, action ),

#   include "../../../dataDict.H"
    ,

    N_( readLabel( actionProperties_.lookup("nFreq") ) ),

    period_( readScalar( actionProperties_.lookup("period") )),

    waveNumber_( vector( actionProperties_.lookup("waveNumber")) )
{
    readIndices( dataDict_, indices_ );

    x_.setSize( indices_.size(), point::zero);

    scalarField x( dataDict_.lookup("x") );
    scalarField y( dataDict_.lookup("y") );
    scalarField z( dataDict_.lookup("z") );

    forAll (indices_ , indexi)
    {
        x_[indexi] =
            vector
            (
                x[indices_[indexi]],
                y[indices_[indexi]],
                z[indices_[indexi]]
            );
    }
示例#6
0
//! reads a mesh sections and creates a mesh buffer from it
IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader)
{
	CDynamicMeshBuffer* buffer = 0;

	core::stringc verticesSectionName = "vertices";
	core::stringc bbSectionName = "boundingBox";
	core::stringc materialSectionName = "material";
	core::stringc indicesSectionName = "indices";
	core::stringc bufferSectionName = "buffer";

	bool insideVertexSection = false;
	bool insideIndexSection = false;

	int vertexCount = 0;
	int indexCount = 0;

	video::SMaterial material;

	if (!reader->isEmptyElement())
	while(reader->read())
	{
		if (reader->getNodeType() == io::EXN_ELEMENT)
		{
			const wchar_t* nodeName = reader->getNodeName();
			if (bbSectionName == nodeName)
			{
				// inside a bounding box, ignore it for now because
				// we are calculating this anyway ourselves later.
			}
			else
			if (materialSectionName == nodeName)
			{
				//we've got a material

				io::IAttributes* attributes = FileSystem->createEmptyAttributes(SceneManager->getVideoDriver());
				attributes->read(reader, true, L"material");

				SceneManager->getVideoDriver()->fillMaterialStructureFromAttributes(material, attributes);
				attributes->drop();
			}
			else
			if (verticesSectionName == nodeName)
			{
				// vertices section

				const core::stringc vertexTypeName1 = "standard";
				const core::stringc vertexTypeName2 = "2tcoords";
				const core::stringc vertexTypeName3 = "tangents";

				const wchar_t* vertexType = reader->getAttributeValue(L"type");
				vertexCount = reader->getAttributeValueAsInt(L"vertexCount");

				insideVertexSection = true;

				video::E_INDEX_TYPE itype = (vertexCount > 65536)?irr::video::EIT_32BIT:irr::video::EIT_16BIT;
				if (vertexTypeName1 == vertexType)
				{
					buffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, itype);

				}
				else
				if (vertexTypeName2 == vertexType)
				{
					buffer = new CDynamicMeshBuffer(irr::video::EVT_2TCOORDS, itype);
				}
				else
				if (vertexTypeName3 == vertexType)
				{
					buffer = new CDynamicMeshBuffer(irr::video::EVT_TANGENTS, itype);
				}
				buffer->getVertexBuffer().reallocate(vertexCount);
				buffer->Material = material;
			}
			else
			if (indicesSectionName == nodeName)
			{
				// indices section

				indexCount = reader->getAttributeValueAsInt(L"indexCount");
				insideIndexSection = true;
			}

		} // end if node type is element
		else
		if (reader->getNodeType() == io::EXN_TEXT)
		{
			// read vertex data
			if (insideVertexSection)
			{
				readMeshBuffer(reader, vertexCount, buffer);
				insideVertexSection = false;

			} // end reading vertex array
			else
			if (insideIndexSection)
			{
				readIndices(reader, indexCount, buffer->getIndexBuffer());
				insideIndexSection = false;
			}

		} // end if node type is text
		else
		if (reader->getNodeType() == io::EXN_ELEMENT_END)
		{
			if (bufferSectionName == reader->getNodeName())
			{
				// end of buffer section reached, cancel out
				break;
			}
		}
	} // end while reader->read();

	if (buffer)
		buffer->recalculateBoundingBox();

	return buffer;
}
示例#7
0
文件: G3D.cpp 项目: BlueBrain/TuvokIO
void G3D::readContent(std::fstream & fs, GeometrySoA & geometry)
{
	readIndices(fs, geometry.indices, geometry.info);
	readVertices(fs, geometry.vertexAttributes, geometry.info);
}
示例#8
0
文件: G3D.cpp 项目: BlueBrain/TuvokIO
void G3D::readContent(std::fstream & fs, GeometryAoS & geometry)
{
	readIndices(fs, geometry.indices, geometry.info);
	readVertices(fs, geometry.vertices, geometry.info);
}
//! reads a mesh sections and creates a mesh buffer from it
IMeshBuffer* CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader)
{
	IMeshBuffer* buffer = 0;
	SMeshBuffer* sbuffer1 = 0;
	SMeshBufferLightMap* sbuffer2 = 0;
	SMeshBufferTangents* sbuffer3 = 0;

	core::stringc verticesSectionName = "vertices";
	core::stringc bbSectionName = "boundingBox";
	core::stringc materialSectionName = "material";
	core::stringc indicesSectionName = "indices";
	core::stringc bufferSectionName = "buffer";

	bool insideVertexSection = false;
	bool insideIndexSection = false;

	int vertexCount = 0;
	int indexCount = 0;

	video::SMaterial material;

	if (!reader->isEmptyElement())
	while(reader->read())
	{
		if (reader->getNodeType() == io::EXN_ELEMENT)
		{
			const wchar_t* nodeName = reader->getNodeName();
			if (bbSectionName == nodeName)
			{
				// inside a bounding box, ignore it for now because
				// we are calculating this anyway ourselves later.
			}
			else
			if (materialSectionName == nodeName)
			{
				//we've got a material

				io::IAttributes* attributes = FileSystem->createEmptyAttributes(SceneManager->getVideoDriver());
				attributes->read(reader, true, L"material");

				SceneManager->getVideoDriver()->fillMaterialStructureFromAttributes(material, attributes);
				attributes->drop();
			}
			else
			if (verticesSectionName == nodeName)
			{
				// vertices section

				core::stringc vertexTypeName1 = "standard";
				core::stringc vertexTypeName2 = "2tcoords";
				core::stringc vertexTypeName3 = "tangents";

				const wchar_t* vertexType = reader->getAttributeValue(L"type");
				vertexCount = reader->getAttributeValueAsInt(L"vertexCount");

				insideVertexSection = true;

				if (vertexTypeName1 == vertexType)
				{
					sbuffer1 = new SMeshBuffer();
					sbuffer1->Vertices.reallocate(vertexCount);
					sbuffer1->Material = material;
					buffer = sbuffer1;
				}
				else
				if (vertexTypeName2 == vertexType)
				{
					sbuffer2 = new SMeshBufferLightMap();
					sbuffer2->Vertices.reallocate(vertexCount);
					sbuffer2->Material = material;
					buffer = sbuffer2;
				}
				else
				if (vertexTypeName3 == vertexType)
				{
					sbuffer3 = new SMeshBufferTangents();
					sbuffer3->Vertices.reallocate(vertexCount);
					sbuffer3->Material = material;
					buffer = sbuffer3;
				}
			}
			else
			if (indicesSectionName == nodeName)
			{
				// indices section

				indexCount = reader->getAttributeValueAsInt(L"indexCount");
				insideIndexSection = true;
			}

		} // end if node type is element
		else
		if (reader->getNodeType() == io::EXN_TEXT)
		{
			// read vertex data
			if (insideVertexSection)
			{
				if (sbuffer1)
					readMeshBuffer(reader, vertexCount, sbuffer1);
				else
				if (sbuffer2)
					readMeshBuffer(reader, vertexCount, sbuffer2);
				else
				if (sbuffer3)
					readMeshBuffer(reader, vertexCount, sbuffer3);

				insideVertexSection = false;

			} // end reading vertex array
			else
			if (insideIndexSection)
			{
				if (sbuffer1)
					readIndices(reader, indexCount, sbuffer1->Indices);
				else
				if (sbuffer2)
					readIndices(reader, indexCount, sbuffer2->Indices);
				else
				if (sbuffer3)
					readIndices(reader, indexCount, sbuffer3->Indices);

				insideIndexSection = false;
			}

		} // end if node type is text
		else
		if (reader->getNodeType() == io::EXN_ELEMENT_END)
		{
			if (bufferSectionName == reader->getNodeName())
			{
				// end of buffer section reached, cancel out
				break;
			}
		}
	} // end while reader->read();

	if (buffer)
		buffer->recalculateBoundingBox();

	return buffer;
}
示例#10
0
void G3D::readContent(AbstractReader& reader, GeometrySoA& geometry) {
    geometry.indices = readIndices(reader, geometry.info);
    geometry.vertexAttributes = readVertexAttributes(reader, geometry.info);
}
示例#11
0
void G3D::readContent(AbstractReader& reader, GeometryAoS& geometry) {
    geometry.indices = readIndices(reader, geometry.info);
    geometry.vertices = readVertices(reader, geometry.info);
}