//==========================================================================//// Function to load a config file from a binary resource ////==========================================================================//bool LoadConfigFromResource(CConfigFile& rConfig, const std::string& strName){CBinaryResource* pResource; // Load the resource // pResource = (CBinaryResource*)CResourceManager::Get().GetResource(strName.c_str(),CResource::Binary); if(!pResource) return false; // Load the config // rConfig.Release(); if(!rConfig.Load(ReadLineFromResource,pResource)) { pResource->Release(); return false; } // Cleanup and return // pResource->Release(); return true;}//==========================================================================//// Function to read a line from a resource. CConfigFile::Load() callback ////==========================================================================//bool ReadLineFromResource(std::string& rLine, void* pContext){CBinaryResource* pResource = (CBinaryResource*)pContext;char ch; rLine = ""; // First, Eat '\r' & '\n' // do { if(!pResource->ReadByte((BYTE&)ch)) return false; } while((ch == '\r') || (ch == '\n')); // Read up to next '\r' or '\n' // do { rLine += ch; if(!pResource->ReadByte((BYTE&)ch)) return (rLine.length() != 0); } while((ch != '\r') && (ch != '\n')); return true;}
And I also edited my CBinaryResource class slightly, to include a position member. That lets you read from it in a more sane way, using fread()like functions.
I also started a bit of work on my animation classes. At the moment, I have CAnimation, which holds a series of frames and delays which make up one animation (e.g. a walk loop or an idle loop), and a CAnimationSet class which holds all of a characters animations (a walk animation, idle animation, etc etc).
I currently load an animation from a config file, the sample one I'm using is this:
# General character information[Character]Width = 64Height = 128# Animations this character can do# Format:# AnimationName = FrameName:Delay, FrameName:Delay, ...[Animations]Walk = Walk00.bmp:100, Walk01.bmp:100, Walk02.bmp:100, Walk03.bmp:100, Walk04.bmp:100, Walk05.bmp:100Idle = Idle00.bmp:1000
I'm loading each individual texture into each frame of the animation, and once I've loaded all of the animations, I'll composite them onto as few textures as possible (ideally 1 texture), and use texture coordinates to address each frame.
That won't be done for a while though, since I'll need to add clothing on top of the body to save on rendering stuff over and over.
In other news, I found 24 videos about string theory, which someone linked to somewhere in the lounge I think. So anyway, there's sod all on TV tonight, so I'll be watching those videos shortly.