Cafu Engine
Loader_ase.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_ASE_MODEL_LOADER_HPP_INCLUDED
8 #define CAFU_ASE_MODEL_LOADER_HPP_INCLUDED
9 
10 #include "Loader.hpp"
11 
12 
13 class TextParserT;
14 
15 
16 /// This class imports an ASE (ASCII Scene Exporter, 3dsmax) model file into a new Cafu model.
17 class LoaderAseT : public ModelLoaderT
18 {
19  public:
20 
21  /// The constructor for importing an ASE (ASCII Scene Exporter, 3dsmax) model file into a new Cafu model.
22  /// @param FileName The name of the .ase file to import.
23  /// @param Flags The flags to load the model with. See ModelLoaderT::FlagsT for details.
24  LoaderAseT(const std::string& FileName, int Flags=NONE);
25 
27  void Load(ArrayT<CafuModelT::SkinT>& Skins, const MaterialManagerImplT& MaterialMan) { }
28  void Load(ArrayT<CafuModelT::GuiFixtureT>& GuiFixtures);
29  void Load(ArrayT<CafuModelT::ChannelT>& Channels) { }
30  bool Load(unsigned int Level, CafuModelT*& DlodModel, float& DlodDist) { return false; }
31 
32 
33  private:
34 
35  /// A geometric object.
36  struct GeomObjectT
37  {
38  /// A single triangle.
39  struct TriangleT
40  {
41  /// Constructor.
43  : SmoothGrps(0)
44  {
45  for (unsigned long i=0; i<3; i++)
46  {
47  IndVertices [i]=0;
48  IndTexCoords[i]=0;
49  }
50  }
51 
52  // This data is read from the file.
53  unsigned long IndVertices [3]; ///< Indices into the Vertices array.
54  unsigned long IndTexCoords[3]; ///< Indices into the TexCoords array.
55  ArrayT<unsigned long> SmoothGroups; ///< The SmoothGroups this triangle is in.
56  uint32_t SmoothGrps; ///< The smoothing groups that this triangle is in: If bit \c i is set, the triangle is in smoothing group \c i.
57 
58  // This data is computed after loading.
59  VectorT Normal; ///< The geometric per-triangle normal.
60  VectorT Normals[3]; ///< The smoothgroup normals for the three vertices.
61  VectorT Tangents[3]; ///< The smoothgroup tangents for the three vertices.
62  VectorT BiNormals[3]; ///< The smoothgroup binormals for the three vertices.
63  };
64 
65 
66  /// Method for initializing the mesh from (a file within) TP.
67  /// @param TP TextParserT used to read the mesh in.
68  void ReadMesh(TextParserT& TP);
69 
70  // This data is read from the file.
71  std::string Name; ///< Name of the object.
72  ArrayT<VectorT> Vertices; ///< List of vertices.
73  ArrayT<VectorT> TexCoords; ///< List of texture coordinates.
74  ArrayT<TriangleT> Triangles; ///< List of triangles.
75  unsigned long IndexMaterial; ///< Index of the material used for this object.
76  bool CastShadows; ///< Whether this object casts shadows.
77  };
78 
79 
80  void ReadMaterials(TextParserT& TP);
81  void ReadGeometry(TextParserT& TP);
82  void Print() const;
83 
84  ArrayT<std::string> m_MaterialNames;
85  ArrayT<GeomObjectT> m_GeomObjects;
86 };
87 
88 #endif
unsigned long IndVertices[3]
Indices into the Vertices array.
Definition: Loader_ase.hpp:53
This class represents a native Cafu model.
Definition: Model_cmdl.hpp:45
VectorT Tangents[3]
The smoothgroup tangents for the three vertices.
Definition: Loader_ase.hpp:61
void Load(ArrayT< CafuModelT::ChannelT > &Channels)
Loads the animation channels (groups of joints) of the Cafu model.
Definition: Loader_ase.hpp:29
uint32_t SmoothGrps
The smoothing groups that this triangle is in: If bit i is set, the triangle is in smoothing group i...
Definition: Loader_ase.hpp:56
A single triangle.
Definition: Loader_ase.hpp:39
LoaderAseT(const std::string &FileName, int Flags=NONE)
The constructor for importing an ASE (ASCII Scene Exporter, 3dsmax) model file into a new Cafu model...
Definition: Loader_ase.cpp:292
bool Load(unsigned int Level, CafuModelT *&DlodModel, float &DlodDist)
Loads the dlod-model and dlod-distance at the given level.
Definition: Loader_ase.hpp:30
VectorT Normals[3]
The smoothgroup normals for the three vertices.
Definition: Loader_ase.hpp:60
The base class for importing arbitrary model files into Cafu models.
Definition: Loader.hpp:15
VectorT BiNormals[3]
The smoothgroup binormals for the three vertices.
Definition: Loader_ase.hpp:62
void Load(ArrayT< CafuModelT::JointT > &Joints, ArrayT< CafuModelT::MeshT > &Meshes, ArrayT< CafuModelT::AnimT > &Anims, MaterialManagerImplT &MaterialMan)
Actually loads the file data into the appropriate parts of the Cafu model.
Definition: Loader_ase.cpp:486
This class implements the MaterialManagerI interface.
Definition: MaterialManagerImpl.hpp:23
ArrayT< unsigned long > SmoothGroups
The SmoothGroups this triangle is in.
Definition: Loader_ase.hpp:55
void Load(ArrayT< CafuModelT::SkinT > &Skins, const MaterialManagerImplT &MaterialMan)
Loads the skins of the Cafu model.
Definition: Loader_ase.hpp:27
unsigned long IndTexCoords[3]
Indices into the TexCoords array.
Definition: Loader_ase.hpp:54
VectorT Normal
The geometric per-triangle normal.
Definition: Loader_ase.hpp:59
This class imports an ASE (ASCII Scene Exporter, 3dsmax) model file into a new Cafu model...
Definition: Loader_ase.hpp:17
TriangleT()
Constructor.
Definition: Loader_ase.hpp:42
This is a class for parsing text.
Definition: TextParser.hpp:21