瀏覽代碼

Rgba2Hex to repair rgba(1,1,1,1)

Hehongyuanlove 5 年之前
父節點
當前提交
3bbc8e76bd
共有 1 個文件被更改,包括 22 次插入10 次删除
  1. 22 10
      code/3MF/D3MFExporter.cpp

+ 22 - 10
code/3MF/D3MFExporter.cpp

@@ -254,16 +254,28 @@ void D3MFExporter::writeBaseMaterials() {
         if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
         if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
             hexDiffuseColor.clear();
             hexDiffuseColor.clear();
             tmp.clear();
             tmp.clear();
-            hexDiffuseColor = "#";
-            
-            tmp = DecimalToHexa( (ai_real) color.r );
-            hexDiffuseColor += tmp;
-            tmp = DecimalToHexa((ai_real)color.g);
-            hexDiffuseColor += tmp;
-            tmp = DecimalToHexa((ai_real)color.b);
-            hexDiffuseColor += tmp;
-            tmp = DecimalToHexa((ai_real)color.a);
-            hexDiffuseColor += tmp;
+            // rgbs %
+    		if(color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1){
+    	
+    			 hexDiffuseColor = Rgba2Hex(
+    			 	((ai_real)color.r)*255,
+    			 	((ai_real)color.g)*255,
+    			 	((ai_real)color.b)*255,
+    			 	((ai_real)color.a)*255,
+    			 	true
+    			 );
+    			 
+    		}else{
+    			hexDiffuseColor = "#";
+            	tmp = DecimalToHexa( (ai_real) color.r );
+            	hexDiffuseColor += tmp;
+            	tmp = DecimalToHexa((ai_real)color.g);
+            	hexDiffuseColor += tmp;
+            	tmp = DecimalToHexa((ai_real)color.b);
+            	hexDiffuseColor += tmp;
+            	tmp = DecimalToHexa((ai_real)color.a);
+            	hexDiffuseColor += tmp;
+    		}
         } else {
         } else {
             hexDiffuseColor = "#FFFFFFFF";
             hexDiffuseColor = "#FFFFFFFF";
         }
         }