Hey all, I'm currently working on a game/engine, just for educational sake, and I've come to a hurdle, I want to be able to save and load scenes from a file, I dont care if it is ascii or binary, but as I hope you can see from the scene class below is that the scene has a list of all the meshes, and textures, and a list of "mesh nodes", with each mesh node containing a pointer to a mesh to be rendered, as well as a pointer to the texture to use, and its position and rotation.
My main problem is that obviously a dump of a pointer is not going to mean anything when it is reloaded.
I've read one of the articles in the enginuity series about data serialization, but it seamed overly complicated, and I was looking at a smaller solution.
my scene class...
class Scene
{
public:
Scene(Mouse *pMouse, Keyboard *pKeyboard);
Mesh *addMesh(const char *pFileName);
void removeMesh(Mesh *pMesh);
MeshNode *addMeshNode();
void removeMeshNode(MeshNode *pMeshNode);
Texture *addTexture(const char *pFileName);
void removeTexture(Texture *pTexture);
Camera *setCamera(Vector3f pPosition, float pYaw, float pPitch);
void update();
void beginScene();
void endScene();
void render();
void removeAll();
bool saveScene(const char *pFileName);
bool loadScene(const char *pFileName);
protected:
Camera mCamera;
std::list<Mesh *> mMesh;
std::list<MeshNode *> mMeshNode;
std::list<Texture *> mTexture;
Keyboard *mKeyboard;
Mouse *mMouse;
};
how I've been creating my scenes so far...
Mesh *mesh = sceneManager->addMesh("data/spaceship.3ds");
Texture *texture = sceneManager->addTexture("data/spaceshiptexture.bmp");
MeshNode *meshNode = sceneManager->addMeshNode();
meshNode->setMesh(mesh);
meshNode->setPosition(Vector3f(-100.0f, 0.0f, 0.0f));
meshNode->setRotation(Vector3f(0.0f, 0.0f, -10.0f));
meshNode->setTexture(texture);
Thanks in advance