1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_ResShape.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_GFX_RESSHAPE_H_
19 #define NW_GFX_RESSHAPE_H_
20 
21 #include <nw/ut/ut_ResUtil.h>
22 #include <nw/ut/ut_ResDictionary.h>
23 #include <nw/gfx/res/gfx_ResSceneObject.h>
24 #include <nw/gfx/res/gfx_ResVertex.h>
25 #include <nw/math/math_ResTypes.h>
26 #include <nw/gfx/res/gfx_ResTypeInfo.h>
27 #include <nw/ut/ut_ResPrimitive.h>
28 
29 namespace nw {
30 namespace gfx {
31 namespace res {
32 
33 //===================================
34 // ブレンドシェイプクラス
35 //===================================
36 //! @details :private
37 struct ResTargetShapeData
38 {
39     nw::ut::ResTypeInfo typeInfo;
40     nw::ut::ResS32 m_VertexAttributesTableCount;
41     nw::ut::Offset toVertexAttributesTable;
42 };
43 
44 //! @details :private
45 struct ResBlendShapeData
46 {
47     nw::ut::ResTypeInfo typeInfo;
48     nw::ut::ResS32 m_TargetShapesTableCount;
49     nw::ut::Offset toTargetShapesTable;
50     nw::ut::ResS32 m_UsageTableTableCount;
51     nw::ut::Offset toUsageTableTable;
52 };
53 
54 //--------------------------------------------------------------------------
55 //! @brief ブレンドシェイプのターゲットシェイプを管理する為バイナリリソースクラスです。
56 //! @details :private
57 //---------------------------------------------------------------------------
58 class ResTargetShape : public nw::ut::ResCommon<ResTargetShapeData>
59 {
60 public:
61     NW_RES_CTOR( ResTargetShape )
62 
63     NW_RES_FIELD_CLASS_LIST_DECL( ResVertexAttribute, VertexAttributes )
64 };
65 
66 //--------------------------------------------------------------------------
67 //! @brief  ターゲットシェイプを合成してシェイプをブレンドするための情報を表すバイナリリソースクラスです。
68 //! @details :private
69 //---------------------------------------------------------------------------
70 class ResBlendShape : public nw::ut::ResCommon<ResBlendShapeData>
71 {
72 public:
73     NW_RES_CTOR( ResBlendShape )
74 
75     NW_RES_FIELD_CLASS_LIST_DECL( ResTargetShape, TargetShapes )
76     NW_RES_FIELD_PRIMITIVE_LIST_DECL( u32, UsageTable )
77 };
78 
79 //===================================
80 //  プリミティブクラス
81 //===================================
82 //! @details :private
83 struct ResPrimitiveData
84 {
85     nw::ut::ResS32 m_IndexStreamsTableCount;
86     nw::ut::Offset toIndexStreamsTable;
87     nw::ut::ResS32 m_BufferObjectsTableCount;
88     nw::ut::Offset toBufferObjectsTable;
89     nw::ut::ResU32 m_Flags;
90     nw::os::IAllocator* m_CommandAllocator;
91 };
92 
93 //--------------------------------------------------------------------------
94 //! @brief シェイプを構成する一つのプリミティブを表すバイナリリソースクラスです。
95 //---------------------------------------------------------------------------
96 class ResPrimitive : public nw::ut::ResCommon< ResPrimitiveData >
97 {
98 public:
99     enum Flag
100     {
101         FLAG_COMMAND_HAS_BEEN_SETUP    = 0x1 << 0 //!< 既にコマンドキャッシュがセットアップ済みかどうかのフラグです。
102     };
103 
104     NW_RES_CTOR( ResPrimitive )
105 
106     //---------------------------------------------------------------------------
107     //! @fn           void SetBufferObjects(int idx, u32 value)
108     //! @brief        バッファオブジェクトのリストに要素を設定します。
109     //---------------------------------------------------------------------------
110     //---------------------------------------------------------------------------
111     //! @fn           s32 GetIndexStreamsCount() const
112     //! @brief        頂点インデックスのストリームの要素数を取得します。
113     //---------------------------------------------------------------------------
114     //---------------------------------------------------------------------------
115     //! @fn           ResIndexStream GetIndexStreams(int idx)
116     //! @brief        頂点インデックスのストリームを取得します。
117     //---------------------------------------------------------------------------
118     //---------------------------------------------------------------------------
119     //! @fn           s32 GetBufferObjectsCount() const
120     //! @brief        バッファオブジェクトの要素数を取得します。
121     //---------------------------------------------------------------------------
122     //---------------------------------------------------------------------------
123     //! @fn           u32 GetBufferObjects(int idx) const
124     //! @brief        バッファオブジェクトを取得します。
125     //---------------------------------------------------------------------------
126     NW_RES_FIELD_CLASS_LIST_DECL( ResIndexStream, IndexStreams ) // GetIndexStreams(int idx), GetIndexStreamsCount()
127     NW_RES_FIELD_PRIMITIVE_LIST_DECL( u32, BufferObjects )       // GetBufferObjects(), GetBufferObjects(int idx), GetBufferObjectsCount()
128 
129     //---------------------------------------------------------------------------
130     //! @fn           u32 GetFlags() const
131     //! @brief        フラグの値を取得します。
132     //---------------------------------------------------------------------------
133     //---------------------------------------------------------------------------
134     //! @fn           void SetFlags(u32 value)
135     //! @brief        フラグの値を設定します。
136     //!               設定されなかったフラグは無効になります。
137     //---------------------------------------------------------------------------
138     //---------------------------------------------------------------------------
139     //! @fn           void EnableFlags(u32 value)
140     //! @brief        指定された Flag の値を有効にします。
141     //!               設定されなかったフラグは変更されません。
142     //---------------------------------------------------------------------------
143     //---------------------------------------------------------------------------
144     //! @fn           void DisableFlags(u32 value)
145     //! @brief        指定された Flag の値を無効にします。
146     //!               設定されなかったフラグは変更されません。
147     //---------------------------------------------------------------------------
148     NW_RES_FIELD_FLAGS_DECL( u32, Flags )                   // GetFlags(), SetFlags(), EnableFlags(), DisableFlags()
149 
150     //---------------------------------------------------------------------------
151     //! @brief        リソースの初期化処理をおこないます。
152     //---------------------------------------------------------------------------
153     void    Setup(nw::os::IAllocator* allocator);
154 
155     //---------------------------------------------------------------------------
156     //! @brief        リソースの解放準備をおこないます。
157     //---------------------------------------------------------------------------
158     void    Cleanup();
159 
160     //---------------------------------------------------------------------------
161     //! @details :private
162     //!
163     //! @brief        描画用のコマンドを構築します。
164     //---------------------------------------------------------------------------
165     void    SetupDrawCommand(bool hasGeometryShader);
166 };
167 typedef nw::ut::ResArrayClass<ResPrimitive>::type ResPrimitiveArray;
168 
169 
170 //! @details :private
171 struct ResPrimitiveSetData
172 {
173     nw::ut::ResS32 m_BoneIndexTableTableCount;
174     nw::ut::Offset toBoneIndexTableTable;
175     nw::ut::ResS32 m_SkinningMode;
176     nw::ut::ResS32 m_PrimitivesTableCount;
177     nw::ut::Offset toPrimitivesTable;
178 };
179 
180 //--------------------------------------------------------------------------
181 //! @brief 同一のマトリクス群に影響する複数のプリミティブを表すバイナリリソースクラスです。
182 //---------------------------------------------------------------------------
183 class ResPrimitiveSet : public nw::ut::ResCommon< ResPrimitiveSetData >
184 {
185 public:
186     //! @brief  スキニングモードを表します。
187     enum SkinningModeType
188     {
189         SKINNING_MODE_NONE,     //!< スキニング無しの設定です。
190         SKINNING_MODE_RIGID,    //!< リジッドスキニングの設定です。
191         SKINNING_MODE_SMOOTH    //!< スムーススキニングの設定です。
192     };
193 
194     NW_RES_CTOR( ResPrimitiveSet )
195 
196     //---------------------------------------------------------------------------
197     //! @fn           void SetSkinningMode(s32 value)
198     //! @brief        スキニングのモードを設定します。
199     //---------------------------------------------------------------------------
200     //---------------------------------------------------------------------------
201     //! @fn           void SetBoneIndexTable(int idx, s32 value)
202     //! @brief        ボーンインデックスのテーブルのリストに要素を設定します。
203     //---------------------------------------------------------------------------
204     //---------------------------------------------------------------------------
205     //! @fn           s32 GetSkinningMode() const
206     //! @brief        スキニングのモードを取得します。
207     //---------------------------------------------------------------------------
208     //---------------------------------------------------------------------------
209     //! @fn           s32 GetPrimitivesCount() const
210     //! @brief        プリミティブの要素数を取得します。
211     //---------------------------------------------------------------------------
212     //---------------------------------------------------------------------------
213     //! @fn           ResPrimitive GetPrimitives(int idx)
214     //! @brief        プリミティブを取得します。
215     //---------------------------------------------------------------------------
216     //---------------------------------------------------------------------------
217     //! @fn           s32 GetBoneIndexTableCount() const
218     //! @brief        ボーンインデックスのテーブルの要素数を取得します。
219     //---------------------------------------------------------------------------
220     //---------------------------------------------------------------------------
221     //! @fn           s32 GetBoneIndexTable(int idx) const
222     //! @brief        ボーンインデックスのテーブルを取得します。
223     //---------------------------------------------------------------------------
224     NW_RES_FIELD_PRIMITIVE_LIST_DECL( s32, BoneIndexTable )  // GetBoneIndexTable(), GetBoneIndexTable(int idx), GetBoneIndexTableCount()
225     NW_RES_FIELD_PRIMITIVE_DECL( s32, SkinningMode )         // GetSkinningMode(), SetSkinningMode()
226     NW_RES_FIELD_CLASS_LIST_DECL( ResPrimitive, Primitives ) // GetPrimitives(int idx), GetPrimitivesCount()
227 
228     //---------------------------------------------------------------------------
229     //! @brief        リソースの初期化処理をおこないます。
230     //---------------------------------------------------------------------------
231     void    Setup(nw::os::IAllocator* allocator);
232 
233     //---------------------------------------------------------------------------
234     //! @brief        リソースの解放準備をおこないます。
235     //---------------------------------------------------------------------------
236     void    Cleanup();
237 };
238 typedef nw::ut::ResArrayClass<ResPrimitiveSet>::type  ResPrimitiveSetArray;
239 
240 
241 //===================================
242 //  シェイプクラス
243 //===================================
244 //! @details :private
245 struct ResShapeData : public ResSceneObjectData
246 {
247     nw::ut::ResU32 m_Flags;
248     nw::ut::Offset toBoundingVolume;
249     nw::ut::ResVec3 m_PositionOffset;
250     nw::ut::ResS32 m_PrimitiveSetsTableCount;
251     nw::ut::Offset toPrimitiveSetsTable;
252     u32            m_BaseAddress;
253 };
254 
255 //--------------------------------------------------------------------------
256 //! @brief 頂点によって構成される形状を表すバイナリリソースクラスです。
257 //---------------------------------------------------------------------------
258 class ResShape : public ResSceneObject
259 {
260 public:
261     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResShape) };
262     enum { SIGNATURE = NW_RES_SIGNATURE32('SHOB') };
263 
264     enum Flag
265     {
266         FLAG_HAS_BEEN_SETUP      = 0x1 << 0  //!< 既にセットアップ済みであることを示すフラグ
267     };
268 
NW_RES_CTOR_INHERIT(ResShape,ResSceneObject)269     NW_RES_CTOR_INHERIT( ResShape, ResSceneObject )
270 
271     //---------------------------------------------------------------------------
272     //! @fn           u32 GetFlags() const
273     //! @brief        フラグの値を取得します。
274     //---------------------------------------------------------------------------
275     //---------------------------------------------------------------------------
276     //! @fn           void SetFlags(u32 value)
277     //! @brief        フラグの値を設定します。
278     //!               設定されなかったフラグは無効になります。
279     //---------------------------------------------------------------------------
280     //---------------------------------------------------------------------------
281     //! @fn           void EnableFlags(u32 value)
282     //! @brief        指定された Flag の値を有効にします。
283     //!               設定されなかったフラグは変更されません。
284     //---------------------------------------------------------------------------
285     //---------------------------------------------------------------------------
286     //! @fn           void DisableFlags(u32 value)
287     //! @brief        指定された Flag の値を無効にします。
288     //!               設定されなかったフラグは変更されません。
289     //---------------------------------------------------------------------------
290     NW_RES_FIELD_FLAGS_DECL( u32, Flags )               // GetFlags(), SetFlags(), EnableFlags(), DisableFlags()
291 
292     //---------------------------------------------------------------------------
293     //! @fn           nw::ut::ResBoundingVolume GetBoundingVolume()
294     //! @brief        指向性境界ボックスを取得します。
295     //---------------------------------------------------------------------------
296     NW_RES_FIELD_CLASS_DECL( nw::ut::ResBoundingVolume, BoundingVolume) // GetBoundingVolume()
297 
298     //---------------------------------------------------------------------------
299     //! @fn           nw::ut::ResOrientedBoundingBox GetOrientedBoundingBox()
300     //! @brief        指向性境界ボックスを取得します。
301     //---------------------------------------------------------------------------
302     nw::ut::ResOrientedBoundingBox GetOrientedBoundingBox()
303     {
304         nw::ut::ResOrientedBoundingBox resOBB( ref().toBoundingVolume.to_ptr() );
305 
306         NW_ASSERT( resOBB.IsValid() || (resOBB.GetTypeInfo() == nw::ut::ResOrientedBoundingBox::TYPE_INFO) );
307         return resOBB;
308     }
309 
GetOrientedBoundingBox()310     const nw::ut::ResOrientedBoundingBox GetOrientedBoundingBox() const
311     {
312         const nw::ut::ResOrientedBoundingBox resOBB( ref().toBoundingVolume.to_ptr() );
313 
314         NW_ASSERT( resOBB.IsValid() || (resOBB.GetTypeInfo() == nw::ut::ResOrientedBoundingBox::TYPE_INFO) );
315         return resOBB;
316     }
317 
318     //---------------------------------------------------------------------------
319     //! @fn           nw::ut::ResOrientedBoundingBoxData & GetOrientedBoundingBoxData()
320     //! @brief        指向性境界ボックスを取得します。
321     //---------------------------------------------------------------------------
GetOrientedBoundingBoxData()322     nw::ut::ResOrientedBoundingBoxData& GetOrientedBoundingBoxData()
323     {
324         return this->GetOrientedBoundingBox().ref();
325     }
326 
GetOrientedBoundingBoxData()327     const nw::ut::ResOrientedBoundingBoxData& GetOrientedBoundingBoxData() const
328     {
329         return this->GetOrientedBoundingBox().ref();
330     }
331 
332     //---------------------------------------------------------------------------
333     //! @fn           const nw::math::VEC3 & GetPositionOffset() const
334     //! @brief        座標情報に加算するオフセット値を取得します。
335     //---------------------------------------------------------------------------
336     //---------------------------------------------------------------------------
337     //! @fn           void SetPositionOffset(f32 x, f32 y, f32 z)
338     //! @brief        座標情報に加算するオフセット値を設定します。
339     //---------------------------------------------------------------------------
NW_RES_FIELD_VECTOR3_DECL(nw::math::VEC3,PositionOffset)340     NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, PositionOffset )     // GetPositionOffset()
341 
342     //---------------------------------------------------------------------------
343     //! @fn           s32 GetPrimitiveSetsCount() const
344     //! @brief        プリミティブの集合の要素数を取得します。
345     //---------------------------------------------------------------------------
346     //---------------------------------------------------------------------------
347     //! @fn           ResPrimitiveSet GetPrimitiveSets(int idx)
348     //! @brief        プリミティブの集合を取得します。
349     //---------------------------------------------------------------------------
350     NW_RES_FIELD_CLASS_LIST_DECL( ResPrimitiveSet, PrimitiveSets ) // GetPrimitiveSets(int idx), GetPrimitiveSetsCount()
351 
352     //--------------------------------------------------------------------------
353     //! @brief        ローカルな中心位置を取得します。
354     //!
355     //! @return       ローカルな中心位置の座標です。
356     //---------------------------------------------------------------------------
357     const nw::math::VEC3& GetCenterPosition() const { return this->GetOrientedBoundingBox().GetCenterPosition(); }
358 
359     //--------------------------------------------------------------------------
360     //! @brief        ローカルな中心位置を設定します。
361     //!
362     //! @param[in]    x       中心位置の x 座標です。
363     //! @param[in]    y       中心位置の y 座標です。
364     //! @param[in]    z       中心位置の z 座標です。
365     //---------------------------------------------------------------------------
SetCenterPosition(f32 x,f32 y,f32 z)366     void SetCenterPosition( f32 x, f32 y, f32 z ) { return this->GetOrientedBoundingBox().SetCenterPosition(x, y, z); }
367 
368     //--------------------------------------------------------------------------
369     //! @brief        ローカルな中心位置を設定します。
370     //!
371     //! @param[in]    value   中心位置の座標です。
372     //---------------------------------------------------------------------------
SetCenterPosition(const nw::math::VEC3 & value)373     void SetCenterPosition(const nw::math::VEC3& value) { return this->GetOrientedBoundingBox().SetCenterPosition(value); }
374 
375     //! @brief リソースの初期化をおこないます。
376     Result Setup(nw::os::IAllocator* allocator);
377 
378     //! @brief リソースの後始末をおこないます。
379     void   Cleanup();
380 };
381 typedef nw::ut::ResArrayClass<ResShape>::type  ResShapeArray;
382 
383 
384 //! @details :private
385 struct ResSeparateDataShapeData : public ResShapeData
386 {
387     nw::ut::ResS32 m_VertexAttributesTableCount;
388     nw::ut::Offset toVertexAttributesTable;
389     nw::ut::Offset toBlendShape;
390 };
391 
392 
393 //--------------------------------------------------------------------------
394 //! @brief 複数の属性を組み合わせて形状を現すバイナリリソースクラスです。
395 //---------------------------------------------------------------------------
396 class ResSeparateDataShape : public ResShape
397 {
398 public:
399     enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResSeparateDataShape) };
400     enum { SIGNATURE = NW_RES_SIGNATURE32('SPSH') };
401 
402     NW_RES_CTOR_INHERIT( ResSeparateDataShape, ResShape )
403 
404     //---------------------------------------------------------------------------
405     //! @fn           s32 GetVertexAttributesCount() const
406     //! @brief        頂点属性の要素数を取得します。
407     //---------------------------------------------------------------------------
408     //---------------------------------------------------------------------------
409     //! @fn           ResVertexAttribute GetVertexAttributes(int idx)
410     //! @brief        頂点属性を取得します。
411     //---------------------------------------------------------------------------
412     //---------------------------------------------------------------------------
413     //! @fn           ResBlendShape GetBlendShape()
414     //! @brief        ブレンドシェイプの設定を取得します。
415     //---------------------------------------------------------------------------
416     NW_RES_FIELD_CLASS_LIST_DECL( ResVertexAttribute, VertexAttributes ) // GetVertexAttributes(int idx), GetVertexAttributesCount()
417     NW_RES_FIELD_CLASS_DECL( ResBlendShape, BlendShape )     // GetBlendShape()
418 
419     // @brief 頂点数を取得します。
420     u32 GetVertexCount();
421 };
422 
423 } // namespace res
424 
425 namespace internal {
426 
427 //--------------------------------------------------------------------------
428 //! @brief ResInterleavedVertexStream に含まれる実データを持たない内部頂点属性も含めて列挙するイテレータです。
429 //!
430 //! @detail nw::gfx::GatherVertexAttributes 関数で取得します。
431 //---------------------------------------------------------------------------
432 class ResVertexAttributeIterator
433 {
434 public:
435     //---------------------------------------------------------------------------
436     //! @brief        シェイプから、ResVertexAttributeIterator を生成します。
437     //!
438     //! @param[in]    shape   シェイプリソースです。
439     //!
440     //! @return       先頭の頂点属性を指すイテレータです。
441     //---------------------------------------------------------------------------
Begin(ResSeparateDataShape shape)442     static ResVertexAttributeIterator Begin(ResSeparateDataShape shape)
443     {
444         return ResVertexAttributeIterator(shape);
445     }
446 
447     //---------------------------------------------------------------------------
448     //! @brief        コピーコンストラクタです。
449     //!
450     //! @param[in]    value   コピー元の値です。
451     //---------------------------------------------------------------------------
ResVertexAttributeIterator(const ResVertexAttributeIterator & value)452     /* implicit */ ResVertexAttributeIterator(const ResVertexAttributeIterator& value)
453      : m_Shape( value.m_Shape ),
454        m_Interleave( value.m_Interleave ),
455        m_IndexOnShape( value.m_IndexOnShape ),
456        m_IndexOnInterleave( value.m_IndexOnInterleave )
457     {
458     }
459 
460     //---------------------------------------------------------------------------
461     //! @brief        イテレータが有効な値を指しているかどうかを取得します。
462     //!
463     //! @return       有効な値であれば true、そうでなければ false を返します。
464     //---------------------------------------------------------------------------
IsValid()465     bool IsValid() const
466     {
467         return (m_IndexOnShape >= 0);
468     }
469 
470     //---------------------------------------------------------------------------
471     //! @brief        ポインタ参照演算子です。
472     //!
473     //! @return       イテレータの指している頂点属性を返します。
474     //---------------------------------------------------------------------------
475     ResVertexAttribute operator*()
476     {
477         if (m_Interleave.IsValid())
478         {
479             return m_Interleave.GetVertexStreams( m_IndexOnInterleave );
480         }
481         else
482         {
483             return m_Shape.GetVertexAttributes( m_IndexOnShape );
484         }
485     }
486 
487     //---------------------------------------------------------------------------
488     //! @brief        ポインタ参照演算子です。
489     //!
490     //! @return       イテレータの指している頂点属性を返します。
491     //---------------------------------------------------------------------------
492     const ResVertexAttribute operator*() const
493     {
494         if (m_Interleave.IsValid())
495         {
496             return m_Interleave.GetVertexStreams( m_IndexOnInterleave );
497         }
498         else
499         {
500             return m_Shape.GetVertexAttributes( m_IndexOnShape );
501         }
502     }
503 
504 
505     //---------------------------------------------------------------------------
506     //! @brief        前置のインクリメント演算子です。
507     //!
508     //! @return       インクリメント後のイテレータを返します。
509     //---------------------------------------------------------------------------
510     ResVertexAttributeIterator& operator++()
511     {
512         if (m_Interleave.IsValid())
513         {
514             ++m_IndexOnInterleave;
515             if (m_Interleave.GetVertexStreamsCount() > m_IndexOnInterleave)
516             {
517                 return *this;
518             }
519 
520             m_Interleave = ResInterleavedVertexStream(NULL);
521             m_IndexOnInterleave = -1;
522         }
523 
524         ++m_IndexOnShape;
525         if (m_Shape.GetVertexAttributesCount() > m_IndexOnShape)
526         {
527             ResVertexAttribute attribute = m_Shape.GetVertexAttributes(m_IndexOnShape);
528 
529             if (attribute.GetFlags() & ResVertexAttribute::FLAG_INTERLEAVE)
530             {
531                 m_Interleave = ResStaticCast<ResInterleavedVertexStream>( attribute );
532                 m_IndexOnInterleave = 0;
533             }
534         }
535         else
536         {
537             m_IndexOnShape = -1;
538         }
539 
540         return *this;
541     }
542 
543     //---------------------------------------------------------------------------
544     //! @brief        後置のインクリメント演算子です。
545     //!
546     //! @return       インクリメント前のイテレータを返します。
547     //---------------------------------------------------------------------------
548     ResVertexAttributeIterator operator++(int)
549     {
550         ResVertexAttributeIterator copy = *this;
551 
552         this->operator++();
553 
554         return copy;
555     }
556 
557 private:
558     ResSeparateDataShape       m_Shape;
559     ResInterleavedVertexStream m_Interleave;
560     s32                        m_IndexOnShape;
561     s32                        m_IndexOnInterleave;
562 
563     //---------------------------------------------------------------------------
564     //! @brief        コンストラクタです。
565     //!
566     //! @param[in]    shape
567     //---------------------------------------------------------------------------
568 
ResVertexAttributeIterator(ResSeparateDataShape shape)569     explicit ResVertexAttributeIterator(ResSeparateDataShape shape)
570      : m_Shape( shape ),
571        m_Interleave( ResInterleavedVertexStream(NULL) ),
572        m_IndexOnShape( 0 ),
573        m_IndexOnInterleave( -1 )
574     {
575         NW_ASSERT( shape.IsValid() );
576 
577         ResVertexAttribute attribute = shape.GetVertexAttributes(0);
578 
579         if (attribute.GetFlags() & ResVertexAttribute::FLAG_INTERLEAVE)
580         {
581             m_Interleave = ResStaticCast<ResInterleavedVertexStream>( attribute );
582             m_IndexOnInterleave = 0;
583         }
584     }
585 };
586 
587 } // namespace internal
588 
589 } // namespace gfx
590 } // namespace nw
591 
592 #endif // NW_GFX_RESSHAPE_H_
593