Das ist Quatsch, was ich geschrieben habe. Mache es lieber so:
C: .cpp
TArray<FTransform> UReadXML::ParseXml()
{
TArray<FTransform> TransformArray;
FXmlFile* file = new FXmlFile(L"C:/Users/ALO/Desktop/CPP/XMLTest"); // Pfad zur Datei; kann auch über Funktionsparameter geladen werden
FXmlNode* RootNode = file->GetRootNode(); // <Points>
TArray<FXmlNode*> Points = RootNode->GetChildrenNodes();
for (FXmlNode* Point : Points) // Loop über jeden <Point>
{
FTransform CurrentTransform = FTransform();
for (FXmlNode* Property : Point->GetChildrenNodes()) // Für alle x,y,z,...
{
FString Tag = Property->GetTag();
if(Tag == "X")
{
CurrentTransform.SetLocation(FVector(FCString::Atof(*Property->GetContent()), CurrentTransform.GetLocation().Y, CurrentTransform.GetLocation().Z));
}
else if(Tag == "Y")
{
CurrentTransform.SetLocation(FVector(CurrentTransform.GetLocation().X, FCString::Atof(*Property->GetContent()), CurrentTransform.GetLocation().Z));
}
else if(Tag == "Z")
{
CurrentTransform.SetLocation(FVector(CurrentTransform.GetLocation().X, CurrentTransform.GetLocation().Y, FCString::Atof(*Property->GetContent())));
}
else if(Tag == "sX")
{
CurrentTransform.SetScale3D(FVector(FCString::Atof(*Property->GetContent()), CurrentTransform.GetScale3D().Y, CurrentTransform.GetScale3D().Z));
}
else if(Tag == "sY")
{
CurrentTransform.SetScale3D(FVector(CurrentTransform.GetScale3D().X, FCString::Atof(*Property->GetContent()), CurrentTransform.GetScale3D().Z));
}
else if(Tag == "sZ")
{
CurrentTransform.SetScale3D(FVector(CurrentTransform.GetScale3D().X, CurrentTransform.GetScale3D().Y, FCString::Atof(*Property->GetContent())));
}
else if(Tag == "rX")
{
}
else if(Tag == "rY")
{
}
else if(Tag == "rZ")
{
}
}
TransformArray.Add(CurrentTransform);
}
return TransformArray;
}
Alles anzeigen
Die Rotation macht mir gerade noch Kopfschmerzen, weil mein Mathe dafür nicht gut genug ist
In der Beispiel .xml waren ja alle Werte der Rotation = 0, weißt du, ob das immer so ist? Dann könnte man das ja weglassen. Ansonsten muss man halt Eulersche Winkel in eine Quaternition umwandeln, nach längerem Grübel und Recherche kriege ich das auch noch hin, oder jemand anderes kann helfen xD