Skip to content

Commit

Permalink
check assimp ver
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@openrobotics.org>
  • Loading branch information
iche033 committed Mar 1, 2024
1 parent 98a9aaf commit eac2ef0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions graphics/src/AssimpLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial(
mat->SetBlendFactors(opacity, 1.0 - opacity);
}

#ifndef GZ_ASSIMP_PRE_5_1_0
// basic support for transmission - currently just overrides opacity
// \todo(iche033) The transmission factor can be used with volume
// material extension to simulate effects like refraction
Expand All @@ -374,6 +375,7 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial(
{
mat->SetTransparency(transmission);
}
#endif

// TODO(luca) more than one texture, Gazebo assumes UV index 0
Pbr pbr;
Expand Down
2 changes: 2 additions & 0 deletions graphics/src/AssimpLoader_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ TEST_F(AssimpLoader, LoadGlTF2BoxExternalTexture)
// Open a gltf mesh with transmission extension
TEST_F(AssimpLoader, LoadGlTF2BoxTransmission)
{
#ifdef GZ_ASSIMP_PRE_5_1_0
common::AssimpLoader loader;
common::Mesh *mesh = loader.Load(
common::testing::TestFile("data", "box_transmission.glb"));
Expand All @@ -685,6 +686,7 @@ TEST_F(AssimpLoader, LoadGlTF2BoxTransmission)
// transmission currently modeled as transparency
EXPECT_FLOAT_EQ(0.1, mat->Transparency());
delete mesh;
#endif
}

/////////////////////////////////////////////////
Expand Down
10 changes: 8 additions & 2 deletions graphics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ gz_build_tests(
)

# Assimp doesn't offer preprocessor version, use cmake to set a compatibility
# mode for versions below 5.2.0
# mode for versions below 5.2.0 and 5.1.0
if(${GzAssimp_VERSION} STRLESS "5.2.0")
message("Warning, assimp below 5.2.0 detected, setting compatibility mode")
target_compile_definitions(${graphics_target} PRIVATE GZ_ASSIMP_PRE_5_2_0)
if(TARGET UNIT_AssimpLoader_TEST)
target_compile_definitions(UNIT_AssimpLoader_TEST PRIVATE GZ_ASSIMP_PRE_5_2_0)
endif()
if(${GzAssimp_VERSION} STRLESS "5.1.0")
message("Warning, assimp below 5.1.0 detected, setting compatibility mode")
target_compile_definitions(${graphics_target} PRIVATE GZ_ASSIMP_PRE_5_1_0)
if(TARGET UNIT_AssimpLoader_TEST)
target_compile_definitions(UNIT_AssimpLoader_TEST PRIVATE GZ_ASSIMP_PRE_5_1_0)
endif()
endif()
endif()


if(USE_EXTERNAL_TINYXML2)

# If we are using an external copy of tinyxml2, add its imported target
Expand Down

0 comments on commit eac2ef0

Please sign in to comment.