// カスタム頂点フォーマット構造体 public struct VertexPositionNormalTextureSample { public Vector3 Position; public Vector3 Normal; public Vector2 TextureCoordinate; public Short4 PatternNumber; // カスタム頂点フォーマットのサイズを取得する public static int SizeInBytes { get { return System.Runtime.InteropServices.Marshal.SizeOf(typeof(VertexPositionNormalTextureSample)); } } // カスタム頂点構造体のコンストラクタ public VertexPositionNormalTextureSample(Vector3 position, Vector3 normal, Vector2 textureCoordinate, Vector4 patternNumber) { this.Position = position; this.Normal = normal; this.TextureCoordinate = textureCoordinate; this.PatternNumber = new Short4(patternNumber); } public static readonly VertexElement[] VertexElements = { // 頂点座標(position) new VertexElement( 0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0 ), // 法線(normal) new VertexElement( 0, sizeof(float) * 3, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Normal, 0 ), // テクスチャ座標(textureCoordinate) new VertexElement( 0, sizeof(float)*(3 + 3), VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0 ), // パターンテクスチャ番号(patternNumber) new VertexElement( 0, sizeof(float)*(3 + 3 + 2), VertexElementFormat.Short4, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, // パターンテクスチャ番号のセマンティクスはTEXCOORD1 1 // パターンテクスチャ番号のセマンティクスはTEXCOORD1 ) }; }