diff options
| author | Stephen Simpson <megazig@gmail.com> | 2011-10-12 23:05:13 -0500 | 
|---|---|---|
| committer | Stephen Simpson <megazig@gmail.com> | 2011-10-12 23:05:13 -0500 | 
| commit | 7a4ee17ea46742a5aff331ad195eb5be098c01b2 (patch) | |
| tree | 8921aba11b849423c2f52e05d902a330a43bc853 | |
| parent | cccb93935e965e10613b16a93aa6970f5f7975aa (diff) | |
| download | kamek-7a4ee17ea46742a5aff331ad195eb5be098c01b2.tar.gz kamek-7a4ee17ea46742a5aff331ad195eb5be098c01b2.zip | |
Started adding animations in. also fix for updated effects
Diffstat (limited to '')
| -rw-r--r-- | include/g3dhax.h | 179 | ||||
| -rw-r--r-- | src/effects.cpp | 8 | 
2 files changed, 171 insertions, 16 deletions
| diff --git a/include/g3dhax.h b/include/g3dhax.h index d816a24..ddeb3ee 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -1,6 +1,8 @@  #ifndef __KAMEK_G3DHAX_H  #define __KAMEK_G3DHAX_H +#include <common.h> +  // nw4r::g3d wrapper  namespace nw4r { @@ -26,6 +28,10 @@ namespace nw4r {  				void * /*ResMat*/ GetResMat(const char *str) const;  		}; +		class ResAnmChr { public: void* data; ResAnmChr(void *p = NULL) { data = p; } }; +		class ResAnmTexPat { public: void* data; ResAnmTexPat(void *p = NULL) { data = p; } }; +		class ResAnmTexSrt { public: void* data; ResAnmTexSrt(void *p = NULL) { data = p; } }; +  		class ResFile {  			public:  				void * /*ResFileData*/ data; @@ -42,11 +48,11 @@ namespace nw4r {  				void * /*ResTex*/ GetResTex(const char *str) const;  				void * /*ResTex*/ GetResTex(const ResName n) const;  				void * /*ResTex*/ GetResTex(u32 idx) const; -				void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; +				ResAnmChr GetResAnmChr(const char *str) const;  				void * /*ResAnmVis*/ GetResAnmVis(const char *str) const;  				void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; -				void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; -				void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; +				ResAnmTexPat GetResAnmTexPat(const char *str) const; +				ResAnmTexSrt GetResAnmTexSrt(const char *str) const;  				void * /*ResAnmScn*/ GetResAnmScn(const char *str) const;  				bool Bind(ResFile rhs); @@ -133,19 +139,40 @@ namespace nw4r {  } -class mHeapAllocator_c { // Actually that weird subclass. INCOMPLETE!! +namespace EGG { +	class Allocator { +		public: +			char data1[0x10]; + +			Allocator(void *heap, s32 align); +			virtual ~Allocator(); + +			virtual void *alloc(u32 size); +			virtual void free(void *block); + +			void *heap; +			s32 alignment; +	}; +} + +class mAllocator_c : public EGG::Allocator {  	public: -		char data1[0x10]; +		mAllocator_c(); +		~mAllocator_c(); + +		void *alloc(u32 size); +		void free(void *block); +}; +class mHeapAllocator_c : public mAllocator_c { +	public:  		mHeapAllocator_c(); -		virtual ~mHeapAllocator_c(); -		virtual void *alloc(u32 size); -		virtual void free(void *block); +		~mHeapAllocator_c();  		bool link(s32 size, void *heap, const char *name, int align);  		u32 unlink(); -		char data2[8]; +		bool linkAndBecomeCurrentHeap(s32 size, void *heap, const char *name, int align);  };  namespace m3d { @@ -186,6 +213,8 @@ namespace m3d {  			void *scnObj;  	}; +	class banm_c; +  	class mdl_c {  		public:  			mdl_c(); @@ -202,12 +231,138 @@ namespace m3d {  			void sub_80064BF0();  			void setDrawMatrix(const Mtx matrix); -			void setScale(float x, float y, float z); -			void setScale(Vec *scale); -			void calcWorld(bool unk); + +			void bindAnim(banm_c *animation, float unk);  			char data[0x3C];  	}; + + + + +	class banm_c { +		public: +			virtual ~banm_c(); + +			virtual int _vf0C() = 0; +			virtual void detach(); +			virtual void process(); + +			bool testAnmFlag(u32 flag); /* nw4r::g3d::AnmObj::AnmFlag */ + +			void *anmObj; // should be NW4R AnmObj class +			void *frameHeap; // should be a frame heap +			mAllocator_c allocator; + +		private: +			void setupHeap(mAllocator_c *allocator, u32 *sizeOutput); +			float _getCurrentFrame(); +			float _setCurrentFrame(float value); +			float _getUpdateRate(); +			float _setUpdateRate(float value); +	}; + +	class fanm_c : public banm_c { +		public: +			fanm_c(); +			~fanm_c(); + +			void process(); + +			void _80169050(float _unk, float updateRate, float _unk2, u8 _unk3); +			void setCurrentFrame(float value); +			bool isAnimationDone(); // I think +			bool querySomething(float value); + +			// 28 might be Max Frame? +			float _28, _2C, currentFrame; +			u8 _34; +	}; + +	class anmChr_c : public fanm_c { +		public: +			~anmChr_c(); +			int _vf0C(); + +			bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmChr anmRes, +					mAllocator_c *allocator, u32 *sizeOutPtr); + +			void bind(/*b*/mdl_c *model, nw4r::g3d::ResAnmChr anmRes, int unk); +	}; + +	class anmTexPat_c : public banm_c { +		public: +			class child_c : public fanm_c { +				~child_c(); +				int _vf0C(); + +				// some methods missing +			}; + +			// some methods missing + +			~anmTexPat_c(); +			int _vf0C(); +			void detach(); +			void process(); + +			bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmTexPat anmRes, +					mAllocator_c *allocator, u32 *sizeOutPtr, int count); + +			void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexPat resource, +					int entryNumber, int _param4); + +			float getFrameForEntry(int number); +			void setFrameForEntry(float value, int number); +			float getUpdateRateForEntry(int number); +			void setUpdateRateForEntry(float value, int number); +			bool isEntryAnimationDone(int number); +			bool queryEntrySomething(float value, int number); +			void setEntryByte34(u8 value, int number); +			float getEntryField28(int number); + +		private: +			child_c *children; + +			void processOneEntry(int number); +	}; + +	class anmTexSrt_c : public banm_c { +		public: +			class child_c : public fanm_c { +				~child_c(); +				int _vf0C(); + +				// some methods missing +			}; + +			// some methods missing + +			~anmTexSrt_c(); +			int _vf0C(); +			void detach(); +			void process(); + +			bool setup(nw4r::g3d::ResMdl modelRes, nw4r::g3d::ResAnmTexSrt anmRes, +					mAllocator_c *allocator, u32 *sizeOutPtr, int count); + +			void bindEntry(/*b*/mdl_c *model, nw4r::g3d::ResAnmTexSrt resource, +					int entryNumber, int _param4); + +			float getFrameForEntry(int number); +			void setFrameForEntry(float value, int number); +			float getUpdateRateForEntry(int number); +			void setUpdateRateForEntry(float value, int number); +			bool isEntryAnimationDone(int number); +			void setEntryByte34(u8 value, int number); +			float getEntryField28(int number); +			float getEntryField2C(int number); + +		private: +			child_c *children; + +			void processOneEntry(int number); +	};  }; diff --git a/src/effects.cpp b/src/effects.cpp index 8d0e565..40f08a2 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1004,7 +1004,7 @@ const char* effects_name_list [] = {  	"Wm_ob_treasureboxwait_b"  }; -extern "C" void SpawnEffect(const char*, int, Vec*, int, int); +extern "C" bool SpawnEffect(const char*, int, Vec*, S16Vec*, Vec*);  // Just call CreateEffect(this, number_between_0_and_1000);  bool CreateEffect(dEn_c* enemy, int effect_num) { @@ -1022,7 +1022,7 @@ bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num) {  		return false;  	if (effect_num < 0)  		return false; -	Vec tempVec = (Vec){ pos.x, pos.y, 5500.0 }; +	Vec tempVec = (Vec){ pos->x, pos->y, 5500.0 };  	const char* effect_name = effects_name_list[effect_num];  	return SpawnEffect(effect_name, 0, &tempVec, rot, scale);  } @@ -1030,8 +1030,8 @@ bool CreateEffect(Vec* pos, S16Vec* rot, Vec* scale, int effect_num) {  bool CreateEffect(const char* name, Vec* pos) {  	//check effects name list  	bool exists = false; -	for( int ii = 0; ii < sizeof(effect_name_list); ii++) { -		if (strncmp(name, effects_name_list[ii], strlen(effects_name_list) ) ) { +	for( int ii = 0; ii < sizeof(effects_name_list); ii++) { +		if (memcmp(name, effects_name_list[ii], strlen(effects_name_list[ii]) ) ) {  			exists = true;  			break;  		} | 
