M2MeshFile loader 0.2
-Texturing (one layer only) -alpha transparency and backface culling flags handled -various fixes
This commit is contained in:
parent
b4ece10cb1
commit
1a79b45b99
@ -1,158 +1,287 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "CM2MeshFileLoader.h"
|
#include "CM2MeshFileLoader.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
|
||||||
CM2MeshFileLoader::CM2MeshFileLoader(IrrlichtDevice* device):Device(device)
|
CM2MeshFileLoader::CM2MeshFileLoader(IrrlichtDevice* device, c8* basedir):Device(device), Basedir(basedir)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CM2MeshFileLoader::~CM2MeshFileLoader()
|
CM2MeshFileLoader::~CM2MeshFileLoader()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CM2MeshFileLoader::isALoadableFileExtension(const c8* filename)const
|
bool CM2MeshFileLoader::isALoadableFileExtension(const c8* filename)const
|
||||||
{
|
{
|
||||||
return strstr(filename, ".m2")!=0;
|
return strstr(filename, ".m2")!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! creates/loads an animated mesh from the file.
|
//! creates/loads an animated mesh from the file.
|
||||||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||||
//! See IUnknown::drop() for more information.
|
//! See IUnknown::drop() for more information.
|
||||||
IAnimatedMesh* CM2MeshFileLoader::createMesh(io::IReadFile* file)
|
IAnimatedMesh* CM2MeshFileLoader::createMesh(io::IReadFile* file)
|
||||||
{
|
{
|
||||||
ILogger* logger =Device->getLogger();
|
ILogger* logger =Device->getLogger();
|
||||||
|
|
||||||
logger->log("Trying to open file",file->getFileName(),ELL_INFORMATION);
|
logger->log("Trying to open file",file->getFileName(),ELL_INFORMATION);
|
||||||
|
|
||||||
|
|
||||||
file->read(&header,sizeof(ModelHeader));
|
file->read(&header,sizeof(ModelHeader));
|
||||||
if (header.version[0] != 4 && header.version[1] != 1 && header.version[2] != 0 && header.version[3] != 0) {
|
if (header.version[0] != 4 && header.version[1] != 1 && header.version[2] != 0 && header.version[3] != 0) {
|
||||||
logger->log("Something wrong!",ELL_ERROR);
|
logger->log("Something wrong!",ELL_ERROR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else logger->log(L"header okay",ELL_INFORMATION);
|
else logger->log(L"header okay",ELL_INFORMATION);
|
||||||
//Name -> not very important I think, but save it nontheless;
|
//Name -> not very important I think, but save it nontheless;
|
||||||
std::cout << "Name offset:" << header.nameOfs << "Name length:" << header.nameLength << "\n";
|
std::cout << "Name offset:" << header.nameOfs << "Name length:" << header.nameLength << "\n";
|
||||||
file->seek(header.nameOfs);
|
//M2MeshName.clear();
|
||||||
file->read(&M2MeshName[0],header.nameLength);
|
//M2MeshName.reserve(header.nameLength);
|
||||||
std::cout << "Read name:"<<M2MeshName.c_str()<<"\n";
|
file->seek(header.nameOfs);
|
||||||
//logger->log("Mesh Name",M2MeshName.c_str(),ELL_INFORMATION);
|
// file->read(&M2MeshName[0],header.nameLength);
|
||||||
//Now we load all kinds of data from the file
|
//std::cout << "Read name:"<<M2MeshName.c_str()<<"Size: "<< M2MeshName.size() <<"|"<<M2MeshName[0]<< "\n";
|
||||||
|
//logger->log("Mesh Name",M2MeshName.c_str(),ELL_INFORMATION);
|
||||||
//Vertices
|
//Now we load all kinds of data from the file
|
||||||
if(!M2MVertices.empty())
|
|
||||||
M2MVertices.clear();
|
//Vertices. Global data
|
||||||
|
if(!M2MVertices.empty())
|
||||||
ModelVertex tempM2MVert;
|
M2MVertices.clear();
|
||||||
file->seek(header.ofsVertices);
|
|
||||||
|
ModelVertex tempM2MVert;
|
||||||
for(u32 i =0;i<header.nVertices;i++)
|
file->seek(header.ofsVertices);
|
||||||
{
|
|
||||||
file->read(&tempM2MVert,sizeof(ModelVertex));
|
for(u32 i =0;i<header.nVertices;i++)
|
||||||
M2MVertices.push_back(tempM2MVert);
|
{
|
||||||
}
|
file->read(&tempM2MVert,sizeof(ModelVertex));
|
||||||
std::cout << "Read "<<M2MVertices.size()<<"/"<<header.nVertices<<" Vertices\n";
|
M2MVertices.push_back(tempM2MVert);
|
||||||
|
}
|
||||||
//Views == Sets of vertices. Usage yet unknown
|
std::cout << "Read "<<M2MVertices.size()<<"/"<<header.nVertices<<" Vertices\n";
|
||||||
if(M2MViews.size()>0)
|
|
||||||
M2MViews.clear();
|
//Views == Sets of vertices. Usage yet unknown. Global data
|
||||||
ModelView tempM2MView;
|
if(M2MViews.size()>0)
|
||||||
file->seek(header.ofsViews);
|
M2MViews.clear();
|
||||||
for(u32 i =0;i<header.nViews;i++)
|
ModelView tempM2MView;
|
||||||
{
|
file->seek(header.ofsViews);
|
||||||
file->read(&tempM2MView,sizeof(ModelView));
|
for(u32 i =0;i<header.nViews;i++)
|
||||||
M2MViews.push_back(tempM2MView);
|
{
|
||||||
}
|
file->read(&tempM2MView,sizeof(ModelView));
|
||||||
std::cout << "Read "<<M2MViews.size()<<"/"<<header.nViews<<" Views\n";
|
M2MViews.push_back(tempM2MView);
|
||||||
|
}
|
||||||
logger->log("Using View 0 for all further operations",ELL_INFORMATION);
|
std::cout << "Read "<<M2MViews.size()<<"/"<<header.nViews<<" Views\n";
|
||||||
|
|
||||||
//Vertex indices of a specific view.
|
logger->log("Using View 0 for all further operations",ELL_INFORMATION);
|
||||||
if(M2MIndices.size()>0)
|
std::cout<<"This View has "<<M2MViews[0].nSub<<" Submeshes\n";
|
||||||
M2MIndices.clear();
|
|
||||||
|
//Vertex indices of a specific view.Local to View 0
|
||||||
u16 tempM2Index;
|
if(M2MIndices.size()>0)
|
||||||
file->seek(M2MViews[0].ofsIndex);
|
M2MIndices.clear();
|
||||||
for(u32 i =0;i<M2MViews[0].nIndex;i++)
|
|
||||||
{
|
u16 tempM2Index;
|
||||||
file->read(&tempM2Index,sizeof(u16));
|
file->seek(M2MViews[0].ofsIndex);
|
||||||
M2MIndices.push_back(tempM2Index);
|
for(u32 i =0;i<M2MViews[0].nIndex;i++)
|
||||||
}
|
{
|
||||||
std::cout << "Read "<<M2MIndices.size()<<"/"<<M2MViews[0].nIndex<<" Indices\n";
|
file->read(&tempM2Index,sizeof(u16));
|
||||||
|
M2MIndices.push_back(tempM2Index);
|
||||||
|
}
|
||||||
//Triangles. Data Points point to the Vertex Indices, not the vertices themself. 3 Points = 1 Triangle
|
std::cout << "Read "<<M2MIndices.size()<<"/"<<M2MViews[0].nIndex<<" Indices\n";
|
||||||
if(M2MTriangles.size()>0)
|
|
||||||
M2MTriangles.clear();
|
|
||||||
|
//Triangles. Data Points point to the Vertex Indices, not the vertices themself. 3 Points = 1 Triangle, Local to View 0
|
||||||
u16 tempM2Triangle;
|
if(M2MTriangles.size()>0)
|
||||||
file->seek(M2MViews[0].ofsTris);
|
M2MTriangles.clear();
|
||||||
for(u32 i =0;i<M2MViews[0].nTris;i++)
|
|
||||||
{
|
u16 tempM2Triangle;
|
||||||
file->read(&tempM2Triangle,sizeof(u16));
|
file->seek(M2MViews[0].ofsTris);
|
||||||
M2MTriangles.push_back(tempM2Triangle);
|
for(u32 i =0;i<M2MViews[0].nTris;i++)
|
||||||
}
|
{
|
||||||
std::cout << "Read "<<M2MTriangles.size()<<"/"<<M2MViews[0].nTris<<" Triangle Indices\n";
|
file->read(&tempM2Triangle,sizeof(u16));
|
||||||
|
M2MTriangles.push_back(tempM2Triangle);
|
||||||
//Texture Lookup table.
|
}
|
||||||
file->seek(header.ofsTexLookup);
|
std::cout << "Read "<<M2MTriangles.size()<<"/"<<M2MViews[0].nTris<<" Triangle Indices\n";
|
||||||
for(u32 i=0;i<header.nTexLookup;i++)
|
|
||||||
{
|
//Submeshes, Local to View 0
|
||||||
|
if(M2MSubmeshes.size()>0)
|
||||||
}
|
M2MSubmeshes.clear();
|
||||||
|
|
||||||
//Now, M2MTriangles refers to M2MIndices and not to M2MVertices.
|
ModelViewSubmesh tempM2Submesh;
|
||||||
//And M2MVertices are not usable like this. Thus we transform
|
file->seek(M2MViews[0].ofsSub);
|
||||||
if(M2Vertices.size()>0)
|
for(u32 i =0;i<M2MViews[0].nSub;i++)
|
||||||
M2Vertices.clear();
|
{
|
||||||
|
file->read(&tempM2Submesh,sizeof(ModelViewSubmesh));
|
||||||
for(u32 i=0;i<M2MVertices.size();i++)
|
M2MSubmeshes.push_back(tempM2Submesh);
|
||||||
{
|
// std::cout<< "Submesh " <<i<<" ID "<<tempM2Submesh.meshpartId<<" starts at V/T "<<tempM2Submesh.ofsVertex<<"/"<<tempM2Submesh.ofsTris<<" and has "<<tempM2Submesh.nVertex<<"/"<<tempM2Submesh.nTris<<" V/T\n";
|
||||||
M2Vertices.push_back(video::S3DVertex(M2MVertices[i].pos,M2MVertices[i].normal, video::SColor(255,100,100,100),M2MVertices[i].texcoords));
|
}
|
||||||
}
|
std::cout << "Read "<<M2MSubmeshes.size()<<"/"<<M2MViews[0].nSub<<" Submeshes\n";
|
||||||
if(M2Indices.size()>0)
|
|
||||||
M2Indices.clear();
|
//Texture units. Local to view 0
|
||||||
|
TextureUnit tempM2TexUnit;
|
||||||
for(u32 i=0;i<M2MTriangles.size();i++)
|
if(!M2MTextureUnit.empty())
|
||||||
{
|
{
|
||||||
M2Indices.push_back(M2MIndices[M2MTriangles[i]]);
|
M2MTextureUnit.clear();
|
||||||
}
|
}
|
||||||
|
file->seek(M2MViews[0].ofsTex);
|
||||||
Mesh=new SMesh();
|
for(u32 i=0;i<M2MViews[0].nTex;i++)
|
||||||
|
{
|
||||||
|
file->read(&tempM2TexUnit,sizeof(TextureUnit));
|
||||||
SMeshBuffer* IMB = new SMeshBuffer;
|
M2MTextureUnit.push_back(tempM2TexUnit);
|
||||||
while(Mesh->getMeshBufferCount()>0)
|
}
|
||||||
{
|
std::cout << "Read "<<M2MTextureUnit.size()<<" Texture Unit entries for View 0\n";
|
||||||
Mesh->MeshBuffers.erase(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Sending "<<M2Vertices.size() <<" Vertices and " << M2Indices.size() <<" Indices to the MeshBuffer\n";
|
|
||||||
IMB->append(M2Vertices.const_pointer(),M2Vertices.size(),M2Indices.const_pointer(),M2Indices.size());
|
//Texture Lookup table. This is global data
|
||||||
|
u16 tempM2TexLookup;
|
||||||
IMB->recalculateBoundingBox();
|
if(!M2MTextureLookup.empty())
|
||||||
Mesh->addMeshBuffer(IMB);
|
{
|
||||||
IMB->drop();
|
M2MTextureLookup.clear();
|
||||||
aniMesh= new SAnimatedMesh();
|
}
|
||||||
|
file->seek(header.ofsTexLookup);
|
||||||
|
for(u32 i=0;i<header.nTexLookup;i++)
|
||||||
aniMesh->addMesh(Mesh);
|
{
|
||||||
Mesh->drop();
|
file->read(&tempM2TexLookup,sizeof(u16));
|
||||||
Mesh = 0;
|
M2MTextureLookup.push_back(tempM2TexLookup);
|
||||||
|
}
|
||||||
aniMesh->recalculateBoundingBox();
|
std::cout << "Read "<<M2MTextureLookup.size()<<" Texture lookup entries\n";
|
||||||
|
|
||||||
return aniMesh;
|
//Texture Definitions table. This is global data
|
||||||
}
|
TextureDefinition tempM2TexDef;
|
||||||
|
if(!M2MTextureDef.empty())
|
||||||
}
|
{
|
||||||
|
M2MTextureDef.clear();
|
||||||
|
}
|
||||||
|
file->seek(header.ofsTextures);
|
||||||
|
for(u32 i=0;i<header.nTextures;i++)
|
||||||
|
{
|
||||||
|
file->read(&tempM2TexDef,sizeof(TextureDefinition));
|
||||||
|
M2MTextureDef.push_back(tempM2TexDef);
|
||||||
|
}
|
||||||
|
std::cout << "Read "<<M2MTextureDef.size()<<" Texture Definition entries\n";
|
||||||
|
|
||||||
|
//Render Flags table. This is global data
|
||||||
|
RenderFlags tempM2RF;
|
||||||
|
if(!M2MRenderFlags.empty())
|
||||||
|
{
|
||||||
|
M2MRenderFlags.clear();
|
||||||
|
}
|
||||||
|
file->seek(header.ofsTexFlags);
|
||||||
|
for(u32 i=0;i<header.nTexFlags;i++)
|
||||||
|
{
|
||||||
|
file->read(&tempM2RF,sizeof(RenderFlags));
|
||||||
|
M2MRenderFlags.push_back(tempM2RF);
|
||||||
|
}
|
||||||
|
std::cout << "Read "<<M2MRenderFlags.size()<<" Render Flags\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//std::cout << M2MTextureUnit[0].submeshIndex1 <<","<<M2MTextureUnit[0].submeshIndex1 <<","<<M2MTextureUnit[0].textureIndex<<";\n";
|
||||||
|
|
||||||
|
if(!M2MTextureFiles.empty())
|
||||||
|
M2MTextureFiles.clear();
|
||||||
|
|
||||||
|
std::string tempTexFileName="";
|
||||||
|
M2MTextureFiles.reallocate(M2MTextureDef.size());
|
||||||
|
for(u32 i=0; i<M2MTextureDef.size(); i++)
|
||||||
|
{
|
||||||
|
file->seek(M2MTextureDef[i].texFileOfs);
|
||||||
|
file->read(&tempTexFileName[0],M2MTextureDef[i].texFileLen);
|
||||||
|
M2MTextureFiles.push_back(tempTexFileName.c_str());
|
||||||
|
std::cout<<M2MTextureFiles.size()<<"-"<<M2MTextureFiles[i].c_str()<<"\n";
|
||||||
|
}
|
||||||
|
// std::cout << "Read "<<M2MTextureFiles.size()<<"/"<<M2MTextureDef.size()<<" Texture file names\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//And M2MVertices are not usable like this. Thus we transform
|
||||||
|
|
||||||
|
if(M2Vertices.size()>0)
|
||||||
|
M2Vertices.clear();
|
||||||
|
|
||||||
|
for(u32 i=0;i<M2MVertices.size();i++)
|
||||||
|
{
|
||||||
|
M2Vertices.push_back(video::S3DVertex(M2MVertices[i].pos,M2MVertices[i].normal, video::SColor(255,100,100,100),M2MVertices[i].texcoords));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Mesh)
|
||||||
|
Mesh->drop();
|
||||||
|
|
||||||
|
Mesh=new SMesh();
|
||||||
|
|
||||||
|
|
||||||
|
while(Mesh->getMeshBufferCount()>0)
|
||||||
|
{
|
||||||
|
Mesh->MeshBuffers.erase(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(u32 i=0; i < M2MViews[0].nSub;i++)//
|
||||||
|
{
|
||||||
|
//std::cout << "Proceeding with Submesh "<<i<<"/"<<M2MViews[0].nSub<<"\n";
|
||||||
|
//Now, M2MTriangles refers to M2MIndices and not to M2MVertices.
|
||||||
|
|
||||||
|
if(M2Indices.size()>0)
|
||||||
|
M2Indices.clear();
|
||||||
|
|
||||||
|
for(u32 j=M2MSubmeshes[i].ofsTris;j<M2MSubmeshes[i].ofsTris+M2MSubmeshes[i].nTris;j++)
|
||||||
|
{
|
||||||
|
M2Indices.push_back(M2MIndices[M2MTriangles[j]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::cout << "Sending "<<M2Vertices.size() <<" Vertices and " << M2Indices.size() <<" Indices to the MeshBuffer\n";
|
||||||
|
|
||||||
|
IMB = new SMeshBuffer;
|
||||||
|
IMB->append(M2Vertices.const_pointer(),M2Vertices.size(),M2Indices.const_pointer(),M2Indices.size());
|
||||||
|
IMB->recalculateBoundingBox();
|
||||||
|
|
||||||
|
//IMB->getMaterial().DiffuseColor.set(255,255-(u32)(255/(M2MSubmeshes.size()))*i,(u32)(255/(M2MSubmeshes.size()))*i,0);
|
||||||
|
//IMB->getMaterial().DiffuseColor.set(255,(M2MSubmeshes[i].meshpartId==0?0:255),(M2MSubmeshes[i].meshpartId==0?255:0),0);
|
||||||
|
|
||||||
|
|
||||||
|
std::string TexName=Basedir.c_str();
|
||||||
|
TexName+="/";
|
||||||
|
TexName+=M2MTextureFiles[M2MTextureUnit[i].textureIndex].c_str();
|
||||||
|
|
||||||
|
while(TexName.find('\\')<TexName.size())//Replace \ by /
|
||||||
|
{
|
||||||
|
TexName.replace(TexName.find('\\'),1,"/");
|
||||||
|
}
|
||||||
|
while(TexName.find(' ')<TexName.size())//Replace space by _
|
||||||
|
{
|
||||||
|
TexName.replace(TexName.find(' '),1,"_");
|
||||||
|
}
|
||||||
|
std::transform(TexName.begin(), TexName.end(), TexName.begin(), tolower);
|
||||||
|
|
||||||
|
IMB->getMaterial().setTexture(0,Device->getVideoDriver()->getTexture(TexName.c_str()));
|
||||||
|
std::cout<<M2MRenderFlags[i].flags<<"--"<<M2MRenderFlags[i].blending<<"\n";
|
||||||
|
IMB->getMaterial().BackfaceCulling=(M2MRenderFlags[i].flags & 0x04)?false:true;
|
||||||
|
if(M2MRenderFlags[i].blending==1)
|
||||||
|
IMB->getMaterial().MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||||
|
Mesh->addMeshBuffer(IMB);
|
||||||
|
IMB->drop();
|
||||||
|
//std::cout << "Mesh now has "<<Mesh->getMeshBufferCount()<<" Buffers\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
aniMesh= new SAnimatedMesh();
|
||||||
|
aniMesh->addMesh(Mesh);
|
||||||
|
Mesh->drop();
|
||||||
|
Mesh = 0;
|
||||||
|
|
||||||
|
aniMesh->recalculateBoundingBox();
|
||||||
|
|
||||||
|
|
||||||
|
return aniMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,151 +1,199 @@
|
|||||||
#include "irrlicht/irrlicht.h"
|
#include "irrlicht/irrlicht.h"
|
||||||
#include "irrlicht/IMeshLoader.h"
|
#include "irrlicht/IMeshLoader.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
|
||||||
class CM2MeshFileLoader : public IMeshLoader
|
class CM2MeshFileLoader : public IMeshLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CM2MeshFileLoader(IrrlichtDevice* device);
|
CM2MeshFileLoader(IrrlichtDevice* device, c8* basedir);
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
~CM2MeshFileLoader();
|
virtual ~CM2MeshFileLoader();
|
||||||
|
|
||||||
//! returns true if the file maybe is able to be loaded by this class
|
//! returns true if the file maybe is able to be loaded by this class
|
||||||
//! based on the file extension (e.g. ".cob")
|
//! based on the file extension (e.g. ".cob")
|
||||||
virtual bool isALoadableFileExtension(const c8* fileName) const;
|
virtual bool isALoadableFileExtension(const c8* fileName)const;
|
||||||
|
|
||||||
//! creates/loads an animated mesh from the file.
|
//! creates/loads an animated mesh from the file.
|
||||||
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
//! \return Pointer to the created mesh. Returns 0 if loading failed.
|
||||||
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
|
||||||
//! See IUnknown::drop() for more information.
|
//! See IUnknown::drop() for more information.
|
||||||
virtual scene::IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
virtual scene::IAnimatedMesh* createMesh(irr::io::IReadFile* file);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
struct ModelHeader {
|
struct ModelHeader {
|
||||||
c8 id[4];
|
c8 id[4];
|
||||||
u8 version[4];
|
u8 version[4];
|
||||||
u32 nameLength;
|
u32 nameLength;
|
||||||
u32 nameOfs;
|
u32 nameOfs;
|
||||||
u32 type;
|
u32 type;
|
||||||
|
|
||||||
u32 nGlobalSequences;
|
u32 nGlobalSequences;
|
||||||
u32 ofsGlobalSequences;
|
u32 ofsGlobalSequences;
|
||||||
u32 nAnimations;
|
u32 nAnimations;
|
||||||
u32 ofsAnimations;
|
u32 ofsAnimations;
|
||||||
u32 nC;
|
u32 nC;
|
||||||
u32 ofsC;
|
u32 ofsC;
|
||||||
u32 nD;
|
u32 nD;
|
||||||
u32 ofsD;
|
u32 ofsD;
|
||||||
u32 nBones;
|
u32 nBones;
|
||||||
u32 ofsBones;
|
u32 ofsBones;
|
||||||
u32 nF;
|
u32 nF;
|
||||||
u32 ofsF;
|
u32 ofsF;
|
||||||
|
|
||||||
u32 nVertices;
|
u32 nVertices;
|
||||||
u32 ofsVertices;
|
u32 ofsVertices;
|
||||||
u32 nViews;
|
u32 nViews;
|
||||||
u32 ofsViews;
|
u32 ofsViews;
|
||||||
|
|
||||||
u32 nColors;
|
u32 nColors;
|
||||||
u32 ofsColors;
|
u32 ofsColors;
|
||||||
|
|
||||||
u32 nTextures;
|
u32 nTextures;
|
||||||
u32 ofsTextures;
|
u32 ofsTextures;
|
||||||
|
|
||||||
u32 nTransparency; // H
|
u32 nTransparency; // H
|
||||||
u32 ofsTransparency;
|
u32 ofsTransparency;
|
||||||
u32 nI; // always unused ?
|
u32 nI; // always unused ?
|
||||||
u32 ofsI;
|
u32 ofsI;
|
||||||
u32 nTexAnims; // J
|
u32 nTexAnims; // J
|
||||||
u32 ofsTexAnims;
|
u32 ofsTexAnims;
|
||||||
u32 nTexReplace;
|
u32 nTexReplace;
|
||||||
u32 ofsTexReplace;
|
u32 ofsTexReplace;
|
||||||
|
|
||||||
u32 nTexFlags;
|
u32 nTexFlags;
|
||||||
u32 ofsTexFlags;
|
u32 ofsTexFlags;
|
||||||
u32 nY;
|
u32 nY;
|
||||||
u32 ofsY;
|
u32 ofsY;
|
||||||
|
|
||||||
u32 nTexLookup;
|
u32 nTexLookup;
|
||||||
u32 ofsTexLookup;
|
u32 ofsTexLookup;
|
||||||
|
|
||||||
u32 nTexUnitLookup; // L
|
u32 nTexUnitLookup; // L
|
||||||
u32 ofsTexUnitLookup;
|
u32 ofsTexUnitLookup;
|
||||||
u32 nTransparencyLookup; // M
|
u32 nTransparencyLookup; // M
|
||||||
u32 ofsTransparencyLookup;
|
u32 ofsTransparencyLookup;
|
||||||
u32 nTexAnimLookup;
|
u32 nTexAnimLookup;
|
||||||
u32 ofsTexAnimLookup;
|
u32 ofsTexAnimLookup;
|
||||||
|
|
||||||
f32 floats[14];
|
f32 floats[14];
|
||||||
|
|
||||||
u32 nBoundingTriangles;
|
u32 nBoundingTriangles;
|
||||||
u32 ofsBoundingTriangles;
|
u32 ofsBoundingTriangles;
|
||||||
u32 nBoundingVertices;
|
u32 nBoundingVertices;
|
||||||
u32 ofsBoundingVertices;
|
u32 ofsBoundingVertices;
|
||||||
u32 nBoundingNormals;
|
u32 nBoundingNormals;
|
||||||
u32 ofsBoundingNormals;
|
u32 ofsBoundingNormals;
|
||||||
|
|
||||||
u32 nAttachments; // O
|
u32 nAttachments; // O
|
||||||
u32 ofsAttachments;
|
u32 ofsAttachments;
|
||||||
u32 nAttachLookup; // P
|
u32 nAttachLookup; // P
|
||||||
u32 ofsAttachLookup;
|
u32 ofsAttachLookup;
|
||||||
u32 nQ; // Q
|
u32 nQ; // Q
|
||||||
u32 ofsQ;
|
u32 ofsQ;
|
||||||
u32 nLights; // R
|
u32 nLights; // R
|
||||||
u32 ofsLights;
|
u32 ofsLights;
|
||||||
u32 nCameras; // S
|
u32 nCameras; // S
|
||||||
u32 ofsCameras;
|
u32 ofsCameras;
|
||||||
u32 nT;
|
u32 nT;
|
||||||
u32 ofsT;
|
u32 ofsT;
|
||||||
u32 nRibbonEmitters; // U
|
u32 nRibbonEmitters; // U
|
||||||
u32 ofsRibbonEmitters;
|
u32 ofsRibbonEmitters;
|
||||||
u32 nParticleEmitters; // V
|
u32 nParticleEmitters; // V
|
||||||
u32 ofsParticleEmitters;
|
u32 ofsParticleEmitters;
|
||||||
|
|
||||||
} header;
|
} header;
|
||||||
|
|
||||||
|
|
||||||
struct ModelVertex {
|
struct ModelVertex {
|
||||||
core::vector3df pos;//Use Irrlicht Vector here!
|
core::vector3df pos;//Use Irrlicht Vector here!
|
||||||
u8 weights[4];
|
u8 weights[4];
|
||||||
u8 bones[4];
|
u8 bones[4];
|
||||||
core::vector3df normal;//Use Irrlicht Vector here!
|
core::vector3df normal;//Use Irrlicht Vector here!
|
||||||
core::vector2df texcoords;//Use Irrlicht Vector here!
|
core::vector2df texcoords;//Use Irrlicht Vector here!
|
||||||
u32 unk1, unk2; // always 0,0 so this is probably unused
|
u32 unk1, unk2; // always 0,0 so this is probably unused
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ModelView {
|
struct ModelView {
|
||||||
u32 nIndex, ofsIndex; // Vertices in this model (index into vertices[])
|
u32 nIndex, ofsIndex; // Vertices in this model (index into vertices[])
|
||||||
u32 nTris, ofsTris; // indices
|
u32 nTris, ofsTris; // indices
|
||||||
u32 nProps, ofsProps; // additional vtx properties
|
u32 nProps, ofsProps; // additional vtx properties
|
||||||
u32 nSub, ofsSub; // materials/renderops/submeshes
|
u32 nSub, ofsSub; // materials/renderops/submeshes
|
||||||
u32 nTex, ofsTex; // material properties/textures
|
u32 nTex, ofsTex; // material properties/textures
|
||||||
s32 lod; // LOD bias?
|
s32 lod; // LOD bias?
|
||||||
};
|
};
|
||||||
|
|
||||||
// io::IFileSystem* FileSystem;
|
struct ModelViewSubmesh {
|
||||||
IrrlichtDevice* Device;
|
u32 meshpartId;
|
||||||
// scene::IMeshManipulator* Manipulator;
|
u16 ofsVertex;//Starting vertex number for this submesh
|
||||||
core::stringc M2MeshName;
|
u16 nVertex;
|
||||||
SAnimatedMesh* aniMesh;
|
u16 ofsTris;//Starting Triangle index
|
||||||
SMesh* Mesh;
|
u16 nTris;
|
||||||
//Taken from the Model file, thus m2M*
|
u16 unk1, unk2, unk3, unk4;
|
||||||
core::array<ModelVertex> M2MVertices;
|
core::vector3df v;
|
||||||
core::array<ModelView> M2MViews;
|
float unkf[4];
|
||||||
core::array<u16> M2MIndices;
|
};
|
||||||
core::array<u16> M2MTriangles;
|
|
||||||
//Used for the Mesh, thus m2_noM_*
|
|
||||||
core::array<video::S3DVertex> M2Vertices;
|
|
||||||
core::array<u16> M2Indices;
|
|
||||||
|
|
||||||
};
|
struct TextureDefinition {
|
||||||
}//namespace scene
|
u32 texType;
|
||||||
|
u16 unk;
|
||||||
|
u16 texFlags;
|
||||||
|
u32 texFileLen;
|
||||||
|
u32 texFileOfs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TextureUnit{
|
||||||
|
u16 Flags;
|
||||||
|
s16 renderOrder;
|
||||||
|
u16 submeshIndex1, submeshIndex2;
|
||||||
|
s16 colorIndex;
|
||||||
|
u16 renderFlagsIndex;
|
||||||
|
u16 TextureUnitNumber;
|
||||||
|
u16 unk1;
|
||||||
|
u16 textureIndex;
|
||||||
|
u16 TextureUnitNumber2;
|
||||||
|
u16 transparencyIndex;
|
||||||
|
u16 texAnimIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RenderFlags{
|
||||||
|
u16 flags;
|
||||||
|
u16 blending;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
io::IFileSystem* FileSystem;
|
||||||
|
IrrlichtDevice* Device;
|
||||||
|
// scene::IMeshManipulator* Manipulator;
|
||||||
|
core::stringc M2MeshName;
|
||||||
|
core::stringc Basedir;
|
||||||
|
SAnimatedMesh* aniMesh;
|
||||||
|
SMesh* Mesh;
|
||||||
|
SMeshBuffer* IMB;
|
||||||
|
//Taken from the Model file, thus m2M*
|
||||||
|
core::array<ModelVertex> M2MVertices;
|
||||||
|
core::array<ModelView> M2MViews;
|
||||||
|
core::array<u16> M2MIndices;
|
||||||
|
core::array<u16> M2MTriangles;
|
||||||
|
core::array<ModelViewSubmesh> M2MSubmeshes;
|
||||||
|
core::array<u16> M2MTextureLookup;
|
||||||
|
core::array<TextureDefinition> M2MTextureDef;
|
||||||
|
core::array<std::string> M2MTextureFiles;
|
||||||
|
core::array<TextureUnit> M2MTextureUnit;
|
||||||
|
core::array<RenderFlags> M2MRenderFlags;
|
||||||
|
//Used for the Mesh, thus m2_noM_*
|
||||||
|
core::array<video::S3DVertex> M2Vertices;
|
||||||
|
core::array<u16> M2Indices;
|
||||||
|
|
||||||
|
};
|
||||||
|
}//namespace scene
|
||||||
}//namespace irr
|
}//namespace irr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user