SuperTuxKart
Loading...
Searching...
No Matches
sp_mesh_loader.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2017 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef HEADER_SP_MESH_LOADER_HPP
19#define HEADER_SP_MESH_LOADER_HPP
20
21#include "ge_animation.hpp"
22
23#include <IMeshLoader.h>
24#include <ISceneManager.h>
25#include <ISkinnedMesh.h>
26#include <IReadFile.h>
27#include <array>
28#include <vector>
29
30using namespace irr;
31
32class Material;
33
34class SPMeshLoader : public scene::IMeshLoader
35{
36private:
37
38 // ------------------------------------------------------------------------
39 unsigned m_bind_frame, m_joint_count, m_frame_count;
40 // ------------------------------------------------------------------------
41 std::vector<GE::Armature> m_all_armatures;
42 // ------------------------------------------------------------------------
43 std::vector<core::matrix4> m_to_bind_pose_matrices;
44 // ------------------------------------------------------------------------
45 enum SPVertexType: unsigned int
46 {
47 SPVT_NORMAL,
48 SPVT_SKINNED
49 };
50 // ------------------------------------------------------------------------
51 void decompress(irr::io::IReadFile* spm, unsigned vertices_count,
52 unsigned indices_count, bool read_normal, bool read_vcolor,
53 bool read_tangent, bool uv_one, bool uv_two,
54 SPVertexType vt, const video::SMaterial& m);
55 // ------------------------------------------------------------------------
56 void decompressGESPM(irr::io::IReadFile* spm, unsigned vertices_count,
57 unsigned indices_count, bool read_normal,
58 bool read_vcolor, bool read_tangent, bool uv_one,
59 bool uv_two, SPVertexType vt,
60 const video::SMaterial& m);
61 // ------------------------------------------------------------------------
62 void decompressSPM(irr::io::IReadFile* spm, unsigned vertices_count,
63 unsigned indices_count, bool read_normal,
64 bool read_vcolor, bool read_tangent, bool uv_one,
65 bool uv_two, SPVertexType vt,
66 Material* m);
67 // ------------------------------------------------------------------------
68 void createAnimationData(irr::io::IReadFile* spm);
69 // ------------------------------------------------------------------------
70 void convertIrrlicht();
71
72 scene::IAnimatedMesh* m_mesh;
73
74 scene::ISceneManager* m_scene_manager;
75
76 std::vector<std::vector<
77 std::pair<std::array<short, 4>, std::array<float, 4> > > > m_joints;
78
79public:
80 // ------------------------------------------------------------------------
81 SPMeshLoader(scene::ISceneManager* smgr) : m_scene_manager(smgr) {}
82 // ------------------------------------------------------------------------
83 virtual bool isALoadableFileExtension(const io::path& filename) const;
84 // ------------------------------------------------------------------------
85 virtual scene::IAnimatedMesh* createMesh(io::IReadFile* file);
86
87};
88
89#endif
90
Definition: material.hpp:48
Definition: sp_mesh_loader.hpp:35