From 563ad6c7a55cdfc099ce80d2333bb0dbc0d28a00 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:47:59 +0100 Subject: [PATCH 01/17] [core] add material models in Core --- src/Core/Material/BlinnPhongMaterialModel.cpp | 31 ++++++++++ src/Core/Material/BlinnPhongMaterialModel.hpp | 52 +++++++++++++++++ src/Core/Material/MaterialModel.cpp | 13 +++++ src/Core/Material/MaterialModel.hpp | 49 ++++++++++++++++ src/Core/Material/SimpleMaterialModel.cpp | 45 +++++++++++++++ src/Core/Material/SimpleMaterialModel.hpp | 57 +++++++++++++++++++ src/Core/filelist.cmake | 6 ++ 7 files changed, 253 insertions(+) create mode 100644 src/Core/Material/BlinnPhongMaterialModel.cpp create mode 100644 src/Core/Material/BlinnPhongMaterialModel.hpp create mode 100644 src/Core/Material/MaterialModel.cpp create mode 100644 src/Core/Material/MaterialModel.hpp create mode 100644 src/Core/Material/SimpleMaterialModel.cpp create mode 100644 src/Core/Material/SimpleMaterialModel.hpp diff --git a/src/Core/Material/BlinnPhongMaterialModel.cpp b/src/Core/Material/BlinnPhongMaterialModel.cpp new file mode 100644 index 00000000000..405f3f38331 --- /dev/null +++ b/src/Core/Material/BlinnPhongMaterialModel.cpp @@ -0,0 +1,31 @@ +#include + +#include + +namespace Ra { +namespace Core { +namespace Material { +void BlinnPhongMaterialModel::displayInfo() const { + using namespace Core::Utils; // log + auto print = []( bool ok, const std::string& name, const auto& value ) { + if ( ok ) { LOG( logINFO ) << name << value; } + else { + LOG( logINFO ) << name << "NO"; + } + }; + + LOG( logINFO ) << "======== MATERIAL INFO ========"; + print( true, " Type : ", getType() ); + print( true, " Kd : ", m_kd.transpose() ); + print( true, " Ks : ", m_ks.transpose() ); + print( true, " Ns : ", m_ns ); + print( true, " Opacity : ", m_alpha ); + print( hasDiffuseTexture(), " Kd Texture : ", m_texDiffuse ); + print( hasSpecularTexture(), " Ks Texture : ", m_texSpecular ); + print( hasShininessTexture(), " Ns Texture : ", m_texShininess ); + print( hasNormalTexture(), " Normal Texture : ", m_texNormal ); + print( hasOpacityTexture(), " Alpha Texture : ", m_texOpacity ); +} +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/Material/BlinnPhongMaterialModel.hpp b/src/Core/Material/BlinnPhongMaterialModel.hpp new file mode 100644 index 00000000000..0fe93db1920 --- /dev/null +++ b/src/Core/Material/BlinnPhongMaterialModel.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include + +namespace Ra { +namespace Core { +namespace Material { + +// RADIUM SUPPORTED MATERIALS +class RA_CORE_API BlinnPhongMaterialModel : public MaterialModel +{ + public: + explicit BlinnPhongMaterialModel( const std::string& name = "" ) : + MaterialModel( name, "BlinnPhong" ) {} + ~BlinnPhongMaterialModel() override = default; + + /// DEBUG + void displayInfo() const override; + + /// QUERY + + bool hasDiffuseTexture() const { return m_hasTexDiffuse; } + + bool hasSpecularTexture() const { return m_hasTexSpecular; } + + bool hasShininessTexture() const { return m_hasTexShininess; } + + bool hasNormalTexture() const { return m_hasTexNormal; } + + bool hasOpacityTexture() const { return m_hasTexOpacity; } + + /// DATA MEMBERS + Core::Utils::Color m_kd { 0.7_ra, 0.7_ra, 0.7_ra }; + Core::Utils::Color m_ks { 0.3_ra, 0.3_ra, 0.3_ra }; + Scalar m_ns { 64_ra }; + Scalar m_alpha { 1_ra }; + std::string m_texDiffuse; + std::string m_texSpecular; + std::string m_texShininess; + std::string m_texNormal; + std::string m_texOpacity; + bool m_hasTexDiffuse { false }; + bool m_hasTexSpecular { false }; + bool m_hasTexShininess { false }; + bool m_hasTexNormal { false }; + bool m_hasTexOpacity { false }; +}; + +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/Material/MaterialModel.cpp b/src/Core/Material/MaterialModel.cpp new file mode 100644 index 00000000000..bfd24b816d7 --- /dev/null +++ b/src/Core/Material/MaterialModel.cpp @@ -0,0 +1,13 @@ +#include +#include + +namespace Ra { +namespace Core { +namespace Material { +void MaterialModel::displayInfo() const { + using namespace Core::Utils; // log + LOG( logERROR ) << "MaterialModel : unknown material type : " << m_materialType; +} +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/Material/MaterialModel.hpp b/src/Core/Material/MaterialModel.hpp new file mode 100644 index 00000000000..688ef8ff778 --- /dev/null +++ b/src/Core/Material/MaterialModel.hpp @@ -0,0 +1,49 @@ +#pragma once +#include + +#include + +#include + +namespace Ra { +namespace Core { +namespace Material { + +/** @brief represent material model, loaded by a file loader. + * + */ +class RA_CORE_API MaterialModel : public Utils::ObservableVoid +{ + public: + /// MATERIAL DATA + MaterialModel( const std::string& name = "", const std::string& type = "AbstractMaterial" ); + virtual ~MaterialModel() { detachAll(); }; + + /// NAME + inline const std::string& getName() const { return m_name; } + inline void setName( const std::string& name ) { m_name = name; } + + /// TYPE + inline std::string getType() const { return m_materialType; } + inline void setType( const std::string& type ) { m_materialType = type; } + + /// DEBUG + virtual void displayInfo() const; + + private: + std::string m_materialType; + std::string m_name; +}; + +/** + * \brief Convenient alias for material usage + */ + +using MaterialModelPtr = std::shared_ptr; + +inline MaterialModel::MaterialModel( const std::string& name, const std::string& type ) : + m_materialType { type }, m_name { name } {} + +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/Material/SimpleMaterialModel.cpp b/src/Core/Material/SimpleMaterialModel.cpp new file mode 100644 index 00000000000..31fe61ba571 --- /dev/null +++ b/src/Core/Material/SimpleMaterialModel.cpp @@ -0,0 +1,45 @@ +#include + +#include + +namespace Ra { +namespace Core { +namespace Material { + +void SimpleMaterialModel::displayInfo() const { + using namespace Core::Utils; // log + auto print = []( bool ok, const std::string& name, const auto& value ) { + if ( ok ) { LOG( logINFO ) << name << value; } + else { + LOG( logINFO ) << name << "NO"; + } + }; + + LOG( logINFO ) << "======== MATERIAL INFO ========"; + print( true, " Type : ", getType() ); + print( true, " Kd : ", m_kd.transpose() ); + print( true, " Opacity : ", m_alpha ); + print( hasDiffuseTexture(), " Kd Texture : ", m_texDiffuse ); + print( hasOpacityTexture(), " Alpha Texture : ", m_texOpacity ); +} + +void LambertianMaterialModel::displayInfo() const { + using namespace Core::Utils; // log + auto print = []( bool ok, const std::string& name, const auto& value ) { + if ( ok ) { LOG( logINFO ) << name << value; } + else { + LOG( logINFO ) << name << "NO"; + } + }; + + LOG( logINFO ) << "======== MATERIAL INFO ========"; + print( true, " Type : ", getType() ); + print( true, " Kd : ", m_kd.transpose() ); + print( true, " Opacity : ", m_alpha ); + print( hasDiffuseTexture(), " Kd Texture : ", m_texDiffuse ); + print( hasNormalTexture(), " Normal Texture : ", m_texNormal ); + print( hasOpacityTexture(), " Alpha Texture : ", m_texOpacity ); +} +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/Material/SimpleMaterialModel.hpp b/src/Core/Material/SimpleMaterialModel.hpp new file mode 100644 index 00000000000..83d3126344d --- /dev/null +++ b/src/Core/Material/SimpleMaterialModel.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include +#include + +namespace Ra { +namespace Core { +namespace Material { + +// RADIUM SUPPORTED MATERIALS +class RA_CORE_API SimpleMaterialModel : public MaterialModel +{ + protected: + SimpleMaterialModel( const std::string& name, const std::string type ) : + MaterialModel( name, type ) {} + + public: + explicit SimpleMaterialModel( const std::string& name = "" ) : MaterialModel( name, "Plain" ) {} + ~SimpleMaterialModel() override = default; + + /// DEBUG + void displayInfo() const override; + + /// QUERY + bool hasDiffuseTexture() const { return m_hasTexDiffuse; } + bool hasOpacityTexture() const { return m_hasTexOpacity; } + + /// DATA MEMBERS + Core::Utils::Color m_kd { 0.9_ra, 0.9_ra, 0.9_ra }; + Scalar m_alpha { 1_ra }; + std::string m_texDiffuse; + std::string m_texOpacity; + bool m_hasTexDiffuse { false }; + bool m_hasTexOpacity { false }; +}; + +class RA_CORE_API LambertianMaterialModel : public SimpleMaterialModel +{ + public: + explicit LambertianMaterialModel( const std::string& name = "" ) : + SimpleMaterialModel( name, "Lambertian" ) {} + ~LambertianMaterialModel() override = default; + + /// DEBUG + void displayInfo() const override; + + /// QUERY + bool hasNormalTexture() const { return m_hasTexNormal; } + + /// DATA MEMBERS + std::string m_texNormal; + bool m_hasTexNormal { false }; +}; + +} // namespace Material +} // namespace Core +} // namespace Ra diff --git a/src/Core/filelist.cmake b/src/Core/filelist.cmake index 7aabbe1b640..02b033812d3 100644 --- a/src/Core/filelist.cmake +++ b/src/Core/filelist.cmake @@ -35,6 +35,9 @@ set(core_sources Geometry/TriangleMesh.cpp Geometry/Volume.cpp Geometry/deprecated/TopologicalMesh.cpp + Material/BlinnPhongMaterialModel.cpp + Material/MaterialModel.cpp + Material/SimpleMaterialModel.cpp Resources/Resources.cpp Tasks/TaskQueue.cpp Utils/Attribs.cpp @@ -101,6 +104,9 @@ set(core_headers Geometry/TriangleMesh.hpp Geometry/Volume.hpp Geometry/deprecated/TopologicalMesh.hpp + Material/BlinnPhongMaterialModel.hpp + Material/MaterialModel.hpp + Material/SimpleMaterialModel.hpp Math/DualQuaternion.hpp Math/Interpolation.hpp Math/LinearAlgebra.hpp From da6fc72e7d53cbcae7bce248e422efd6e320c6f4 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:49:08 +0100 Subject: [PATCH 02/17] [core] material asset data uses material model --- src/Core/Asset/BlinnPhongMaterialData.cpp | 33 ------ src/Core/Asset/BlinnPhongMaterialData.hpp | 121 ---------------------- src/Core/Asset/GeometryData.cpp | 2 +- src/Core/Asset/GeometryData.hpp | 4 +- src/Core/Asset/MaterialData.cpp | 22 ---- src/Core/Asset/MaterialData.hpp | 56 +++------- src/Core/filelist.cmake | 3 - 7 files changed, 19 insertions(+), 222 deletions(-) delete mode 100644 src/Core/Asset/BlinnPhongMaterialData.cpp delete mode 100644 src/Core/Asset/BlinnPhongMaterialData.hpp delete mode 100644 src/Core/Asset/MaterialData.cpp diff --git a/src/Core/Asset/BlinnPhongMaterialData.cpp b/src/Core/Asset/BlinnPhongMaterialData.cpp deleted file mode 100644 index 336ebb38b46..00000000000 --- a/src/Core/Asset/BlinnPhongMaterialData.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -namespace Ra { -namespace Core { -namespace Asset { - -/////////////////// -/// BLINN PHONG /// -/////////////////// -BlinnPhongMaterialData::BlinnPhongMaterialData( const std::string& name ) : - MaterialData( name, "BlinnPhong" ), - m_diffuse(), - m_specular(), - m_shininess(), - m_opacity( 1.0 ), - m_texDiffuse( "" ), - m_texSpecular( "" ), - m_texShininess( "" ), - m_texNormal( "" ), - m_texOpacity( "" ), - m_hasDiffuse( false ), - m_hasSpecular( false ), - m_hasShininess( false ), - m_hasOpacity( false ), - m_hasTexDiffuse( false ), - m_hasTexSpecular( false ), - m_hasTexShininess( false ), - m_hasTexNormal( false ), - m_hasTexOpacity( false ) {} - -} // namespace Asset -} // namespace Core -} // namespace Ra diff --git a/src/Core/Asset/BlinnPhongMaterialData.hpp b/src/Core/Asset/BlinnPhongMaterialData.hpp deleted file mode 100644 index 2fa05e0e5eb..00000000000 --- a/src/Core/Asset/BlinnPhongMaterialData.hpp +++ /dev/null @@ -1,121 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace Ra { -namespace Core { -namespace Asset { - -// RADIUM SUPPORTED MATERIALS -class RA_CORE_API BlinnPhongMaterialData : public MaterialData -{ - public: - explicit BlinnPhongMaterialData( const std::string& name = "" ); - - /// DEBUG - inline void displayInfo() const final; - - /// QUERY - inline bool hasDiffuse() const; - - inline bool hasSpecular() const; - - inline bool hasShininess() const; - - inline bool hasOpacity() const; - - inline bool hasDiffuseTexture() const; - - inline bool hasSpecularTexture() const; - - inline bool hasShininessTexture() const; - - inline bool hasNormalTexture() const; - - inline bool hasOpacityTexture() const; - - /// DATA MEMBERS - Core::Utils::Color m_diffuse; - Core::Utils::Color m_specular; - Scalar m_shininess; - Scalar m_opacity; - std::string m_texDiffuse; - std::string m_texSpecular; - std::string m_texShininess; - std::string m_texNormal; - std::string m_texOpacity; - bool m_hasDiffuse; - bool m_hasSpecular; - bool m_hasShininess; - bool m_hasOpacity; - bool m_hasTexDiffuse; - bool m_hasTexSpecular; - bool m_hasTexShininess; - bool m_hasTexNormal; - bool m_hasTexOpacity; -}; - -/////////////////// -/// BLINN PHONG /// -/////////////////// -inline bool BlinnPhongMaterialData::hasDiffuse() const { - return m_hasDiffuse; -} - -inline bool BlinnPhongMaterialData::hasSpecular() const { - return m_hasSpecular; -} - -inline bool BlinnPhongMaterialData::hasShininess() const { - return m_hasShininess; -} - -inline bool BlinnPhongMaterialData::hasOpacity() const { - return m_hasOpacity; -} - -inline bool BlinnPhongMaterialData::hasDiffuseTexture() const { - return m_hasTexDiffuse; -} - -inline bool BlinnPhongMaterialData::hasSpecularTexture() const { - return m_hasTexSpecular; -} - -inline bool BlinnPhongMaterialData::hasShininessTexture() const { - return m_hasTexShininess; -} - -inline bool BlinnPhongMaterialData::hasNormalTexture() const { - return m_hasTexNormal; -} - -inline bool BlinnPhongMaterialData::hasOpacityTexture() const { - return m_hasTexOpacity; -} - -/// DEBUG -inline void BlinnPhongMaterialData::displayInfo() const { - using namespace Core::Utils; // log - auto print = []( bool ok, const std::string& name, const auto& value ) { - if ( ok ) { LOG( logINFO ) << name << value; } - else { LOG( logINFO ) << name << "NO"; } - }; - - LOG( logINFO ) << "======== MATERIAL INFO ========"; - print( hasDiffuse(), " Kd : ", m_diffuse.transpose() ); - print( hasSpecular(), " Ks : ", m_specular.transpose() ); - print( hasShininess(), " Ns : ", m_shininess ); - print( hasOpacity(), " Opacity : ", m_opacity ); - print( hasDiffuseTexture(), " Kd Texture : ", m_texDiffuse ); - print( hasSpecularTexture(), " Ks Texture : ", m_texSpecular ); - print( hasShininessTexture(), " Ns Texture : ", m_texShininess ); - print( hasNormalTexture(), " Normal Texture : ", m_texNormal ); - print( hasOpacityTexture(), " Alpha Texture : ", m_texOpacity ); -} - -} // namespace Asset -} // namespace Core -} // namespace Ra diff --git a/src/Core/Asset/GeometryData.cpp b/src/Core/Asset/GeometryData.cpp index d4a78d62550..2c982f5a844 100644 --- a/src/Core/Asset/GeometryData.cpp +++ b/src/Core/Asset/GeometryData.cpp @@ -70,7 +70,7 @@ void GeometryData::displayInfo() const { LOG( logINFO ) << " Color ? : " << hasAttrib( MeshAttrib::VERTEX_COLOR ); LOG( logINFO ) << " Material ? : " << ( ( !hasMaterial() ) ? "NO" : "YES" ); - if ( hasMaterial() ) { m_material->displayInfo(); } + if ( hasMaterial() ) { m_material.displayInfo(); } } } // namespace Asset } // namespace Core diff --git a/src/Core/Asset/GeometryData.hpp b/src/Core/Asset/GeometryData.hpp index 59ccb880a41..97d90559c28 100644 --- a/src/Core/Asset/GeometryData.hpp +++ b/src/Core/Asset/GeometryData.hpp @@ -75,7 +75,7 @@ class RA_CORE_API GeometryData : public AssetData inline const MaterialData& getMaterial() const; /// Set the MaterialData for the object. - inline void setMaterial( MaterialData* material ); + inline void setMaterial( MaterialData material ); /// Read/write access to the multiIndexedGeometry; inline Geometry::MultiIndexedGeometry& getGeometry(); @@ -147,7 +147,7 @@ class RA_CORE_API GeometryData : public AssetData int m_primitiveCount { -1 }; /// The MaterialData for the object. - std::shared_ptr m_material; + MaterialData m_material; }; inline void GeometryData::setName( const std::string& name ) { diff --git a/src/Core/Asset/MaterialData.cpp b/src/Core/Asset/MaterialData.cpp deleted file mode 100644 index 3d23b34daff..00000000000 --- a/src/Core/Asset/MaterialData.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -namespace Ra { -namespace Core { -namespace Asset { - -/// CONSTRUCTOR -MaterialData::MaterialData( const std::string& name, const std::string& type ) : - AssetData( name ), m_type( type ) {} - -MaterialData::~MaterialData() {} - -/// DEBUG -void MaterialData::displayInfo() const { - using namespace Core::Utils; // log - LOG( logERROR ) << "MaterialData : unkonwn material type : " << m_type; -} - -} // namespace Asset -} // namespace Core -} // namespace Ra diff --git a/src/Core/Asset/MaterialData.hpp b/src/Core/Asset/MaterialData.hpp index fce815bf100..70631353a6d 100644 --- a/src/Core/Asset/MaterialData.hpp +++ b/src/Core/Asset/MaterialData.hpp @@ -5,11 +5,14 @@ #include #include +#include + namespace Ra { namespace Core { namespace Asset { -/** @brief represent material data loaded by a file loader. +/** \brief represent material data loaded by a file loader. + * \todo rewrite the doc * Material data must be identified by a unique name. * Radium Engine reserves the following names * "AbstractMaterial" --> unknown material, might serve for error management @@ -32,58 +35,31 @@ namespace Asset { * * The active system (GeometrySystem is the Radium Default), will then automatically use your * new material and technique so that the rendering will be fine. When writing your own system, see - * GeometrySystem implementation as an example. - * - * That's all folks. + * GeometrySystem implementation as an example */ class RA_CORE_API MaterialData : public AssetData { public: /// MATERIAL DATA - MaterialData( const std::string& name = "", const std::string& type = "AbstractMaterial" ); - virtual ~MaterialData(); + MaterialData( const std::string& name = "" ) : AssetData( name ) {} + ~MaterialData() = default; /// NAME - inline void setName( const std::string& name ); - - /// TYPE - inline std::string getType() const; - - inline void setType( const std::string& type ); + void setName( const std::string& name ) { m_name = name; } /// DEBUG - virtual void displayInfo() const; + void displayInfo() const { + if ( m_material ) { m_material->displayInfo(); } + } + + /// Model + void setMaterialModel( Material::MaterialModelPtr model ) { m_material = model; } + Material::MaterialModelPtr getMaterialModel() const { return m_material; } private: - std::string m_type; + Material::MaterialModelPtr m_material; }; } // namespace Asset } // namespace Core } // namespace Ra - -namespace Ra { -namespace Core { -namespace Asset { - -//////////////// -/// MATERIAL /// -//////////////// - -/// NAME -inline void MaterialData::setName( const std::string& name ) { - m_name = name; -} - -/// TYPE -inline std::string MaterialData::getType() const { - return m_type; -} - -inline void MaterialData::setType( const std::string& type ) { - m_type = type; -} - -} // namespace Asset -} // namespace Core -} // namespace Ra diff --git a/src/Core/filelist.cmake b/src/Core/filelist.cmake index 02b033812d3..101f98962d4 100644 --- a/src/Core/filelist.cmake +++ b/src/Core/filelist.cmake @@ -15,14 +15,12 @@ set(core_sources Animation/Sequence.cpp Animation/Skeleton.cpp Asset/AnimationData.cpp - Asset/BlinnPhongMaterialData.cpp Asset/Camera.cpp Asset/FileData.cpp Asset/GeometryData.cpp Asset/HandleData.cpp Asset/HandleToSkeleton.cpp Asset/LightData.cpp - Asset/MaterialData.cpp Containers/AdjacencyList.cpp Containers/VariableSet.cpp Geometry/CatmullClarkSubdivider.cpp @@ -66,7 +64,6 @@ set(core_headers Asset/AnimationData.hpp Asset/AnimationTime.hpp Asset/AssetData.hpp - Asset/BlinnPhongMaterialData.hpp Asset/Camera.hpp Asset/DataLoader.hpp Asset/FileData.hpp From 66a83d6e620d8f99817396bebbed891b87a98485 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:49:41 +0100 Subject: [PATCH 03/17] [io] update material loading to load material models --- .../AssimpLoader/AssimpGeometryDataLoader.cpp | 191 +++++++++++++----- 1 file changed, 136 insertions(+), 55 deletions(-) diff --git a/src/IO/AssimpLoader/AssimpGeometryDataLoader.cpp b/src/IO/AssimpLoader/AssimpGeometryDataLoader.cpp index 537aa34bb20..14768f80d01 100644 --- a/src/IO/AssimpLoader/AssimpGeometryDataLoader.cpp +++ b/src/IO/AssimpLoader/AssimpGeometryDataLoader.cpp @@ -5,8 +5,8 @@ #include -#include - +#include +#include namespace Ra { namespace IO { @@ -212,71 +212,152 @@ void AssimpGeometryDataLoader::loadMaterial( const aiMaterial& material, matName = assimpName.C_Str(); } // Radium V2 : use AI_MATKEY_SHADING_MODEL to select the apropriate model - // (http://assimp.sourceforge.net/lib_html/material_8h.html#a93e23e0201d6ed86fb4287e15218e4cf) - auto blinnPhongMaterial = new BlinnPhongMaterialData( matName ); - if ( AI_DEFAULT_MATERIAL_NAME != matName ) { - aiColor4D color; - float shininess; - float opacity; - aiString name; - - if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_DIFFUSE, color ) ) { - blinnPhongMaterial->m_hasDiffuse = true; - blinnPhongMaterial->m_diffuse = assimpToCore( color ); + // (https://assimp.sourceforge.net/lib_html/materials.html) + MaterialData assetMaterial( matName ); + + // Identify Lambertian or Blinn-Phong material + // The following correspond to assimp doc but always identify Gouraud shading model + int shadingModel = aiShadingMode_Gouraud; + material.Get( AI_MATKEY_SHADING_MODEL, shadingModel ); + if ( shadingModel == aiShadingMode_Gouraud ) { + // follow assimp documentation at https://assimp.sourceforge.net/lib_html/materials.html + // here, if shininess is present, assume phong shading model (somehow different of what's + // written in the - buggy? - documentation) + float sd { -1 }; + if ( AI_SUCCESS == material.Get( AI_MATKEY_SHININESS, sd ) ) { + shadingModel = ( sd > 0 ) ? aiShadingMode_Phong : aiShadingMode_Gouraud; } + } + if ( AI_DEFAULT_MATERIAL_NAME != matName ) { + switch ( shadingModel ) { + case aiShadingMode_Flat: { + LOG( logINFO ) << "Loading assimp shadingModel Flat --> plainMaterial"; + auto plainMaterial = std::make_shared( matName ); + assetMaterial.setMaterialModel( plainMaterial ); + aiColor4D color; + aiString name; + if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_DIFFUSE, color ) ) { + plainMaterial->m_kd = assimpToCore( color ); + } + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_DIFFUSE, 0 ), name ) ) { + plainMaterial->m_texDiffuse = m_filepath + "/" + assimpToCore( name ); + plainMaterial->m_hasTexDiffuse = true; + } + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_OPACITY, 0 ), name ) ) { + plainMaterial->m_texOpacity = m_filepath + "/" + assimpToCore( name ); + plainMaterial->m_hasTexOpacity = true; + } + } break; - if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_SPECULAR, color ) ) { - blinnPhongMaterial->m_hasSpecular = true; - blinnPhongMaterial->m_specular = assimpToCore( color ); - } + case aiShadingMode_Gouraud: { - if ( AI_SUCCESS == material.Get( AI_MATKEY_SHININESS, shininess ) ) { - blinnPhongMaterial->m_hasShininess = true; - // Assimp gives the Phong exponent, we use the Blinn-Phong exponent - blinnPhongMaterial->m_shininess = shininess * 4; - } + auto lambertianMaterial = + std::make_shared( matName ); + assetMaterial.setMaterialModel( lambertianMaterial ); + aiColor4D color; + aiString name; + if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_DIFFUSE, color ) ) { + lambertianMaterial->m_kd = assimpToCore( color ); + } + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_DIFFUSE, 0 ), name ) ) { + lambertianMaterial->m_texDiffuse = m_filepath + "/" + assimpToCore( name ); + lambertianMaterial->m_hasTexDiffuse = true; + } + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_OPACITY, 0 ), name ) ) { + lambertianMaterial->m_texOpacity = m_filepath + "/" + assimpToCore( name ); + lambertianMaterial->m_hasTexOpacity = true; + } + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_NORMALS, 0 ), name ) ) { + lambertianMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); + lambertianMaterial->m_hasTexNormal = true; + } + // Assimp loads objs bump maps as height maps, gj bro + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_HEIGHT, 0 ), name ) ) { + lambertianMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); + lambertianMaterial->m_hasTexNormal = true; + } + } break; - if ( AI_SUCCESS == material.Get( AI_MATKEY_OPACITY, opacity ) ) { - blinnPhongMaterial->m_hasOpacity = true; - // NOTE(charly): Due to collada way of handling objects that have an alpha map, we must - // ensure - // we do not have zeros in here. - blinnPhongMaterial->m_opacity = opacity < 1e-5 ? 1 : opacity; - } + default: { + // all other shading model are considered as blinn-phong ... + auto blinnPhongMaterial = + std::make_shared( matName ); + assetMaterial.setMaterialModel( blinnPhongMaterial ); - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_DIFFUSE, 0 ), name ) ) { - blinnPhongMaterial->m_texDiffuse = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexDiffuse = true; - } + aiColor4D color; + float shininess; + float opacity; + aiString name; - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_SPECULAR, 0 ), name ) ) { - blinnPhongMaterial->m_texSpecular = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexSpecular = true; - } + if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_DIFFUSE, color ) ) { + blinnPhongMaterial->m_kd = assimpToCore( color ); + } - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_SHININESS, 0 ), name ) ) { - blinnPhongMaterial->m_texShininess = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexShininess = true; - } + if ( AI_SUCCESS == material.Get( AI_MATKEY_COLOR_SPECULAR, color ) ) { + blinnPhongMaterial->m_ks = assimpToCore( color ); + } - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_NORMALS, 0 ), name ) ) { - blinnPhongMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexNormal = true; - } + if ( AI_SUCCESS == material.Get( AI_MATKEY_SHININESS, shininess ) ) { + // Assimp gives the Phong exponent, we use the Blinn-Phong exponent + blinnPhongMaterial->m_ns = shininess * 4; + } - // Assimp loads objs bump maps as height maps, gj bro - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_HEIGHT, 0 ), name ) ) { - blinnPhongMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexNormal = true; - } + if ( AI_SUCCESS == material.Get( AI_MATKEY_OPACITY, opacity ) ) { + // NOTE(charly): Due to collada way of handling objects that have an alpha map, we + // must ensure + // we do not have zeros in here. + blinnPhongMaterial->m_alpha = opacity < 1e-5 ? 1 : opacity; + } + + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_DIFFUSE, 0 ), name ) ) { + blinnPhongMaterial->m_texDiffuse = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexDiffuse = true; + } + + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_SPECULAR, 0 ), name ) ) { + blinnPhongMaterial->m_texSpecular = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexSpecular = true; + } - if ( AI_SUCCESS == material.Get( AI_MATKEY_TEXTURE( aiTextureType_OPACITY, 0 ), name ) ) { - blinnPhongMaterial->m_texOpacity = m_filepath + "/" + assimpToCore( name ); - blinnPhongMaterial->m_hasTexOpacity = true; + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_SHININESS, 0 ), name ) ) { + blinnPhongMaterial->m_texShininess = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexShininess = true; + } + + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_NORMALS, 0 ), name ) ) { + blinnPhongMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexNormal = true; + } + + // Assimp loads objs bump maps as height maps, gj bro + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_HEIGHT, 0 ), name ) ) { + blinnPhongMaterial->m_texNormal = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexNormal = true; + } + + if ( AI_SUCCESS == + material.Get( AI_MATKEY_TEXTURE( aiTextureType_OPACITY, 0 ), name ) ) { + blinnPhongMaterial->m_texOpacity = m_filepath + "/" + assimpToCore( name ); + blinnPhongMaterial->m_hasTexOpacity = true; + } } + } + } + else { + LOG( logINFO ) << "Found assimp default material " << matName; } - else { LOG( logINFO ) << "Found assimp default material " << matName; } - data.setMaterial( blinnPhongMaterial ); + data.setMaterial( assetMaterial ); } void AssimpGeometryDataLoader::loadGeometryData( From e5969c57061d70b4ad6ac9ddcc0da0855621c253 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:50:48 +0100 Subject: [PATCH 04/17] [engine] build engine materials from material models --- src/Engine/Data/BlinnPhongMaterial.cpp | 14 +++++++------- src/Engine/Data/BlinnPhongMaterial.hpp | 6 +++--- src/Engine/Data/LambertianMaterial.cpp | 26 +++++++++++++++++++++++++- src/Engine/Data/LambertianMaterial.hpp | 20 ++++++++++++++++++++ src/Engine/Data/MaterialConverters.cpp | 4 ++-- src/Engine/Data/MaterialConverters.hpp | 10 +++++----- src/Engine/Data/PlainMaterial.cpp | 23 ++++++++++++++++++++++- src/Engine/Data/PlainMaterial.hpp | 21 +++++++++++++++++++++ src/Engine/Data/RawShaderMaterial.hpp | 20 ++++++++++---------- src/Engine/Data/SimpleMaterial.cpp | 3 +++ src/Engine/Data/SimpleMaterial.hpp | 14 +++++++++++++- 11 files changed, 131 insertions(+), 30 deletions(-) diff --git a/src/Engine/Data/BlinnPhongMaterial.cpp b/src/Engine/Data/BlinnPhongMaterial.cpp index c430379064f..126773a09ce 100644 --- a/src/Engine/Data/BlinnPhongMaterial.cpp +++ b/src/Engine/Data/BlinnPhongMaterial.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -148,16 +148,16 @@ void BlinnPhongMaterial::unregisterMaterial() { } Material* -BlinnPhongMaterialConverter::operator()( const Ra::Core::Asset::MaterialData* toconvert ) { +BlinnPhongMaterialConverter::operator()( const Ra::Core::Material::MaterialModel* toconvert ) { auto result = new BlinnPhongMaterial( toconvert->getName() ); // we are sure here that the concrete type of "toconvert" is BlinnPhongMaterialData // static cst is safe here - auto source = static_cast( toconvert ); + auto source = static_cast( toconvert ); - if ( source->hasDiffuse() ) result->m_kd = source->m_diffuse; - if ( source->hasSpecular() ) result->m_ks = source->m_specular; - if ( source->hasShininess() ) result->m_ns = source->m_shininess; - if ( source->hasOpacity() ) result->m_alpha = source->m_opacity; + result->m_kd = source->m_kd; + result->m_ks = source->m_ks; + result->m_ns = source->m_ns; + result->m_alpha = source->m_alpha; if ( source->hasDiffuseTexture() ) result->addTexture( BlinnPhongMaterial::TextureSemantic::TEX_DIFFUSE, source->m_texDiffuse ); diff --git a/src/Engine/Data/BlinnPhongMaterial.hpp b/src/Engine/Data/BlinnPhongMaterial.hpp index 50980bc1f23..a41ae9ecee5 100644 --- a/src/Engine/Data/BlinnPhongMaterial.hpp +++ b/src/Engine/Data/BlinnPhongMaterial.hpp @@ -11,8 +11,8 @@ namespace Ra { namespace Core { -namespace Asset { -class MaterialData; +namespace Material { +class MaterialModel; } } // namespace Core @@ -135,7 +135,7 @@ class RA_ENGINE_API BlinnPhongMaterialConverter final BlinnPhongMaterialConverter() = default; ~BlinnPhongMaterialConverter() = default; - Material* operator()( const Ra::Core::Asset::MaterialData* toconvert ); + Material* operator()( const Ra::Core::Material::MaterialModel* toconvert ); }; // Add a texture as material parameter from an already existing Radium Texture diff --git a/src/Engine/Data/LambertianMaterial.cpp b/src/Engine/Data/LambertianMaterial.cpp index 3714801da0d..3cd8a0e4d5f 100644 --- a/src/Engine/Data/LambertianMaterial.cpp +++ b/src/Engine/Data/LambertianMaterial.cpp @@ -1,5 +1,6 @@ +#include #include - +#include #include #include #include @@ -25,6 +26,8 @@ void LambertianMaterial::registerMaterial() { auto resourcesRootDir { RadiumEngine::getInstance()->getResourcesDir() }; auto shaderProgramManager = RadiumEngine::getInstance()->getShaderProgramManager(); + EngineMaterialConverters::registerMaterialConverter( materialName, + LambertianMaterialConverter() ); shaderProgramManager->addNamedString( "/Lambertian.glsl", resourcesRootDir + "Shaders/Materials/Lambertian/Lambertian.glsl" ); // registering re-usable shaders @@ -58,6 +61,7 @@ void LambertianMaterial::registerMaterial() { } void LambertianMaterial::unregisterMaterial() { + EngineMaterialConverters::removeMaterialConverter( materialName ); Rendering::EngineRenderTechniques::removeDefaultTechnique( materialName ); } @@ -71,6 +75,26 @@ nlohmann::json LambertianMaterial::getParametersMetadata() const { return s_parametersMetadata; } +Material* +LambertianMaterialConverter::operator()( const Ra::Core::Material::MaterialModel* toconvert ) { + auto result = new LambertianMaterial( toconvert->getName() ); + // we are sure here that the concrete type of "toconvert" is BlinnPhongMaterialData + // static cst is safe here + auto source = static_cast( toconvert ); + + result->m_color = source->m_kd; + result->m_alpha = source->m_alpha; + + if ( source->hasDiffuseTexture() ) + result->addTexture( SimpleMaterial::TextureSemantic::TEX_COLOR, source->m_texDiffuse ); + if ( source->hasOpacityTexture() ) + result->addTexture( SimpleMaterial::TextureSemantic::TEX_MASK, source->m_texOpacity ); + if ( source->hasNormalTexture() ) + result->addTexture( SimpleMaterial::TextureSemantic::TEX_NORMAL, source->m_texNormal ); + + return result; +} + } // namespace Data } // namespace Engine } // namespace Ra diff --git a/src/Engine/Data/LambertianMaterial.hpp b/src/Engine/Data/LambertianMaterial.hpp index 220cf2e3ab2..8187289f750 100644 --- a/src/Engine/Data/LambertianMaterial.hpp +++ b/src/Engine/Data/LambertianMaterial.hpp @@ -3,6 +3,12 @@ #include namespace Ra { +namespace Core { +namespace Material { +class MaterialModel; +} +} // namespace Core + namespace Engine { namespace Data { /** @@ -18,6 +24,8 @@ namespace Data { */ class RA_ENGINE_API LambertianMaterial final : public SimpleMaterial { + friend class LambertianMaterialConverter; + public: /** * Construct a named Lambertian material @@ -58,6 +66,18 @@ class RA_ENGINE_API LambertianMaterial final : public SimpleMaterial static nlohmann::json s_parametersMetadata; }; +/** + * Converter from an external representation coming from FileData to internal representation. + */ +class RA_ENGINE_API LambertianMaterialConverter final +{ + public: + LambertianMaterialConverter() = default; + ~LambertianMaterialConverter() = default; + + Material* operator()( const Ra::Core::Material::MaterialModel* toconvert ); +}; + } // namespace Data } // namespace Engine } // namespace Ra diff --git a/src/Engine/Data/MaterialConverters.cpp b/src/Engine/Data/MaterialConverters.cpp index 72cd51268a4..f13262b0854 100644 --- a/src/Engine/Data/MaterialConverters.cpp +++ b/src/Engine/Data/MaterialConverters.cpp @@ -19,7 +19,7 @@ using namespace Core::Utils; // log namespace EngineMaterialConverters { /// Map that stores each conversion function -static std::map> +static std::map> MaterialConverterRegistry; bool registerMaterialConverter( const std::string& name, ConverterFunction converter ) { @@ -35,7 +35,7 @@ bool removeMaterialConverter( const std::string& name ) { std::pair getMaterialConverter( const std::string& name ) { auto search = MaterialConverterRegistry.find( name ); if ( search != MaterialConverterRegistry.end() ) { return { true, search->second }; } - auto result = std::make_pair( false, [name]( AssetMaterialPtr ) -> RadiumMaterialPtr { + auto result = std::make_pair( false, [name]( MaterialModelPtr ) -> RadiumMaterialPtr { LOG( logERROR ) << "Required material converter " << name << " not found!"; return nullptr; } ); diff --git a/src/Engine/Data/MaterialConverters.hpp b/src/Engine/Data/MaterialConverters.hpp index dcff906d014..0737e808bd4 100644 --- a/src/Engine/Data/MaterialConverters.hpp +++ b/src/Engine/Data/MaterialConverters.hpp @@ -12,9 +12,9 @@ class Material; } } // namespace Engine namespace Core { -namespace Asset { -class MaterialData; -} +namespace Material { +class MaterialModel; +} // namespace Material } // namespace Core /////////////////////////////////////////////// @@ -42,7 +42,7 @@ namespace EngineMaterialConverters { /** * Type of a pointer to an IO/ASSET representation of the material */ -using AssetMaterialPtr = const Ra::Core::Asset::MaterialData*; +using MaterialModelPtr = const Ra::Core::Material::MaterialModel*; /** * Type of a pointer to an Engine representation of the material */ @@ -51,7 +51,7 @@ using RadiumMaterialPtr = Ra::Engine::Data::Material*; /** * Type of the conversion functor from IO/ASSET representation to Engine representation */ -using ConverterFunction = std::function; +using ConverterFunction = std::function; /** register a new material converter * @return true if converter added, false else (e.g, a converter with the same name exists) diff --git a/src/Engine/Data/PlainMaterial.cpp b/src/Engine/Data/PlainMaterial.cpp index 993af771e12..c7c7b26d58e 100644 --- a/src/Engine/Data/PlainMaterial.cpp +++ b/src/Engine/Data/PlainMaterial.cpp @@ -1,5 +1,6 @@ +#include +#include #include - #include #include #include @@ -26,6 +27,8 @@ void PlainMaterial::registerMaterial() { auto resourcesRootDir { RadiumEngine::getInstance()->getResourcesDir() }; auto shaderProgramManager = RadiumEngine::getInstance()->getShaderProgramManager(); + EngineMaterialConverters::registerMaterialConverter( materialName, PlainMaterialConverter() ); + shaderProgramManager->addNamedString( "/Plain.glsl", resourcesRootDir + "Shaders/Materials/Plain/Plain.glsl" ); // registering re-usable shaders @@ -58,6 +61,7 @@ void PlainMaterial::registerMaterial() { } void PlainMaterial::unregisterMaterial() { + EngineMaterialConverters::removeMaterialConverter( materialName ); Rendering::EngineRenderTechniques::removeDefaultTechnique( "Plain" ); } @@ -71,6 +75,23 @@ nlohmann::json PlainMaterial::getParametersMetadata() const { return s_parametersMetadata; } +Material* PlainMaterialConverter::operator()( const Ra::Core::Material::MaterialModel* toconvert ) { + auto result = new PlainMaterial( toconvert->getName() ); + // we are sure here that the concrete type of "toconvert" is BlinnPhongMaterialData + // static cst is safe here + auto source = static_cast( toconvert ); + + result->m_color = source->m_kd; + result->m_alpha = source->m_alpha; + + if ( source->hasDiffuseTexture() ) + result->addTexture( SimpleMaterial::TextureSemantic::TEX_COLOR, source->m_texDiffuse ); + if ( source->hasOpacityTexture() ) + result->addTexture( SimpleMaterial::TextureSemantic::TEX_MASK, source->m_texOpacity ); + + return result; +} + } // namespace Data } // namespace Engine } // namespace Ra diff --git a/src/Engine/Data/PlainMaterial.hpp b/src/Engine/Data/PlainMaterial.hpp index 91ec2252644..8928fe3bbc1 100644 --- a/src/Engine/Data/PlainMaterial.hpp +++ b/src/Engine/Data/PlainMaterial.hpp @@ -3,6 +3,12 @@ #include namespace Ra { +namespace Core { +namespace Material { +class MaterialModel; +} +} // namespace Core + namespace Engine { namespace Data { /** @@ -18,6 +24,8 @@ namespace Data { */ class RA_ENGINE_API PlainMaterial final : public SimpleMaterial { + friend class PlainMaterialConverter; + public: /** * Construct a named Plain material @@ -57,6 +65,19 @@ class RA_ENGINE_API PlainMaterial final : public SimpleMaterial private: static nlohmann::json s_parametersMetadata; }; + +/** + * Converter from an external representation coming from FileData to internal representation. + */ +class RA_ENGINE_API PlainMaterialConverter final +{ + public: + PlainMaterialConverter() = default; + ~PlainMaterialConverter() = default; + + Material* operator()( const Ra::Core::Material::MaterialModel* toconvert ); +}; + } // namespace Data } // namespace Engine } // namespace Ra diff --git a/src/Engine/Data/RawShaderMaterial.hpp b/src/Engine/Data/RawShaderMaterial.hpp index 7d797e80e9c..2f7b30cbe9e 100644 --- a/src/Engine/Data/RawShaderMaterial.hpp +++ b/src/Engine/Data/RawShaderMaterial.hpp @@ -2,7 +2,7 @@ #include -#include +#include #include namespace Ra { @@ -14,12 +14,12 @@ class RawShaderMaterialConverter; } // namespace Engine namespace Core { -namespace Asset { +namespace Material { /** * External shaderMaterial representation */ -class RA_ENGINE_API RawShaderMaterialData : public MaterialData +class RA_ENGINE_API RawShaderMaterialModel : public MaterialModel { /// allow converter to access private members friend class Ra::Engine::Data::RawShaderMaterialConverter; @@ -32,23 +32,23 @@ class RA_ENGINE_API RawShaderMaterialData : public MaterialData * allowed) * @param paramProvider The parameter provider for the resulting program */ - RawShaderMaterialData( + RawShaderMaterialModel( const std::string& instanceName, const std::vector>& shaders, std::shared_ptr paramProvider ) : - MaterialData( instanceName, "Ra::Engine::Data::RawShaderMaterial" ), + MaterialModel( instanceName, "Ra::Engine::Data::RawShaderMaterial" ), m_shaders { shaders }, m_paramProvider { std::move( paramProvider ) } {} - RawShaderMaterialData() = delete; - RawShaderMaterialData( const RawShaderMaterialData& ) = delete; - ~RawShaderMaterialData() = default; + RawShaderMaterialModel() = delete; + RawShaderMaterialModel( const RawShaderMaterialModel& ) = delete; + ~RawShaderMaterialModel() = default; private: std::vector> m_shaders; std::shared_ptr m_paramProvider; }; -} // namespace Asset +} // namespace Material } // namespace Core namespace Engine { @@ -63,7 +63,7 @@ class RA_ENGINE_API RawShaderMaterialConverter final public: RawShaderMaterialConverter() = default; ~RawShaderMaterialConverter() = default; - inline Material* operator()( const Ra::Core::Asset::MaterialData* toconvert ); + inline Material* operator()( const Ra::Core::Material::MaterialModel* toconvert ); }; /** diff --git a/src/Engine/Data/SimpleMaterial.cpp b/src/Engine/Data/SimpleMaterial.cpp index be031fcda5a..82e26fc1fbe 100644 --- a/src/Engine/Data/SimpleMaterial.cpp +++ b/src/Engine/Data/SimpleMaterial.cpp @@ -27,6 +27,9 @@ void SimpleMaterial::updateRenderingParameters() { tex = getTexture( SimpleMaterial::TextureSemantic::TEX_MASK ); if ( tex != nullptr ) { renderParameters.addParameter( "material.tex.mask", tex ); } renderParameters.addParameter( "material.tex.hasMask", tex != nullptr ); + tex = getTexture( SimpleMaterial::TextureSemantic::TEX_NORMAL ); + if ( tex != nullptr ) { renderParameters.addParameter( "material.tex.normal", tex ); } + renderParameters.addParameter( "material.tex.hasNormal", tex != nullptr ); } void SimpleMaterial::updateGL() { diff --git a/src/Engine/Data/SimpleMaterial.hpp b/src/Engine/Data/SimpleMaterial.hpp index 02a273d386a..e22f5090e88 100644 --- a/src/Engine/Data/SimpleMaterial.hpp +++ b/src/Engine/Data/SimpleMaterial.hpp @@ -20,7 +20,7 @@ class RA_ENGINE_API SimpleMaterial : public Material, public ParameterSetEditing { public: /// Semantic of the texture : define which BSDF parameter is controled by the texture - enum class TextureSemantic { TEX_COLOR, TEX_MASK }; + enum class TextureSemantic { TEX_COLOR, TEX_MASK, TEX_NORMAL }; /** * Construct a named material @@ -75,10 +75,22 @@ class RA_ENGINE_API SimpleMaterial : public Material, public ParameterSetEditing public: /// The base color of the material Core::Utils::Color m_color { 0.9, 0.9, 0.9, 1.0 }; + /// Transparency of the material (not use right now) + Scalar m_alpha { 1.0 }; /// Indicates if the material will takes its base color from vertices' attributes. /// \todo make this private ? bool m_perVertexColor { false }; + protected: + /** + * Add an new texture, from a given file, to control the specified BSDF parameter. + * @param semantic The texture semantic + * @param texture The texture to use (file) + * @return the corresponding TextureData struct + */ + inline TextureParameters& addTexture( const TextureSemantic& semantic, + const std::string& texture ); + private: /** * Update the rendering parameters for the Material From c4ca548366352d58fc0e49c3b9ee423c6c26a618 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:51:27 +0100 Subject: [PATCH 05/17] [engine] build renderobjects using material models --- src/Engine/Scene/GeometryComponent.cpp | 16 +++++++++------- src/Engine/Scene/GeometryComponent.hpp | 22 ++++++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Engine/Scene/GeometryComponent.cpp b/src/Engine/Scene/GeometryComponent.cpp index c9056fed4dd..6632489fa82 100644 --- a/src/Engine/Scene/GeometryComponent.cpp +++ b/src/Engine/Scene/GeometryComponent.cpp @@ -53,7 +53,7 @@ PointCloudComponent::PointCloudComponent( const std::string& name, PointCloudComponent::PointCloudComponent( const std::string& name, Entity* entity, Core::Geometry::PointCloud&& mesh, - Core::Asset::MaterialData* mat ) : + Core::Material::MaterialModelPtr mat ) : GeometryComponent( name, entity ), m_displayMesh( new Data::PointCloud( name, std::move( mesh ) ) ) { finalizeROFromGeometry( mat, Core::Transform::Identity() ); @@ -78,18 +78,20 @@ void PointCloudComponent::generatePointCloud( const Ra::Core::Asset::GeometryDat m_displayMesh->loadGeometry( std::move( mesh ) ); - finalizeROFromGeometry( data->hasMaterial() ? &( data->getMaterial() ) : nullptr, + finalizeROFromGeometry( data->hasMaterial() ? data->getMaterial().getMaterialModel() : nullptr, data->getFrame() ); } -void PointCloudComponent::finalizeROFromGeometry( const Core::Asset::MaterialData* data, +void PointCloudComponent::finalizeROFromGeometry( Core::Material::MaterialModelPtr matModel, Core::Transform transform ) { // The technique for rendering this component std::shared_ptr roMaterial; // First extract the material from asset or create a default one - if ( data != nullptr ) { - auto converter = Data::EngineMaterialConverters::getMaterialConverter( data->getType() ); - auto mat = converter.second( data ); + if ( matModel != nullptr ) { + auto converter = + Data::EngineMaterialConverters::getMaterialConverter( matModel->getType() ); + // todo : convert from the shared ptr instead of from the raw ptr + auto mat = converter.second( matModel.get() ); roMaterial.reset( mat ); } else { @@ -99,7 +101,7 @@ void PointCloudComponent::finalizeROFromGeometry( const Core::Asset::MaterialDat Ra::Core::Geometry::getAttribName( Ra::Core::Geometry::VERTEX_COLOR ) ); roMaterial.reset( mat ); } - // initialize with a default rendertechique that draws nothing + // initialize with a default rendertechnique that draws nothing std::string roName( m_name + "_" + m_contentName + "_RO" ); auto ro = Rendering::RenderObject::createRenderObject( roName, this, diff --git a/src/Engine/Scene/GeometryComponent.hpp b/src/Engine/Scene/GeometryComponent.hpp index 16fa5104e15..f0e0ad68f21 100644 --- a/src/Engine/Scene/GeometryComponent.hpp +++ b/src/Engine/Scene/GeometryComponent.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,7 @@ class SurfaceMeshComponent : public GeometryComponent inline SurfaceMeshComponent( const std::string& name, Entity* entity, CoreMeshType&& mesh, - Core::Asset::MaterialData* mat = nullptr ); + Core::Material::MaterialModelPtr mat = nullptr ); ~SurfaceMeshComponent() override = default; @@ -95,7 +96,7 @@ class SurfaceMeshComponent : public GeometryComponent private: inline void generateMesh( const Ra::Core::Asset::GeometryData* data ); - inline void finalizeROFromGeometry( const Core::Asset::MaterialData* data, + inline void finalizeROFromGeometry( Core::Material::MaterialModelPtr matModel, Core::Transform transform ); // Give access to the mesh and (if deformable) to update it @@ -130,7 +131,7 @@ class RA_ENGINE_API PointCloudComponent : public GeometryComponent PointCloudComponent( const std::string& name, Entity* entity, Core::Geometry::PointCloud&& mesh, - Core::Asset::MaterialData* mat = nullptr ); + Core::Material::MaterialModelPtr mat = nullptr ); ~PointCloudComponent() override; @@ -154,7 +155,8 @@ class RA_ENGINE_API PointCloudComponent : public GeometryComponent private: void generatePointCloud( const Ra::Core::Asset::GeometryData* data ); - void finalizeROFromGeometry( const Core::Asset::MaterialData* data, Core::Transform transform ); + void finalizeROFromGeometry( Core::Material::MaterialModelPtr matModel, + Core::Transform transform ); // Give access to the mesh and (if deformable) to update it const Ra::Core::Geometry::PointCloud* getMeshOutput() const; @@ -229,7 +231,7 @@ template SurfaceMeshComponent::SurfaceMeshComponent( const std::string& name, Entity* entity, CoreMeshType&& mesh, - Core::Asset::MaterialData* mat ) : + Core::Material::MaterialModelPtr mat ) : GeometryComponent( name, entity ), m_displayMesh( new RenderMeshType( name, std::move( mesh ) ) ) { setContentName( name ); @@ -244,20 +246,20 @@ void SurfaceMeshComponent::generateMesh( const Ra::Core::Asset::Ge m_displayMesh->loadGeometry( std::move( mesh ) ); - finalizeROFromGeometry( data->hasMaterial() ? &( data->getMaterial() ) : nullptr, + finalizeROFromGeometry( data->hasMaterial() ? data->getMaterial().getMaterialModel() : nullptr, data->getFrame() ); } template void SurfaceMeshComponent::finalizeROFromGeometry( - const Core::Asset::MaterialData* data, + Core::Material::MaterialModelPtr matModel, Core::Transform transform ) { // The technique for rendering this component std::shared_ptr roMaterial; // First extract the material from asset or create a default one - if ( data != nullptr ) { - auto converter = Data::EngineMaterialConverters::getMaterialConverter( data->getType() ); - auto mat = converter.second( data ); + if ( matModel != nullptr ) { + auto converter = Data::EngineMaterialConverters::getMaterialConverter( matModel->getType() ); + auto mat = converter.second( matModel.get() ); roMaterial.reset( mat ); } else { From 9d1ca8e5f2f0006dea2330c4500b7b6501a28a4c Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:51:58 +0100 Subject: [PATCH 06/17] [shaders] improve Lambertian bsdf shader --- .../Materials/Lambertian/Lambertian.frag.glsl | 16 +++++++++++++--- Shaders/Materials/Lambertian/Lambertian.glsl | 18 +++++++++++++----- .../Materials/Lambertian/Lambertian.vert.glsl | 5 +++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Shaders/Materials/Lambertian/Lambertian.frag.glsl b/Shaders/Materials/Lambertian/Lambertian.frag.glsl index 6611334bfad..302f2a05597 100644 --- a/Shaders/Materials/Lambertian/Lambertian.frag.glsl +++ b/Shaders/Materials/Lambertian/Lambertian.frag.glsl @@ -7,11 +7,21 @@ layout( location = 6 ) in vec3 in_lightVector; out vec4 out_color; void main() { - vec4 bc = getBaseColor( material, getPerVertexTexCoord() ); - vec3 normal = getWorldSpaceNormal(); + vec4 bc = getDiffuseColor( material, getPerVertexTexCoord() ); + vec3 normalWorld = getWorldSpaceNormal(); + vec3 tangentWorld = getWorldSpaceTangent(); // normalized tangent + vec3 binormalWorld = getWorldSpaceBiTangent(); // normalized bitangent + // Computing attributes using dfdx or dfdy must be done before discarding fragments if ( toDiscard( material, bc ) ) discard; + vec3 lightDir = normalize( in_lightVector ); // incident direction + normalWorld = getNormal( material, + getPerVertexTexCoord(), + normalWorld, + tangentWorld, + binormalWorld ); // normalized bump-mapped normal + vec3 le = lightContributionFrom( light, getWorldSpacePosition().xyz ); - out_color = vec4( bc.rgb * dot( normal, normalize( in_lightVector ) ) * le, 1 ); + out_color = vec4( (bc.rgb / Pi) * dot( normalWorld, lightDir ) * le, 1 ); } diff --git a/Shaders/Materials/Lambertian/Lambertian.glsl b/Shaders/Materials/Lambertian/Lambertian.glsl index bb1f8df94d4..812db5b091e 100644 --- a/Shaders/Materials/Lambertian/Lambertian.glsl +++ b/Shaders/Materials/Lambertian/Lambertian.glsl @@ -4,9 +4,11 @@ struct LambertianTextures { int hasColor; int hasMask; + int hasNormal; sampler2D color; sampler2D mask; + sampler2D normal; }; struct Material { @@ -17,8 +19,6 @@ struct Material { //------------------- VertexAttrib interface --------------------- vec4 getPerVertexBaseColor(); -vec3 getWorldSpaceNormal(); -#define DONT_USE_INPUT_TANGENT //---------------------------------------------------------------- const float Pi = 3.141592653589793; @@ -51,10 +51,18 @@ vec3 getSpecularColor( Material material, vec3 texCoord ) { return vec3( 0 ); } -// Return the world-space normal computed according to the microgeometry definition` -// As no normal map is defined, return N +// Return the world-space normal computed according to the microgeometry definition vec3 getNormal( Material material, vec3 texCoord, vec3 N, vec3 T, vec3 B ) { - return N; + if ( material.tex.hasNormal == 1 ) { + vec3 normalLocal = normalize( vec3( texture( material.tex.normal, texCoord.xy ) ) * 2 - 1 ); + mat3 tbn; + tbn[0] = T; + tbn[1] = B; + tbn[2] = N; + return normalize( tbn * normalLocal ); + } else { + return N; + } } // return true if the fragment must be condidered as transparent (either fully or partially) diff --git a/Shaders/Materials/Lambertian/Lambertian.vert.glsl b/Shaders/Materials/Lambertian/Lambertian.vert.glsl index bb0b82d5314..1139523c0a0 100644 --- a/Shaders/Materials/Lambertian/Lambertian.vert.glsl +++ b/Shaders/Materials/Lambertian/Lambertian.vert.glsl @@ -5,6 +5,7 @@ // declare expected attributes layout( location = 0 ) in vec3 in_position; layout( location = 1 ) in vec3 in_normal; +layout( location = 2 ) in vec3 in_tangent; layout( location = 4 ) in vec3 in_texcoord; layout( location = 5 ) in vec4 in_color; @@ -17,6 +18,7 @@ layout( location = 0 ) out vec3 out_position; layout( location = 1 ) out vec3 out_normal; layout( location = 2 ) out vec3 out_texcoord; layout( location = 3 ) out vec3 out_vertexcolor; +layout( location = 4 ) out vec3 out_tangent; layout( location = 6 ) out vec3 out_lightVector; // Main function for vertex shader @@ -46,5 +48,8 @@ void main() { vec3 normal = mat3( transform.worldNormal ) * in_normal; out_normal = normal; + vec3 tangent = mat3( transform.model ) * in_tangent; + out_tangent = tangent; + out_lightVector = getLightDirection( light, out_position ); } From 83db710c8ea75b7c63afe71dac2c923ece5d4024 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Wed, 8 Mar 2023 08:52:29 +0100 Subject: [PATCH 07/17] [exemples] update example to use material models --- .../DrawPrimitives/AllPrimitivesComponent.cpp | 9 ++++----- examples/RawShaderMaterial/main.cpp | 6 +++--- examples/SimpleAnimation/main.cpp | 11 ++++++----- examples/TexturedQuad/main.cpp | 15 ++++++++------- examples/TexturedQuadDynamic/main.cpp | 15 ++++++++------- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/examples/DrawPrimitives/AllPrimitivesComponent.cpp b/examples/DrawPrimitives/AllPrimitivesComponent.cpp index 3437251299c..2f8b6dbaf7d 100644 --- a/examples/DrawPrimitives/AllPrimitivesComponent.cpp +++ b/examples/DrawPrimitives/AllPrimitivesComponent.cpp @@ -715,13 +715,12 @@ void AllPrimitivesComponent::initialize() { } std::shared_ptr roMaterial; - const Core::Asset::MaterialData* md = - gd->hasMaterial() ? &( gd->getMaterial() ) : nullptr; + auto mm = gd->hasMaterial() ? gd->getMaterial().getMaterialModel() : nullptr; // First extract the material from asset or create a default one - if ( md != nullptr ) { + if ( mm != nullptr ) { auto converter = - Data::EngineMaterialConverters::getMaterialConverter( md->getType() ); - auto mat = converter.second( md ); + Data::EngineMaterialConverters::getMaterialConverter( mm->getType() ); + auto mat = converter.second( mm.get() ); roMaterial.reset( mat ); } else { diff --git a/examples/RawShaderMaterial/main.cpp b/examples/RawShaderMaterial/main.cpp index f6be9e9401a..e5fe772fdb8 100644 --- a/examples/RawShaderMaterial/main.cpp +++ b/examples/RawShaderMaterial/main.cpp @@ -102,11 +102,11 @@ std::shared_ptr initQuad( Ra::Gui::BaseAppl paramProvider->setOrComputeTheParameterValues(); //! [Create the shader material] - Ra::Core::Asset::RawShaderMaterialData mat { "Quad Material", _config1, paramProvider }; + auto mat = std::make_shared( + "Quad Material", _config1, paramProvider ); //! [Create a geometry component using the custom material] - auto c = - new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), &mat ); + auto c = new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), mat ); //! [Register the entity/component association to the geometry system ] auto system = app.m_engine->getSystem( "GeometrySystem" ); diff --git a/examples/SimpleAnimation/main.cpp b/examples/SimpleAnimation/main.cpp index a8e019e8e2d..d22d9ef2199 100644 --- a/examples/SimpleAnimation/main.cpp +++ b/examples/SimpleAnimation/main.cpp @@ -3,8 +3,8 @@ #include // include the core geometry/appearance interface -#include #include +#include // include the Engine/entity/component/system/animation interface #include @@ -49,10 +49,11 @@ class KeyFramedGeometryComponent : public Ra::Engine::Scene::TriangleMeshCompone inline KeyFramedGeometryComponent( const std::string& name, Ra::Engine::Scene::Entity* entity, Ra::Core::Geometry::TriangleMesh&& mesh ) : - Ra::Engine::Scene::TriangleMeshComponent( name, - entity, - std::move( mesh ), - new Ra::Core::Asset::BlinnPhongMaterialData {} ), + Ra::Engine::Scene::TriangleMeshComponent( + name, + entity, + std::move( mesh ), + std::make_shared( name + "Material" ) ), m_transform( 0_ra, Ra::Core::Transform::Identity() ) { //! [Creating the transform KeyFrames] Ra::Core::Transform T = Ra::Core::Transform::Identity(); diff --git a/examples/TexturedQuad/main.cpp b/examples/TexturedQuad/main.cpp index 7cc38dabe7a..d8f8d589e39 100644 --- a/examples/TexturedQuad/main.cpp +++ b/examples/TexturedQuad/main.cpp @@ -3,8 +3,8 @@ #include // include the Engine/entity/component interface -#include #include +#include #include #include #include @@ -43,17 +43,18 @@ int main( int argc, char* argv[] ) { //! [Create an entity and component to draw or data] auto e = app.m_engine->getEntityManager()->createEntity( "Textured quad" ); - Ra::Core::Asset::BlinnPhongMaterialData matData( "myMaterialData" ); + auto matData = + std::make_shared( "myMaterialData" ); // remove glossy highlight - matData.m_specular = Ra::Core::Utils::Color::Black(); - matData.m_hasSpecular = true; + matData->m_ks = Ra::Core::Utils::Color::Black(); + matData->m_hasSpecular = true; - matData.m_hasTexDiffuse = true; + matData->m_hasTexDiffuse = true; // this name has to be the same as texManager added texture name - matData.m_texDiffuse = "myTexture"; + matData->m_texDiffuse = "myTexture"; // the entity get's this new component ownership. a bit wired since hidden in ctor. - new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), &matData ); + new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), matData ); //! [Create an entity and component to draw or data] //! [Tell the window that something is to be displayed] diff --git a/examples/TexturedQuadDynamic/main.cpp b/examples/TexturedQuadDynamic/main.cpp index 4ddc602f6cd..673a47e98c0 100644 --- a/examples/TexturedQuadDynamic/main.cpp +++ b/examples/TexturedQuadDynamic/main.cpp @@ -5,8 +5,8 @@ #include // include the Engine/entity/component interface -#include #include +#include #include #include #include @@ -48,17 +48,18 @@ int main( int argc, char* argv[] ) { //! [Create an entity and component to draw or data] auto e = app.m_engine->getEntityManager()->createEntity( "Textured quad" ); - Ra::Core::Asset::BlinnPhongMaterialData matData( "myMaterialData" ); + auto matData = + std::make_shared( "myMaterialData" ); // remove glossy highlight - matData.m_specular = Ra::Core::Utils::Color::Black(); - matData.m_hasSpecular = true; + matData->m_ks = Ra::Core::Utils::Color::Black(); + matData->m_hasSpecular = true; - matData.m_hasTexDiffuse = true; + matData->m_hasTexDiffuse = true; // this name has to be the same as texManager added texture name - matData.m_texDiffuse = "myTexture"; + matData->m_texDiffuse = "myTexture"; // the entity get's this new component ownership. a bit wired since hidden in ctor. - new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), &matData ); + new Ra::Engine::Scene::TriangleMeshComponent( "Quad Mesh", e, std::move( quad ), matData ); //! [Create an entity and component to draw or data] //! [Tell the window that something is to be displayed] From 97712970ada07179b6f52f80ed46eee844663f3f Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Sat, 15 Apr 2023 11:28:11 +0200 Subject: [PATCH 08/17] [core][engine] fix merge conflicts and missing --- src/Core/Asset/GeometryData.hpp | 8 ++++---- src/Engine/Data/SimpleMaterial.hpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Core/Asset/GeometryData.hpp b/src/Core/Asset/GeometryData.hpp index 97d90559c28..0493fa45b99 100644 --- a/src/Core/Asset/GeometryData.hpp +++ b/src/Core/Asset/GeometryData.hpp @@ -171,11 +171,11 @@ inline void GeometryData::setFrame( const Transform& frame ) { } inline const MaterialData& GeometryData::getMaterial() const { - return *( m_material.get() ); + return m_material; } -inline void GeometryData::setMaterial( MaterialData* material ) { - m_material.reset( material ); +inline void GeometryData::setMaterial( MaterialData material ) { + m_material = material; } inline bool GeometryData::isPointCloud() const { @@ -233,7 +233,7 @@ inline bool GeometryData::hasPolyhedra() const { } inline bool GeometryData::hasMaterial() const { - return m_material != nullptr; + return m_material.getMaterialModel() != nullptr; } const Geometry::MultiIndexedGeometry& GeometryData::getGeometry() const { diff --git a/src/Engine/Data/SimpleMaterial.hpp b/src/Engine/Data/SimpleMaterial.hpp index e22f5090e88..6ae8a620e37 100644 --- a/src/Engine/Data/SimpleMaterial.hpp +++ b/src/Engine/Data/SimpleMaterial.hpp @@ -128,6 +128,17 @@ inline TextureParameters& SimpleMaterial::addTexture( const TextureSemantic& sem return m_pendingTextures[semantic]; } +// Add a texture as material parameter with texture parameter set by default for this material +inline TextureParameters& SimpleMaterial::addTexture( const TextureSemantic& semantic, + const std::string& texture ) { + CORE_ASSERT( !texture.empty(), "Invalid texture name" ); + TextureParameters data; + data.name = texture; + data.wrapS = GL_REPEAT; + data.wrapT = GL_REPEAT; + return addTexture( semantic, data ); +} + inline Texture* SimpleMaterial::getTexture( const TextureSemantic& semantic ) const { Texture* tex = nullptr; From 3171ab6d90150a451997b00b240b4b37096ed96e Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Sat, 15 Apr 2023 16:06:40 +0200 Subject: [PATCH 09/17] [core][engine][examples] improve FileData processing --- .../DrawPrimitives/AllPrimitivesComponent.cpp | 8 +- src/Core/Asset/FileData.cpp | 31 +-- src/Core/Asset/FileData.hpp | 181 ++++-------------- src/Engine/Scene/CameraManager.cpp | 6 +- src/Engine/Scene/GeometrySystem.cpp | 16 +- src/Engine/Scene/LightManager.cpp | 4 +- .../Scene/SkeletonBasedAnimationSystem.cpp | 10 +- src/Engine/Scene/SkeletonComponent.cpp | 2 +- src/Engine/Scene/SkeletonComponent.hpp | 3 +- 9 files changed, 75 insertions(+), 186 deletions(-) diff --git a/examples/DrawPrimitives/AllPrimitivesComponent.cpp b/examples/DrawPrimitives/AllPrimitivesComponent.cpp index 2f8b6dbaf7d..80abc24a2a0 100644 --- a/examples/DrawPrimitives/AllPrimitivesComponent.cpp +++ b/examples/DrawPrimitives/AllPrimitivesComponent.cpp @@ -693,22 +693,22 @@ void AllPrimitivesComponent::initialize() { data = l.loadFile( filename ); #endif if ( data != nullptr ) { - auto geomData = data->getGeometryData(); + const auto& geomData = data->getGeometryData(); for ( const auto& gd : geomData ) { std::shared_ptr mesh { nullptr }; switch ( gd->getType() ) { case Ra::Core::Asset::GeometryData::TRI_MESH: mesh = std::shared_ptr { - createMeshFromGeometryData( "logo", gd ) }; + createMeshFromGeometryData( "logo", gd.get() ) }; break; case Ra::Core::Asset::GeometryData::QUAD_MESH: mesh = std::shared_ptr { - createMeshFromGeometryData( "logo", gd ) }; + createMeshFromGeometryData( "logo", gd.get() ) }; break; case Ra::Core::Asset::GeometryData::POLY_MESH: mesh = std::shared_ptr { - createMeshFromGeometryData( "logo", gd ) }; + createMeshFromGeometryData( "logo", gd.get() ) }; break; default: break; diff --git a/src/Core/Asset/FileData.cpp b/src/Core/Asset/FileData.cpp index 12933570238..30f73475b87 100644 --- a/src/Core/Asset/FileData.cpp +++ b/src/Core/Asset/FileData.cpp @@ -1,24 +1,29 @@ #include +#include + namespace Ra { namespace Core { namespace Asset { /// CONSTRUCTOR -FileData::FileData( const std::string& filename, const bool VERBOSE_MODE ) : - m_filename( filename ), - m_loadingTime( 0.0 ), - m_geometryData(), - m_volumeData(), - m_handleData(), - m_animationData(), - m_lightData(), - m_processed( false ), - m_verbose( VERBOSE_MODE ) {} - -/// DESTRUCTOR -FileData::~FileData() {} +void FileData::displayInfo() const { + using namespace Core::Utils; // log + uint64_t vtxCount = 0; + for ( const auto& geom : m_geometryData ) { + vtxCount += geom->getGeometry().vertices().size(); + } + LOG( logINFO ) << "======== LOADING SUMMARY ========"; + LOG( logINFO ) << "Mesh loaded : " << m_geometryData.size(); + LOG( logINFO ) << "Total vertex count : " << vtxCount; + LOG( logINFO ) << "Handle loaded : " << m_handleData.size(); + LOG( logINFO ) << "Animation loaded : " << m_animationData.size(); + LOG( logINFO ) << "Volume loaded : " << m_volumeData.size(); + LOG( logINFO ) << "Light loaded : " << m_lightData.size(); + LOG( logINFO ) << "Camera loaded : " << m_cameraData.size(); + LOG( logINFO ) << "Loading Time (sec) : " << m_loadingTime; +} } // namespace Asset } // namespace Core } // namespace Ra diff --git a/src/Core/Asset/FileData.hpp b/src/Core/Asset/FileData.hpp index 4a1080369e7..19ec42fea65 100644 --- a/src/Core/Asset/FileData.hpp +++ b/src/Core/Asset/FileData.hpp @@ -1,8 +1,5 @@ #pragma once - -#include -#include -#include +#include #include #include @@ -10,8 +7,10 @@ #include #include #include -#include -#include + +#include +#include +#include namespace Ra { namespace Core { @@ -21,187 +20,71 @@ class RA_CORE_API FileData final { public: /// CONSTRUCTOR - FileData( const std::string& filename = "", const bool VERBOSE_MODE = false ); + explicit FileData( const std::string& filename = "", const bool VERBOSE_MODE = false ) : + m_filename( filename ), m_verbose( VERBOSE_MODE ) {} FileData( FileData&& data ) = default; - /// DESTRUCTOR - ~FileData(); - /// FILENAME - inline std::string getFileName() const; + [[nodiscard]] inline std::string getFileName() const { return m_filename; } - inline void setFileName( const std::string& filename ); + inline void setFileName( const std::string& filename ) { m_filename = filename; } /// TIMING - inline Scalar getLoadingTime() const; + [[nodiscard]] inline Scalar getLoadingTime() const { return m_loadingTime; } /// DATA - inline std::vector getGeometryData() const; - inline std::vector getVolumeData() const; - inline std::vector getHandleData() const; - inline std::vector getAnimationData() const; - inline std::vector getLightData() const; - inline std::vector getCameraData() const; + [[nodiscard]] inline const auto& getGeometryData() const { return m_geometryData; } + [[nodiscard]] inline const auto& getVolumeData() const { return m_volumeData; } + [[nodiscard]] inline const auto& getHandleData() const { return m_handleData; } + [[nodiscard]] inline const auto& getAnimationData() const { return m_animationData; } + [[nodiscard]] inline const auto& getLightData() const { return m_lightData; } + [[nodiscard]] inline const auto& getCameraData() const { return m_cameraData; } - inline void setVerbose( const bool VERBOSE_MODE ); + inline void setVerbose( const bool VERBOSE_MODE ) { m_verbose = VERBOSE_MODE; } /// QUERY - inline bool isInitialized() const; - inline bool isProcessed() const; - inline bool hasGeometry() const; - inline bool hasHandle() const; - inline bool hasAnimation() const; - inline bool hasLight() const; - inline bool hasCamera() const; - inline bool isVerbose() const; + inline bool isInitialized() const { return !m_processed && m_filename != ""; } + inline bool isProcessed() const { return m_processed; } + inline bool hasGeometry() const { return !m_geometryData.empty(); } + inline bool hasHandle() const { return !m_handleData.empty(); } + inline bool hasAnimation() const { return !m_animationData.empty(); } + inline bool hasLight() const { return !m_lightData.empty(); } + inline bool hasCamera() const { return !m_cameraData.empty(); } + inline bool isVerbose() const { return m_verbose; } /// RESET inline void reset(); - inline void displayInfo() const; + void displayInfo() const; // TODO(Matthieu) : handle attributes in a better way than "public:" public: /// VARIABLE std::string m_filename; - Scalar m_loadingTime; + Scalar m_loadingTime { 0_ra }; std::vector> m_geometryData; std::vector> m_volumeData; std::vector> m_handleData; std::vector> m_animationData; std::vector> m_lightData; std::vector> m_cameraData; - bool m_processed; - bool m_verbose; + bool m_processed { false }; + bool m_verbose { false }; }; -/// FILENAME -inline std::string FileData::getFileName() const { - return m_filename; -} - -inline void FileData::setFileName( const std::string& filename ) { - m_filename = filename; -} - -/// TIMING -inline Scalar FileData::getLoadingTime() const { - return m_loadingTime; -} - -/// DATA -inline std::vector FileData::getGeometryData() const { - std::vector list; - list.reserve( m_geometryData.size() ); - for ( const auto& item : m_geometryData ) { - list.push_back( item.get() ); - } - return list; -} - -inline std::vector FileData::getVolumeData() const { - std::vector list; - list.reserve( m_volumeData.size() ); - for ( const auto& item : m_volumeData ) { - list.push_back( item.get() ); - } - return list; -} - -inline std::vector FileData::getHandleData() const { - std::vector list; - list.reserve( m_handleData.size() ); - for ( const auto& item : m_handleData ) { - list.push_back( item.get() ); - } - return list; -} - -inline std::vector FileData::getAnimationData() const { - std::vector list; - list.reserve( m_animationData.size() ); - for ( const auto& item : m_animationData ) { - list.push_back( item.get() ); - } - return list; -} - -inline std::vector FileData::getLightData() const { - std::vector list; - list.reserve( m_lightData.size() ); - for ( const auto& item : m_lightData ) { - list.push_back( item.get() ); - } - return list; -} - -inline std::vector FileData::getCameraData() const { - std::vector list; - list.reserve( m_cameraData.size() ); - for ( const auto& item : m_cameraData ) { - list.push_back( item.get() ); - } - return list; -} - -inline void FileData::setVerbose( const bool VERBOSE_MODE ) { - m_verbose = VERBOSE_MODE; -} - -/// QUERY -inline bool FileData::isInitialized() const { - return ( ( m_filename != "" ) && !m_processed ); -} - -inline bool FileData::isProcessed() const { - return m_processed; -} - -inline bool FileData::hasGeometry() const { - return ( !m_geometryData.empty() ); -} - -inline bool FileData::hasHandle() const { - return ( !m_handleData.empty() ); -} - -inline bool FileData::hasAnimation() const { - return ( !m_animationData.empty() ); -} - -inline bool FileData::hasLight() const { - return ( !m_lightData.empty() ); -} - -inline bool FileData::isVerbose() const { - return m_verbose; -} - /// RESET inline void FileData::reset() { m_filename = ""; m_geometryData.clear(); + m_volumeData.clear(); m_handleData.clear(); m_animationData.clear(); + m_lightData.clear(); + m_cameraData.clear(); m_processed = false; } -inline void FileData::displayInfo() const { - using namespace Core::Utils; // log - uint64_t vtxCount = 0; - for ( const auto& geom : m_geometryData ) { - vtxCount += geom->getGeometry().vertices().size(); - } - LOG( logINFO ) << "======== LOADING SUMMARY ========"; - LOG( logINFO ) << "Mesh loaded : " << m_geometryData.size(); - LOG( logINFO ) << "Total vertex count : " << vtxCount; - LOG( logINFO ) << "Handle loaded : " << m_handleData.size(); - LOG( logINFO ) << "Animation loaded : " << m_animationData.size(); - LOG( logINFO ) << "Volume loaded : " << m_volumeData.size(); - LOG( logINFO ) << "Loading Time (sec) : " << m_loadingTime; -} - } // namespace Asset } // namespace Core } // namespace Ra diff --git a/src/Engine/Scene/CameraManager.cpp b/src/Engine/Scene/CameraManager.cpp index 09bcca00ad1..4f94f2bb0e6 100644 --- a/src/Engine/Scene/CameraManager.cpp +++ b/src/Engine/Scene/CameraManager.cpp @@ -96,9 +96,9 @@ void CameraManager::generateTasks( Core::TaskQueue* taskQueue, } void CameraManager::handleAssetLoading( Entity* entity, const FileData* filedata ) { - std::vector cameraData = filedata->getCameraData(); - uint id = 0; - uint cpt = 0; + const auto& cameraData = filedata->getCameraData(); + uint id = 0; + uint cpt = 0; for ( const auto& data : cameraData ) { std::string componentName = "CAMERA_" + entity->getName() + std::to_string( id++ ); auto comp = new CameraComponent( entity, componentName, 100, 100 ); diff --git a/src/Engine/Scene/GeometrySystem.cpp b/src/Engine/Scene/GeometrySystem.cpp index 78517d084d6..ad7db56f358 100644 --- a/src/Engine/Scene/GeometrySystem.cpp +++ b/src/Engine/Scene/GeometrySystem.cpp @@ -18,7 +18,7 @@ GeometrySystem::GeometrySystem() : System() {} void GeometrySystem::handleAssetLoading( Entity* entity, const Ra::Core::Asset::FileData* fileData ) { - auto geomData = fileData->getGeometryData(); + const auto& geomData = fileData->getGeometryData(); uint id = 0; @@ -27,19 +27,19 @@ void GeometrySystem::handleAssetLoading( Entity* entity, std::string componentName = "GEOM_" + entity->getName() + std::to_string( id++ ); switch ( data->getType() ) { case Ra::Core::Asset::GeometryData::POINT_CLOUD: - comp = new PointCloudComponent( componentName, entity, data ); + comp = new PointCloudComponent( componentName, entity, data.get() ); break; case Ra::Core::Asset::GeometryData::LINE_MESH: - // comp = new LineMeshComponent( componentName, entity, data ); + // comp = new LineMeshComponent( componentName, entity, data.get() ); // break; case Ra::Core::Asset::GeometryData::TRI_MESH: - comp = new TriangleMeshComponent( componentName, entity, data ); + comp = new TriangleMeshComponent( componentName, entity, data.get() ); break; case Ra::Core::Asset::GeometryData::QUAD_MESH: - comp = new QuadMeshComponent( componentName, entity, data ); + comp = new QuadMeshComponent( componentName, entity, data.get() ); break; case Ra::Core::Asset::GeometryData::POLY_MESH: - comp = new PolyMeshComponent( componentName, entity, data ); + comp = new PolyMeshComponent( componentName, entity, data.get() ); break; case Ra::Core::Asset::GeometryData::TETRA_MESH: case Ra::Core::Asset::GeometryData::HEX_MESH: @@ -50,13 +50,13 @@ void GeometrySystem::handleAssetLoading( Entity* entity, registerComponent( entity, comp ); } - auto volumeData = fileData->getVolumeData(); + const auto& volumeData = fileData->getVolumeData(); id = 0; for ( const auto& data : volumeData ) { std::string componentName = "VOL_" + entity->getName() + std::to_string( id++ ); - auto comp = new VolumeComponent( componentName, entity, data ); + auto comp = new VolumeComponent( componentName, entity, data.get() ); registerComponent( entity, comp ); } } diff --git a/src/Engine/Scene/LightManager.cpp b/src/Engine/Scene/LightManager.cpp index ffa9ba2a0b3..472c3bd8458 100644 --- a/src/Engine/Scene/LightManager.cpp +++ b/src/Engine/Scene/LightManager.cpp @@ -39,8 +39,8 @@ void LightManager::generateTasks( Core::TaskQueue* /*taskQueue*/, } void LightManager::handleAssetLoading( Entity* entity, const FileData* filedata ) { - std::vector lightData = filedata->getLightData(); - uint id = 0; + const auto& lightData = filedata->getLightData(); + uint id = 0; // If thereis some lights already in the manager, just remove from the manager the lights that // belong to the system entity (e.g. the headlight) from the list of managed lights. Beware to diff --git a/src/Engine/Scene/SkeletonBasedAnimationSystem.cpp b/src/Engine/Scene/SkeletonBasedAnimationSystem.cpp index 8337d42c4c6..a128af33c2d 100644 --- a/src/Engine/Scene/SkeletonBasedAnimationSystem.cpp +++ b/src/Engine/Scene/SkeletonBasedAnimationSystem.cpp @@ -87,15 +87,15 @@ void SkeletonBasedAnimationSystem::generateTasks( Core::TaskQueue* taskQueue, void SkeletonBasedAnimationSystem::handleAssetLoading( Entity* entity, const Core::Asset::FileData* fileData ) { - auto skelData = fileData->getHandleData(); - auto animData = fileData->getAnimationData(); + const auto& skelData = fileData->getHandleData(); + const auto& animData = fileData->getAnimationData(); // deal with AnimationComponents Scalar startTime = std::numeric_limits::max(); Scalar endTime = 0; for ( const auto& skel : skelData ) { auto component = new SkeletonComponent( "AC_" + skel->getName(), entity ); - component->handleSkeletonLoading( skel ); + component->handleSkeletonLoading( skel.get() ); component->handleAnimationLoading( animData ); auto [s, e] = component->getAnimationTimeInterval(); startTime = std::min( startTime, s ); @@ -109,7 +109,7 @@ void SkeletonBasedAnimationSystem::handleAssetLoading( Entity* entity, engine->setEndTime( endTime ); // deal with SkinningComponents - auto geomData = fileData->getGeometryData(); + const auto& geomData = fileData->getGeometryData(); if ( geomData.size() > 0 && skelData.size() > 0 ) { for ( const auto& geom : geomData ) { // look for a skeleton skinning this mesh @@ -125,7 +125,7 @@ void SkeletonBasedAnimationSystem::handleAssetLoading( Entity* entity, const auto& skel = *it; SkinningComponent* component = new SkinningComponent( "SkC_" + geom->getName(), SkinningComponent::LBS, entity ); - component->handleSkinDataLoading( skel, geom->getName() ); + component->handleSkinDataLoading( skel.get(), geom->getName() ); registerComponent( entity, component ); } } diff --git a/src/Engine/Scene/SkeletonComponent.cpp b/src/Engine/Scene/SkeletonComponent.cpp index b47ed0e888d..c6db485c5d4 100644 --- a/src/Engine/Scene/SkeletonComponent.cpp +++ b/src/Engine/Scene/SkeletonComponent.cpp @@ -90,7 +90,7 @@ void SkeletonComponent::handleSkeletonLoading( const Core::Asset::HandleData* da } void SkeletonComponent::handleAnimationLoading( - const std::vector& data ) { + const std::vector>& data ) { CORE_ASSERT( ( m_skel.size() != 0 ), "A Skeleton should be loaded first." ); m_animations.clear(); m_animations.reserve( data.size() ); diff --git a/src/Engine/Scene/SkeletonComponent.hpp b/src/Engine/Scene/SkeletonComponent.hpp index 9ec28d62a85..778cb16578c 100644 --- a/src/Engine/Scene/SkeletonComponent.hpp +++ b/src/Engine/Scene/SkeletonComponent.hpp @@ -75,7 +75,8 @@ class RA_ENGINE_API SkeletonComponent : public Component void handleSkeletonLoading( const Core::Asset::HandleData* data ); /// Create the animations from the given data. - void handleAnimationLoading( const std::vector& data ); + void + handleAnimationLoading( const std::vector>& data ); /// \} /// \name Skeleton-based animation data From 211d427a38b6224b74c98f2949ab0cc1b522e3a1 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Sat, 15 Apr 2023 16:51:02 +0200 Subject: [PATCH 10/17] [engine] fix rebase/merge conflicts --- src/Engine/Data/RawShaderMaterial.cpp | 1 - src/Engine/Data/RawShaderMaterial.hpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Engine/Data/RawShaderMaterial.cpp b/src/Engine/Data/RawShaderMaterial.cpp index 0c7e3030178..2d4ff4340d7 100644 --- a/src/Engine/Data/RawShaderMaterial.cpp +++ b/src/Engine/Data/RawShaderMaterial.cpp @@ -7,7 +7,6 @@ namespace Ra { namespace Engine { namespace Data { - RawShaderMaterial::RawShaderMaterial( const std::string& instanceName, const std::vector>& shaders, diff --git a/src/Engine/Data/RawShaderMaterial.hpp b/src/Engine/Data/RawShaderMaterial.hpp index 2f7b30cbe9e..5bba92bbd23 100644 --- a/src/Engine/Data/RawShaderMaterial.hpp +++ b/src/Engine/Data/RawShaderMaterial.hpp @@ -156,8 +156,8 @@ class RA_ENGINE_API RawShaderMaterial : public Material }; inline Material* -RawShaderMaterialConverter::operator()( const Ra::Core::Asset::MaterialData* toconvert ) { - auto mat = static_cast( toconvert ); +RawShaderMaterialConverter::operator()( const Ra::Core::Material::MaterialModel* toconvert ) { + auto mat = static_cast( toconvert ); return new RawShaderMaterial( mat->getName(), mat->m_shaders, mat->m_paramProvider ); } From da9732dfaeb7c689454c9d04629485e70248207f Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Sat, 15 Apr 2023 16:43:21 +0200 Subject: [PATCH 11/17] [core] small refactor on asset : AssetData base class --- src/Core/Asset/AssetData.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Core/Asset/AssetData.hpp b/src/Core/Asset/AssetData.hpp index 606083a73bf..e4e7a0f59c1 100644 --- a/src/Core/Asset/AssetData.hpp +++ b/src/Core/Asset/AssetData.hpp @@ -1,6 +1,6 @@ #pragma once - #include + #include namespace Ra { @@ -19,16 +19,15 @@ class RA_CORE_API AssetData /// Construct an asset data given its name. explicit AssetData( const std::string& name ) : m_name( name ) {} - /// Copy constructor. Default here - AssetData( const AssetData& other ) = default; - /// Simple delete operator - virtual ~AssetData() {} + virtual ~AssetData() = default; - /// Acces to the name of the asset - inline virtual const std::string& getName() const { return m_name; } + /// Access to the name of the asset + inline const std::string& getName() const { return m_name; } + /// Set the name of the asset + inline void setName( const std::string& name ) { m_name = name; } - protected: + private: std::string m_name; }; From 5a2c8fece4fc8c613c20f6dd735fc6a964f17952 Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Sat, 15 Apr 2023 17:20:15 +0200 Subject: [PATCH 12/17] [core][io] small refactor on asset : animation data --- src/Core/Asset/AnimationData.cpp | 19 +- src/Core/Asset/AnimationData.hpp | 52 ++-- src/Core/Asset/AnimationTime.hpp | 26 +- src/Core/Asset/HandleData.cpp | 34 ++- src/Core/Asset/HandleData.hpp | 237 +++--------------- .../AssimpAnimationDataLoader.cpp | 2 +- 6 files changed, 106 insertions(+), 264 deletions(-) diff --git a/src/Core/Asset/AnimationData.cpp b/src/Core/Asset/AnimationData.cpp index b4aa88ffca9..26e9b8fa23c 100644 --- a/src/Core/Asset/AnimationData.cpp +++ b/src/Core/Asset/AnimationData.cpp @@ -1,17 +1,20 @@ #include +#include + namespace Ra { namespace Core { namespace Asset { -HandleAnimation::HandleAnimation( const std::string& name ) : - m_name( name ), m_anim( -1, Transform::Identity() ) {} - -AnimationData::AnimationData( const std::string& name ) : - AssetData( name ), m_time(), m_dt( 0.0 ), m_keyFrame() {} - -AnimationData::~AnimationData() {} - +void AnimationData::displayInfo() const { + using namespace Core::Utils; // log + LOG( logDEBUG ) << "======== ANIMATION INFO ========"; + LOG( logDEBUG ) << " Name : " << getName(); + LOG( logDEBUG ) << " Start Time : " << m_time.getStart(); + LOG( logDEBUG ) << " End Time : " << m_time.getEnd(); + LOG( logDEBUG ) << " Time Step : " << m_dt; + LOG( logDEBUG ) << " Animated Object # : " << m_keyFrame.size(); +} } // namespace Asset } // namespace Core } // namespace Ra diff --git a/src/Core/Asset/AnimationData.hpp b/src/Core/Asset/AnimationData.hpp index 525431879df..81f99bb4e95 100644 --- a/src/Core/Asset/AnimationData.hpp +++ b/src/Core/Asset/AnimationData.hpp @@ -4,26 +4,27 @@ #include #include #include -#include #include #include namespace Ra { namespace Core { +using namespace Animation; namespace Asset { /** * A HandleAnimation stores data for an animation Handle. */ struct RA_CORE_API HandleAnimation { - explicit HandleAnimation( const std::string& name = "" ); + explicit HandleAnimation( const std::string& name = "" ) : + m_name( name ), m_anim( -1, Transform::Identity() ) {} /// The Handle's name. std::string m_name; /// The list of KeyFramed transforms applied to the Handle. - Core::Animation::KeyFramedValue m_anim; + KeyFramedValue m_anim; /// The AnimationTime for the Handle. AnimationTime m_animationTime; @@ -37,14 +38,8 @@ struct RA_CORE_API HandleAnimation { class RA_CORE_API AnimationData : public AssetData { public: - explicit AnimationData( const std::string& name = "" ); - - ~AnimationData(); - - /** - * Sets the name of the animation. - */ - inline void setName( const std::string& name ) { m_name = name; } + explicit AnimationData( const std::string& name = "" ) : + AssetData( name ), m_dt( 0.0 ), m_keyFrame() {} /// \name Time /// \{ @@ -59,12 +54,12 @@ class RA_CORE_API AnimationData : public AssetData */ inline void setTime( const AnimationTime& time ) { m_time = time; } /** - * \returns the animation timestep. + * \returns the animation time-step. */ inline AnimationTime::Time getTimeStep() const { return m_dt; } /** - * Sets the animation timestep. + * Sets the animation time-step.  */ inline void setTimeStep( const AnimationTime::Time& delta ) { m_dt = delta; } @@ -81,49 +76,32 @@ class RA_CORE_API AnimationData : public AssetData /** * \returns the list of HandleAnimations, i.e. the whole animation frames. */ - inline std::vector getHandleData() const { return m_keyFrame; } + inline const std::vector& getHandleData() const { return m_keyFrame; } /** * Sets the animation frames. */ - inline void setHandleData( const std::vector& frameList ); + inline void setHandleData( std::vector&& keyFrames ) { + m_keyFrame = std::move( keyFrames ); + } /// \} /** * Print stat info to the Debug output. */ - inline void displayInfo() const; + void displayInfo() const; - protected: + private: /// The AnimationTime for the object. AnimationTime m_time; - /// The animation timestep. + /// The animation time-step. AnimationTime::Time m_dt { 0 }; /// The animation frames. std::vector m_keyFrame; }; -inline void AnimationData::setHandleData( const std::vector& frameList ) { - const uint size = frameList.size(); - m_keyFrame.resize( size ); -#pragma omp parallel for - for ( int i = 0; i < int( size ); ++i ) { - m_keyFrame[i] = frameList[i]; - } -} - -inline void AnimationData::displayInfo() const { - using namespace Core::Utils; // log - LOG( logDEBUG ) << "======== ANIMATION INFO ========"; - LOG( logDEBUG ) << " Name : " << m_name; - LOG( logDEBUG ) << " Start Time : " << m_time.getStart(); - LOG( logDEBUG ) << " End Time : " << m_time.getEnd(); - LOG( logDEBUG ) << " Time Step : " << m_dt; - LOG( logDEBUG ) << " Animated Object # : " << m_keyFrame.size(); -} - } // namespace Asset } // namespace Core } // namespace Ra diff --git a/src/Core/Asset/AnimationTime.hpp b/src/Core/Asset/AnimationTime.hpp index 6eb774cb906..cb28b28795a 100644 --- a/src/Core/Asset/AnimationTime.hpp +++ b/src/Core/Asset/AnimationTime.hpp @@ -1,6 +1,6 @@ #pragma once - #include + #include #include @@ -20,13 +20,9 @@ class RA_CORE_API AnimationTime using Time = Scalar; AnimationTime( const Time& start = std::numeric_limits