예제 #1
0
UInstancedStaticMeshComponent &ACityMapMeshHolder::GetInstantiator(ECityMapMeshTag Tag)
{
  UInstancedStaticMeshComponent *instantiator = MeshInstatiators[CityMapMeshTag::ToUInt(Tag)];
  if (instantiator == nullptr) {
    // Create and register an instantiator.
    instantiator = NewObject<UInstancedStaticMeshComponent>(this);
    instantiator->SetMobility(EComponentMobility::Static);
    instantiator->SetCollisionObjectType(ECollisionChannel::ECC_WorldStatic);
    instantiator->SetupAttachment(SceneRootComponent);
    instantiator->SetStaticMesh(GetStaticMesh(Tag));
    MeshInstatiators[CityMapMeshTag::ToUInt(Tag)] = instantiator;
    instantiator->RegisterComponent();
  }
  check(instantiator != nullptr);
  return *instantiator;
}
예제 #2
0
void UVoxelComponent::InitVoxel()
{
	CellBounds = FBoxSphereBounds(FVector::ZeroVector, FVector(100.f, 100.f, 100.f), 100.f);
	Mesh.Empty();
	Cell.Empty();
	InstancedStaticMeshComponents.Empty();
	if (Voxel) {
		CellBounds = Voxel->CellBounds;
		Mesh = Voxel->Mesh;
		Cell = Voxel->Voxel;
		for (int32 i = 0; i < Mesh.Num(); ++i) {
			UInstancedStaticMeshComponent* Proxy = NewObject<UInstancedStaticMeshComponent>(this, NAME_None, RF_Transactional);
			Proxy->SetStaticMesh(Mesh[i]);
			Proxy->AttachTo(GetOwner()->GetRootComponent(), NAME_None);
			InstancedStaticMeshComponents.Add(Proxy);
		}
		AddVoxel();
	}
}