Esempio n. 1
0
void Trigger::loadInstance(const Aurora::GFF3Struct &gff) {
	// Tag

	_tag = gff.getString("Tag", _tag);

	loadPositional(gff);

	const Aurora::GFF3List &geometry = gff.getList("Geometry");
	float x, y, z;

	Graphics::VertexDecl vertexDecl;

	vertexDecl.push_back(Graphics::VertexAttrib(Graphics::VPOSITION, 3, GL_FLOAT));

	_vertexBuffer.setVertexDeclLinear(geometry.size(), vertexDecl);

	float *v = reinterpret_cast<float *>(_vertexBuffer.getData());
	for (uint32 i = 0; i < geometry.size(); i++) {
		geometry[i]->getVector("Vertex", x, y, z);

		// Position
		*v++ = x;
		*v++ = y;
		*v++ = z;
	}
}
Esempio n. 2
0
void TRXFile::loadWATR(Common::SeekableReadStream &trx, Packet &packet) {
	Common::SeekableSubReadStream watr(&trx, trx.pos(), trx.pos() + packet.size);

	Common::UString name = Common::readStringFixed(watr, Common::kEncodingASCII, 128);

	float color[3];
	color[0] = watr.readIEEEFloatLE();
	color[1] = watr.readIEEEFloatLE();
	color[2] = watr.readIEEEFloatLE();

	watr.skip(4); // float rippleX
	watr.skip(4); // float rippleY
	watr.skip(4); // float smoothness
	watr.skip(4); // float refBias
	watr.skip(4); // float refPower
	watr.skip(4); // Unknown
	watr.skip(4); // Unknown

	Common::UString textures[3];
	for (int i = 0; i < 3; i++) {
		textures[i] = Common::readStringFixed(watr, Common::kEncodingASCII, 32);

		watr.skip(4); // float dirX
		watr.skip(4); // float dirY
		watr.skip(4); // float rate
		watr.skip(4); // float angle
	}

	watr.skip(4); // float offsetX
	watr.skip(4); // float offsetY

	uint32 vCount = watr.readUint32LE();
	uint32 fCount = watr.readUint32LE();


	GLsizei vpsize = 3;
	GLsizei vnsize = 0;
	GLsizei vcsize = 3;

	uint32 vSize = (vpsize + vnsize + vcsize) * sizeof(float);

	Graphics::VertexBuffer vBuf;
	vBuf.setSize(vCount, vSize);

	float *vertexData = (float *) vBuf.getData();
	Graphics::VertexDecl vertexDecl;

	Graphics::VertexAttrib vp;
	vp.index = Graphics::VPOSITION;
	vp.size = vpsize;
	vp.type = GL_FLOAT;
	vp.stride = vSize;
	vp.pointer = vertexData;
	vertexDecl.push_back(vp);

	/*
	Graphics::VertexAttrib vn;
	vn.index = Graphics::VNORMAL;
	vn.size = vnsize;
	vn.type = GL_FLOAT;
	vn.stride = vSize;
	vn.pointer = vertexData + vpsize;
	vertexDecl.push_back(vn);
	*/

	Graphics::VertexAttrib vc;
	vc.index = Graphics::VCOLOR;
	vc.size = vcsize;
	vc.type = GL_FLOAT;
	vc.stride = vSize;
	vc.pointer = vertexData + vpsize + vnsize;
	vertexDecl.push_back(vc);

	vBuf.setVertexDecl(vertexDecl);

	float *v = vertexData;
	for (uint32 i = 0; i < vCount; i++) {
		*v++ = watr.readIEEEFloatLE();
		*v++ = watr.readIEEEFloatLE();
		*v++ = watr.readIEEEFloatLE();

		*v++ = color[0];
		*v++ = color[1];
		*v++ = color[2];

		watr.skip(16); // texture coordinates?
	}

	Graphics::IndexBuffer iBuf;
	iBuf.setSize(fCount * 3, sizeof(uint16), GL_UNSIGNED_SHORT);

	uint16 *f = (uint16 *) iBuf.getData();
	for (uint32 i = 0; i < fCount; i++) {
		*f++ = watr.readUint16LE();
		*f++ = watr.readUint16LE();
		*f++ = watr.readUint16LE();
	}

	/* TODO:
	 *   - uint32  ddsSize
	 *   - byte   *dds
	 *   - uint32  flags[vCount]
	 *   - uint32  tileX
	 *   - uint32  tileY
	 */

	_water.push_back(new Graphics::Aurora::GeometryObject(vBuf, iBuf));
	_water.back()->setRotation(-90.0, 0.0, 0.0);
}
Esempio n. 3
0
void TRXFile::loadTRRN(Common::SeekableReadStream &trx, Packet &packet) {
	Common::SeekableSubReadStream ttrn(&trx, trx.pos(), trx.pos() + packet.size);

	Common::UString name = Common::readStringFixed(ttrn, Common::kEncodingASCII, 128);

	Common::UString textures[6];
	for (int i = 0; i < 6; i++)
		textures[i] = Common::readStringFixed(ttrn, Common::kEncodingASCII, 32);

	float textureColors[6][3];
	for (int i = 0; i < 6; i++)
		for (int j = 0; j < 3; j++)
			textureColors[i][j] = ttrn.readIEEEFloatLE();

	uint32 vCount = ttrn.readUint32LE();
	uint32 fCount = ttrn.readUint32LE();


	GLsizei vpsize = 3;
	GLsizei vnsize = 3;
	GLsizei vcsize = 4;

	uint32 vSize = (vpsize + vnsize + vcsize) * sizeof(float);

	Graphics::VertexBuffer vBuf;
	vBuf.setSize(vCount, vSize);

	float *vertexData = (float *) vBuf.getData();
	Graphics::VertexDecl vertexDecl;

	Graphics::VertexAttrib vp;
	vp.index = Graphics::VPOSITION;
	vp.size = vpsize;
	vp.type = GL_FLOAT;
	vp.stride = vSize;
	vp.pointer = vertexData;
	vertexDecl.push_back(vp);

	Graphics::VertexAttrib vn;
	vn.index = Graphics::VNORMAL;
	vn.size = vnsize;
	vn.type = GL_FLOAT;
	vn.stride = vSize;
	vn.pointer = vertexData + vpsize;
	vertexDecl.push_back(vn);

	Graphics::VertexAttrib vc;
	vc.index = Graphics::VCOLOR;
	vc.size = vcsize;
	vc.type = GL_FLOAT;
	vc.stride = vSize;
	vc.pointer = vertexData + vpsize + vnsize;
	vertexDecl.push_back(vc);

	vBuf.setVertexDecl(vertexDecl);

	float *v = vertexData;
	for (uint32 i = 0; i < vCount; i++) {
		*v++ = ttrn.readIEEEFloatLE();
		*v++ = ttrn.readIEEEFloatLE();
		*v++ = ttrn.readIEEEFloatLE();

		*v++ = ttrn.readIEEEFloatLE();
		*v++ = ttrn.readIEEEFloatLE();
		*v++ = ttrn.readIEEEFloatLE();

		for (int j = 0; j < 3; j++) {
			int   vals = 1;
			float rgb  = ttrn.readByte() / 255.0f;

			for (int k = 0; k < 6; k++) {
				if (!textures[k].empty()) {
					rgb += textureColors[k][j];
					vals++;
				}
			}

			rgb /= vals;

			*v++ = rgb;
		}

		*v++ = ttrn.readByte() / 255.0f;

		ttrn.skip(16); // Some texture coordinates?
	}

	Graphics::IndexBuffer iBuf;
	iBuf.setSize(fCount * 3, sizeof(uint16), GL_UNSIGNED_SHORT);

	uint16 *f = (uint16 *) iBuf.getData();
	for (uint32 i = 0; i < fCount; i++) {
		*f++ = ttrn.readUint16LE();
		*f++ = ttrn.readUint16LE();
		*f++ = ttrn.readUint16LE();
	}

	/* TODO:
	 *   - uint32 dds1Size
	 *   - byte  *dds1
	 *   - uint32 dds2Size
	 *   - byte  *dds2
	 *   - uint32 grassCount
	 *   - Grass  grass
	 */

	_terrain.push_back(new Graphics::Aurora::GeometryObject(vBuf, iBuf));
	_terrain.back()->setRotation(-90.0, 0.0, 0.0);
}