i am trying to make a mesh than get generated while the game is played by copying and merging some static meshes so i started by copying the cube mesh
first:: i located it
cubeMesh = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cube.Cube'")).Object;
second i collected the vertices and triangleindices to my arrays
//convert ro px mesh
PxTriangleMesh* TempTriMesh = meshparam->BodySetup->TriMeshes[0];
//get parameters
const PxVec3* PVertices = TempTriMesh->getVertices();
int32 TriNumber = TempTriMesh->getNbTriangles();
const void* Triangles = TempTriMesh->getTriangles();
int32 vertexNum = TempTriMesh->getNbVertices();
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString(std::to_string(vertexNum).c_str()));
for (int32 TriIndex = 0; TriIndex < TriNumber; ++TriIndex)
{
//adding indices
FVector triNormal;
if (TempTriMesh->getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES)
{
PxU16* P16BitIndices = (PxU16*)Triangles;
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P16BitIndices[(TriIndex * 3) + 0]])));
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P16BitIndices[(TriIndex * 3) + 1]])));
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P16BitIndices[(TriIndex * 3) + 2]])));
}
else
{
PxU32* P32BitIndices = (PxU32*)Triangles;
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P32BitIndices[(TriIndex * 3) + 0]])));
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P32BitIndices[(TriIndex * 3) + 1]])));
meshIndices.Add(RegisterVertex(GetFVector(PVertices[P32BitIndices[(TriIndex * 3) + 2]])));
}
//add UVs
meshUVs.Add(FVector2D(0, 0));
meshUVs.Add(FVector2D(0, 1));
meshUVs.Add(FVector2D(1, 0));
}
and u may wonder where the tangets and normals and colors but i filled them by myself in old attempt but they didnt change the result so i use this code to generate them
UKismetProceduralMeshLibrary::CalculateTangentsForMesh(meshVertices, meshIndices, meshUVs, meshNormals, meshTangets);
after all of that that what i get is this the texture is so currapted
while if i registered the vertices by my self like that
//define triangel index
meshIndices.Add(fPointIndix);
meshIndices.Add(sPointIndix);
meshIndices.Add(tPointIndix);
//add UVs
meshUVs.Add(FVector2D(0, 0));
meshUVs.Add(FVector2D(0, 1));
meshUVs.Add(FVector2D(1, 0));
the triangle become so clear with the textures
i dont know what to do i made a low vertices number mesh by blender like 6 vertices but it was the same as the cube i searshed alot but no thing
pls helppppppppppp