Sorry for the late reply but this was exactly what I was looking for, thank you very much.
Now I am having issues trying to get the heightdata from Landscape. I thought I could do it just like the other Shapes:
for (TActorIterator<AStaticMeshActor> ActorItr(gi->GetWorld()); ActorItr; ++ActorItr)
{
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Yellow, ActorItr->GetName());
UStaticMeshComponent* collision;
for (int32 a = 0; a < ActorItr->GetComponentsByClass(UStaticMeshComponent::StaticClass()).Num(); a++)
{
collision = (UStaticMeshComponent*)ActorItr->GetComponentsByClass(UStaticMeshComponent::StaticClass())[a];
TArray<physx::PxShape*> CollisionShapes = collision->BodyInstance.GetAllShapes(shapes);
for (int32 shape = 0; shape < CollisionShapes.Num(); shape++)
{
physx::PxShape* s = CollisionShapes[shape];
physx::PxGeometryType::Enum gt = s->getGeometryType();
switch (gt)
{
case physx::PxGeometryType::Enum::eBOX:
///GOOD
break;
case physx::PxGeometryType::Enum::eCAPSULE:
///GOOD
case physx::PxGeometryType::Enum::eSPHERE:
///GOOD
break;
case physx::PxGeometryType::Enum::eHEIGHTFIELD:
///NEVER GETS HIT
}
}
}
but the case for the eHeightField never gets hit. I was thinking this was because Landscape wasn’t inheriting from AStaticMeshActor. So I tried this:
for (TActorIterator<ALandscape> ActorItr(gi->GetWorld()); ActorItr; ++ActorItr)
{
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Yellow, ActorItr->GetName());
lprxy = (ALandscape*)*ActorItr;
TArray<physx::PxShape*> CollisionShapes = lprxy->BodyInstance.GetAllShapes(shapes2);
bi = lprxy->BodyInstance;
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Blue, FString("Col Shapes: ").Append(FString::FromInt(CollisionShapes.Num())));
for (int32 shape = 0; shape < CollisionShapes.Num(); shape++)
{
physx::PxShape* s = CollisionShapes[shape];
physx::PxGeometryType::Enum gt = s->getGeometryType();
}
}
but CollisionShapes var is always returning 0. So I am at a loss of how to get the PhysX heightfield data. Once I get the instance of it I can:
physx::PxHeightFieldGeometry heightFieldG = PxHeightFieldGeometry();
case physx::PxGeometryType::Enum::eHEIGHTFIELD:
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Yellow, "HEIGHTFIELD");
if (s->getHeightFieldGeometry(heightFieldG))
{
bpterrain.Center = FPositionData(center.X, -center.Y, center.Z);
bpterrain.LocalScale = FPositionData(localScale.X, localScale.Z, localScale.Y);
bpterrain.Rotation = FPositionData(rotation.Yaw, rotation.Pitch, rotation.Roll);
physx::PxHeightField* heightField = heightFieldG.heightField;
}
but I cannot get the instance. Any thoughts?