OROCHI
 
Loading...
Searching...
No Matches
GxColladaReader.h
Go to the documentation of this file.
1//===========================================================================
12//===========================================================================
13#pragma once
14
15#if GX_DEVELOP
16
17GX_CORE_NAMESPACE_BEGIN()
18
19// COLLADAファイル読み込み解析通知基底クラス宣言
20class GxColladaReaderNotifierBase;
21
22//===========================================================================
24//===========================================================================
25class GxColladaReader : public GxXmlReader
26{
27 //-----------------------------------------------------------
29 //-----------------------------------------------------------
31public:
32 // RTTI定義
33 GX_RTTI_CLASS(GxColladaReader, GxXmlReader)
34 // GxClassBase継承クラス用禁止宣言
35 GX_PROHIBIT_CLASS_BASE(GxColladaReader)
36
37
38 enum class ROTATE_ORDER_SHIFT
39 {
40 _1 = 0x0,
41 _2 = 0x4,
42 _3 = 0x8
43 };
44
46 enum class ROTATE_ORDER_VALUE
47 {
48 NONE = 0,
49 X,
50 Y,
51 Z
52 };
53
55 enum class ROTATE_ORDER_TYPE
56 {
57 NONE = 0x0000,
58 XYZ = 0x0321,
59 XZY = 0x0231,
60 YXZ = 0x0312,
61 YZX = 0x0132,
62 ZXY = 0x0213,
63 ZYX = 0x0123
64 };
65
66protected:
67 static GX_CCHAR COLLADA_DATA_DELIMITER = ' ';
68
70 struct MaterialTable
71 {
72 GX_CSTR _pSymbol;
73 u32 _materialId;
74 };
75
77 struct SkinTable
78 {
79 GX_CSTR _pName;
80 u32 _shapeId;
81 };
82
83public:
85 struct GxColladaCommonAsset
86 {
87 //-----------------------------------------------------------
89 //-----------------------------------------------------------
91 public:
93 enum class METER_TYPE
94 {
95 METER = 0,
96 CENTI,
97
98 MAX
99 };
100
102 enum class AXIS_TYPE
103 {
104 X_UP = 0,
105 Y_UP,
106 Z_UP,
107
108 MAX
109 };
110
112 //-----------------------------------------------------------
114 //-----------------------------------------------------------
116
118 GxColladaCommonAsset(void)
119 : _meterValue(1.0f)
120 , _meterType(METER_TYPE::METER)
121 , _axisType(AXIS_TYPE::X_UP)
122 {}
123
125 //-----------------------------------------------------------
127 //-----------------------------------------------------------
129 public:
130 f32 _meterValue;
131 METER_TYPE _meterType;
132 AXIS_TYPE _axisType;
133
135 };
136
138 struct GxColladaCamera
139 {
140 //-----------------------------------------------------------
142 //-----------------------------------------------------------
144 public:
145 // new, delete定義
146 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
147
149 //-----------------------------------------------------------
151 //-----------------------------------------------------------
153 public:
155 GxColladaCamera(void)
156 : _yfov(0.0f)
157 , _aspect(0.0f)
158 , _znear(0.0f)
159 , _zfar(0.0f)
160 {}
161
163 //-----------------------------------------------------------
165 //-----------------------------------------------------------
167 public:
168 f32 _yfov;
169 f32 _aspect;
170 f32 _znear;
171 f32 _zfar;
172
174 };
175
177 struct GxColladaTexture
178 {
179 //-----------------------------------------------------------
181 //-----------------------------------------------------------
183 public:
184 // new, delete定義
185 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
186
188 //-----------------------------------------------------------
190 //-----------------------------------------------------------
192 public:
194 GxColladaTexture(void)
195 : _pFilePath(nullptr)
196 {}
197
199 //-----------------------------------------------------------
201 //-----------------------------------------------------------
203 public:
204 GX_CSTR _pFilePath;
205
207 };
208
210 struct GxColladaRootNode
211 {
212 //-----------------------------------------------------------
214 //-----------------------------------------------------------
216 public:
217 // new, delete定義
218 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
219
221 //-----------------------------------------------------------
223 //-----------------------------------------------------------
225 public:
227 GxColladaRootNode(void)
228 : _matrix(GxMatrix44::IDENTITY)
229 , _translate(GxVector3::ZERO)
230 , _rotate(GxVector3::ZERO)
231 , _orient(GxVector3::ZERO)
232 , _scale(GxVector3::ONE)
233 , _rotateOrderType(GxColladaReader::ROTATE_ORDER_TYPE::NONE)
234 , _orientOrderType(GxColladaReader::ROTATE_ORDER_TYPE::NONE)
235 {}
236
238 //-----------------------------------------------------------
240 //-----------------------------------------------------------
242 public:
243 GxMatrix44 _matrix;
244 GxVector3 _translate;
245 GxVector3 _rotate;
246 GxVector3 _orient;
247 GxVector3 _scale;
248 GxColladaReader::ROTATE_ORDER_TYPE _rotateOrderType;
249 GxColladaReader::ROTATE_ORDER_TYPE _orientOrderType;
250
252 };
253
255 struct GxColladaJoint
256 {
257 //-----------------------------------------------------------
259 //-----------------------------------------------------------
261 public:
262 // new, delete定義
263 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
264
266 static constexpr u32 ROTATE_NUM = 3;
267
269 //-----------------------------------------------------------
271 //-----------------------------------------------------------
273 public:
275 GxColladaJoint(void)
276 : _pName(nullptr)
277 , _myId(GX_INVALID_HANDLE)
278 , _parentId(GX_INVALID_HANDLE)
279 , _matrix(GxMatrix44::IDENTITY)
280 , _translate(GxVector3::ZERO)
281 , _rotate(GxVector3::ZERO)
282 , _orient(GxVector3::ZERO)
283 , _scale(GxVector3::ONE)
284 , _rotateOrderType(ROTATE_ORDER_TYPE::NONE)
285 , _orientOrderType(ROTATE_ORDER_TYPE::NONE)
286 {}
287
289 //-----------------------------------------------------------
291 //-----------------------------------------------------------
293 public:
294 GX_CSTR _pName;
295 u32 _myId;
296 u32 _parentId;
297 GxMatrix44 _matrix;
298 GxVector3 _translate;
299 GxVector3 _rotate;
300 GxVector3 _orient;
301 GxVector3 _scale;
302 GxColladaReader::ROTATE_ORDER_TYPE _rotateOrderType;
303 GxColladaReader::ROTATE_ORDER_TYPE _orientOrderType;
304
306 };
307
308 //---- パーツ情報
309
311 struct GxColladaParts
312 {
313 //-----------------------------------------------------------
315 //-----------------------------------------------------------
317 public:
318 // new, delete定義
319 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
320
322 //-----------------------------------------------------------
324 //-----------------------------------------------------------
326 public:
328 GxColladaParts(void)
329 : _pName(nullptr)
330 , _shapeId(GX_INVALID_HANDLE)
331 , _partsId(0xFFFF)
332 , _lodMask(0xFFFF)
333 {}
334
336 //-----------------------------------------------------------
338 //-----------------------------------------------------------
340 public:
341 GX_CSTR _pName;
342 u32 _shapeId;
343 u16 _partsId;
344 u16 _lodMask;
345
347 };
348
349 static constexpr u32 DESTRUCTION_PARTS_MAX = 256;
350
352 struct GxColladaWeight
353 {
354 //-----------------------------------------------------------
356 //-----------------------------------------------------------
358 public:
360 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
361
363 static constexpr u32 EFFECT_JOINT_NUM = 4;
364
366 //-----------------------------------------------------------
368 //-----------------------------------------------------------
370 public:
372 GxColladaWeight(void)
373 : _count(0)
374 {
375 GX_MEMSET(_joint, 0xFFFFFFF, sizeof(_joint));
376 GX_MEMSET(_weight, 0, sizeof(_weight));
377 }
378
380 //-----------------------------------------------------------
382 //-----------------------------------------------------------
384 public:
385 u32 _count;
386 u32 _joint[EFFECT_JOINT_NUM];
387 f32 _weight[EFFECT_JOINT_NUM];
388
390 };
391
393 struct GxColladaBindMatrix
394 {
395 //-----------------------------------------------------------
397 //-----------------------------------------------------------
399 public:
400 // new, delete定義
401 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
402
404 //-----------------------------------------------------------
406 //-----------------------------------------------------------
408 public:
410 GxColladaBindMatrix(void)
411 : _matrix(GxMatrix44::IDENTITY)
412 , _joint(0)
413 {}
414
416 //-----------------------------------------------------------
418 //-----------------------------------------------------------
420 public:
421 GxMatrix44 _matrix;
422 u32 _joint;
423
425 };
426
428 struct GxColladaSkin
429 {
430 //-----------------------------------------------------------
432 //-----------------------------------------------------------
434 public:
435 // new, delete定義
436 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
437
439 //-----------------------------------------------------------
441 //-----------------------------------------------------------
443 public:
445 GxColladaSkin(void)
446 : _shapeId(0)
447 , _bindShapeMatrix(GxMatrix44::IDENTITY)
448 , _pBindPoseMatrixArray(nullptr)
449 , _bindPoseMatrixCount(0)
450 , _pWeightArray(nullptr)
451 , _weightCount(0)
452 {
453 }
455 ~GxColladaSkin(void)
456 {
457 GX_SAFE_DELETE_ARRAY(_pWeightArray);
458 GX_SAFE_DELETE_ARRAY(_pBindPoseMatrixArray);
459 }
460
462 //-----------------------------------------------------------
464 //-----------------------------------------------------------
466 public:
467 u32 _shapeId;
468 GxMatrix44 _bindShapeMatrix;
469 GxColladaBindMatrix* _pBindPoseMatrixArray;
470 u32 _bindPoseMatrixCount;
471 GxColladaWeight* _pWeightArray;
472 u32 _weightCount;
473
475 };
476
477 //---- ジオメトリ情報
478
480 struct GxColladaTriangleElement
481 {
482 //-----------------------------------------------------------
484 //-----------------------------------------------------------
486 public:
487 // new, delete定義
488 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
489
490 public:
492 enum class VERTICES_ELEMENT
493 {
494 POSITION = 0,
495 NORMAL,
496 COLOR,
497 TEXCOORD,
498 TEXTANGENT,
499 TEXBINORMAL,
500
501 MAX
502 };
503
505 //-----------------------------------------------------------
507 //-----------------------------------------------------------
509 public:
511 GxColladaTriangleElement(void)
512 : _pName(nullptr)
513 , _type(VERTICES_ELEMENT::POSITION)
514 , _offset(0)
515 , _set(0)
516 , _index(0)
517 , _padding(0)
518 {}
519
521 //-----------------------------------------------------------
523 //-----------------------------------------------------------
525 public:
526 GX_CSTR _pName;
527 VERTICES_ELEMENT _type;
528 u8 _offset;
529 u8 _set;
530 u8 _index;
531 u8 _padding;
532
534 };
535
537 struct GxColladaTriangles
538 {
539 //-----------------------------------------------------------
541 //-----------------------------------------------------------
543 public:
544 // new, delete定義
545 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
546
548 //-----------------------------------------------------------
550 //-----------------------------------------------------------
552 public:
554 GxColladaTriangles(void)
555 : _materialId(0)
556 , _triangleCount(0)
557 , _pTriangleElementArray(nullptr)
558 , _triangleElementCount(0)
559 , _pPrimitiveArray(nullptr)
560 , _primitiveCount(0)
561 , _primitiveOneSize(0)
562 {
563 }
565 ~GxColladaTriangles(void)
566 {
567 GX_SAFE_DELETE_ARRAY(_pTriangleElementArray);
568 GX_SAFE_FREE_MEMORY(_pPrimitiveArray);
569 }
570
572 //-----------------------------------------------------------
574 //-----------------------------------------------------------
576
578 s32 getTriangleElementIndex(GX_CSTR elementName) const
579 {
580 for( u32 i=0; i < _triangleElementCount; ++i )
581 {
582 if( (_pTriangleElementArray[i]._pName != nullptr) && (GX_STRCMP(_pTriangleElementArray[i]._pName, elementName) == 0) )
583 {
584 return i;
585 }
586 }
587 return -1;
588 }
590 s32 getTriangleElementIndex(GxColladaTriangleElement::VERTICES_ELEMENT elementType) const
591 {
592 for( u32 i=0; i < _triangleElementCount; ++i )
593 {
594 if( _pTriangleElementArray[i]._type == elementType )
595 {
596 return i;
597 }
598 }
599 return -1;
600 }
602 const GxColladaTriangleElement* getTriangleElement(GX_CSTR elementName) const
603 {
604 s32 index = getTriangleElementIndex(elementName);
605 if( index < 0 )
606 {
607 return nullptr;
608 }
609 else
610 {
611 return &_pTriangleElementArray[index];
612 }
613 }
615 const GxColladaTriangleElement* getTriangleElement(GxColladaTriangleElement::VERTICES_ELEMENT elementType) const
616 {
617 s32 index = getTriangleElementIndex(elementType);
618 if( index < 0 )
619 {
620 return nullptr;
621 }
622 else
623 {
624 return &_pTriangleElementArray[index];
625 }
626 }
627
629 //-----------------------------------------------------------
631 //-----------------------------------------------------------
633 public:
634 u32 _materialId;
635 u32 _triangleCount;
636 GxColladaTriangleElement* _pTriangleElementArray;
637 u32 _triangleElementCount;
638 u32* _pPrimitiveArray;
639 u32 _primitiveCount;
640 u32 _primitiveOneSize;
641
643 };
644
646 struct GxColladaColor
647 {
648 //-----------------------------------------------------------
650 //-----------------------------------------------------------
652 public:
653 // new, delete定義
654 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
655
657 //-----------------------------------------------------------
659 //-----------------------------------------------------------
661 public:
663 GxColladaColor(void)
664 : _pValueArray(nullptr)
665 , _valueCount(0)
666 {
667 }
669 ~GxColladaColor(void)
670 {
671 GX_SAFE_FREE_MEMORY(_pValueArray);
672 }
673
675 //-----------------------------------------------------------
677 //-----------------------------------------------------------
679 public:
680 GxColorHDR* _pValueArray;
681 u32 _valueCount;
682
684 };
685
687 struct GxColladaTexcoord
688 {
689 //-----------------------------------------------------------
691 //-----------------------------------------------------------
693 public:
694 // new, delete定義
695 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
696
698 //-----------------------------------------------------------
700 //-----------------------------------------------------------
702 public:
704 GxColladaTexcoord(void)
705 : _pValueArray(nullptr)
706 , _valueCount(0)
707 {
708 }
710 ~GxColladaTexcoord(void){ GX_SAFE_FREE_MEMORY(_pValueArray); }
711
713 //-----------------------------------------------------------
715 //-----------------------------------------------------------
717 public:
718 GxVector2* _pValueArray;
719 u32 _valueCount;
720
722 };
723
725 struct GxColladaTexTangent
726 {
727 //-----------------------------------------------------------
729 //-----------------------------------------------------------
731 public:
732 // new, delete定義
733 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
734
736 //-----------------------------------------------------------
738 //-----------------------------------------------------------
740 public:
742 GxColladaTexTangent(void)
743 : _pValueArray(nullptr)
744 , _valueCount(0)
745 {}
746
748 ~GxColladaTexTangent(void){ GX_SAFE_FREE_MEMORY(_pValueArray); }
749
751 //-----------------------------------------------------------
753 //-----------------------------------------------------------
755 public:
756 GxVector3* _pValueArray;
757 u32 _valueCount;
758
760 };
761
763 struct GxColladaTexBinormal
764 {
765 //-----------------------------------------------------------
767 //-----------------------------------------------------------
769 public:
770 // new, delete定義
771 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
772
774 //-----------------------------------------------------------
776 //-----------------------------------------------------------
778 public:
780 GxColladaTexBinormal(void)
781 : _pValueArray(nullptr)
782 , _valueCount(0)
783 {}
785 ~GxColladaTexBinormal(void){ GX_SAFE_FREE_MEMORY(_pValueArray); }
786
788 //-----------------------------------------------------------
790 //-----------------------------------------------------------
792 public:
793 GxVector3* _pValueArray;
794 u32 _valueCount;
795
797 };
798
800 struct GxColladaGeometry
801 {
802 //-----------------------------------------------------------
804 //-----------------------------------------------------------
806 public:
807 // new, delete定義
808 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
809
811 //-----------------------------------------------------------
813 //-----------------------------------------------------------
815 public:
817 GxColladaGeometry(void)
818 : _pTrianglesArray(nullptr)
819 , _trianglesCount(0)
820 , _pPositionArray(nullptr)
821 , _positionCount(0)
822 , _pNormalArray(nullptr)
823 , _normalCount(0)
824 , _pColorArray(nullptr)
825 , _colorCount(0)
826 , _pTexcoordArray(nullptr)
827 , _texcoordCount(0)
828 , _pTexTangentArray(nullptr)
829 , _texTangentCount(0)
830 , _pTexBinormalArray(nullptr)
831 , _texBinormalCount(0)
832 {}
833
835 ~GxColladaGeometry(void)
836 {
837 GX_SAFE_DELETE_ARRAY(_pTrianglesArray);
838 GX_SAFE_FREE_MEMORY(_pPositionArray);
839 GX_SAFE_FREE_MEMORY(_pNormalArray);
840 GX_SAFE_DELETE_ARRAY(_pColorArray);
841 GX_SAFE_DELETE_ARRAY(_pTexcoordArray);
842 GX_SAFE_DELETE_ARRAY(_pTexTangentArray);
843 GX_SAFE_DELETE_ARRAY(_pTexBinormalArray);
844 }
845
847 //-----------------------------------------------------------
849 //-----------------------------------------------------------
851
853 const GxColladaTriangleElement* getTriangleElement(GX_CSTR elementName) const
854 {
855 for( u32 i = 0; i < _trianglesCount; ++i )
856 {
857 const auto* pColladaTriangleElement = _pTrianglesArray[i].getTriangleElement(elementName);
858 if( pColladaTriangleElement )
859 {
860 return pColladaTriangleElement;
861 }
862 }
863 return nullptr;
864 }
865
867 //-----------------------------------------------------------
869 //-----------------------------------------------------------
871 public:
872 GxColladaTriangles* _pTrianglesArray;
873 u32 _trianglesCount;
874 GxVector3* _pPositionArray;
875 u32 _positionCount;
876 GxVector3* _pNormalArray;
877 u32 _normalCount;
878 GxColladaColor* _pColorArray;
879 u8 _colorCount;
880 GxColladaTexcoord* _pTexcoordArray;
881 u8 _texcoordCount;
882 GxColladaTexTangent* _pTexTangentArray;
883 u8 _texTangentCount;
884 GxColladaTexBinormal* _pTexBinormalArray;
885 u8 _texBinormalCount;
886
888 };
889
891 struct GxColladaMaterialParameter
892 {
893 //-----------------------------------------------------------
895 //-----------------------------------------------------------
897 public:
898 // new, delete定義
899 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
900
902 enum class PARAMETER_TYPE
903 {
904 UNKNOWN = -1,
905 BOOL = 0,
906 INT,
907 FLOAT,
908 FLOAT2,
909 FLOAT3,
910 FLOAT4,
911 FLOAT4x4,
912 SAMPLER_2D,
913 SAMPLER_CUBE,
914 SURFACE
915 };
916
918 enum class FILTER_TYPE
919 {
920 UNKNOWN = -1,
921 POINT = 0,
922 LINEAR
923 };
924
926 struct Sampler
927 {
928 //-----------------------------------------------------------
930 //-----------------------------------------------------------
932 public:
934 Sampler(void)
935 : _pSurfaceName(nullptr)
936 , _minFilter(FILTER_TYPE::UNKNOWN)
937 , _magFilter(FILTER_TYPE::UNKNOWN)
938 {}
939
941 //-----------------------------------------------------------
943 //-----------------------------------------------------------
945 public:
946 GX_CSTR _pSurfaceName;
947 FILTER_TYPE _minFilter;
948 FILTER_TYPE _magFilter;
949
951 };
952
954 //-----------------------------------------------------------
956 //-----------------------------------------------------------
958 public:
960 GxColladaMaterialParameter(void)
961 : _pRef(nullptr)
962 , _type(PARAMETER_TYPE::UNKNOWN)
963 , _int(0)
964 , _float(0.f)
965 {}
966
968 ~GxColladaMaterialParameter(void){}
969
971 //-----------------------------------------------------------
973 //-----------------------------------------------------------
975 public:
976 GX_CSTR _pRef;
977 PARAMETER_TYPE _type;
978 b32 _bool;
979 u32 _int;
980 f32 _float;
981 GxVector2 _float2;
982 GxVector3 _float3;
983 GxVector4 _float4;
984 GxMatrix44 _float4x4;
985 Sampler _sampler;
986
988 };
989
991 struct GxColladaMaterialExtra
992 {
993 //-----------------------------------------------------------
995 //-----------------------------------------------------------
997 public:
998 // new, delete定義
999 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1000
1002 //-----------------------------------------------------------
1004 //-----------------------------------------------------------
1006 public:
1008 GxColladaMaterialExtra(void)
1009 : _hitFlag(0)
1010 , _hitMaterial(0)
1011 {}
1013 ~GxColladaMaterialExtra(void){}
1014
1016 //-----------------------------------------------------------
1018 //-----------------------------------------------------------
1020 public:
1021 u32 _hitFlag;
1022 s32 _hitMaterial;
1023
1025 };
1026
1028 struct GxColladaMaterial
1029 {
1030 //-----------------------------------------------------------
1032 //-----------------------------------------------------------
1034 public:
1035 // new, delete定義
1036 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1037
1039 //-----------------------------------------------------------
1041 //-----------------------------------------------------------
1043 public:
1045 GxColladaMaterial(void)
1046 : _pTechniqueHintArray(nullptr)
1047 , _techniqueHintCount(0)
1048 , _pSetParameterArray(nullptr)
1049 , _setParameterCount(0)
1050 , _pExtraData(nullptr)
1051 {}
1052
1054 ~GxColladaMaterial(void)
1055 {
1056 GX_SAFE_FREE_MEMORY(_pTechniqueHintArray);
1057 GX_SAFE_DELETE_ARRAY(_pSetParameterArray);
1058 GX_SAFE_DELETE(_pExtraData);
1059 }
1060
1062 //-----------------------------------------------------------
1064 //-----------------------------------------------------------
1066 public:
1067 GX_CSTR* _pTechniqueHintArray;
1068 u32 _techniqueHintCount;
1069 GxColladaMaterialParameter* _pSetParameterArray;
1070 u32 _setParameterCount;
1071 GxColladaMaterialExtra* _pExtraData;
1072
1074 };
1075
1077 struct GxColladaUVEffect
1078 {
1079 //-----------------------------------------------------------
1081 //-----------------------------------------------------------
1083 public:
1084 // new, delete定義
1085 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1086
1088 static constexpr u32 NUM_UVEFFECT_STAGES = 16;
1089
1091 //-----------------------------------------------------------
1093 //-----------------------------------------------------------
1095 public:
1097 GxColladaUVEffect(void)
1098 {
1099 for ( s32 i = 0; i < static_cast<s32>(NUM_UVEFFECT_STAGES); i ++ )
1100 {
1101 _repeatUV[i] = GxVector2::ONE;
1102 _offsetUV[i] = GxVector2::ZERO;
1103 _rotateUV[i] = 0.f;
1104 }
1105 }
1106
1108 //-----------------------------------------------------------
1110 //-----------------------------------------------------------
1112 public:
1113 GxVector2 _repeatUV[NUM_UVEFFECT_STAGES];
1114 GxVector2 _offsetUV[NUM_UVEFFECT_STAGES];
1115 f32 _rotateUV[NUM_UVEFFECT_STAGES];
1116
1118 };
1119
1121 struct GxColladaEffect
1122 {
1123 //-----------------------------------------------------------
1125 //-----------------------------------------------------------
1127 public:
1128 // new, delete定義
1129 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1130
1132 struct Texture
1133 {
1134 //-----------------------------------------------------------
1136 //-----------------------------------------------------------
1138 public:
1140 Texture(void)
1141 : _pTexcoordName(nullptr)
1142 , _repeatUV(1.f,1.f)
1143 , _offsetUV(0.f,0.f)
1144 , _rotateUV(0.f)
1145 {}
1146
1148 //-----------------------------------------------------------
1150 //-----------------------------------------------------------
1152 public:
1153 GX_CSTR _pTexcoordName;
1154 GxVector2 _repeatUV;
1155 GxVector2 _offsetUV;
1156 f32 _rotateUV;
1157
1159 };
1160
1162 //-----------------------------------------------------------
1164 //-----------------------------------------------------------
1166 public:
1168 GxColladaEffect(void)
1169 : _pEffectTextureArray(nullptr)
1170 , _effectTextureCount(0)
1171 {}
1173 ~GxColladaEffect(void){ GX_SAFE_DELETE_ARRAY(_pEffectTextureArray); }
1174
1176 //-----------------------------------------------------------
1178 //-----------------------------------------------------------
1180 public:
1181 Texture* _pEffectTextureArray;
1182 u32 _effectTextureCount;
1183
1185 };
1186
1188 struct GxColladaAnimationTangentKey
1189 {
1190 //-----------------------------------------------------------
1192 //-----------------------------------------------------------
1194 public:
1195 // new, delete定義
1196 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1197
1199 //-----------------------------------------------------------
1201 //-----------------------------------------------------------
1203 public:
1204 GxVector3 _vector0;
1205 GxVector3 _vector1;
1206
1208 };
1209
1211 struct GxColladaAnimations
1212 {
1213 //-----------------------------------------------------------
1215 //-----------------------------------------------------------
1217 public:
1218 // new, delete定義
1219 GX_OPERATOR_NEW_DELETE_USE_ARRAY(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP);
1220
1222 enum class ANIMATION_ELEMENT
1223 {
1224 INVALID = -1,
1225 INPUT = 0,
1226 OUTPUT,
1227 INTANGENT,
1228 OUTTANGENT,
1229 INTERPOLATION,
1230
1231 MAX
1232 };
1233
1235 enum class OUTPUT_TYPE
1236 {
1237 FLOAT = 0,
1238 VECTOR2,
1239 VECTOR3,
1240 VECTOR4
1241 };
1242
1244 enum class INTERPOLATION_TYPE
1245 {
1246 LINEAR = 0,
1247 BEZIER,
1248 HELMITE,
1249 CARDINAL,
1250 BSPLINE,
1251 STEP,
1252 NURBS
1253 };
1254
1256 //-----------------------------------------------------------
1258 //-----------------------------------------------------------
1260 public:
1262 GxColladaAnimations(void)
1263 : _pName(nullptr)
1264 , _keyCount(0)
1265 , _outputType(OUTPUT_TYPE::FLOAT)
1266 , _pInputKeyArray(nullptr)
1267 , _pOutputKeyArray(nullptr)
1268 , _pInTangentKeyArray(nullptr)
1269 , _pOutTangentKeyArray(nullptr)
1270 , _pInterpolationKeyArray(nullptr)
1271 {}
1273 ~GxColladaAnimations(void)
1274 {
1275 GX_SAFE_FREE_MEMORY(_pInputKeyArray);
1276 GX_SAFE_FREE_MEMORY(_pOutputKeyArray);
1277 GX_SAFE_DELETE_ARRAY(_pInTangentKeyArray);
1278 GX_SAFE_DELETE_ARRAY(_pOutTangentKeyArray);
1279 GX_SAFE_FREE_MEMORY(_pInterpolationKeyArray);
1280 }
1281
1283 //-----------------------------------------------------------
1285 //-----------------------------------------------------------
1287 public:
1288 GX_CSTR _pName;
1289 u32 _keyCount;
1290 OUTPUT_TYPE _outputType;
1291
1292 f32* _pInputKeyArray;
1293 void* _pOutputKeyArray;
1294 GxColladaAnimationTangentKey* _pInTangentKeyArray;
1295 GxColladaAnimationTangentKey* _pOutTangentKeyArray;
1296 INTERPOLATION_TYPE* _pInterpolationKeyArray;
1297
1299 };
1300
1302 //-----------------------------------------------------------
1304 //-----------------------------------------------------------
1306public:
1308 GxColladaReader(void);
1310 ~GxColladaReader(void) override;
1311
1313 b32 initialize(GxStream& stream, GxColladaReaderNotifierBase* pNotifier = nullptr);
1315 void terminate(void);
1316
1318 //-----------------------------------------------------------
1320 //-----------------------------------------------------------
1322public:
1324 b32 read(void);
1325
1326protected:
1328 virtual b32 analyseCollada(const GxXmlParser* pXmlParser);
1330 virtual b32 analyseCustom(const GxXmlParser* pXmlParser);
1331
1333 virtual b32 analyseCommonAsset(const GxXmlParser::GxNode* pNode);
1335 virtual b32 analyseLibraryCameras(const GxXmlParser::GxNode* pNode);
1337 virtual b32 analyseLibraryImages(const GxXmlParser::GxNode* pNode);
1339 virtual b32 analyseLibraryVisualScenesJoint(const GxXmlParser::GxNode* pNode);
1341 virtual b32 analyseLibraryMaterials(const GxXmlParser::GxNode* pNode);
1343 virtual b32 analyseLibraryEffects(const GxXmlParser::GxNode* pNode);
1345 virtual b32 analyseLibraryVisualScenesBindMaterial(const GxXmlParser::GxNode* pNode);
1347 virtual b32 analyseLibraryGeometories(const GxXmlParser::GxNode* pNode);
1349 virtual b32 analyseLibraryControllers(const GxXmlParser::GxNode* pNode);
1351 virtual b32 analyseLibraryVisualScenesParts(const GxXmlParser::GxNode* pNode);
1353 virtual b32 analyseLibraryAnimations(const GxXmlParser::GxNode* pNode);
1354
1356 virtual b32 analyseLibraryMaterialSubRoutineTechniqueHint(GxColladaMaterial* pColladaMaterial, const GxXmlParser::GxNode*& pNodeTechniqueHint);
1358 virtual b32 analyseLibraryMaterialSubRoutineSetParam(GxColladaMaterial* pColladaMaterial, const GxXmlParser::GxNode*& pNodeSetParam);
1360 virtual b32 analyseLibraryMaterialSubRoutineExtra(GxColladaMaterial* pColladaMaterial, const GxXmlParser::GxNode* pNodeExtra);
1362 virtual b32 analyseLibraryGeometrySubRoutineMesh(GxColladaGeometry* pColladaGeometry, const GxXmlParser::GxNode* pNodeMesh);
1364 virtual b32 analyseLibraryVisualScenesSubRoutineRootNode(const GxXmlParser::GxNode* pNodeRoot);
1366 virtual b32 analyseLibraryVisualScenesSubRoutineJoint(const GxXmlParser::GxNode* pNodeJoint, u32 parentId = GX_INVALID_HANDLE);
1368 virtual b32 analyseLibraryVisualScenesSubRoutineParts(GxColladaParts* pColladaParts, const GxXmlParser::GxNode* pNodeParts, u16 partsId, u16 lodMask);
1369
1371 static s32 checkPartsKeyWord(GX_CSTR src);
1373 static s32 checkLODKeyWord(GX_CSTR src);
1375 static s32 checkHavokKeyWord(GX_CSTR src);
1376
1378 //-----------------------------------------------------------
1380 //-----------------------------------------------------------
1382public:
1384 GX_FORCE_INLINE const GxColladaCommonAsset* getCommonAsset(void) const { return &_commonData; };
1385
1387 constexpr GxColladaCamera* getCameraArray(void) const { return _pCameraData; };
1389 constexpr u32 getCameraCount(void) const { return _cameraCount; };
1390
1392 constexpr GxColladaTexture* getTextureArray(void) const { return _pTextureData; }
1394 constexpr u32 getTextureCount(void) const { return _textureCount; }
1395
1397 constexpr GxColladaMaterial* getMaterialArray(void) const { return _pMaterialData; }
1399 constexpr u32 getMaterialCount(void) const { return _materialCount; }
1401 constexpr GxColladaMaterial* getMaterialData(u32 id) const { return _pMaterialData ? &_pMaterialData[id] : nullptr; }
1403 constexpr GxColladaMaterial* getMaterialData(GX_CSTR name) const { return getMaterialData(getMaterialId(name)); }
1405 constexpr GX_CSTR getMaterialName(u32 id) const { return _pMaterialTable ? _pMaterialTable[id] : nullptr; }
1407 constexpr GX_CSTR getMaterialName(const GxColladaTriangles& triangles) const { return getMaterialName(triangles._materialId); }
1408
1410 constexpr GxColladaGeometry* getGeometryArray(void) const { return _pGeometryData; }
1412 constexpr u32 getGeometryCount(void) const { return _geometryCount; }
1413
1415 GX_FORCE_INLINE const GxColladaRootNode* getRootNode(void) const { return &_rootNodeData; }
1416
1418 constexpr GxColladaJoint* getJointArray(void) const { return _pJointData; }
1420 constexpr u32 getJointCount(void) const { return _jointCount; }
1421
1423 constexpr GxColladaSkin* getSkinArray(void) const { return _pSkinData; }
1425 constexpr u32 getSkinCount(void) const { return _skinCount; }
1426
1428 constexpr GxColladaParts* getPartsArray(void) const { return _pPartsData; }
1430 constexpr u32 getPartsCount(void) const { return _partsCount; }
1431
1433 constexpr GxColladaAnimations* getAnimationArray(void) const { return _pAnimationData; }
1435 constexpr u32 getAnimationCount(void) const { return _animationCount; }
1436
1438 constexpr u32* getDestructionPartsCount(void) const { return _pDestructionPartsCount; }
1439
1440protected:
1442 u32 getCameraId(GX_CSTR cameraName) const;
1444 u32 getTextureId(GX_CSTR textureName) const;
1446 u32 getMaterialId(GX_CSTR materialName) const;
1448 u32 getMaterialIdBySymbol(GX_CSTR materialSymbol) const;
1450 u32 getShapeId(GX_CSTR shapeName) const;
1452 u32 getShapeIdBySkinName(GX_CSTR skinName) const;
1454 u32 getJointIdBySymbol(GX_CSTR jointSymbol) const;
1456 u32 getAnimationId(GX_CSTR animationName) const;
1457
1458 //---- GxColladaUVEffect用
1459
1461 void setColladaUVEffect(u32 mateIndex, GX_CSTR semaName, GX_CSTR inputSet);
1463 b32 getUVEffectById(u32 mateIndex, u32 inputSet, GxVector2& retRepeatUV, GxVector2& outOffsetUV, f32& outRotateUV) const;
1464
1466 static void getColladaAnimationTangentKeyFromXmlData(GxColladaAnimationTangentKey* pDst, GX_CSTR src, u32 count = 1);
1468 static GxColladaMaterialParameter::FILTER_TYPE getFilterType(GX_CSTR filterName);
1470 static b32 isJointNode(const GxXmlParser::GxNode* pNodeJoint);
1472 static GX_CSTR getLastWord(GX_CSTR src);
1473
1475 //-----------------------------------------------------------
1477 //-----------------------------------------------------------
1479protected:
1480 GxXmlParser* _pXmlParser;
1481 GxColladaReaderNotifierBase* _pNotifier;
1482
1483 GX_CSTR* _pCameraTable;
1484 GX_CSTR* _pTextureTable;
1485 GX_CSTR* _pMaterialTable;
1486 GX_CSTR* _pMaterialSymbolTable;
1487 GX_CSTR* _pMaterialInsEffectTable;
1488 GX_CSTR* _pEffectTable;
1489 GX_CSTR* _pShapeTable;
1490 SkinTable* _pSkinTable;
1491 GX_CSTR* _pJointSubIdTable;
1492 GX_CSTR* _pAnimationTable;
1493
1494 GxColladaCommonAsset _commonData;
1495 GxColladaCamera* _pCameraData;
1496 GxColladaTexture* _pTextureData;
1497 GxColladaMaterial* _pMaterialData;
1498 GxColladaEffect* _pEffectData;
1499 GxColladaUVEffect* _pUVEffectData;
1500 GxColladaGeometry* _pGeometryData;
1501 GxColladaSkin* _pSkinData;
1502 GxColladaRootNode _rootNodeData;
1503 GxColladaJoint* _pJointData;
1504 GxColladaParts* _pPartsData;
1505 GxColladaAnimations* _pAnimationData;
1506 u32* _pDestructionPartsCount;
1507
1508 u32 _cameraCount;
1509 u32 _textureCount;
1510 u32 _materialCount;
1511 u32 _effectCount;
1512 u32 _geometryCount;
1513 u32 _skinCount;
1514 u32 _jointCount;
1515 u32 _partsCount;
1516 u32 _animationCount;
1517
1518 u32 _jointIndex;
1519
1521};
1522
1523//===========================================================================
1525//===========================================================================
1526class GxColladaReaderNotifierBase
1527{
1528 //-----------------------------------------------------------
1530 //-----------------------------------------------------------
1532public:
1533 // new, delete定義
1534 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
1535
1536public:
1538 struct GxColladaCommonAssetCallback
1539 {
1540 GxColladaReader::GxColladaCommonAsset _commonAsset;
1541 };
1542
1544 struct GxColladaCameraCallback
1545 {
1546 GxColladaReader::GxColladaCamera* _pCameraArray;
1547 u32 _cameraCount;
1548 };
1549
1551 struct GxColladaTextureCallback
1552 {
1553 GxColladaReader::GxColladaTexture* _pTextureArray;
1554 u32 _textureCount;
1555 };
1556
1558 struct GxColladaMaterialCallback
1559 {
1560 GxColladaReader::GxColladaMaterial* _pMaterialArray;
1561 u32 _materialCount;
1562 };
1563
1565 struct GxColladaGeometryCallback
1566 {
1567 GxColladaReader::GxColladaGeometry* _pGeometryArray;
1568 u32 _geometryCount;
1569 };
1570
1572 struct GxColladaRootNodeCallback
1573 {
1574 GxColladaReader::GxColladaRootNode* _pRootNode;
1575 };
1576
1578 struct GxColladaJointCallback
1579 {
1580 GxColladaReader::GxColladaJoint* _pJointArray;
1581 u32 _jointCount;
1582 };
1583
1585 struct GxColladaSkinCallback
1586 {
1587 GxColladaReader::GxColladaSkin* _pSkinArray;
1588 u32 _skinCount;
1589 };
1590
1592 struct GxColladaPartsCallback
1593 {
1594 GxColladaReader::GxColladaParts* _pPartsArray;
1595 u32 _partsCount;
1596 u32 _destructionMeshCount;
1597 u32 _normalPartsCount;
1598 };
1599
1601 struct GxColladaAnimationCallback
1602 {
1603 GxColladaReader::GxColladaAnimations* _pAnimationArray;
1604 u32 _animationCount;
1605 };
1606
1608 //-----------------------------------------------------------
1610 //-----------------------------------------------------------
1612
1613public:
1615 GxColladaReaderNotifierBase(void){}
1617 virtual ~GxColladaReaderNotifierBase(void){}
1618
1620 //-----------------------------------------------------------
1622 //-----------------------------------------------------------
1624public:
1625 /* ※下記記述順序はコールバック発生順序を表す */
1626
1628 virtual void onColladaCommonAsset(const GxColladaCommonAssetCallback& /*value*/) {}
1630 virtual void onColladaCamera(const GxColladaCameraCallback& /*value*/) {}
1632 virtual void onColladaTexture(const GxColladaTextureCallback& /*value*/) {}
1634 virtual void onColladaRootNode(const GxColladaRootNodeCallback& /*value*/) {}
1636 virtual void onColladaJoint(const GxColladaJointCallback& /*value*/) {}
1638 virtual void onColladaMaterial(const GxColladaMaterialCallback& /*value*/) {}
1640 virtual void onColladaGeometry(const GxColladaGeometryCallback& /*value*/) {}
1642 virtual void onColladaSkin(const GxColladaSkinCallback& /*value*/) {}
1644 virtual void onColladaParts(const GxColladaPartsCallback& /*value*/) {}
1646 virtual void onColladaAnimation(const GxColladaAnimationCallback& /*value*/) {}
1647
1648 // COLLADA解析結果TTY出力処理 (デバッグ用)
1650 static void printColladaCommonAsset(const GxColladaCommonAssetCallback& value);
1652 static void printColladaCamera(const GxColladaCameraCallback& value);
1654 static void printColladaTexture(const GxColladaTextureCallback& value);
1656 static void printColladaMaterial(const GxColladaMaterialCallback& value);
1658 static void printColladaGeometry(const GxColladaGeometryCallback& value);
1660 static void printColladaRootNode(const GxColladaRootNodeCallback& value);
1662 static void printColladaJoint(const GxColladaJointCallback& value);
1664 static void printColladaSkin(const GxColladaSkinCallback& value);
1666 static void printColladaParts(const GxColladaPartsCallback& value);
1668 static void printColladaAnimation(const GxColladaAnimationCallback& value);
1669
1671};
1672
1673GX_CORE_NAMESPACE_END()
1674
1675#endif // GX_DEVELOP
#define GX_SAFE_FREE_MEMORY(pAddress)
Definition GxAllocator.h:594
#define GX_PROHIBIT_CLASS_BASE(__CLASS__)
GxClassBase継承の禁止宣言
Definition GxBase.h:240
OUTPUT_TYPE
出力形式
Definition GxDefine.h:244
@ MAX
定義数
@ ZERO
全て 0 で初期化
@ NONE
何もしない
@ IDENTITY
基礎値で初期化
@ X
X.
@ Z
Z.
@ Y
Y.
@ LINEAR
線形補間
@ _2
ビュー2
@ _1
ビュー1
@ INVALID
無効なビュー
@ _3
ビュー3
@ POINT
点で描画する
@ NORMAL
法線(VS入力,VS→PS)
@ POSITION
位置データ(VS入力,VS出力)
@ COLOR
4D パック済み 正規化される u8(GxColor形式)
@ FLOAT3
3D f32 (f, f, f, 1) に展開される
@ FLOAT2
2D f32 (f, f, 0, 1) に展開される
@ FLOAT4
4D f32 (f, f, f, f) に展開される
@ UNKNOWN
未定義
#define GX_STRCMP(__STRING0__, __STRING1__)
文字列比較
Definition GxString.h:616
ストリーム基礎クラス
Definition GxStream.h:20
色(HDR)
Definition GxColor.h:241
4×4行列(行優先)
Definition GxMatrix.h:607
2次元ベクトル
Definition GxVector.h:34
static const GxVector2 ONE
(1, 1)
Definition GxVector.h:47
static const GxVector2 ZERO
(0, 0)
Definition GxVector.h:45
3次元ベクトル
Definition GxVector.h:245
4次元ベクトル
Definition GxVector.h:582
32bitブーリアン
Definition GxDefine.h:173