Import .mesh file binary into entity dynamically

Problems building or running the engine, queries about how to use features etc.
Post Reply
jack
Gnoblar
Posts: 1
Joined: Sat Dec 02, 2017 9:23 pm

Import .mesh file binary into entity dynamically

Post by jack »

I'm working on a project that effectively acts as JavaScript bindings for Ogre. As a result, I'm doing file loading on the JavaScript side and trying to pass it to Ogre.

Here's how I'm attempting to use a buffer that has the contents of a .mesh file:

Code: Select all

 
  // buffer_str is a std::string with sphere.mesh's contents
  // mSceneMgr is an Ogre scene manager
  Ogre::DataStreamPtr stream = Ogre::DataStreamPtr(new Ogre::MemoryDataStream(buffer_str.data(), buffer_str.size()));
  Ogre::ResourceGroupManager groupMgr;
  groupMgr.createResourceGroup("foo");
  Ogre::MeshPtr m = Ogre::MeshPtr(Ogre::MeshManager::getSingleton().createManual(
    "bar.mesh",
    "foo"
  ));
  Ogre::MeshSerializer mSerializer;
  mSerializer.importMesh(stream, m.getPointer());
  Ogre::Entity* entity = mSceneMgr->createEntity(id, m);
When I run this, I get:
An exception has occurred: OGRE EXCEPTION(2:InvalidParametersException): Header chunk didn't match either endian: Cor
rupted stream? in Serializer::determineEndianness at /home/jack/ogre/OgreMain/src/OgreSerializer.cpp (line 90)
I know the data I'm reading in is good because if I write it back out to file and import it the conventional way I don't have a problem loading it.

Anyone know what API calls I'm getting wrong here?
Post Reply