summaryrefslogtreecommitdiffstats
path: root/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.h
blob: 1a7ac778eefeea2910e33b8dce86eaedb62e1151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/****************************************************************************
**
** Copyright (C) 1993-2009 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#pragma once
/*
This is the main file responsible for conversion from the uip format into the runtime's data format.
The runtime works in a sort of global space so any object, be it an animation, action or element,
once
activated stays activated.  Furthermore it is important that the runtime declare and set the fewest
number
of properties possible to still get the right answer.  In order to achieve this the runtime relies
on the
rendering system to have the initial state of the entire scene graph, including state that is only
"Add"
commands declared in slides.

Given that you understand master slide/ slide distinction, an accurate description would be to do
this:
1.  Move all parse objects (actions, animations, elements) to be master objects and deactivate them.
2.  Running through the list of nonmaster slides, activate the objects on those slides that would be
activated.
3.  Now remove properties that are both unreferenced and applied 1 or fewer times.


The parsing system does this in reverse order so the passes look like:
1.  Load meta data information (scripts, effects) to have a complete meta data model.
1.  Build element graph.  This is used during attribute lookup
2.  Figure out which attributes will be on the elements in the graph by resolving behavior
references, action references and
        Animations, and Set command attribute applications.

        During this pass we also build the set of actions and animations which will appear on each
slide.  This involves both promoting
        actions/animations that appear on the master slide to child slides and pulling
animations/actions declared on all child slides
        onto the master slide.

3.  Count the objects that we will need.  The runtime currently requires fixed object counts that
can't be exceeded
        thus we have to effectively preallocate all runtime objects.

4.  Run through the file again and build the actual runtime datastructures.  Actions and animations
are built from
        an intermediate memory representation but the set commands and element activations are built
via running through
        the file.


Care needs to be taken so the runtime can survive poorly formed or just meaningless uip files.
Studio is only *one*
system for producing UIP files, clients are free to use code generates (like ruby scripts and such)
to build their final
uip files so we need to be careful that we are as robust as possible and can tolerate gracefully
some level of incorrect
uip file data.
*/

//==============================================================================
//	Includes
//==============================================================================
#include "Qt3DSUIPParser.h"
#include "Qt3DSTypes.h"
#include "Qt3DSMetadata.h"
#include "Qt3DSRenderInputStreamFactory.h"
#include "Qt3DSSlideSystem.h"
#include "Qt3DSDMDataTypes.h"
#include "foundation/Qt3DSMemoryBuffer.h"
#include <EASTL/map.h>
#include <EASTL/set.h>
#include <EASTL/hash_map.h>
#include "Qt3DSElementSystem.h"
#include "Qt3DSSlideSystem.h"

namespace qt3ds {
namespace render {
    class IRefCountedInputStream;
}
}

namespace qt3dsdm {
class IDOMReader;
class IDOMWriter;
}
//==============================================================================
//	Namespace
//==============================================================================
namespace Q3DStudio {

//==============================================================================
//	Forwards
//==============================================================================
class IPresentation;
class SElementBuilder;
class CContractBuilder;
class CAnimationBuilder;
class CLogicBuilder;
class CSlideBuilder;
class IRuntimeMetaData;
class CUIPParserActionHelper;
class CUIPParserObjectRefHelper;

typedef eastl::vector<qt3ds::runtime::element::TPropertyDescAndValue> TPropertyDescAndValueList;

using qt3ds::render::IInputStreamFactory;
using qt3ds::render::IRefCountedInputStream;
typedef NVScopedRefCounted<IRefCountedInputStream> TInputStreamPtr;
typedef qt3ds::foundation::CRegisteredString TStrType;
using qt3ds::runtime::element::SElement;

struct SElementPropertyInfo
{
    enum Enum {
        MaxArity = 4,
    };
    TStrType m_PropertyName;
    ERuntimeDataModelDataType m_DataType;
    ERuntimeAdditionalMetaDataType m_AdditionalType;
    // Number of sub components of the property, 1-4
    qt3ds::QT3DSU32 m_Arity;
    qt3ds::QT3DSU32 m_PropertyHashes[MaxArity];
    CRegisteredString m_PropertyNames[MaxArity];
    bool m_ElementFlag; // True if this property exists on the element.  Some properties do not.
    bool m_SlideFlag; // True if this property exists on the slides at all.
    // starttime,endtime are forced to be on the slides whether they are in the UIP or not.
    bool m_SlideForceFlag; // True if this property is *forced* on the slides whether it needs to be
                           // there or not

    SElementPropertyInfo(TStrType inPropName)
        : m_PropertyName(inPropName)
        , m_DataType(ERuntimeDataModelDataTypeNone)
        , m_Arity(0)
        , m_ElementFlag(false)
        , m_SlideFlag(false)
        , m_SlideForceFlag(false)
    {
        memZero(m_PropertyHashes, sizeof(m_PropertyHashes));
    }
    bool operator<(const SElementPropertyInfo &inOther) const
    {
        return m_PropertyName < inOther.m_PropertyName;
    }
};

typedef eastl::hash_map<TStrType, SElementPropertyInfo> TAttrMap;

struct SElementData
{
    SElement *m_Element;
    TStrType m_Id;
    TStrType m_Type;
    TStrType m_Class;
    TAttrMap m_PropertyMap;

    SElementData(TStrType inId)
        : m_Element(NULL)
        , m_Id(inId)
    {
    }
    void SetElement(SElement *inElement, TStrType inType, TStrType inClass)
    {
        m_Element = inElement;
        m_Type = inType;
        m_Class = inClass;
    }
};

typedef eastl::hash_map<TStrType, SElementData> TIdElementMap;

struct SParseElementManager
{
    IRuntimeMetaData &m_MetaData;
    TIdElementMap m_ElementMap;
    // Temporary variables for various algorithms
    eastl::string m_Workspace;
    eastl::vector<eastl::string> m_PropertyList;
    qt3ds::foundation::IStringTable &m_StringTable;

    SParseElementManager(IRuntimeMetaData &inMetaData, qt3ds::foundation::IStringTable &inStrTable)
        : m_MetaData(inMetaData)
        , m_StringTable(inStrTable)
    {
    }
    TStrType RegisterStr(const char8_t *inStr);
    SElementData &GetOrCreateElementData(const char8_t *inElemIdOrRef, const char8_t *inElemType,
                                         const char8_t *inElemClassId);
    SElementData *FindElementData(const char8_t *inIdOrRef);
    // We don't allow creation of properties that don't exist in the meta data in the first place.
    SElementPropertyInfo *GetOrCreateProperty(SElementData &inData, const char8_t *inPropertyName);
    SElementPropertyInfo *GetOrCreateProperty(const char8_t *inIdOrRef, const char8_t *inElemType,
                                              const char8_t *inElemClassId,
                                              const char8_t *inPropertyName);
    SElementPropertyInfo *FindProperty(SElementData &inElement, const char8_t *inPropertyName);
    SElementPropertyInfo *FindProperty(const char8_t *inIdOrRef, const char8_t *inPropertyName);
    eastl::pair<SElementPropertyInfo *, qt3ds::QT3DSU32>
    FindPropertyWithSubIndex(SElementData &inElement, const char8_t *inPropertyName);
    // Attribute marking stage; mark which attributes will be kept on elements at all.
    void MarkAttributeAsReferenced(SElementData &inElement, const char8_t *inPropertyName);
    void MarkAttributeAsReferenced(const char8_t *inElement, const char8_t *inPropertyName);
    void MarkAllAttributesAsReferenced(SElementData &inElement, bool searchParent = false);
};

struct SParseSlideActionEntry
{
    TStrType m_SlideId;
    TStrType m_ActionId;
    qt3ds::QT3DSI32 m_ActionCount;
    bool m_Active;
    qt3ds::runtime::SSlideAnimAction *m_Actions[SElementPropertyInfo::MaxArity];

    SParseSlideActionEntry(TStrType inSlideId, TStrType inActionId, qt3ds::QT3DSI32 inActionCount,
                           bool inActive)
        : m_SlideId(inSlideId)
        , m_ActionId(inActionId)
        , m_ActionCount(inActionCount)
        , m_Active(inActive)
    {
        memZero(m_Actions, sizeof(m_Actions));
    }
    SParseSlideActionEntry()
        : m_ActionCount(0)
        , m_Active(false)
    {
    }
    // Partial equals, used for finding object in vector.
    bool operator==(const SParseSlideActionEntry &inOther) const
    {
        return m_SlideId == inOther.m_SlideId && m_ActionId == inOther.m_ActionId;
    }
};

typedef eastl::vector<SParseSlideActionEntry> TActionList;

struct SParseSlideAnimationTypes
{
    enum Enum {
        NoAnimation = 0,
        Linear,
        EaseInOut,
        Bezier,
    };
};

struct SParseSlideAnimationEntry
{
    TStrType m_SlideId;
    TStrType m_InstanceId;
    TStrType m_PropertyName;
    qt3ds::QT3DSU32 m_PropertyHash;
    qt3ds::QT3DSI32 m_AnimationIndex;
    eastl::vector<float> m_KeyframeData;
    SParseSlideAnimationTypes::Enum m_AnimationType;
    bool m_IsDynamic;

    SParseSlideAnimationEntry()
        : m_AnimationIndex(-1)
        , m_KeyframeData("")
        , m_AnimationType(SParseSlideAnimationTypes::NoAnimation)
        , m_IsDynamic(false)
    {
    }
    SParseSlideAnimationEntry(TStrType inSlideId, TStrType inInstanceId, TStrType inPropertyName,
                              qt3ds::QT3DSU32 inPropHash, SParseSlideAnimationTypes::Enum inAnimType,
                              const float *inKeyframeData, qt3ds::QT3DSU32 inNumFloats, bool inIsDynamic)
        : m_SlideId(inSlideId)
        , m_InstanceId(inInstanceId)
        , m_PropertyName(inPropertyName)
        , m_PropertyHash(inPropHash)
        , m_AnimationType(inAnimType)
        , m_IsDynamic(inIsDynamic)
    {
        m_KeyframeData.insert(m_KeyframeData.begin(), inKeyframeData, inKeyframeData + inNumFloats);
    }
};

struct SParseAnimationRef
{
    TStrType m_SlideId;
    TStrType m_InstanceId;
    TStrType m_PropertyName;
    bool m_Active;
    const SParseSlideAnimationEntry *m_Animation;

    SParseAnimationRef(TStrType inSlideId, TStrType inInstanceId, TStrType inPropName,
                       const SParseSlideAnimationEntry *inAnimation, bool inActive)
        : m_SlideId(inSlideId)
        , m_InstanceId(inInstanceId)
        , m_PropertyName(inPropName)
        , m_Active(inActive)
        , m_Animation(inAnimation)
    {
    }
    SParseAnimationRef()
        : m_Active(false)
        , m_Animation(NULL)
    {
    }
    // Partial equals, used for finding object in vector.
    bool operator==(const SParseAnimationRef &inOther) const
    {
        return m_SlideId == inOther.m_SlideId && m_InstanceId == inOther.m_InstanceId
            && m_PropertyName == inOther.m_PropertyName;
    }
};

typedef eastl::vector<SParseAnimationRef> TAnimationList;

typedef eastl::hash_map<TStrType, TAnimationList> TInstanceIdAnimationMap;

struct SParseSlide
{
    TStrType m_SlideId;
    qt3ds::QT3DSI32 m_SlideIndex;
    TActionList m_ActionList;
    TInstanceIdAnimationMap m_Animations;

    SParseSlide(TStrType inId, qt3ds::QT3DSI32 inSlideIndex)
        : m_SlideId(inId)
        , m_SlideIndex(inSlideIndex)
    {
    }
    SParseSlide() {}
};

typedef eastl::hash_map<TStrType, SParseSlide> TSlideIdToParseSlideMap;

struct SParseSlideManager
{
    IRuntimeMetaData &m_MetaData;
    SParseElementManager &m_ElementManager;
    TSlideIdToParseSlideMap m_SlideMap;
    eastl::vector<SParseSlideAnimationEntry *> m_Animations;
    qt3ds::QT3DSI32 m_SlideAnimationCount;
    qt3ds::QT3DSI32 m_AnimationKeyframeCount;
    qt3ds::QT3DSI32 m_ActionCount;
    eastl::vector<qt3ds::QT3DSF32> m_KeyframeParseFloatBuffer;
    eastl::string m_KeyframeParseBuffer;

    SParseSlideManager(IRuntimeMetaData &inMD, SParseElementManager &inElemMgr)
        : m_MetaData(inMD)
        , m_ElementManager(inElemMgr)
        , m_SlideAnimationCount(0)
        , m_AnimationKeyframeCount(0)
        , m_ActionCount(0)
    {
    }
    ~SParseSlideManager();
    TStrType RegisterId(const char8_t *inStr);
    TStrType RegisterStr(const char8_t *inStr) { return m_ElementManager.RegisterStr(inStr); }
    SParseSlide &GetOrCreateSlide(const char8_t *inSlideId, qt3ds::QT3DSI32 inSlideIndex);
    SParseSlide *FindSlide(const char8_t *inSlideId);
    // Create an animation and reference that animation
    void SetAnimationData(SParseSlide &inSlide, const char8_t *inInstanceId,
                          const char8_t *inPropertyName, const char8_t *inKeyframeData,
                          SParseSlideAnimationTypes::Enum inType, bool inIsDynamic,
                          bool inIsActive);
    // Reference an animation.
    void ReferenceAnimation(SParseSlide &inSlide, const SParseSlideAnimationEntry &inSource,
                            bool inIsActive);
    TAnimationList *GetAnimationsForInstance(SParseSlide &inSlide, const char8_t *inInstanceId);
    SParseSlideActionEntry &GetOrCreateAction(SParseSlide &inSlide, const char8_t *inActionId,
                                              qt3ds::QT3DSI32 inActionCount, bool inEyeball);
    SParseSlideActionEntry *FindAction(SParseSlide &inSlide, const char8_t *inActionId);
};

//==============================================================================
/**
 *	@class	CUIPParserImpl
 *	@brief	Class for parsing UIP file
 */
class CUIPParserImpl : public IUIPParser
{

    typedef eastl::basic_string<char8_t> TNarrowStr;

    //==============================================================================
    //	Fields
    //==============================================================================
protected:
    std::shared_ptr<qt3dsdm::IDOMReader> m_DOMReader;
    std::shared_ptr<qt3dsdm::IDOMWriter> m_DOMWriter;
    IRuntimeMetaData &m_MetaData; ///< Reference to Metadata
    IInputStreamFactory &m_InputStreamFactory;
    SParseElementManager m_ParseElementManager; ///< Map of id, SElement*
    SParseSlideManager m_ParseSlideManager;

    CUIPParserActionHelper *m_ActionHelper; ///< Action Helper
    CUIPParserObjectRefHelper *m_ObjectRefHelper; ///< Object Reference Helper

    typedef eastl::set<SElement *> TAddedSlideElements;
    TAddedSlideElements m_SlideElements; ///< Caching of slide elements added, so that we don't need
                                         ///to pass this around

    typedef eastl::map<eastl::string, eastl::string> TIdSourcePathMap;
    TIdSourcePathMap m_IdScriptMap; ///< Map of the class id and script sourcepath

    typedef eastl::map<eastl::string, eastl::string> TIdClassMap;
    TIdClassMap m_IdClassMap; ///< Map of id and class reference

    typedef eastl::set<eastl::string> TStringSet;
    typedef eastl::vector<eastl::string> TStringVector;

    TStringSet m_SourcePathSet;
    TStringVector m_SourcePathList;

    struct SElementRefCache
    {
        SElementData *m_Element;
        eastl::string m_Name;
        eastl::string m_Value;
    };
    eastl::vector<SElementRefCache> m_ElementRefCache; ///< Cache those element refs in the scene
                                                       ///graph that needs to be patch later

    struct SEaseInEaseOutKeyframe
    {
        float m_Time;
        float m_Value;
        float m_EaseIn;
        float m_EaseOut;
    };

    struct SGraphSectionCount
    {
        INT32 m_ElementCount;
        INT32 m_ComponentCount;
        INT32 m_AttributeCount;
        INT32 m_StringAttrCount;

        SGraphSectionCount()
            : m_ElementCount(0)
            , m_ComponentCount(0)
            , m_AttributeCount(0)
            , m_StringAttrCount(0)
        {
        }
    };

    struct SLogicSectionCount
    {
        INT32 m_SlideCount;
        INT32 m_SlideElementCount;
        INT32 m_SlideAttributeCount;
        INT32 m_StringAttrCount;
        INT32 m_PaddingCount;

        SLogicSectionCount()
            : m_SlideCount(0)
            , m_SlideElementCount(0)
            , m_SlideAttributeCount(0)
            , m_StringAttrCount(0)
            , m_PaddingCount(0)
        {
        }
    };

    struct SActionSectionCount
    {
        INT32 m_TriggerElementCount;
        INT32 m_TriggerEventCount;
        INT32 m_ActionCount;
        INT32 m_StringAttrCount;
        INT32 m_CustomParamCount;

        SActionSectionCount()
            : m_TriggerElementCount(0)
            , m_TriggerEventCount(0)
            , m_ActionCount(0)
            , m_StringAttrCount(0)
            , m_CustomParamCount(0)
        {
        }
    };

    long m_NumGraphElements; /// eclee testing only, must remove
    long m_NumGraphComponents; /// eclee testing only, must remove
    long m_NumGraphAttributes; /// eclee testing only, must remove
    long m_NumSlides; /// eclee testing only, must remove
    long m_NumSlideElements; /// eclee testing only, must remove
    long m_NumSlideAttributes; /// eclee testing only, must remove
    long m_NumAnimationTracks; /// eclee testing only, must remove
    long m_NumAnimationKeys; /// eclee testing only, must remove
    long m_NumSlideAnimations; /// eclee testing only, must remove
    long m_NumSlideActions; /// klarinda testing only, must remove

    // temporarily this is here
    qt3ds::foundation::MemoryBuffer<RawAllocator> m_TempBuffer;
    qt3ds::foundation::MemoryBuffer<RawAllocator> m_ValueBuffer;

    IPresentation *m_CurrentPresentation;

    //==============================================================================
    //	Methods
    //==============================================================================
public: // Construction
    CUIPParserImpl(const QString &inFileName, IRuntimeMetaData &inMetaData,
                   IInputStreamFactory &inFactory, qt3ds::foundation::IStringTable &inStringTable);
    virtual ~CUIPParserImpl();

public: // Parse UIP file
    BOOL Load(IPresentation &inPresentation,
                      NVConstDataRef<SElementAttributeReference> inStateReferences,
                      qt3ds::state::debugger::ISceneGraphRuntimeDebugger &debugger) override;
    qt3dsdm::IDOMReader &GetDOMReader() override;
    IRuntimeMetaData &GetMetaData() override;
    SElementAndType GetElementForID(const char *inStringId) override;
    eastl::string ResolveReference(const char *inStringId, const char *inReferance) override;
    NVConstDataRef<eastl::string> GetSourcePaths() const override
    {
        return NVConstDataRef<eastl::string>(m_SourcePathList.data(), m_SourcePathList.size());
    }

protected: // Operation
    BOOL LoadProjectSettings(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);
    BOOL LoadClasses(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);
    BOOL LoadGraph(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);
    BOOL LoadSceneGraph(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader,
                        qt3ds::runtime::element::SElement *inNewStyleParent = NULL);
    BOOL LoadLogic(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);
    BOOL LoadStateGraph(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);

protected: // Memory Counter
    void ComputeAndReserveMemory(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader);
    void DoGraphSectionCount(qt3dsdm::IDOMReader &inReader, SGraphSectionCount &outGraphCounter);
    void DoLogicSectionCount(qt3dsdm::IDOMReader &inReader, SLogicSectionCount &outLogicCounter);
    void DoStateSectionCount(qt3dsdm::IDOMReader &inReader, INT32 inSlideIndex,
                             SLogicSectionCount &outLogicCounter);
    void DoRefSectionCount(qt3dsdm::IDOMReader &inReader, INT32 inNumSlideMultiplier,
                           INT32 inSlideIndex, SLogicSectionCount &outLogicCounter);

protected: // Scene graph heler
    void CacheGraphRequiredAttributes(qt3dsdm::IDOMReader &inReader);
    BOOL CacheLogicRequiredAttributes(qt3dsdm::IDOMReader &inReader, qt3ds::QT3DSI32 inSlideIndex = 0,
                                      SParseSlide *inParentSlide = NULL);
    void CacheClassRequiredAttributes(qt3dsdm::IDOMReader &inReader);
    void CacheClassSceneAttributes(qt3dsdm::IDOMReader &inReader);
    void CacheClassStateAttributes(qt3dsdm::IDOMReader &inReader);
    void AddElementRefToPatch(TPropertyDescAndValueList &outDescList, SElementData &inElement,
                              const char *inName, const char *inValue);
    void PatchSceneElementRef();

protected: // Slide helper
    BOOL LoadState(IPresentation &inPresentation, SElement *inComponent, INT32 inSlideIndex,
                   qt3dsdm::IDOMReader &inReader);
    qt3ds::runtime::SSlidePlayInformation GetPlayMode(qt3dsdm::IDOMReader &inReader);
    INT32 GetPlayThroughTo(INT32 inCurrentSlideIndex, qt3dsdm::IDOMReader &inReader);
    eastl::string GetSlideName(qt3dsdm::IDOMReader &inReader);
    eastl::string GetSlideId(qt3dsdm::IDOMReader &inReader);
    BOOL LoadSlideElements(IPresentation &inPresentation, qt3dsdm::IDOMReader &inReader,
                           bool inMaster, SElement *inComponent, INT32 *outMaxTime = NULL);
    SElementData *AddSlideElement(IPresentation &inPresentation, bool inMaster,
                                  qt3dsdm::IDOMReader &inReader, INT32 *outMaxTime = NULL);
    BOOL LoadSlideElementAttrs(IPresentation &inPresentation, bool inMaster,
                               SElementData &inElementData, qt3dsdm::IDOMReader &inReader,
                               SElement *inComponent);
    BOOL ProcessStateRef(IPresentation &inPresentation, SElement *inComponent, bool inMaster,
                         qt3dsdm::IDOMReader &inReader);

protected: // Animation helper
    void LoadAnimationTrack(IPresentation &inPresentation, SElementData &inElementData,
                            SParseSlideAnimationEntry &inAnimation);
    void LoadAnimationKeys(IPresentation &inPresentation,
                           const SParseSlideAnimationEntry &inAnimation, bool inIsRotation);
    BOOL LoadBezierKeys(IPresentation &inPresentation, NVConstDataRef<float> &inValues,
                        bool inIsRotation);
    BOOL LoadLinearKeys(IPresentation &inPresentation, NVConstDataRef<float> &inValues,
                        bool inIsRotation);
    BOOL LoadEaseInOutKeys(IPresentation &inPresentation, NVConstDataRef<float> &inValues,
                           bool inIsRotation);
    SEaseInEaseOutKeyframe ParseEaseInOutKey(const float *&inFloatIter);
    BOOL ProcessSlideAnimAction(IPresentation &inPresentation, eastl::string &inSlideId,
                                bool inMaster, qt3dsdm::IDOMReader &inReader);
    BOOL AddSlideAction(IPresentation &inPresentation, eastl::string &inSlideId, bool inActive,
                        qt3dsdm::IDOMReader &inReader);
    void CreateBezierKeyframeFromEaseInEaseOutKeyframe(float *inPreviousValue,
                                                       SEaseInEaseOutKeyframe &inCurrent,
                                                       float *inNextValue, float *&outBezierValues);

protected: // Helper methods
    bool IsStringType(ERuntimeDataModelDataType inDataType);
    void GetAttributeList(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList,
                          TStrType inType, TStrType inName, TStrType inClassId, const char *inValue,
                          CRegisteredString *inPropNameStrs);
    void GetAttributeList(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList,
                          ERuntimeDataModelDataType inDataType,
                          ERuntimeAdditionalMetaDataType inAdditionalType, const char *inName,
                          const char *inValue, CRegisteredString *inPropNameStrs);

    SElementData *GetElementData(TStrType inElementName);
    SElementData *GetElementData(const char8_t *inElementName);
    SElement *GetElement(const char8_t *inElementName);
    // Returns the data type and a boolean indicating if this attribute is actually used on a
    // particular slide.
    eastl::pair<ERuntimeDataModelDataType, bool>
    GetAttributeType(const char8_t *inElementName, const char8_t *inPropertyName,
                     const SElementData &inElementData);
    SElementData *ParseObjectRef(const eastl::string &inObjectPath, const char8_t *inOwnerId);
    TStrType ParseObjectRefId(const eastl::string &inObjectPath, const char8_t *inOwnerId);

    void GetMetaAttribute(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList,
                          TStrType inType, TStrType inName, TStrType inClassId,
                          CRegisteredString *inAttStrNames);

protected:
    void AddFloatAttribute(TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName,
                           float &inValue);
    void AddLongAttribute(TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName,
                          qt3ds::QT3DSI32 &inValue);
    void AddBoolAttribute(TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName,
                          bool &inValue);
    void AddFloat2Attribute(TPropertyDescAndValueList &outDescList,
                            CRegisteredString *inAttStrNames, qt3dsdm::SFloat2 &inValue);
    void AddFloat3Attribute(TPropertyDescAndValueList &outDescList,
                            ERuntimeAdditionalMetaDataType inAdditionalType,
                            CRegisteredString *inAttStrNames, qt3dsdm::SFloat3 &inValue);
    void AddStringAttribute(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList,
                            CRegisteredString inAttStrName, const char *inValue);
    void AddElementRefAttribute(TPropertyDescAndValueList &outDescList,
                                CRegisteredString inAttStrName, SElement *inElement);

    void AddSourcePath(const char *inValue)
    {
        if (m_SourcePathSet.find(inValue) == m_SourcePathSet.end()) {
            m_SourcePathSet.insert(inValue);
            m_SourcePathList.push_back(eastl::string(inValue));
        }
    }

public: //
    void release() override { delete this; }

    //==============================================================================
    //	Friends
    //==============================================================================
    friend class CUIPParserActionHelper;
};

} // namespace Q3DStudio