Browse Source

Enable interpret and generate tag 'd' in materials, to apply

George Tavares 9 years ago
parent
commit
94a782ffe1
1 changed files with 11 additions and 0 deletions
  1. 11 0
      utils/converters/utf8/src/mesh.h

+ 11 - 0
utils/converters/utf8/src/mesh.h

@@ -312,9 +312,14 @@ struct Material {
   std::string name;
   float Kd[3];
   std::string map_Kd;
+  std::string d;
+  
 
   void DumpJson(FILE* out = stdout) const {
     fprintf(out, "    \"%s\": { ", name.c_str());
+    if (!d.empty()) {
+      fprintf(out, "\"d\": %s ,", d.c_str());
+    }    
     if (map_Kd.empty()) {
       fprintf(out, "\"Kd\": [%hu, %hu, %hu] }",
               Quantize(Kd[0], 0, 1, 255),
@@ -357,6 +362,9 @@ class WavefrontMtlFile {
       case 'K':
         ParseColor(line + 1, line_num);
         break;
+      case 'd':
+        ParseD(line + 1, line_num);
+        break;
       case 'm':
         if (0 == strncmp(line + 1, "ap_Kd", 5)) {
           ParseMapKd(line + 6, line_num);
@@ -386,6 +394,9 @@ class WavefrontMtlFile {
         break;
     }
   }
+  void ParseD(const char* line, unsigned int line_num) {
+      current_->d = StripLeadingWhitespace(line);
+  }
 
   void ParseMapKd(const char* line, unsigned int line_num) {
     current_->map_Kd = StripLeadingWhitespace(line);