Displaying: model_ff11.h | View full page

// Noesis FF11 support
// Life regrettably wasted by Rich Whitehouse
// (c) Never, all rights to be taken to the grave.
#pragma once

#ifndef _MODEL_FF11_H
#define _MODEL_FF11_H

#include <vector>
#include <map>
#include <algorithm>

class CFFXIChunkHandler;


class CFFXIDat
	static const int skChunkType_Texture = 0x20;
	static const int skChunkType_Skeleton = 0x29;
	static const int skChunkType_Geo = 0x2A;
	static const int skChunkType_Animation = 0x2B;
	static const int skChunkType_Map = 0x1C;
	static const int skChunkType_MapGeo = 0x2E;
	static const int skBinaryChunkSize = 16;

	enum EValidateChunkResult
		kVCR_Invalid = 0,

	struct SChunk
		explicit SChunk(const unsigned char *pData, const int chunkOffset)
			memcpy(mName, pData, 4);
			mName[4] = 0;
			const unsigned int info = *(const unsigned int *)(pData + 4);
			mType = (info & 0x7F);
			mSize = ((info >> 3) & 0x7FFFF0);
			//are low 4 bits ever set?
			mDataOffset = chunkOffset + skBinaryChunkSize;

		char mName[8];
		int mType;
		int mDataOffset;
		int mSize;
	typedef std::vector<SChunk> TChunkList;

	explicit CFFXIDat(unsigned char *pData, const int dataSize, noeRAPI_t *pRapi)
		: mpData(pData)
		, mDataSize(dataSize)
		, mpRapi(pRapi)

	EValidateChunkResult ValidateChunk(const SChunk &chunk) const;

	bool ParseChunksOfInterest();
	bool RunChunkHandlersForChunksOfInterest(const int forChunkType = -1) const;

	void RegisterChunkHandler(CFFXIChunkHandler *pChunkHandler);

	const unsigned char *GetData() const { return mpData; }
	int GetDataSize() const { return mDataSize; }

	noeRAPI_t *GetRAPI() const { return mpRapi; } //what a marine does after getting a girl drunk

	typedef std::map< int, CRefCountedPtr<CFFXIChunkHandler> > TChunkHandlerContainer;

	unsigned char *mpData;
	int mDataSize;
	noeRAPI_t *mpRapi;
	TChunkList mChunks; //only chunks of interest

	TChunkHandlerContainer mChunkHandlers;


class CFFXIChunkHandler : public CRefCountedObject
	explicit CFFXIChunkHandler(const int chunkType)
		: mChunkType(chunkType)

	virtual CFFXIDat::EValidateChunkResult ValidateChunk(const CFFXIDat &dat, const CFFXIDat::SChunk &chunk, 
															const unsigned char *pChunkData, const int dataSize) const = 0;
	virtual bool HandleChunk(const CFFXIDat &dat, const CFFXIDat::SChunk &chunk,
								const unsigned char *pChunkData, const int dataSize) = 0;

	int GetChunkType() const { return mChunkType; }

	int mChunkType;


class CFFXITextureHandler;
class CFFXISkelHandler;
class CFFXIAnimHandler;
class CFFXIGeoHandler;
class CFFXIMapHandler;
class CFFXIMapGeoHandler;

class CFFXIDefaultHandlerSet
	explicit CFFXIDefaultHandlerSet(CFFXIDat *pDat = NULL);

	void RegisterHandlersWithDat(CFFXIDat &dat);

	CFFXITextureHandler *TextureHandler() { return mpTextureHandler; }
	CFFXISkelHandler *SkelHandler() { return mpSkelHandler; }
	CFFXIAnimHandler *AnimHandler() { return mpAnimHandler; }
	CFFXIGeoHandler *GeoHandler() { return mpGeoHandler; }
	CFFXIMapHandler *MapHandler() { return mpMapHandler; }
	CFFXIMapGeoHandler *MapGeoHandler() { return mpMapGeoHandler; }
	CRefCountedPtr<CFFXITextureHandler> mpTextureHandler;
	CRefCountedPtr<CFFXISkelHandler> mpSkelHandler;
	CRefCountedPtr<CFFXIAnimHandler> mpAnimHandler;
	CRefCountedPtr<CFFXIGeoHandler> mpGeoHandler;
	CRefCountedPtr<CFFXIMapHandler> mpMapHandler;
	CRefCountedPtr<CFFXIMapGeoHandler> mpMapGeoHandler;

#endif //_MODEL_FF11_H

2823389 page hits since February 11, 2009.

Site design and contents (c) 2009 Rich Whitehouse. Except those contents which happen to be images or screenshots containing shit that is (c) someone/something else entirely. That shit isn't really mine. Fair use though! FAIR USE!
All works on this web site are the result of my own personal efforts, and are not in any way supported by any given company. You alone are responsible for any damages which you may incur as a result of this web site or files related to this web site.