mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 10:21:31 +00:00
WME3D: Move portions code to mesh loader
This commit is contained in:
parent
625c1d10c8
commit
327b35407f
@ -28,6 +28,7 @@
|
||||
#include "engines/wintermute/dcgf.h"
|
||||
#include "engines/wintermute/base/gfx/skin_mesh_helper.h"
|
||||
#include "engines/wintermute/base/gfx/xskinmesh_loader.h"
|
||||
#include "engines/wintermute/base/gfx/xfile_loader.h"
|
||||
|
||||
namespace Wintermute {
|
||||
|
||||
@ -43,7 +44,7 @@ SkinMeshHelper::~SkinMeshHelper() {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
uint SkinMeshHelper::getNumFaces() {
|
||||
return 0;//_mesh->getNumFaces();
|
||||
return _mesh->_meshObject->_numFaces;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -67,25 +67,18 @@ bool XMesh::loadFromXData(const Common::String &filename, XFileData *xobj, Commo
|
||||
return false;
|
||||
}
|
||||
|
||||
XSkinMeshLoader *mesh = new XSkinMeshLoader(this);
|
||||
XSkinMeshLoader *mesh = new XSkinMeshLoader(this, meshObject);
|
||||
_skinMesh = new SkinMeshHelper(mesh);
|
||||
|
||||
mesh->_vertexCount = meshObject->_numVertices;
|
||||
|
||||
// vertex format for .X meshes will be position + normals + textures
|
||||
mesh->_vertexData = new float[XSkinMeshLoader::kVertexComponentCount * mesh->_vertexCount]();
|
||||
mesh->_vertexPositionData = new float[3 * mesh->_vertexCount]();
|
||||
// we already know how big this is supposed to be
|
||||
// TODO: might have to generate normals if file does not contain any
|
||||
mesh->_vertexNormalData = new float[3 * mesh->_vertexCount]();
|
||||
|
||||
mesh->parsePositionCoords(meshObject);
|
||||
|
||||
int faceCount = meshObject->_numFaces;
|
||||
uint numFaces = _skinMesh->getNumFaces();
|
||||
|
||||
//uint numBones = _skinMesh->getNumBones();
|
||||
|
||||
Common::Array<int> indexCountPerFace;
|
||||
|
||||
mesh->parseFaces(meshObject, faceCount, indexCountPerFace);
|
||||
mesh->parseFaces(meshObject, numFaces, indexCountPerFace);
|
||||
|
||||
uint numChildren = 0;
|
||||
xobj->getChildren(numChildren);
|
||||
@ -100,7 +93,7 @@ bool XMesh::loadFromXData(const Common::String &filename, XFileData *xobj, Commo
|
||||
} else if (objectType == kXClassMeshNormals) {
|
||||
mesh->parseNormalCoords(&xchildData);
|
||||
} else if (objectType == kXClassMeshMaterialList) {
|
||||
mesh->parseMaterials(&xchildData, _gameRef, faceCount, filename, materialReferences, indexCountPerFace);
|
||||
mesh->parseMaterials(&xchildData, _gameRef, numFaces, filename, materialReferences, indexCountPerFace);
|
||||
} else if (objectType == kXClassMaterial) {
|
||||
Material *mat = new Material(_gameRef);
|
||||
mat->loadFromX(&xchildData, filename);
|
||||
|
@ -34,13 +34,17 @@ namespace Wintermute {
|
||||
// define constant to make it available to the linker
|
||||
const uint32 XSkinMeshLoader::kNullIndex;
|
||||
|
||||
XSkinMeshLoader::XSkinMeshLoader(XMesh *mesh) {
|
||||
XSkinMeshLoader::XSkinMeshLoader(XMesh *mesh, XMeshObject *meshObject) {
|
||||
_mesh = mesh;
|
||||
_meshObject = meshObject;
|
||||
|
||||
_vertexData = nullptr;
|
||||
_vertexPositionData = nullptr;
|
||||
_vertexNormalData = nullptr;
|
||||
_vertexCount = 0;
|
||||
_vertexCount = meshObject->_numVertices;
|
||||
// vertex format for .X meshes will be position + normals + textures
|
||||
_vertexData = new float[kVertexComponentCount * _vertexCount]();
|
||||
_vertexPositionData = new float[3 * _vertexCount]();
|
||||
// we already know how big this is supposed to be
|
||||
// TODO: might have to generate normals if file does not contain any
|
||||
_vertexNormalData = new float[3 * _vertexCount]();
|
||||
}
|
||||
|
||||
XSkinMeshLoader::~XSkinMeshLoader() {
|
||||
|
@ -33,6 +33,7 @@ class Material;
|
||||
class XModel;
|
||||
class XMesh;
|
||||
class ShadowVolume;
|
||||
class SkinMeshHelper;
|
||||
class VideoTheoraPlayer;
|
||||
struct XMeshObject;
|
||||
|
||||
@ -47,9 +48,10 @@ class XSkinMeshLoader {
|
||||
friend class XMesh;
|
||||
friend class XMeshOpenGL;
|
||||
friend class XMeshOpenGLShader;
|
||||
friend class SkinMeshHelper;
|
||||
|
||||
public:
|
||||
XSkinMeshLoader(XMesh *mesh);
|
||||
XSkinMeshLoader(XMesh *mesh, XMeshObject *meshObject);
|
||||
virtual ~XSkinMeshLoader();
|
||||
|
||||
protected:
|
||||
@ -89,6 +91,7 @@ protected:
|
||||
BaseArray<int> _materialIndices;
|
||||
|
||||
XMesh *_mesh;
|
||||
XMeshObject *_meshObject;
|
||||
};
|
||||
|
||||
} // namespace Wintermute
|
||||
|
Loading…
Reference in New Issue
Block a user