#ifndef __MODEL_s__ #define __MODEL_s__ #pragma once #include "ColladaModel.h" #include "tinyxml2.h" #include "geometry.h" #include "tgaimage.h" #include "joint.h" #include "animator.h" #include "animation.h" #include #include #include #include #include #include #include #include #include class ColladaModel { private: int face_count; int vertex_count; int joint_count; Joint rootjoint; int rootindex=0; char* rootname; Matrix root_transform; //Animator animator; std::vector > faces_; //vertex/normal/uv std::vector vertices_; std::vector normals_; std::vector texturecos_; // #include // map joint_names; // joints.add(pair("TORSO", 0)); // {TORSO, 0} // {LEG, 1} // {HAND, 2} //joint_names.get("TORSO"); // 1. Get jointnames and map them to ids // 2. get each joint and fill in the Joint class // 3. get inversebindtransforms // Vector -> Vectors -> (joint , weight) std::vector> vertexweights_; //joint/weight std::vector jointIDs_; // { TORSO , LEG, TEZ} // { 0, 1, 2} // jointIDs[0] std::vector weights_; TGAImage diffusemap_; TGAImage normalmap_; TGAImage specularmap_; void load_texture(std::string filename, const char* suffix, TGAImage& img); public: ColladaModel() = default; ColladaModel(const char* filename); ~ColladaModel(); int nfaces(); int nvertices(); Vec3f vertix(int iface, int nthvert); Vec3f vertix(int i); Vec3f normal(int iface, int nthvert); Vec3f normal(Vec2f uv); Vec2f uv(int iface, int nthvert); Matrix Transform; Matrix Rotation; Matrix Scale; Matrix Translation; void translate(Vec3f tr); void rotate(Vec3f rot); void scale(Vec3f scl); void ApplyTransform(); TGAColor diffuse(Vec2f uv); float specular(Vec2f uv); std::vector face(int idx); ///////////////////////////// Joint getrootjoint(); void doanimation(Animation animation); void updateanimator(); std::vector getjointtransforms(); void addjointtoarray(Joint parent, std::vector); }; #endif