ラインリスト
配列を使用VertexPositionColor
して個々のグラフ値を格納し、定義済みのライン リスト (インデックス)GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>
と一緒に使用して正投影で描画することができます。
.gif は、ファイル サイズが原因で 50% のサイズに変更されます。
これらのサンプル (それぞれ 300 値ポイント/ピクセルの 4 つのグラフ) を 60fps で描画しています。

トライアングルストリップ
線の下のグラフを埋める必要がある場合は、代わりに三角形のストリップを描くことができます(グラフの下部に点があります)。

明細リスト コード
上記でレンダリングされた最初のグラフに関連するコードは次のとおりです。
Matrix worldMatrix;
Matrix viewMatrix;
Matrix projectionMatrix;
BasicEffect basicEffect;
VertexPositionColor[] pointList;
short[] lineListIndices;
protected override void Initialize()
{
int n = 300;
//GeneratePoints generates a random graph, implementation irrelevant
pointList = new VertexPositionColor[n];
for (int i = 0; i < n; i++)
pointList[i] = new VertexPositionColor() { Position = new Vector3(i, (float)(Math.Sin((i / 15.0)) * height / 2.0 + height / 2.0 + minY), 0), Color = Color.Blue };
//links the points into a list
lineListIndices = new short[(n * 2) - 2];
for (int i = 0; i < n - 1; i++)
{
lineListIndices[i * 2] = (short)(i);
lineListIndices[(i * 2) + 1] = (short)(i + 1);
}
worldMatrix = Matrix.Identity;
viewMatrix = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up);
projectionMatrix = Matrix.CreateOrthographicOffCenter(0, (float)GraphicsDevice.Viewport.Width, (float)GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f);
basicEffect = new BasicEffect(graphics.GraphicsDevice);
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projectionMatrix;
basicEffect.VertexColorEnabled = true; //important for color
base.Initialize();
}
それを描くには:
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
PrimitiveType.LineList,
pointList,
0,
pointList.Length,
lineListIndices,
0,
pointList.Length - 1
);
}
トライアングル ストリップ グラフの場合、トライアングルストリップを表示するようにコードを変更し、グラフ曲線の各点について、グラフの下部に配置します。