コード例 #1
0
ファイル: MMDAccessory.cs プロジェクト: himapo/ccm
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="vertices">頂点データ</param>
 /// <param name="parts">パーツ情報</param>
 public MMDAccessory(MMDVertexNmTxVc[] vertices, IList<MMDAccessoryPart> parts)
 {
     this.vertexBuffer = new VertexBuffer(parts[0].indices.GraphicsDevice, typeof(VertexPositionNormalTextureColor), vertices.Length, BufferUsage.WriteOnly);
     VertexPositionNormalTextureColor[] gpuVertices = new VertexPositionNormalTextureColor[vertices.Length];
     //初期値代入
     for (int i = 0; i < vertices.Length; i++)
     {
         gpuVertices[i].Position = vertices[i].Position;
         gpuVertices[i].Normal = vertices[i].Normal;
         gpuVertices[i].Color = new Color(vertices[i].VertexColor);
         gpuVertices[i].TextureCoordinate = vertices[i].TextureCoordinate;
     }
     // put the vertices into our vertex buffer
     vertexBuffer.SetData(gpuVertices, 0, vertices.Length);
     m_parts = new ReadOnlyCollection<MMDAccessoryPart>(parts);
 }
コード例 #2
0
ファイル: MMDGPUModelPart.cs プロジェクト: himapo/ccm
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="triangleCount">三角形の個数</param>
 /// <param name="vertices">頂点配列</param>
 /// <param name="vertMap">モデルの頂点とMMDの頂点対応</param>
 /// <param name="indexBuffer">インデックスバッファ</param>
 public MMDGPUModelPartPNmTxVc(int triangleCount, MMDVertexNmTxVc[] vertices, Dictionary<long, int[]> vertMap, IndexBuffer indexBuffer)
     : base(triangleCount, vertices.Length, vertMap, indexBuffer)
 {
     this.vertices = vertices;
     //GPUリソース作成
     gpuVertices = new VertexPositionNormalTextureColor[vertices.Length];
     vertexBuffer = new WritableVertexBuffer(indexBuffer.GraphicsDevice, vertices.Length * 4, typeof(VertexPositionNormalTextureColor));
     //初期値代入
     for (int i = 0; i < vertices.Length; i++)
     {
         gpuVertices[i].Position = vertices[i].Position;
         gpuVertices[i].Normal = vertices[i].Normal;
         gpuVertices[i].Color = new Color(vertices[i].VertexColor);
         gpuVertices[i].TextureCoordinate = vertices[i].TextureCoordinate;
     }
     // put the vertices into our vertex buffer
     vertexOffset = vertexBuffer.SetData(gpuVertices);
 }
コード例 #3
0
ファイル: MMDCPUModelPart.cs プロジェクト: himapo/ccm
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="triangleCount">三角形の個数</param>
 /// <param name="vertices">頂点配列</param>
 /// <param name="indexBuffer">インデックスバッファ</param>
 public MMDCPUModelPartPNmTxVc(int triangleCount, MMDVertexNmTxVc[] vertices, int[] vertMap, IndexBuffer indexBuffer)
     : base(triangleCount, vertices.Length, vertMap, indexBuffer)
 {
     this.vertices = vertices;
     //GPUリソース作成
     gpuVertices = new VertexPositionNormalTextureColor[vertices.Length];
     vertexBuffer = new DynamicVertexBuffer(indexBuffer.GraphicsDevice, typeof(VertexPositionNormalTextureColor), vertices.Length, BufferUsage.WriteOnly);
     //初期値代入
     for (int i = 0; i < vertices.Length; i++)
     {
         gpuVertices[i].Position = vertices[i].Position;
         gpuVertices[i].Normal = vertices[i].Normal;
         gpuVertices[i].Color = new Color(vertices[i].VertexColor);
         gpuVertices[i].TextureCoordinate = vertices[i].TextureCoordinate;
     }
     // put the vertices into our vertex buffer
     vertexBuffer.SetData(gpuVertices, 0, vertexCount, SetDataOptions.Discard);
 }