public void AddTexcoordStreamComponent(H1VertexStreamComponent texcordStreamComponent) { if (texcordStreamComponent.Type != H1VertexStreamSematicType.Texcoord) { throw new ArgumentException("invalid argument for TexcoordStreamComponent, please check it!"); } m_TexcoordStreamComponents.Add(texcordStreamComponent); }
public new void GenerateVertexDeclaration() { // add vertex streams String baseSemanticName = "ATTRIBUTE"; Int32 semanticIndex = 0; // 1. position stream component if (m_PositionStreamComponent != null) { H1VertexStream positionVertexStream = new H1VertexStream(m_PositionStreamComponent.Name, baseSemanticName, semanticIndex, m_PositionStreamComponent.ElementType, m_PositionStreamComponent.Stride, m_PositionStreamComponent.Offset, m_ShaderData.PositionBuffer); AddVertexStream(positionVertexStream); semanticIndex++; } // 2. tangentZ stream component if (m_TangentZStreamComponent != null) { H1VertexStream tangentZVertexStream = new H1VertexStream(m_TangentZStreamComponent.Name, baseSemanticName, semanticIndex, m_TangentZStreamComponent.ElementType, m_TangentZStreamComponent.Stride, m_TangentZStreamComponent.Offset, m_ShaderData.TangentZBuffer); AddVertexStream(tangentZVertexStream); semanticIndex++; } // 3. tangentX stream component if (m_TangentXStreamComponent != null) { H1VertexStream tangentXVertexStream = new H1VertexStream(m_TangentXStreamComponent.Name, baseSemanticName, semanticIndex, m_TangentXStreamComponent.ElementType, m_TangentXStreamComponent.Stride, m_TangentXStreamComponent.Offset, m_ShaderData.TangentXBuffer); AddVertexStream(tangentXVertexStream); semanticIndex++; } // 4. bone indices if (m_BoneIndicesStreamComponent != null) { H1VertexStream boneIndicesStream = new H1VertexStream(m_BoneIndicesStreamComponent.Name, baseSemanticName, semanticIndex, m_BoneIndicesStreamComponent.ElementType, m_BoneIndicesStreamComponent.Stride, m_BoneIndicesStreamComponent.Offset, m_ShaderData.BoneIndices); AddVertexStream(boneIndicesStream); semanticIndex++; } // 5. bone weights if (m_BoneWeightsStreamComponent != null) { H1VertexStream boneWeightsStream = new H1VertexStream(m_BoneWeightsStreamComponent.Name, baseSemanticName, semanticIndex, m_BoneWeightsStreamComponent.ElementType, m_BoneWeightsStreamComponent.Stride, m_BoneWeightsStreamComponent.Offset, m_ShaderData.BoneWeights); AddVertexStream(boneWeightsStream); semanticIndex++; } // 6. texcoords stream component m_TexCoord2DStreamComponentNum = 0; m_TexCoord3DStreamComponentNum = 0; for (int i = 0; i < m_TexcoordStreamComponents.Count; ++i) { H1VertexStreamComponent component = m_TexcoordStreamComponents[i]; String name = component.Name; String typeName; switch (component.ElementType) { case H1VertexElementType.Float2: typeName = "2D"; m_TexCoord2DStreamComponentNum++; break; case H1VertexElementType.Float3: typeName = "3D"; m_TexCoord3DStreamComponentNum++; break; default: typeName = ""; break; } name += typeName; String number = i.ToString(); name += number; // final semantic name // add texcoord H1VertexStream stream = new H1VertexStream(name, baseSemanticName, semanticIndex, component.ElementType, component.Stride, component.Offset, m_ShaderData.TexcoordBuffers[i]); AddVertexStream(stream); semanticIndex++; } // 7. color if (m_ColorStreamComponent != null) { H1VertexStream colorStream = new H1VertexStream(m_ColorStreamComponent.Name, baseSemanticName, semanticIndex, m_ColorStreamComponent.ElementType, m_ColorStreamComponent.Stride, m_ColorStreamComponent.Offset, m_ShaderData.ColorBuffer); AddVertexStream(colorStream); semanticIndex++; } // finally generate vertex declaration if (!base.GenerateVertexDeclaration()) { throw new Exception("failed to create vertex declaration please check!"); } }
public new void GenerateVertexDeclaration() { // add vertex streams String baseSemanticName = "ATTRIBUTE"; int semanticIndex = 0; // 1. position stream component if (m_PositionStreamComponent != null) { H1VertexStream positionVertexStream = new H1VertexStream(m_PositionStreamComponent.Name, baseSemanticName, semanticIndex, m_PositionStreamComponent.ElementType, m_PositionStreamComponent.Stride, m_PositionStreamComponent.Offset, m_PositionVertexBuffer); AddVertexStream(positionVertexStream); semanticIndex++; } // 2. normal stream component if (m_NormalStreamComponent != null) { H1VertexStream normalVertexStream = new H1VertexStream(m_NormalStreamComponent.Name, baseSemanticName, semanticIndex, m_NormalStreamComponent.ElementType, m_NormalStreamComponent.Stride, m_NormalStreamComponent.Offset, m_NormalVertexBuffer); AddVertexStream(normalVertexStream); semanticIndex++; } // 3. texture coordinate stream components m_TexCoord2DStreamComponentNum = 0; m_TexCoord3DStreamComponentNum = 0; for (int i = 0; i < m_TexcoordStreamComponents.Count; ++i) { H1VertexStreamComponent component = m_TexcoordStreamComponents[i]; String name = component.Name; String typeName; switch (component.ElementType) { case H1VertexElementType.Float2: typeName = "2D"; m_TexCoord2DStreamComponentNum++; break; case H1VertexElementType.Float3: typeName = "3D"; m_TexCoord3DStreamComponentNum++; break; default: typeName = ""; break; } name += typeName; String number = i.ToString(); name += number; // final semantic name // add texcoord H1VertexStream stream = new H1VertexStream(name, baseSemanticName, semanticIndex, component.ElementType, component.Stride, component.Offset, m_TexcoordVertexBuffers[i]); AddVertexStream(stream); semanticIndex++; } // 4. color stream component if (m_ColorStreamComponent != null) { // @TODO - need to fix, temporary set as '4' semanticIndex = 4; H1VertexStream colorVertexStream = new H1VertexStream(m_ColorStreamComponent.Name, baseSemanticName, semanticIndex, m_ColorStreamComponent.ElementType, m_ColorStreamComponent.Stride, m_ColorStreamComponent.Offset, m_ColorVertexBuffer); AddVertexStream(colorVertexStream); } // finally generate vertex declaration if (!base.GenerateVertexDeclaration()) { throw new Exception("failed to create vertex declaration please check!"); } }