protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here // ワールド座標変換行列 Matrix world = Matrix.CreateScale(100.0f) * Matrix.CreateRotationX(MathHelper.ToRadians(90)) * Matrix.CreateTranslation(Vector3.Zero); // ビュー座標変換行列 Matrix view = Matrix.CreateLookAt( new Vector3(0, 0, 400), Vector3.Zero, Vector3.Up); // 射影変換行列 Viewport viewport = graphics.GraphicsDevice.Viewport; float aspectRatio = (float)viewport.Width / (float)viewport.Height; Matrix projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, aspectRatio, 10, 1000); // ワールド、ビュー、射影変換行列の設定 myEffect.Parameters["World"].SetValue(world); myEffect.Parameters["View"].SetValue(view); myEffect.Parameters["Projection"].SetValue(projection); // 描画モードを「Textured」に設定(BasicEffect Shader付属ドキュメント参照) myEffect.Parameters["ShaderIndex"].SetValue(2); myEffect.Parameters["BasicTexture"].SetValue(myTexture); foreach (ModelMesh mesh in myModel.Meshes) { // 頂点バッファデータのコピーを取得する mesh.VertexBuffer.GetData(verData); // テクスチャ座標を書き替える(テスト) verData[0].TextureCoordinate = new Vector2(0.4f, 0.4f); // 書き替えたデータをセットする mesh.VertexBuffer.SetData(verData); // カスタムエフェクトを適用する foreach (ModelMeshPart modelMeshPart in mesh.MeshParts) { modelMeshPart.Effect = myEffect; } // モデルを描画する mesh.Draw(); } base.Draw(gameTime); }