Guest User

HW skinning vertex format

a guest
Jun 4th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.86 KB | None | 0 0
  1. Index: include/CVertexBuffer.h
  2. ===================================================================
  3. --- include/CVertexBuffer.h (revision 4533)
  4. +++ include/CVertexBuffer.h (working copy)
  5. @@ -169,6 +169,8 @@
  6.                 return video::EVT_2TCOORDS;    
  7.             case sizeof(video::S3DVertexTangents):
  8.                 return video::EVT_TANGENTS;
  9. +           case sizeof(video::S3DVertexBlended):
  10. +               return video::EVT_BLENDED;
  11.             default:
  12.                 return (video::E_VERTEX_TYPE)-1;
  13.             }
  14. @@ -187,6 +189,7 @@
  15.     typedef CVertexBuffer<video::S3DVertex> SVertexBuffer;
  16.     typedef CVertexBuffer<video::S3DVertex2TCoords> SVertexBufferLightMap;
  17.     typedef CVertexBuffer<video::S3DVertexTangents> SVertexBufferTangents;
  18. +   typedef CVertexBuffer<video::S3DVertexBlended> SVertexBufferBlended;
  19.  }
  20.  }
  21.  
  22. Index: include/S3DVertex.h
  23. ===================================================================
  24. --- include/S3DVertex.h (revision 4533)
  25. +++ include/S3DVertex.h (working copy)
  26. @@ -26,7 +26,11 @@
  27.  
  28.     //! Vertex with a tangent and binormal vector, video::S3DVertexTangents.
  29.     /** Usually used for tangent space normal mapping. */
  30. -   EVT_TANGENTS
  31. +   EVT_TANGENTS,
  32. +
  33. +   //! Vertex with a blend indices and wieghts, video::S3DVertexBlend.
  34. +   /** Usually used for tangent space normal mapping. */
  35. +   EVT_BLENDED
  36.  };
  37.  
  38.  //! Array holding the built in vertex type names
  39. @@ -35,6 +39,7 @@
  40.     "standard",
  41.     "2tcoords",
  42.     "tangents",
  43. +   "blended",
  44.     0
  45.  };
  46.  
  47. @@ -251,8 +256,71 @@
  48.     }
  49.  };
  50.  
  51. +//! Vertex with blend indices and weights along with a tangent and binormal vector.
  52. +/** Usually used for tangent space normal mapping. */
  53. +struct S3DVertexBlended : public S3DVertexTangents
  54. +{
  55. +   //! default constructor
  56. +   S3DVertexBlended() : S3DVertexTangents() { }
  57.  
  58. +   //! constructor
  59. +   S3DVertexBlended(const core::vector3df& pos,
  60. +       const core::vector3df& normal, SColor c,
  61. +       const core::vector2df& tcoords,
  62. +       const core::vector3df& tangent,
  63. +       const core::vector3df& binormal,
  64. +       const float blendIndices[4],
  65. +       const float blendWeights[4],
  66. +       const core::vector2df& tcoords2)
  67. +       : S3DVertexTangents(pos, normal, c, tcoords, tangent, binormal), TCoords2(tcoords2) {
  68. +           BlendIndices[0] = blendIndices[0];
  69. +           BlendIndices[1] = blendIndices[1];
  70. +           BlendIndices[2] = blendIndices[2];
  71. +           BlendIndices[3] = blendIndices[3];
  72.  
  73. +           BlendWeights[0] = blendWeights[0];
  74. +           BlendWeights[1] = blendWeights[1];
  75. +           BlendWeights[2] = blendWeights[2];
  76. +           BlendWeights[3] = blendWeights[3];
  77. +   }
  78. +
  79. +   //! Blend indices
  80. +   float BlendIndices[4];
  81. +
  82. +   //! Blend weights
  83. +   float BlendWeights[4];
  84. +
  85. +   //! Second set of texture coordinates
  86. +   core::vector2d<f32> TCoords2;
  87. +
  88. +   //! Equality operator
  89. +   bool operator==(const S3DVertexBlended& other) const
  90. +   {
  91. +       return ((static_cast<S3DVertex>(*this)==other) &&
  92. +           (TCoords2 == other.TCoords2));
  93. +   }
  94. +
  95. +   //! Inequality operator
  96. +   bool operator!=(const S3DVertexBlended& other) const
  97. +   {
  98. +       return ((static_cast<S3DVertex>(*this)!=other) ||
  99. +           (TCoords2 != other.TCoords2));
  100. +   }
  101. +
  102. +   bool operator<(const S3DVertexBlended& other) const
  103. +   {
  104. +       return ((static_cast<S3DVertex>(*this) < other) ||
  105. +               ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
  106. +   }
  107. +
  108. +   E_VERTEX_TYPE getType() const
  109. +   {
  110. +       return EVT_BLENDED;
  111. +   }
  112. +};
  113. +
  114. +
  115. +
  116.  inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
  117.  {
  118.     switch (vertexType)
  119. @@ -261,6 +329,8 @@
  120.         return sizeof(video::S3DVertex2TCoords);
  121.     case video::EVT_TANGENTS:
  122.         return sizeof(video::S3DVertexTangents);
  123. +   case video::EVT_BLENDED:
  124. +       return sizeof(video::S3DVertexBlended);
  125.     default:
  126.         return sizeof(video::S3DVertex);
  127.     }
  128. Index: source/Irrlicht/CNullDriver.cpp
  129. ===================================================================
  130. --- source/Irrlicht/CNullDriver.cpp (revision 4533)
  131. +++ source/Irrlicht/CNullDriver.cpp (working copy)
  132. @@ -268,7 +268,19 @@
  133.     VertexDescriptor[2]->addAttribute("inTexCoord0", 2, EVAS_TEXCOORD0, EVAT_FLOAT);
  134.     VertexDescriptor[2]->addAttribute("inTangent", 3, EVAS_TANGENT, EVAT_FLOAT);
  135.     VertexDescriptor[2]->addAttribute("inBinormal", 3, EVAS_BINORMAL, EVAT_FLOAT);
  136. +  
  137. +   addVertexDescriptor("blended");
  138. +   VertexDescriptor[3]->addAttribute("inPosition", 3, EVAS_POSITION, EVAT_FLOAT);
  139. +   VertexDescriptor[3]->addAttribute("inNormal", 3, EVAS_NORMAL, EVAT_FLOAT);
  140. +   VertexDescriptor[3]->addAttribute("inColor", 4, EVAS_COLOR, EVAT_UBYTE);
  141. +   VertexDescriptor[3]->addAttribute("inTexCoord0", 2, EVAS_TEXCOORD0, EVAT_FLOAT);
  142. +   VertexDescriptor[3]->addAttribute("inTangent", 3, EVAS_TANGENT, EVAT_FLOAT);
  143. +   VertexDescriptor[3]->addAttribute("inBinormal", 3, EVAS_BINORMAL, EVAT_FLOAT);
  144. +   VertexDescriptor[3]->addAttribute("inBlendIndices", 4, EVAS_BLEND_INDICES, EVAT_FLOAT);
  145. +   VertexDescriptor[3]->addAttribute("inBlendWeights", 4, EVAS_BLEND_WEIGHTS, EVAT_FLOAT);
  146. +   VertexDescriptor[3]->addAttribute("inTexCoord1", 2, EVAS_TEXCOORD1, EVAT_FLOAT);
  147.  
  148. +
  149.     return true;
  150.  }
Advertisement
Add Comment
Please, Sign In to add comment