5#include <gtest/gtest.h>
13#include "testing/testing.h"
34 std::string tmp_file_name =
"mtl_test.mtl";
35 std::string tmp_file_path = tmp_dir +
SEP_STR + tmp_file_name;
36 FILE *tmp_file =
BLI_fopen(tmp_file_path.c_str(),
"wb");
37 fputs(text, tmp_file);
40 check_impl(tmp_file_name, tmp_dir, expect, expect_count);
42 BLI_delete(tmp_file_path.c_str(),
false,
false);
46 std::string obj_dir = blender::tests::flags_test_asset_dir() +
48 check_impl(file, obj_dir, expect, expect_count);
55 MTLParser parser(mtl_file_path, file_dir +
"dummy.obj");
59 for (
int i = 0;
i < expect_count; ++
i) {
62 fprintf(stderr,
"Material '%s' was expected in parsed result\n",
exp.name.c_str());
67 const float tol = 0.0001f;
69 EXPECT_V3_NEAR(
exp.color, got.
color, tol);
74 EXPECT_NEAR(
exp.ior, got.
ior, tol);
75 EXPECT_NEAR(
exp.alpha, got.
alpha, tol);
80 EXPECT_NEAR(
exp.sheen, got.
sheen, tol);
83 EXPECT_NEAR(
exp.aniso, got.
aniso, tol);
90 EXPECT_V3_NEAR(exp_tex.
scale, got_tex.
scale, tol);
102 " # indented comment\n"
103 "# comment with CRLF line ending\r\n"
110 "newmtl\ttab_indentation\n"
111 "Kd\t \t0.2 0.3\t0.4 \t \n"
113 "newmtl space_after_name \t \n"
116 "newmtl space_before_name\n"
118 "newmtl indented_values\n"
120 "\t\t\tKd 0.6 0.7 0.8\n"
122 "newmtl crlf_ending\r\n"
124 "map_Kd sometex_d.png\r\n"
125 "map_Ks sometex_s_spaces_after_name.png \t \r\n";
127 mat[0].
name =
"simple";
130 mat[1].
name =
"tab_indentation";
131 mat[1].
color = {0.2f, 0.3f, 0.4f};
132 mat[2].
name =
"space_after_name";
134 mat[3].
name =
"space_before_name";
135 mat[4].
name =
"indented_values";
137 mat[4].
color = {0.6f, 0.7f, 0.8f};
138 mat[5].
name =
"crlf_ending";
148 mat[0].
name =
"no_textures_red";
150 mat[0].
color = {0.8f, 0.3f, 0.1f};
153 mat[1].
name =
"four_maps";
155 mat[1].
color = {0.8f, 0.8f, 0.8f};
174 mat[2].
name =
"Clay";
176 mat[2].
color = {0.8f, 0.682657f, 0.536371f};
186 mat[3].
color = {0.8f, 0.8f, 0.8f};
192 kd.
image_path =
"someHatTexture_BaseColor.jpg";
194 ns.
image_path =
"someHatTexture_Roughness.jpg";
196 refl.
image_path =
"someHatTexture_Metalness.jpg";
198 bump.
image_path =
"someHatTexture_Normal.jpg";
201 mat[4].
name =
"Parser_Test";
203 mat[4].
color = {0.4f, 0.5f, 0.6f};
226 refl.
scale = {1.5f, 2.5f, 3.5f};
231 bump.
scale = {3, 4, 5};
234 mat[5].
name =
"Parser_ScaleOffset_Test";
240 ks.
scale = {1.5f, 2.5f, 1.0f};
242 ks.
image_path =
"ScaleOffsetBothTwovalues.png";
244 ns.
scale = {0.5f, 1.0f, 1.0f};
254 mat[0].
name =
"Mat1";
255 mat[0].
color = {0.8f, 0.276449f, 0.101911f};
263 mat[0].
sheen = 0.06f;
269 mat[1].
name =
"Mat2";
270 mat[1].
color = {0.8f, 0.8f, 0.8f};
282 pr.
image_path =
"../blend_geometry/texture_roughness.png";
284 ps.
image_path =
"../blend_geometry/texture_checker.png";
286 ke.
image_path =
"../blend_geometry/texture_illum.png";
289 check(
"materials_pbr.mtl", mat,
ARRAY_SIZE(mat));
void BKE_tempdir_init(const char *userdir)
const char * BKE_tempdir_base() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
const Value & lookup(const Key &key) const
bool contains(const Key &key) const
void parse_and_store(Map< std::string, std::unique_ptr< MTLMaterial > > &r_materials)
void check_string(const char *text, const MTLMaterial *expect, size_t expect_count)
void check_impl(StringRefNull mtl_file_path, StringRefNull file_dir, const MTLMaterial *expect, size_t expect_count)
static void SetUpTestCase()
void check(const char *file, const MTLMaterial *expect, size_t expect_count)
static void TearDownTestCase()
TEST_F(OBJExportTest, filter_objects_curves_as_mesh)
const MTLTexMap & tex_map_of_type(MTLTexMapType key) const
MTLTexMap texture_maps[int(MTLTexMapType::Count)]