Commit 1b637bdd by wester

instances

parent 756191bf
......@@ -118,21 +118,21 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
gltf->loadModel(&data.GetData()[GLTFstart], (data.Num() - GLTFstart));
//https://answers.unrealengine.com/questions/136562/is-there-a-way-to-clone-duplicate-an-actor-in-c.html
//http://www.dirsig.org/docs/new/coordinates.html
if (JsonParsed->HasField("POSITION")) {
uint32 featureTableBinaryOffset = i3dmheader->getFeatureStart() + i3dmheader->featureTable.featureTableJSONByteLength;
TSharedPtr<FJsonObject> binaryBodyReference = JsonParsed->GetObjectField("POSITION");
int32 byteOffset = binaryBodyReference->GetIntegerField("byteOffset");
TArray<FVector> positons = TArray<FVector>();// getAsArray<FVector>(data.GetData(), featureTableBinaryOffset + byteOffset, instances_length);
TArray<FVector> positons = getAsArray<FVector>(data.GetData(), (int32)(featureTableBinaryOffset + byteOffset), instances_length);
FString outputString = "[";
for (FVector pos : positons)
{
outputString += "[" + pos.ToString() +"] ";
gltf->clone(pos);
}
outputString += "]";
UE_LOG(TILES, Warning, TEXT("InStanced 3D Model Positions %s"), *outputString);
......@@ -144,10 +144,7 @@ void ATilesetActor::parseInstanced3DTile(const TArray<uint8> data, FTile * tile)
}
}
}
void ATilesetActor::parse3DTile(const TArray<uint8> data, FTile *tile)
......
......@@ -299,15 +299,14 @@ private:
void parseBatched3DTile(const TArray<uint8> data, FTile *tile);
void parseInstanced3DTile(const TArray<uint8> data, FTile *tile);
template <typename T> TArray<T> getAsArray(uint8* data, int32 offset, int32 numberOfElements);
template <typename T> TArray<T> getAsArray(const uint8* data, int32 offset, int32 numberOfElements);
};
template<typename T>
inline TArray<T> ATilesetActor::getAsArray(uint8 *data, int32 offset, int32 numberOfElements)
inline TArray<T> ATilesetActor::getAsArray(const uint8 *data, int32 offset, int32 numberOfElements)
{
//T *ArrayPointer = (T*)(data + offset);
//TArray<T> result;
//result.Append(ArrayPointer, numberOfElements);
//return result;
return TArray<T>();
T *ArrayPointer = (T*)(data + offset);
TArray<T> result;
result.Append(ArrayPointer, numberOfElements);
return result;
}
......@@ -278,6 +278,23 @@ void AProceduralEntity::loadModel(const uint8* RawFileData, int32 lenght) {
UE_LOG(GLTF, Log, TEXT("GLTF loaded: %i Vertecies in %f seconds"), _numVertecies, end - start);
}
AProceduralEntity* AProceduralEntity::clone(const FVector position)
{
FActorSpawnParameters Parameters;
Parameters.Template = this;
class AProceduralEntity * New = GetWorld()->SpawnActor<AProceduralEntity>(GetClass(), Parameters);
New->SetOwner(GetOwner());
#if WITH_EDITOR
New->SetFolderPath(this->GetFolderPath());
#endif
FTransform trans = FTransform(position);
New->SetActorTransform(trans);
return New;
}
UMaterialInterface *AProceduralEntity::GetMaterialForIndex(unsigned int index, const aiScene* scene){
if (MaterialMap.Contains(index)) {
return *MaterialMap.Find(index);
......
......@@ -56,6 +56,8 @@ public:
void loadModel(const uint8* RawFileData, int32 lenght);
AProceduralEntity* clone(FVector position);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment