Skip to content

Commit

Permalink
workaround for missing uv0 coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
NegInfinity committed Jun 3, 2019
1 parent 117f537 commit e33fd20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ void JsonImporter::importStaticMesh(const JsonMesh &jsonMesh, int32 meshId){
);

if (mesh){
/*
auto bodySetup = mesh->BodySetup;
if (!bodySetup){
mesh->CreateBodySetup();
}
*/

auto meshPath = mesh->GetPathName();
meshIdMap.Add(jsonMesh.id, meshPath);
}
Expand Down Expand Up @@ -111,6 +104,7 @@ void JsonImporter::importSkeletalMesh(const JsonMesh &jsonMesh, int32 meshId){
}

void JsonImporter::importMesh(const JsonMesh &jsonMesh, int32 meshId){
UE_LOG(JsonLog, Log, TEXT("Importing mesh: %s(%d)"), *jsonMesh.name, jsonMesh.id.id)
UE_LOG(JsonLog, Log, TEXT("Mesh data: Verts: %d; submeshes: %d; materials: %d; colors %d; normals: %d"),
jsonMesh.verts.Num(), jsonMesh.subMeshes.Num(), jsonMesh.colors.Num(), jsonMesh.normals.Num());
UE_LOG(JsonLog, Log, TEXT("Mesh data: uv0: %d; uv1: %d; uv2: %d; uv3: %d; uv4: %d; uv5: %d; uv6: %d; uv7: %d;"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ void MeshBuilder::setupStaticMesh(UStaticMesh *mesh, const JsonMesh &jsonMesh, s
UE_LOG(JsonLog, Log, TEXT("Uv floats[%d]: %d, hasUvs: %d"), i, uvFloats[i]->Num(), (int)hasUvs[i]);
}

if (!hasUvs[0]){
UE_LOG(JsonLog, Warning, TEXT("No default uvs found on mesh %s(%d). Placeholder coordinates will be used."), *jsonMesh.name, jsonMesh.id.id);
}

//submesh generation
newRawMesh.WedgeIndices.SetNum(0);

Expand Down Expand Up @@ -101,8 +105,14 @@ void MeshBuilder::setupStaticMesh(UStaticMesh *mesh, const JsonMesh &jsonMesh, s
);

for(int32 uvIndex = 0; uvIndex < maxUvs; uvIndex++){
if (!hasUvs[uvIndex])
if (!hasUvs[uvIndex]){
if (uvIndex != 0)
continue;
auto tmpPos = getIdxVector3(jsonMesh.verts, origIndex);
FVector2D tmpUv(tmpPos.X, tmpPos.Y);
newRawMesh.WedgeTexCoords[uvIndex].Add(tmpUv);
continue;
}

auto tmpUv = getIdxVector2(*uvFloats[uvIndex], origIndex);
tmpUv.Y = 1.0f - tmpUv.Y;
Expand Down

0 comments on commit e33fd20

Please sign in to comment.