ソースを参照

Add files via upload

scale blender vert color out to 0-1 range as aiColor specifies
TrianglesPCT 9 年 前
コミット
28c9f56c5e
1 ファイル変更5 行追加4 行削除
  1. 5 4
      code/BlenderLoader.cpp

+ 5 - 4
code/BlenderLoader.cpp

@@ -1118,12 +1118,13 @@ void BlenderImporter::ConvertMesh(const Scene& /*in*/, const Object* /*obj*/, co
             const aiFace& f = out->mFaces[out->mNumFaces++];
             const aiFace& f = out->mFaces[out->mNumFaces++];
 
 
             aiColor4D* vo = &out->mColors[0][out->mNumVertices];
             aiColor4D* vo = &out->mColors[0][out->mNumVertices];
+			const float scaleZeroToOne = 1.f / 255.f;
             for (unsigned int j = 0; j < f.mNumIndices; ++j,++vo,++out->mNumVertices) {
             for (unsigned int j = 0; j < f.mNumIndices; ++j,++vo,++out->mNumVertices) {
                 const MLoopCol& col = mesh->mloopcol[v.loopstart + j];
                 const MLoopCol& col = mesh->mloopcol[v.loopstart + j];
-                vo->r = col.r;
-                vo->g = col.g;
-                vo->b = col.b;
-                vo->a = col.a;
+                vo->r = float(col.r) * scaleZeroToOne;
+                vo->g = float(col.g) * scaleZeroToOne;
+                vo->b = float(col.b) * scaleZeroToOne;
+                vo->a = float(col.a) * scaleZeroToOne;
             }
             }
 
 
         }
         }