Radium Engine  1.5.20
Loading...
Searching...
No Matches
FileData.hpp
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
7#include <Core/Asset/AnimationData.hpp>
8#include <Core/Asset/Camera.hpp>
9#include <Core/Asset/GeometryData.hpp>
10#include <Core/Asset/HandleData.hpp>
11#include <Core/Asset/LightData.hpp>
12#include <Core/Asset/VolumeData.hpp>
13#include <Core/RaCore.hpp>
14#include <Core/Utils/Log.hpp>
15
16namespace Ra {
17namespace Core {
18namespace Asset {
19
20class RA_CORE_API FileData final
21{
22 public:
24 FileData( const std::string& filename = "", const bool VERBOSE_MODE = false );
25
26 FileData( FileData&& data ) = default;
27
29 ~FileData();
30
32 inline std::string getFileName() const;
33
34 inline void setFileName( const std::string& filename );
35
37 inline Scalar getLoadingTime() const;
38
40 inline std::vector<GeometryData*> getGeometryData() const;
41 inline std::vector<VolumeData*> getVolumeData() const;
42 inline std::vector<HandleData*> getHandleData() const;
43 inline std::vector<AnimationData*> getAnimationData() const;
44 inline std::vector<LightData*> getLightData() const;
45 inline std::vector<Camera*> getCameraData() const;
46
47 inline void setVerbose( const bool VERBOSE_MODE );
48
50 inline bool isInitialized() const;
51 inline bool isProcessed() const;
52 inline bool hasGeometry() const;
53 inline bool hasHandle() const;
54 inline bool hasAnimation() const;
55 inline bool hasLight() const;
56 inline bool hasCamera() const;
57 inline bool isVerbose() const;
58
60 inline void reset();
61
62 inline void displayInfo() const;
63
64 // TODO(Matthieu) : handle attributes in a better way than "public:"
65 public:
67 std::string m_filename;
68 Scalar m_loadingTime;
75 bool m_processed;
76 bool m_verbose;
77};
78
80inline std::string FileData::getFileName() const {
81 return m_filename;
82}
83
84inline void FileData::setFileName( const std::string& filename ) {
85 m_filename = filename;
86}
87
89inline Scalar FileData::getLoadingTime() const {
90 return m_loadingTime;
91}
92
94inline std::vector<GeometryData*> FileData::getGeometryData() const {
96 list.reserve( m_geometryData.size() );
97 for ( const auto& item : m_geometryData ) {
98 list.push_back( item.get() );
99 }
100 return list;
101}
102
103inline std::vector<VolumeData*> FileData::getVolumeData() const {
105 list.reserve( m_volumeData.size() );
106 for ( const auto& item : m_volumeData ) {
107 list.push_back( item.get() );
108 }
109 return list;
110}
111
112inline std::vector<HandleData*> FileData::getHandleData() const {
114 list.reserve( m_handleData.size() );
115 for ( const auto& item : m_handleData ) {
116 list.push_back( item.get() );
117 }
118 return list;
119}
120
121inline std::vector<AnimationData*> FileData::getAnimationData() const {
123 list.reserve( m_animationData.size() );
124 for ( const auto& item : m_animationData ) {
125 list.push_back( item.get() );
126 }
127 return list;
128}
129
130inline std::vector<LightData*> FileData::getLightData() const {
132 list.reserve( m_lightData.size() );
133 for ( const auto& item : m_lightData ) {
134 list.push_back( item.get() );
135 }
136 return list;
137}
138
139inline std::vector<Camera*> FileData::getCameraData() const {
141 list.reserve( m_cameraData.size() );
142 for ( const auto& item : m_cameraData ) {
143 list.push_back( item.get() );
144 }
145 return list;
146}
147
148inline void FileData::setVerbose( const bool VERBOSE_MODE ) {
149 m_verbose = VERBOSE_MODE;
150}
151
153inline bool FileData::isInitialized() const {
154 return ( ( m_filename != "" ) && !m_processed );
155}
156
157inline bool FileData::isProcessed() const {
158 return m_processed;
159}
160
161inline bool FileData::hasGeometry() const {
162 return ( !m_geometryData.empty() );
163}
164
165inline bool FileData::hasHandle() const {
166 return ( !m_handleData.empty() );
167}
168
169inline bool FileData::hasAnimation() const {
170 return ( !m_animationData.empty() );
171}
172
173inline bool FileData::hasLight() const {
174 return ( !m_lightData.empty() );
175}
176
177inline bool FileData::isVerbose() const {
178 return m_verbose;
179}
180
182inline void FileData::reset() {
183 m_filename = "";
184 m_geometryData.clear();
185 m_handleData.clear();
186 m_animationData.clear();
187 m_processed = false;
188}
189
190inline void FileData::displayInfo() const {
191 using namespace Core::Utils; // log
192 uint64_t vtxCount = 0;
193 for ( const auto& geom : m_geometryData ) {
194 vtxCount += geom->getGeometry().vertices().size();
195 }
196 LOG( logINFO ) << "======== LOADING SUMMARY ========";
197 LOG( logINFO ) << "Mesh loaded : " << m_geometryData.size();
198 LOG( logINFO ) << "Total vertex count : " << vtxCount;
199 LOG( logINFO ) << "Handle loaded : " << m_handleData.size();
200 LOG( logINFO ) << "Animation loaded : " << m_animationData.size();
201 LOG( logINFO ) << "Volume loaded : " << m_volumeData.size();
202 LOG( logINFO ) << "Loading Time (sec) : " << m_loadingTime;
203}
204
205} // namespace Asset
206} // namespace Core
207} // namespace Ra
T clear(T... args)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
T push_back(T... args)
T reserve(T... args)