mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-25 15:42:25 +01:00
IMeshLoader can now set hints to prefer 16/32 bit buffers. Obj loader can now load 32 bit buffers.
- IMeshLoader::setPreferredIndexType and getPreferredIndexType allow setting hints for the loaders if users prefer 16 or 32 bit meshbuffers. Loaders are free to ignore those hints (all but .obj will do that for now). - obj meshloader loads now 32-bit buffers when setPreferredIndexType is set to EIT_32BIT. NOTE: It's 16 bit meshes use now also an IDynamicMeshbuffer instead of an SMeshBuffer. That will break the code of people who accessed meshbuffer before by casting to SMeshBuffer* And might even be somewhat slower (lot's of virtual functions...), but shouldn't really matter and can maybe be a bit improved. Sorry about that, I considered keeping SMeshBuffer for 16-bit (still considering it), but it would add some overhead in code and I don't think it's worth that. If there are any complains I'll maybe consider it again. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6333 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
456bf86e66
commit
c58afe8038
@ -1,5 +1,8 @@
|
||||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
- obj meshloader can now load 32-bit buffers when setPreferredIndexType is set to EIT_32BIT.
|
||||
It's 16 bit meshes use now also an IDynamicMeshbuffer instead of an SMeshBuffer.
|
||||
- Add IMeshLoader::setPreferredIndexType and getPreferredIndexType to allow setting hints for the loaders if users prefer 16 or 32 bit meshbuffers.
|
||||
- Add IMeshBuffer::getType to allow finding out which class type a meshbuffer has (similar to ISceneNode::getType).
|
||||
- Add IGUIImage::flip to flip/mirror images
|
||||
- IBillboardSceneNode got functions to access meshbuffers. So uv-coordinates can now be modified directly (previously only possible via texture matrix).
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "IReferenceCounted.h"
|
||||
#include "path.h"
|
||||
#include "IMeshTextureLoader.h"
|
||||
#include "SVertexIndex.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -29,7 +30,7 @@ class IMeshLoader : public virtual IReferenceCounted
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
IMeshLoader() : TextureLoader(0) {}
|
||||
IMeshLoader() : TextureLoader(0), PreferredIndexType(video::EIT_16BIT) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~IMeshLoader()
|
||||
@ -78,8 +79,30 @@ public:
|
||||
return TextureLoader;
|
||||
}
|
||||
|
||||
//! Give loader a hint if you would prefer 16 or 32 bit meshbuffers.
|
||||
/**
|
||||
Generally Irrlicht works with 16-bit meshbuffers so far.
|
||||
Rendering 32-bit meshbuffers works, other functions like
|
||||
mesh-writing and mesh manipulation might not work yet.
|
||||
NOTE: Most loaders will ignore this hint so far, but hopefully
|
||||
will care about it in the future.
|
||||
*/
|
||||
void setPreferredIndexType(irr::video::E_INDEX_TYPE typeHint)
|
||||
{
|
||||
PreferredIndexType = typeHint;
|
||||
}
|
||||
|
||||
//! Return current preference user has for the index-size of meshbuffers
|
||||
/** Note that this is _not_ necessarily the type used by the meshloader */
|
||||
irr::video::E_INDEX_TYPE getPreferredIndexType() const
|
||||
{
|
||||
return PreferredIndexType;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
IMeshTextureLoader* TextureLoader;
|
||||
irr::video::E_INDEX_TYPE PreferredIndexType;
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
core::array<core::vector3df, core::irrAllocatorFast<core::vector3df> > normalsBuffer(1000);
|
||||
core::array<core::vector2df, core::irrAllocatorFast<core::vector2df> > textureCoordBuffer(1000);
|
||||
|
||||
SObjMtl * currMtl = new SObjMtl();
|
||||
SObjMtl * currMtl = new SObjMtl(PreferredIndexType);
|
||||
Materials.push_back(currMtl);
|
||||
u32 smoothingGroup=0;
|
||||
|
||||
@ -224,6 +224,8 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
v.Color = currMtl->Meshbuffer->Material.DiffuseColor;
|
||||
|
||||
// get all vertices data in this face (current line of obj file)
|
||||
IVertexBuffer& mbVertexBuffer = currMtl->Meshbuffer->getVertexBuffer();
|
||||
IIndexBuffer& mbIndexBuffer = currMtl->Meshbuffer->getIndexBuffer();
|
||||
const core::stringc wordBuffer = copyLine(bufPtr, bufEnd);
|
||||
const c8* linePtr = wordBuffer.c_str();
|
||||
const c8* const endPtr = linePtr+wordBuffer.size();
|
||||
@ -272,8 +274,8 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
}
|
||||
else
|
||||
{
|
||||
currMtl->Meshbuffer->Vertices.push_back(v);
|
||||
vertLocation = currMtl->Meshbuffer->Vertices.size() -1;
|
||||
mbVertexBuffer.push_back(v);
|
||||
vertLocation = mbVertexBuffer.size() -1;
|
||||
currMtl->VertMap.insert(v, vertLocation);
|
||||
}
|
||||
|
||||
@ -292,9 +294,9 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
const int b = faceCorners[i];
|
||||
if (a != b && a != c && b != c) // ignore degenerated faces. We can get them when we merge vertices above in the VertMap.
|
||||
{
|
||||
currMtl->Meshbuffer->Indices.push_back(a);
|
||||
currMtl->Meshbuffer->Indices.push_back(b);
|
||||
currMtl->Meshbuffer->Indices.push_back(c);
|
||||
mbIndexBuffer.push_back(a);
|
||||
mbIndexBuffer.push_back(b);
|
||||
mbIndexBuffer.push_back(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -577,7 +579,7 @@ void COBJMeshFileLoader::readMTL(const c8* fileName, const io::path& relPath)
|
||||
c8 mtlNameBuf[WORD_BUFFER_LENGTH];
|
||||
bufPtr = goAndCopyNextWord(mtlNameBuf, bufPtr, WORD_BUFFER_LENGTH, bufEnd);
|
||||
|
||||
currMaterial = new SObjMtl;
|
||||
currMaterial = new SObjMtl(PreferredIndexType);
|
||||
currMaterial->Name = mtlNameBuf;
|
||||
}
|
||||
break;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "IFileSystem.h"
|
||||
#include "ISceneManager.h"
|
||||
#include "irrString.h"
|
||||
#include "SMeshBuffer.h"
|
||||
#include "CDynamicMeshBuffer.h"
|
||||
#include "irrMap.h"
|
||||
|
||||
namespace irr
|
||||
@ -42,10 +42,10 @@ private:
|
||||
|
||||
struct SObjMtl
|
||||
{
|
||||
SObjMtl() : Meshbuffer(0), Bumpiness (1.0f), Illumination(0),
|
||||
SObjMtl(irr::video::E_INDEX_TYPE indexType) : IndexType(indexType), Meshbuffer(0), Bumpiness (1.0f), Illumination(0),
|
||||
RecalculateNormals(false)
|
||||
{
|
||||
Meshbuffer = new SMeshBuffer();
|
||||
Meshbuffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, IndexType);
|
||||
Meshbuffer->Material.Shininess = 0.0f;
|
||||
Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor();
|
||||
Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor();
|
||||
@ -53,16 +53,17 @@ private:
|
||||
}
|
||||
|
||||
SObjMtl(const SObjMtl& o)
|
||||
: Name(o.Name), Group(o.Group),
|
||||
: IndexType(o.IndexType), Name(o.Name), Group(o.Group),
|
||||
Bumpiness(o.Bumpiness), Illumination(o.Illumination),
|
||||
RecalculateNormals(false)
|
||||
{
|
||||
Meshbuffer = new SMeshBuffer();
|
||||
Meshbuffer = new CDynamicMeshBuffer(irr::video::EVT_STANDARD, IndexType);
|
||||
Meshbuffer->Material = o.Meshbuffer->Material;
|
||||
}
|
||||
|
||||
core::map<video::S3DVertex, int> VertMap;
|
||||
scene::SMeshBuffer *Meshbuffer;
|
||||
irr::video::E_INDEX_TYPE IndexType;
|
||||
scene::CDynamicMeshBuffer *Meshbuffer;
|
||||
core::stringc Name;
|
||||
core::stringc Group;
|
||||
f32 Bumpiness;
|
||||
|
@ -1,4 +1,4 @@
|
||||
Tests finished. 72 tests of 72 passed.
|
||||
Compiled as DEBUG
|
||||
Test suite pass at GMT Wed Apr 06 20:16:43 2022
|
||||
Test suite pass at GMT Thu Apr 14 13:52:29 2022
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user