void EMIModel::loadMesh(Common::SeekableReadStream *data) { int strLength = 0; // Usefull for PS2-strings Common::String nameString = readLAString(*data); _sphereData = readVector4d(*data); _boxData = readVector3d(*data); _boxData2 = readVector3d(*data); _numTexSets = data->readUint32LE(); _setType = data->readUint32LE(); _numTextures = data->readUint32LE(); _texNames = new Common::String[_numTextures]; for(uint32 i = 0;i < _numTextures; i++) { _texNames[i] = readLAString(*data); // Every texname seems to be followed by 4 0-bytes (Ref mk1.mesh, // this is intentional) data->skip(4); } // 4 unknown bytes - usually with value 19 data->skip(4); _numVertices = data->readUint32LE(); // Vertices _vertices = readVector3d(*data, _numVertices); _normals = readVector3d(*data, _numVertices); _colorMap = new EMIColormap[_numVertices]; for (int i = 0; i < _numVertices; ++i) { _colorMap[i].r = data->readByte(); _colorMap[i].g = data->readByte(); _colorMap[i].b = data->readByte(); _colorMap[i].a = data->readByte(); } _texVerts = readVector2d(*data, _numVertices); // Faces _numFaces = data->readUint32LE(); // Handle the empty-faced fx/screen?.mesh-files if (data->eos()) { _numFaces = 0; _faces = NULL; return; } _faces = new EMIMeshFace[_numFaces]; for(uint32 j = 0;j < _numFaces; j++) { _faces[j].setParent(this); _faces[j].loadFace(data); } int hasBones = data->readUint32LE(); // TODO add in the bone-stuff, as well as the skeleton prepare(); // <- Initialize materials etc. }
void EMIModel::loadMesh(Common::SeekableReadStream *data) { //int strLength = 0; // Usefull for PS2-strings Common::String nameString = readLAString(data); _sphereData->readFromStream(data); _boxData->readFromStream(data); _boxData2->readFromStream(data); _numTexSets = data->readUint32LE(); _setType = data->readUint32LE(); _numTextures = data->readUint32LE(); _texNames = new Common::String[_numTextures]; for (uint32 i = 0; i < _numTextures; i++) { _texNames[i] = readLAString(data); // Every texname seems to be followed by 4 0-bytes (Ref mk1.mesh, // this is intentional) data->skip(4); } prepareTextures(); int type = data->readUint32LE(); // Check that it is one of the known types //3 is no texture vertecies //18 is no normals //19 is regular assert(type == 19 || type == 18 || type == 3); _numVertices = data->readUint32LE(); // Vertices _vertices = new Math::Vector3d[_numVertices]; _drawVertices = new Math::Vector3d[_numVertices]; for (int i = 0; i < _numVertices; i++) { _vertices[i].readFromStream(data); _drawVertices[i] = _vertices[i]; } _normals = new Math::Vector3d[_numVertices]; if (type != 18) { for (int i = 0; i < _numVertices; i++) { _normals[i].readFromStream(data); } } _colorMap = new EMIColormap[_numVertices]; for (int i = 0; i < _numVertices; ++i) { _colorMap[i].r = data->readByte(); _colorMap[i].g = data->readByte(); _colorMap[i].b = data->readByte(); _colorMap[i].a = data->readByte(); } if (type != 3) { _texVerts = new Math::Vector2d[_numVertices]; for (int i = 0; i < _numVertices; i++) { _texVerts[i].readFromStream(data); } } // Faces _numFaces = data->readUint32LE(); if (data->eos()) { _numFaces = 0; _faces = NULL; return; } _faces = new EMIMeshFace[_numFaces]; for (uint32 j = 0; j < _numFaces; j++) { _faces[j].setParent(this); _faces[j].loadFace(data); } int hasBones = data->readUint32LE(); if (hasBones == 1) { _numBones = data->readUint32LE(); _boneNames = new Common::String[_numBones]; for (int i = 0; i < _numBones; i++) { _boneNames[i] = readLAString(data); } _numBoneInfos = data->readUint32LE(); _boneInfos = new BoneInfo[_numBoneInfos]; for (int i = 0; i < _numBoneInfos; i++) { _boneInfos[i]._incFac = data->readUint32LE(); _boneInfos[i]._joint = data->readUint32LE(); _boneInfos[i]._weight = data->readUint32LE(); } } else { _numBones = 0; _numBoneInfos = 0; } prepareForRender(); }
void EMIModel::loadMesh(Common::SeekableReadStream *data) { //int strLength = 0; // Usefull for PS2-strings Common::String nameString = readLAString(data); _sphereData->readFromStream(data); _boxData->readFromStream(data); _boxData2->readFromStream(data); _numTexSets = data->readUint32LE(); _setType = data->readUint32LE(); _numTextures = data->readUint32LE(); _texNames = new Common::String[_numTextures]; for(uint32 i = 0;i < _numTextures; i++) { _texNames[i] = readLAString(data); // Every texname seems to be followed by 4 0-bytes (Ref mk1.mesh, // this is intentional) data->skip(4); } // 4 unknown bytes - usually with value 19 data->skip(4); _numVertices = data->readUint32LE(); // Vertices _vertices = new Math::Vector3d[_numVertices]; _drawVertices = new Math::Vector3d[_numVertices]; for (int i = 0; i < _numVertices; i++) { _vertices[i].readFromStream(data); _drawVertices[i] = _vertices[i]; } _normals = new Math::Vector3d[_numVertices]; for (int i = 0; i < _numVertices; i++) { _normals[i].readFromStream(data); } _colorMap = new EMIColormap[_numVertices]; for (int i = 0; i < _numVertices; ++i) { _colorMap[i].r = data->readByte(); _colorMap[i].g = data->readByte(); _colorMap[i].b = data->readByte(); _colorMap[i].a = data->readByte(); } _texVerts = new Math::Vector2d[_numVertices]; for (int i = 0; i < _numVertices; i++) { _texVerts[i].readFromStream(data); } // Faces _numFaces = data->readUint32LE(); // Handle the empty-faced fx/screen?.mesh-files if (data->eos()) { _numFaces = 0; _faces = NULL; return; } _faces = new EMIMeshFace[_numFaces]; for(uint32 j = 0;j < _numFaces; j++) { _faces[j].setParent(this); _faces[j].loadFace(data); } int hasBones = data->readUint32LE(); if (hasBones == 1) { _numBones = data->readUint32LE(); _bones = new Bone[_numBones]; _boneNames = new Common::String[_numBones]; for(int i = 0;i < _numBones; i++) { _bones[i]._boneName = readLAString(data); _boneNames[i] = _bones[i]._boneName; } _numBoneInfos = data->readUint32LE(); _boneInfos = new BoneInfo[_numBoneInfos]; for(int i = 0;i < _numBoneInfos; i++) { _boneInfos[i]._incFac = data->readUint32LE(); _boneInfos[i]._joint = data->readUint32LE(); _boneInfos[i]._weight = data->readUint32LE(); } } else { _numBones = 0; _numBoneInfos = 0; } prepare(); // <- Initialize materials etc. }