summaryrefslogtreecommitdiffstats
path: root/src/uipparser/Qt3DSUIPParserImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uipparser/Qt3DSUIPParserImpl.cpp')
-rw-r--r--src/uipparser/Qt3DSUIPParserImpl.cpp157
1 files changed, 132 insertions, 25 deletions
diff --git a/src/uipparser/Qt3DSUIPParserImpl.cpp b/src/uipparser/Qt3DSUIPParserImpl.cpp
index 80187bf..923ff26 100644
--- a/src/uipparser/Qt3DSUIPParserImpl.cpp
+++ b/src/uipparser/Qt3DSUIPParserImpl.cpp
@@ -470,7 +470,8 @@ SParseSlideActionEntry *SParseSlideManager::FindAction(SParseSlide &inSlide,
*/
CUIPParserImpl::CUIPParserImpl(const QString &inFileName, IRuntimeMetaData &inMetaData,
IInputStreamFactory &inFactory,
- qt3ds::foundation::IStringTable &inStringTable)
+ qt3ds::foundation::IStringTable &inStringTable,
+ int &uipVersion)
: m_MetaData(inMetaData)
, m_InputStreamFactory(inFactory)
, m_ParseElementManager(inMetaData, inStringTable)
@@ -495,6 +496,9 @@ CUIPParserImpl::CUIPParserImpl(const QString &inFileName, IRuntimeMetaData &inMe
qCCritical(qt3ds::INVALID_OPERATION)
<< "Invalid UIP file: " << inFileName.toLatin1().constData();
}
+ int version = 0;
+ if (m_DOMReader->Att("version", version))
+ uipVersion = version;
}
// Create Helper class
@@ -842,16 +846,19 @@ void CUIPParserImpl::AddFloat4Attribute(TPropertyDescAndValueList &outDescList,
void CUIPParserImpl::AddStringAttribute(IPresentation &inPresentation,
TPropertyDescAndValueList &outDescList,
- CRegisteredString inAttStrName, const char *inValue)
+ CRegisteredString inAttStrName, const char *inValue,
+ bool addSourceAsString)
{
qt3ds::foundation::CStringHandle theString = inPresentation.GetStringTable().GetHandle(inValue);
UVariant theValue;
theValue.m_StringHandle = theString.handle();
outDescList.push_back(
eastl::make_pair(SPropertyDesc(inAttStrName, ATTRIBUTETYPE_STRING), theValue));
- if (CHash::HashAttribute(inAttStrName.c_str()) == Q3DStudio::ATTRIBUTE_SOURCEPATH && inValue
- && *inValue)
+ if ((addSourceAsString
+ || CHash::HashAttribute(inAttStrName.c_str()) == Q3DStudio::ATTRIBUTE_SOURCEPATH)
+ && inValue && *inValue) {
AddSourcePath(inValue, false);
+ }
}
void CUIPParserImpl::AddElementRefAttribute(TPropertyDescAndValueList &outDescList,
@@ -944,7 +951,10 @@ void CUIPParserImpl::GetAttributeList(IPresentation &inPresentation,
const char *theDataPtr = "";
if (!IsTrivial(inValue))
theReader.Read(theDataPtr);
- AddStringAttribute(inPresentation, outDescList, inPropNameStrs[0], theDataPtr);
+ bool addSourceAsString = inAdditionalType
+ == ERuntimeAdditionalMetaDataType::ERuntimeAdditionalMetaDataTypeTexture;
+ AddStringAttribute(inPresentation, outDescList, inPropNameStrs[0], theDataPtr,
+ addSourceAsString);
break;
}
case ERuntimeDataModelDataTypeLong4: {
@@ -1021,7 +1031,7 @@ EElementType GetElementType(const char *inType)
*/
BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &inReader,
qt3ds::runtime::element::SElement *inNewStyleParent,
- bool initInRenderThread)
+ bool initInRenderThread, bool isInsideLayer)
{
IDOMReader::Scope __childScope(inReader);
IScriptBridge *theScriptBridgeQml = inPresentation.GetScriptBridgeQml();
@@ -1046,6 +1056,7 @@ BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &i
UINT32 theLoopTime = 0;
bool isComponent = false;
bool isBehavior = false;
+ bool isChildInsideLayer = isInsideLayer;
// Create SElement
if (AreEqual(theType, "Scene") || AreEqual(theType, "Component")) {
@@ -1055,7 +1066,14 @@ BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &i
Q3DStudio_ASSERT(theLoopTime != 0); // Something is wrong here
isComponent = true;
} else {
- if (AreEqual(theType, "Behavior") && !IsTrivial(theClass)) {
+ if (AreEqual(theType, "Layer")) {
+ isChildInsideLayer = true;
+ } else if ((AreEqual(theType, "Material") || AreEqual(theType, "CustomMaterial")
+ || AreEqual(theType, "Image")) && !isInsideLayer) {
+ // Identify objects outside a Layer object with types of Material, CustomMaterial
+ // or Image to be inside the material container
+ m_materialContainerIds.append(QString::fromUtf8(theId));
+ } else if (AreEqual(theType, "Behavior") && !IsTrivial(theClass)) {
// Find the sourcepath and load the script
++theClass; // remove the '#'
TIdSourcePathMap::iterator theSourcePathIter = m_IdScriptMap.find(theClass);
@@ -1148,7 +1166,7 @@ BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &i
thePath.insert(0, theNode->m_Name);
}
if (thePath.size())
- theNewElem.m_Path = m_ParseElementManager.m_StringTable.RegisterStr(thePath.c_str());
+ theNewElem.setPath(m_ParseElementManager.m_StringTable.RegisterStr(thePath.c_str()));
if (isBehavior) {
if (theFileString.find(".qml") != eastl::string::npos) {
@@ -1156,7 +1174,8 @@ BOOL CUIPParserImpl::LoadSceneGraph(IPresentation &inPresentation, IDOMReader &i
theFileString.c_str(), initInRenderThread);
}
}
- LoadSceneGraph(inPresentation, inReader, &theNewElem, initInRenderThread);
+ LoadSceneGraph(inPresentation, inReader, &theNewElem, initInRenderThread,
+ isChildInsideLayer);
}
return true;
@@ -1203,7 +1222,8 @@ void CUIPParserImpl::CacheGraphRequiredAttributes(qt3dsdm::IDOMReader &inReader)
m_ParseElementManager.MarkAttributeAsReferenced(theData, "observedproperty");
// Behaviors need all attributes possible on the object on them all the time.
- if (AreEqual(theType, "Behavior") || AreEqual(theType, "RenderPlugin")) {
+ if (AreEqual(theType, "Behavior") || AreEqual(theType, "RenderPlugin")
+ || AreEqual(theType, "CustomMaterial")) {
m_ParseElementManager.MarkAllAttributesAsReferenced(theData);
}
@@ -1627,6 +1647,32 @@ BOOL CUIPParserImpl::LoadStateGraph(IPresentation &inPresentation, qt3dsdm::IDOM
}
}
+ // Add source paths of the source materials of the ReferencedMaterials
+ // to the slide source paths
+ for (const auto &slideRefMats : qAsConst(m_referencedMaterialsBySlide)) {
+ const auto &slideKey = slideRefMats.first;
+ const auto &refMats = slideRefMats.second;
+
+ QVector<QString> sourcePathRefs;
+ for (const auto &refMat : refMats) {
+ // CustomMaterials contains their own source paths
+ sourcePathRefs.append(refMat);
+ // Materials have their source paths inside Image objects
+ if (m_imagesByMaterial.contains(refMat))
+ sourcePathRefs.append(m_imagesByMaterial[refMat]);
+ }
+
+ for (const auto &sourcePathRef : qAsConst(sourcePathRefs)) {
+ if (m_sourcePathsById.contains(sourcePathRef)) {
+ const auto &sourcePaths = m_sourcePathsById[sourcePathRef];
+ for (const auto &sourcePath : sourcePaths) {
+ inPresentation.GetSlideSystem().AddSourcePath(slideKey,
+ sourcePath.toUtf8().constData());
+ }
+ }
+ }
+ }
+
return theStatus;
}
@@ -1643,6 +1689,7 @@ BOOL CUIPParserImpl::LoadState(IPresentation &inPresentation, SElement *inCompon
BOOL theResult = true;
ISlideSystem &theBuilder = inPresentation.GetSlideSystem();
+ m_currentSlideReferencedMaterials.clear();
eastl::string theSlideName = GetSlideName(inReader);
@@ -1673,6 +1720,16 @@ BOOL CUIPParserImpl::LoadState(IPresentation &inPresentation, SElement *inCompon
if (theMaxTime != 0)
theBuilder.SetSlideMaxTime((QT3DSU32)theMaxTime);
+ if (!m_currentSlideReferencedMaterials.empty()) {
+ qt3ds::runtime::SSlideKey key;
+ key.m_Component = inComponent;
+ key.m_Index = inSlideIndex;
+ QPair<qt3ds::runtime::SSlideKey, QVector<QString>> pair;
+ pair.first = key;
+ pair.second = m_currentSlideReferencedMaterials;
+ m_referencedMaterialsBySlide.append(pair);
+ }
+
return theResult;
}
@@ -2155,6 +2212,9 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m
inReader.Att("ref", theRef);
if (theRef && *theRef && theRef[0] == '#')
++theRef;
+
+ bool isInsideMaterialContainer = m_materialContainerIds.contains(theRef);
+
bool isSet = AreEqual(inReader.GetNarrowElementName(), "Set");
const char8_t *sourcepath;
if (inReader.UnregisteredAtt("sourcepath", sourcepath)) {
@@ -2165,21 +2225,53 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m
ibl = true;
}
if (!IsTrivial(sourcepath) && sourcepath[0] != '#') {
- AddSourcePath(sourcepath, ibl);
- theBuilder.AddSourcePath(sourcepath);
- if (!masterSlide)
+ m_sourcePathsById[QLatin1Char('#') + QString::fromUtf8(theRef)].append(
+ QString::fromUtf8(sourcepath));
+ // Don't add material container assets to the Master Slide source path list
+ if (!isInsideMaterialContainer) {
+ AddSourcePath(sourcepath, ibl);
+ theBuilder.AddSourcePath(sourcepath);
+ }
+ // Add the material container assets to the list of source paths used by slides
+ // other than the Master Slide, so that the assets are not loaded at startup
+ if (!masterSlide || isInsideMaterialContainer)
m_slideSourcePaths.push_back(QString::fromLatin1(sourcepath));
if (AreEqual(inElementData.m_Type.c_str(), "Layer"))
theBuilder.AddSubPresentation(sourcepath);
-
}
}
+
const char8_t *subpres;
if (inReader.UnregisteredAtt("subpresentation", subpres)) {
if (!IsTrivial(subpres))
theBuilder.AddSubPresentation(subpres);
}
+ const char8_t *referencedmaterial;
+ if (inReader.UnregisteredAtt("referencedmaterial", referencedmaterial)) {
+ if (!IsTrivial(referencedmaterial))
+ m_currentSlideReferencedMaterials.append(referencedmaterial);
+ }
+
+ if (strcmp(inElementData.m_Type, "Material") == 0) {
+ eastl::vector<eastl::string> propertyList;
+ m_MetaData.GetInstanceProperties(inElementData.m_Type, inElementData.m_Class,
+ propertyList, false);
+ for (int i = 0; i < propertyList.size(); ++i) {
+ ERuntimeDataModelDataType type = m_MetaData.GetPropertyType(inElementData.m_Type,
+ m_MetaData.Register(propertyList[i].c_str()),
+ inElementData.m_Class);
+ if (type == ERuntimeDataModelDataTypeLong4) {
+ const char8_t *attValue = "";
+ bool hasAtt = inReader.UnregisteredAtt(propertyList[i].c_str(), attValue);
+ if (hasAtt) {
+ m_imagesByMaterial[QLatin1Char('#') + inElementData.m_Id.c_str()]
+ .append(QString::fromUtf8(attValue));
+ }
+ }
+ }
+ }
+
const bool dyn = IsDynamicObject(inElementData.m_Type);
Option<qt3dsdm::SMetaDataCustomMaterial> mat;
Option<qt3dsdm::SMetaDataEffect> eff;
@@ -2226,9 +2318,13 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m
// Handle dynamic object texture source paths
if (hasAtt && !IsTrivial(theAttValue) && IsDynamicObject(inElementData.m_Type)
&& theIter->second.m_AdditionalType == ERuntimeAdditionalMetaDataTypeTexture) {
- AddSourcePath(theAttValue, false);
- theBuilder.AddSourcePath(theAttValue);
- if (!masterSlide)
+ m_sourcePathsById[QLatin1Char('#') + QString::fromUtf8(theRef)].append(
+ QString::fromUtf8(theAttValue));
+ if (!isInsideMaterialContainer) {
+ AddSourcePath(theAttValue, false);
+ theBuilder.AddSourcePath(theAttValue);
+ }
+ if (!masterSlide || isInsideMaterialContainer)
m_slideSourcePaths.push_back(QString::fromLatin1(theAttValue));
}
if (isSet == false && theIter->second.m_SlideForceFlag == false) {
@@ -2236,7 +2332,7 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m
for (QT3DSU32 idx = previousListSize, end = theAttributeList.size(); idx < end;
++idx) {
UVariant *theValue = inElementData.m_Element->FindPropertyValue(
- theAttributeList[idx].first.m_Name);
+ theAttributeList[idx].first.name());
if (theValue) {
*theValue = theAttributeList[idx].second;
}
@@ -2251,11 +2347,17 @@ BOOL CUIPParserImpl::LoadSlideElementAttrs(IPresentation &inPresentation, bool m
if (prop.m_DataType == qt3ds::render::NVRenderShaderDataTypes::NVRenderTexture2DPtr) {
const char8_t *theAttValue = "";
bool hasAtt = inReader.UnregisteredAtt(prop.m_Name, theAttValue);
- if (hasAtt && !IsTrivial(theAttValue) ) {
- AddSourcePath(theAttValue, false);
- theBuilder.AddSourcePath(theAttValue);
- if (!masterSlide)
- m_slideSourcePaths.push_back(QString::fromLatin1(theAttValue));
+ if (hasAtt && !IsTrivial(theAttValue)) {
+ if (theAttValue[0] != '#') {
+ m_sourcePathsById[QLatin1Char('#') + QString::fromUtf8(theRef)].append(
+ QString::fromUtf8(theAttValue));
+ if (!isInsideMaterialContainer) {
+ AddSourcePath(theAttValue, false);
+ theBuilder.AddSourcePath(theAttValue);
+ }
+ if (!masterSlide || isInsideMaterialContainer)
+ m_slideSourcePaths.push_back(QString::fromLatin1(theAttValue));
+ }
}
}
}
@@ -2604,6 +2706,9 @@ SElementAndType CUIPParserImpl::GetElementForID(const char *inElementName)
case qt3dsdm::ComposerObjectTypes::Group:
theUIPType = UIPElementTypes::Group;
break;
+ case qt3dsdm::ComposerObjectTypes::Signal:
+ theUIPType = UIPElementTypes::Signal;
+ break;
case qt3dsdm::ComposerObjectTypes::Component:
theUIPType = UIPElementTypes::Component;
break;
@@ -2672,9 +2777,11 @@ IRuntimeMetaData &CUIPParserImpl::GetMetaData()
IUIPParser &IUIPParser::Create(const QString &inFileName, IRuntimeMetaData &inMetaData,
IInputStreamFactory &inFactory,
- qt3ds::foundation::IStringTable &inStrTable)
+ qt3ds::foundation::IStringTable &inStrTable,
+ int &uipVersion)
{
- CUIPParserImpl &retval = *new CUIPParserImpl(inFileName, inMetaData, inFactory, inStrTable);
+ CUIPParserImpl &retval = *new CUIPParserImpl(inFileName, inMetaData, inFactory,
+ inStrTable, uipVersion);
return retval;
}
}