コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
最近の更新
未作成ページ
おまかせ表示
ヘルプ
MonoBook
検索
検索
ログイン
個人用ツール
ログイン
ログアウトした編集者のページ
もっと詳しく
投稿記録
トーク
「
MonoGame/クラスライブラリ/VertexPositionColor構造体
」を編集中 (節単位)
ページ
議論
日本語
閲覧
編集
ソースを編集
履歴表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
編集
ソースを編集
履歴表示
全般
リンク元
関連ページの更新状況
特別ページ
ページ情報
警告:
ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。
ログイン
または
アカウントを作成
すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。
スパム攻撃防止用のチェックです。 けっして、ここには、値の入力は
しない
でください!
== 実装例 == この例ではVertexBufferを作らずにDrawUserPrimitivesメソッドで描画している。 VertexBufferを作りDrawPrimitivesメソッドで描画しても同じ結果になる。 どちらも[[頂点バッファ]]だけでの描画なのでどちらが優れているかは知らん。可能であれば[[インデックスバッファ]]を使った描画の方が良いと思うぞ。 BasicEffectのVertexColorEnabledプロパティで色付けを有効にしている。これを設定しないと真っ白になり、設定すると頂点カラー間でグラデーションが掛かる。 <source lang="csharp"> using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace DrawVertex { /// <summary> /// This is the main type for your game. /// </summary> public class Game1 : Game { GraphicsDeviceManager _graphics; VertexPositionColor[] _vertices; Vector3 _cameraPosition = new Vector3(30, 0, 20); BasicEffect _effect; public Game1() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } protected override void Initialize() { // マウスカーソルを表示する this.IsMouseVisible = true; // ウインドウサイズを変更する _graphics.PreferredBackBufferWidth = 800; _graphics.PreferredBackBufferHeight = 600; _graphics.ApplyChanges(); // MonoGame標準搭載の固定シェーダーを生成する _effect = new BasicEffect(_graphics.GraphicsDevice); // 色を有効にする _effect.VertexColorEnabled = true; // 頂点データを作成する _vertices = new VertexPositionColor[6]; _vertices[0] = new VertexPositionColor(new Vector3(-10, -10, 0), Color.Red); _vertices[1] = new VertexPositionColor(new Vector3(-10, +10, 0), Color.Green); _vertices[2] = new VertexPositionColor(new Vector3(+10, -10, 0), Color.Blue); _vertices[3] = new VertexPositionColor(new Vector3(-10, +10, 0), Color.Green); _vertices[4] = new VertexPositionColor(new Vector3(+10, +10, 0), Color.White); _vertices[5] = new VertexPositionColor(new Vector3(+10, -10, 0), Color.Blue); base.Initialize(); } protected override void LoadContent() { } protected override void Update(GameTime gameTime) { // For Mobile devices, this logic will close the Game when the Back button is pressed // Exit() is obsolete on iOS #if !__IOS__ && !__TVOS__ if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); #endif base.Update(gameTime); } protected override void Draw(GameTime gameTime) { _graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // カメラ var cameraLookAtVector = Vector3.Zero; var cameraUpVector = Vector3.UnitZ; _effect.View = Matrix.CreateLookAt(_cameraPosition, cameraLookAtVector, cameraUpVector); float aspectRatio = _graphics.PreferredBackBufferWidth / (float)_graphics.PreferredBackBufferHeight; float fieldOfView = Microsoft.Xna.Framework.MathHelper.PiOver4; float nearClipPlane = 1; float farClipPlane = 200; _effect.Projection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, nearClipPlane, farClipPlane); // 描画 foreach (var pass in _effect.CurrentTechnique.Passes) { pass.Apply(); _graphics.GraphicsDevice.DrawUserPrimitives( PrimitiveType.TriangleList, _vertices, vertexOffset: 0, primitiveCount: _vertices.Length / 3); }; base.Draw(gameTime); } } } </source>
編集内容の要約:
MonoBookへの投稿はすべて、他の投稿者によって編集、変更、除去される場合があります。 自分が書いたものが他の人に容赦なく編集されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください(詳細は
MonoBook:著作権
を参照)。
著作権保護されている作品は、許諾なしに投稿しないでください!
このページを編集するには、下記の確認用の質問に回答してください (
詳細
):
1たす1は?(全角で入力してください)
キャンセル
編集の仕方
(新しいウィンドウで開きます)
本文の横幅制限を有効化/無効化