Fillwave  10.0.0
TModelLoader.h
1 #pragma once
2 
3 /*
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2018 Filip Wasil and Fillwave community members
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <flw/flf/loaders/modelloader/ModelLoaderTraits.h>
25 #include <flw/cmn/Material.h>
26 #include <flw/cmn/Empty.h>
27 #include <flw/flf/loaders/modelloader/AnimatorDefault.h>
28 
29 namespace flw {
30 
31 struct Material;
32 
33 namespace flc {
34 class IndexBuffer;
35 class VertexBufferBasic;
36 }
37 
38 namespace flf {
39 
40 class Animator;
41 class Entity;
42 struct PhysicsMeshBuffer;
43 
44 template <class Traits>
45 struct TModelLoader final {
46  template <typename C>
47  static typename C::NodeType getNodeType(bool);
48  template <typename C>
49  static flw::Empty getNodeType(...);
50 
51  using NodeType = decltype(getNodeType<Traits>(0));
52 
53  template <typename C>
54  static typename C::SceneType getSceneType(bool);
55  template <typename C>
56  static flw::Empty getSceneType(...);
57 
58  using SceneType = decltype(getSceneType<Traits>(0));
59 
60  template <typename C>
61  static typename C::ShapeType getShapeType(bool);
62  template <typename C>
63  static flw::Empty getShapeType(...);
64 
65  using ShapeType = decltype(getShapeType<Traits>(0));
66 
67  template <typename C>
68  static typename C::MaterialType getMaterialType(bool);
69  template <typename C>
70  static flw::Empty getMaterialType(...);
71 
72  using MaterialType = decltype(getMaterialType<Traits>(0));
73 
74  template <typename C>
75  static typename C::TextureType getTextureType(bool);
76  template <typename C>
77  static flw::Empty getTextureType(...);
78 
79  using TextureType = decltype(getTextureType<Traits>(0));
80 
81  template <typename C>
82  static typename C::String getString(bool);
83  template <typename C>
84  static flw::Empty getString(...);
85 
86  using String = decltype(getString<Traits>(0));
87 
88  template <typename C>
89  static typename C::Animator getAnimator(bool);
90  template <typename C>
91  static AnimatorDefault getAnimator(...);
92 
93  using Animator = decltype(getAnimator<Traits>(0));
94 
96  const ShapeType* shape;
97  const Material material;
98  const std::string diffuse;
99  const std::string normal;
100  const std::string specular;
101  };
102 
103  static constexpr int COUNT_BONES_DEFINED = Traits::COUNT_BONES_DEFINED;
104  static constexpr int COUNT_BONES_USED = Traits::COUNT_BONES_USED;
105  static constexpr int FLAG_ANIMATION_OFF = Traits::FLAG_ANIMATION_OFF;
106 
107  static void getPhysicsBuffer(const char*, PhysicsMeshBuffer& buffer);
108  static const Material getMaterial(const MaterialType& material);
109  static ::flw::flc::IndexBuffer* getIndexBuffer(const ShapeType* shape);
110  static ::flw::flc::VertexBufferBasic* getVertexBuffer(const ShapeType *shape, Animator *a);
111  static void setTransformation (const NodeType* node, Entity* entity);
112  static std::vector<MeshCreationInfo> getMeshes(const NodeType* node, const SceneType& scene);
113  static std::vector<NodeType*> getChildren(const NodeType*);
114  static NodeType* getRootNode(const SceneType&);
115  static Animator* getAnimator(const SceneType&);
116 };
117 
118 } /* flf */
119 } /* flw */
Definition: Aliases.h:30
Per mesh material info.
Definition: Material.h:32
Definition: TModelLoader.h:45
Definition: AnimatorDefault.h:35
Base for all Scene nodes.
Definition: Entity.h:48
Empty class for various purposes.
Definition: Empty.h:30
Physical mesh data.
Definition: PhysicsMeshBuffer.h:33
Definition: TModelLoader.h:95