diff --git a/Sources/Assimp/AiMatKey.swift b/Sources/Assimp/AiMatKey.swift index f98cbef..7bb7967 100644 --- a/Sources/Assimp/AiMatKey.swift +++ b/Sources/Assimp/AiMatKey.swift @@ -14,9 +14,7 @@ public struct AiMatKey: RawRepresentable { public let rawValue: String init(base: Base, texType: AiTextureType = .none, texIndex: Int = 0) { - self.rawValue = base.rawValue.withCString { basePtr -> String in - return String(format: "%@,%d,%d", basePtr, texType.rawValue, texIndex) - } + self.rawValue = "\(base.rawValue),\(texType.rawValue),\(texIndex)" self.baseName = base.rawValue self.texType = texType.rawValue self.texIndex = UInt32(texIndex) diff --git a/Tests/AssimpTests/AssimpTests.swift b/Tests/AssimpTests/AssimpTests.swift index a3011a0..286b4a3 100644 --- a/Tests/AssimpTests/AssimpTests.swift +++ b/Tests/AssimpTests/AssimpTests.swift @@ -71,7 +71,7 @@ final class AssimpTests: XCTestCase { XCTAssertEqual(scene.meshes[0].numFaces, 2144) XCTAssertEqual(scene.meshes[0].numBones, 0) XCTAssertEqual(scene.meshes[0].numAnimMeshes, 0) - + // Faces XCTAssertEqual(scene.meshes[0].numFaces, 2144) @@ -100,7 +100,11 @@ final class AssimpTests: XCTestCase { // Cameras XCTAssertEqual(scene.cameras.count, 1) - + + print(scene.materials.map { $0.debugDescription }) + + XCTAssertEqual(scene.materials[0].getMaterialColor(.COLOR_DIFFUSE), SIMD4(1.0, 1.0, 1.0, 1.0)) + XCTAssertEqual(scene.materials[0].getMaterialString(.TEXTURE(.diffuse, 0)), "./duckCM.tga") } func testLoadAiSceneObj() throws { @@ -237,6 +241,9 @@ final class AssimpTests: XCTestCase { // Cameras XCTAssertEqual(scene.cameras.count, 0) + + XCTAssertEqual(scene.materials[0].getMaterialColor(.COLOR_DIFFUSE), SIMD4(0.5882353, 0.5882353, 0.5882353, 1.0)) + XCTAssertEqual(scene.materials[0].getMaterialString(.TEXTURE(.diffuse, 0)), "TEST.PNG") } }