Exemplo n.º 1
0
void Model::readArray(Common::SeekableReadStream &stream,
                      uint32 offset, uint32 count, std::vector<T> &values) {

	uint32 pos = stream.seekTo(offset);

	values.resize(count);
	for (uint32 i = 0; i < count; i++)
		readValue(stream, values[i]);

	stream.seekTo(pos);
}
Exemplo n.º 2
0
void WOKFile::load(Common::SeekableReadStream &s) {
	auto header = doLoad<wok::Header>(s);
	fu::fold(header, xxofs, dump());

	*xxofs << "--Vertices--" << std::endl;

	for (auto i = 0; i < header.verticesCount; ++i) {
		s.seekTo(header.offsetToVertices + i * sizeof(wok::Vertex));
		auto vertex = doLoad<wok::Vertex>(s);
		*xxofs << vertex.X << "," << vertex.Y << "," << vertex.Z << std::endl;

		Vector3 pt;
		pt.x = vertex.X;
		pt.y = vertex.Y;
		pt.z = vertex.Z;

		_vertices.push_back(pt);
	}

	*xxofs << "--Normals--" << std::endl;

	for (auto i = 0; i < header.verticesCount; ++i) {
		s.seekTo(header.offsetToNormalizedInvertedNormals + i * sizeof(wok::Vertex));
		auto vertex = doLoad<wok::Vertex>(s);
		*xxofs << vertex.X << "," << vertex.Y << "," << vertex.Z << std::endl;

		Vector3 pt;
		pt.x = vertex.X;
		pt.y = vertex.Y;
		pt.z = vertex.Z;

		_normals.push_back(pt);
	}

	*xxofs << "--Triangles--" << std::endl;

	for (auto i = 0; i < header.facesCount; ++i) {
		s.seekTo(header.offsetToFaces + i * sizeof(wok::Face));
		auto face = doLoad<wok::Face>(s);
		*xxofs << face.V1_Index << "," << face.V2_Index << "," << face.V3_Index << std::endl;
		Triangle t;
		t[0] = face.V1_Index;
		t[1] = face.V2_Index;
		t[2] = face.V3_Index;
		_triangles.push_back(t);
	}

	_position[0] = header.positionX;
	_position[1] = header.positionY;
	_position[2] = header.positionZ;

}
Exemplo n.º 3
0
void Model_KotOR::readStrings(Common::SeekableReadStream &mdl,
		const std::vector<uint32> &offsets, uint32 offset,
		std::vector<Common::UString> &strings) {

	uint32 pos = mdl.pos();

	strings.reserve(offsets.size());
	for (std::vector<uint32>::const_iterator o = offsets.begin(); o != offsets.end(); ++o) {
		mdl.seekTo(offset + *o);

		strings.push_back(Common::readString(mdl, Common::kEncodingASCII));
	}

	mdl.seekTo(pos);
}