2020-12-31 07:32:16 -08:00
// Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2012-10-20 18:45:35 -07:00
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
2014-01-25 09:13:39 -08:00
# ifndef _SCENEGRAPH_ASSIMPLOADER_H
# define _SCENEGRAPH_ASSIMPLOADER_H
/**
* Model loader using Assimp
2012-04-15 07:55:28 -07:00
*/
2014-01-25 09:13:39 -08:00
# include "BaseLoader.h"
2014-02-15 12:15:17 -08:00
# include "CollisionGeometry.h"
2012-04-15 07:55:28 -07:00
# include "graphics/Material.h"
2018-10-11 08:10:23 -07:00
// Disable some GCC diagnostics errors.
# ifdef __GNUC__
2019-01-02 08:59:07 -08:00
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wfloat-equal"
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wold-style-cast"
# include <assimp/types.h>
# pragma GCC diagnostic pop
2018-10-11 08:10:23 -07:00
# else
2019-01-02 08:59:07 -08:00
# include <assimp/types.h>
2018-10-11 08:10:23 -07:00
# endif
2012-04-15 07:55:28 -07:00
2012-04-29 12:16:22 -07:00
struct aiNode ;
2012-05-23 17:54:35 -07:00
struct aiMesh ;
struct aiScene ;
2012-06-07 19:30:06 -07:00
struct aiNodeAnim ;
2012-04-29 12:16:22 -07:00
2012-11-24 15:06:28 -08:00
namespace SceneGraph {
2012-04-15 07:55:28 -07:00
2019-01-02 08:59:07 -08:00
class Loader : public BaseLoader {
public :
Loader ( Graphics : : Renderer * r , bool logWarnings = false , bool loadSGMfiles = true ) ;
2014-01-25 09:13:39 -08:00
2019-01-02 08:59:07 -08:00
//find & attempt to load a model, based on filename (without path or .model suffix)
Model * LoadModel ( const std : : string & name ) ;
Model * LoadModel ( const std : : string & name , const std : : string & basepath ) ;
2012-04-15 07:55:28 -07:00
2019-01-02 08:59:07 -08:00
const std : : vector < std : : string > & GetLogMessages ( ) const { return m_logMessages ; }
2013-02-03 14:35:34 -08:00
2019-01-02 08:59:07 -08:00
protected :
bool m_doLog ;
bool m_loadSGMs ;
bool m_mostDetailedLod ;
std : : vector < std : : string > m_logMessages ;
std : : string m_curMeshDef ; //for logging
2012-06-25 18:23:10 -07:00
2019-01-02 08:59:07 -08:00
RefCountedPtr < Group > m_thrustersRoot ;
RefCountedPtr < Group > m_billboardsRoot ;
2013-05-26 13:25:17 -07:00
2019-01-02 08:59:07 -08:00
bool CheckKeysInRange ( const aiNodeAnim * , double start , double end ) ;
matrix4x4f ConvertMatrix ( const aiMatrix4x4 & ) const ;
Model * CreateModel ( ModelDefinition & def ) ;
RefCountedPtr < Node > LoadMesh ( const std : : string & filename , const AnimList & animDefs ) ; //load one mesh file so it can be added to the model scenegraph. Materials should be created before this!
void AddLog ( const std : : string & ) ;
void CheckAnimationConflicts ( const Animation * , const std : : vector < Animation * > & ) ; //detect animation overlap
void ConvertAiMeshes ( std : : vector < RefCountedPtr < StaticGeometry > > & , const aiScene * ) ; //model is only for material lookup
void ConvertAnimations ( const aiScene * , const AnimList & , Node * meshRoot ) ;
void ConvertNodes ( aiNode * node , Group * parent , std : : vector < RefCountedPtr < StaticGeometry > > & meshes , const matrix4x4f & ) ;
void CreateLabel ( Group * parent , const matrix4x4f & ) ;
void CreateThruster ( const std : : string & name , const matrix4x4f & nodeTrans ) ;
void CreateNavlight ( const std : : string & name , const matrix4x4f & nodeTrans ) ;
RefCountedPtr < CollisionGeometry > CreateCollisionGeometry ( RefCountedPtr < StaticGeometry > , unsigned int collFlag ) ;
void LoadCollision ( const std : : string & filename ) ;
2012-12-06 06:15:08 -08:00
2019-01-02 08:59:07 -08:00
unsigned int GetGeomFlagForNodeName ( const std : : string & ) ;
} ;
2012-04-15 07:55:28 -07:00
2019-01-02 08:59:07 -08:00
} // namespace SceneGraph
2012-04-15 07:55:28 -07:00
# endif