DatasmithSceneXmlReader.h
1 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
2 
3 #pragma once
4 
5 #include "DatasmithMaterialElements.h"
6 #include "IDatasmithSceneElements.h"
7 
8 class FXmlFile;
9 class FXmlNode;
10 class UTexture;
11 
12 class DATASMITHCORE_API FDatasmithSceneXmlReader
13 {
14 public:
15  // Force non-inline constructor and destructor to prevent instantiating TUniquePtr< FXmlFile > with an incomplete FXmlFile type (forward declared)
18 
19  bool ParseFile(const FString& InFilename, TSharedRef< IDatasmithScene >& OutScene, bool bInAppend = false);
20  bool ParseBuffer(const FString& XmlBuffer, TSharedRef< IDatasmithScene >& OutScene, bool bInAppend = false);
21 
22 private:
23  bool ParseXmlFile(TSharedRef< IDatasmithScene >& OutScene, bool bInAppend = false);
24 
25  void PatchUpVersion(TSharedRef< IDatasmithScene >& OutScene);
26 
27  void ParseElement(FXmlNode* InNode, TSharedRef<IDatasmithElement> OutElement) const;
28  void ParseLevelSequence(FXmlNode* InNode, const TSharedRef<IDatasmithLevelSequenceElement>& OutElement) const;
29  void ParseMesh(FXmlNode* InNode, TSharedPtr<IDatasmithMeshElement>& OutElement) const;
30  void ParseTextureElement(FXmlNode* InNode, TSharedPtr<IDatasmithTextureElement>& OutElement) const;
31  void ParseTexture(FXmlNode* InNode, FString& OutTextureFilename, FDatasmithTextureSampler& OutTextureUV) const;
32  void ParseTransform(FXmlNode* InNode, TSharedPtr< IDatasmithActorElement >& OutElement) const;
33  FTransform ParseTransform(FXmlNode* InNode) const;
34  void ParseActor(FXmlNode* InNode, TSharedPtr<IDatasmithActorElement>& InOutElement, TSharedRef< IDatasmithScene > Scene, TMap< FString, TSharedPtr<IDatasmithActorElement> >& Actors) const;
35  void ParseMeshActor(FXmlNode* InNode, TSharedPtr<IDatasmithMeshActorElement>& OutElement, TSharedRef< IDatasmithScene > Scene) const;
36  void ParseHierarchicalInstancedStaticMeshActor(FXmlNode* InNode, TSharedPtr<IDatasmithHierarchicalInstancedStaticMeshActorElement>& OutElement, TSharedRef< IDatasmithScene > Scene) const;
37  void ParseLight(FXmlNode* InNode, TSharedPtr<IDatasmithLightActorElement>& OutElement) const;
38  void ParseCamera(FXmlNode* InNode, TSharedPtr<IDatasmithCameraActorElement>& OutElement) const;
39  void ParsePostProcess(FXmlNode* InNode, const TSharedPtr< IDatasmithPostProcessElement >& Element) const;
40  void ParsePostProcessVolume(FXmlNode* InNode, const TSharedRef< IDatasmithPostProcessVolumeElement >& Element) const;
41  void ParseColor(FXmlNode* InNode, FLinearColor& OutColor) const;
42  void ParseComp(FXmlNode* InNode, TSharedPtr< IDatasmithCompositeTexture >& OutCompTexture, bool bInIsNormal = false) const;
43  void ParseMaterial(FXmlNode* InNode, TSharedPtr< IDatasmithMaterialElement >& OutElement) const;
44  void ParseMasterMaterial(FXmlNode* InNode, TSharedPtr< IDatasmithMasterMaterialElement >& OutElement) const;
45  void ParseUEPbrMaterial(FXmlNode* InNode, TSharedPtr< IDatasmithUEPbrMaterialElement >& OutElement) const;
46  void ParseCustomActor(FXmlNode* InNode, TSharedPtr< IDatasmithCustomActorElement >& OutElement) const;
47  void ParseMetaData(FXmlNode* InNode, TSharedPtr< IDatasmithMetaDataElement >& OutElement, const TSharedRef< IDatasmithScene >& InScene, TMap< FString, TSharedPtr<IDatasmithActorElement> >& Actors) const;
48  void ParseLandscape(FXmlNode* InNode, TSharedRef< IDatasmithLandscapeElement >& OutElement) const;
49 
50  template< typename ElementType >
51  void ParseKeyValueProperties(const FXmlNode* InNode, ElementType& OutElement) const;
52 
53  bool LoadFromFile(const FString& InFilename);
54  bool LoadFromBuffer(const FString& XmlBuffer);
55 
56  FString ResolveFilePath(const FString& InAssetFile) const;
57 
58  FQuat QuatFromHexString(const FString& HexString) const;
59 
60  TUniquePtr< FXmlFile > XmlFile;
61  FString ProjectPath;
62 };
FDatasmithSceneXmlReader
Definition: DatasmithSceneXmlReader.h:12
FDatasmithTextureSampler
Definition: DatasmithTypes.h:16