00001 #pragma once
00002 #include "types.h"
00003 #include <fstream>
00004
00005
00006
00007
00008 float Deg2Rad (float fDeg);
00009 float Rad2Deg(float fRad);
00010 vec3f transformVector(vec3f v3f, float m16[16]);
00011 void myMultMatrix(float A[16], float B[16], float RESULT[16]);
00012 void copymatrix(float DEST[16], float SOURCE[16]);
00013 void cleanupmatrix(float M[16]);
00014 void applytransformation(bone_t *bone, float transformationmatrix[16]);
00015 float interpolate(float oldvalue, float newvalue, float totaltime, float dt);
00016 void createunitymatrix(float [16]);
00017
00018
00019
00020
00021 void getXRotationMatrix(float m[16], float pitch);
00022 void getYRotationMatrix(float m[16], float yaw);
00023 void getZRotationMatrix(float m[16], float azimuth);
00024 void getTranslationMatrix(float m[16], float x, float y, float z);
00025 void normalizeVector(vec3f v);
00026 void calculateNormal(vec3f result, vec3f p1, vec3f p2, vec3f p3);
00027 void crossProduct(vec3f *n, vec3f *v1, vec3f *v2);
00028
00029
00030
00031
00032 void rotatebone(bone_t *bone, bone_t *parentbone, float pitch, float yaw, float azimuth);
00033 void drawbone(bone_t *bone, bone_t *selectedbone, int flags);
00034 void draw(bone_t *root);
00035 void initmatrix(bone_t *bone);
00036 bone_t *getboneforindex(int i, bone_t *root);
00037 int updateskeleton(skeleton_t *skeleton, keyframe_t oldstate, keyframe_t newstate, int dt);
00038 int resetbones(bone_t *root);
00039 int countchildren(bone_t *root);
00040
00041 int updatemodel(model_t *model, skeleton_t *skeleton, keyframe_t oldstate, keyframe_t newstate, float dt);
00042 int rebuildskeleton(bone_t *root, float ACCUMULATION_MATRIX[16]);
00043 int skin_mesh(model_t *model, skeleton_t *skeleton);
00044 int createvertexmapping(model_t *model, bone_t* root);
00045
00046
00047
00048
00049 int updateanimation(model_t *model, float now);
00050 keyframe_t *getkeyframe(keyframelibrary_t *library, char *_lpcstrName);
00051 int replacekeyframe(keyframelibrary_t *library, char *_lpcstrName, keyframe_t *_newkeyframe);
00052 keyframe_t *makekeyframe(int _iidx, char *_lpcstrName, float _fduration, vec3f _offset, bone_t *root);
00053 int fillkeyframe(keyframe_t *newkeyframe, bone_t *root);
00054 animation_t *getanimation(animationlibrary_t *library, char* _lpcstrName);
00055
00056
00057
00058
00059 void reshape(int w, int h);
00060 int handleInput(void);
00061
00062
00063
00064
00065 int loadskeleton(std::string filename, skeleton_t *skeleton);
00066 int loadkeyframes(std::string filename, keyframelibrary_t *library);
00067 int loadOBJ(std::string filename, model_t *model);
00068 int parsematerial(std::string filename, model_t *model);
00069 int loadvertexmapping(std::string filename, model_t *model);
00070 int loadanimations(std::string filename, animationlibrary_t *library);
00071
00072 int storeBoneRotations(fstream *f, bone_t *bone);
00073 int storeAllBones(fstream *f, bone_t *root);
00074
00075
00076
00077 float nextFloatFromString(char *, int&);
00078 int trimString(char *);
00079 int trimStringRight(char *);
00080 int firstWord(char *, int &, char *);
00081 int trimleft(char *);
00082 int trimright(char *);
00083 int countslash(char *str);
00084 int getval(char *str, char *res, int &pos);
00085 int getpart(char * str, char * result, int &pos);
00086
00087
00088
00089
00090 int getindex(vector<int> v, int a);
00091
00092
00093
00094
00095 int mapmaterial(std::string str, model_t *model);
00096 void displaymodel(model_t *model, int flags, int selectedvertex);
00097 int skinmesh(model_t *model, skeleton_t *skeleton);
00098 int displaymesh(model_t *model, int flags);
00099 int outlinemappedvertices(model_t *model);
00100 int BeginWithZero(model_t *model);
00101
00102
00103
00104
00105 int transformboundingbox(bone_t *root);
00106 int resetbounds(vec3f bounds[8], vec3f *minvalues, vec3f *maxvalues);
00107 int drawboundingbox(boundingbox_t *boundingbox);
00108 int getminima(vec3f bounds[8], vec3f *result);
00109 int getmaxima(vec3f bounds[8], vec3f *result);
00110 int checkcollision(boundingbox_t *box1, boundingbox_t *box2);
00111 int reboundmodel(model_t *model);
00112
00113
00114
00115
00116 vec3f calculatenormal(vec3f *p1, vec3f *p2, vec3f *p3);
00117 int checknormals(model_t *model);