1

VertexPositionTexture と BasicEffect を使用して、画面の一人称視点から Z 軸上で特定の距離だけ伸びる traingleStrip を描画しています。ループで、開始ベクトルと終了ベクトルをこのコードに渡して、頂点を作成します。

    public VertexPositionTexture[] vertices = new VertexPositionTexture[4];
    private int xPos = 4;

    public waypointLineSegment(Vector3 startPoint, Vector3 endPoint)
    {
        this.texture = texture1;
        vertices[0].Position = new Vector3(endPoint.X - xPos, endPoint.Y, endPoint.Z); //Upper Left Point
        vertices[0].TextureCoordinate = new Vector2(0, 1);
        vertices[1].Position = new Vector3(startPoint.X - xPos, endPoint.Y, startPoint.Z); //Lower Left point
        vertices[1].TextureCoordinate = new Vector2(0, 0);
        vertices[2].Position = new Vector3(endPoint.X + xPos, endPoint.Y, endPoint.Z); //Upper Right Point
        vertices[2].TextureCoordinate = new Vector2(1, 1);
        vertices[3].Position = new Vector3(startPoint.X + xPos, endPoint.Y, startPoint.Z); //Lower Right Point
        vertices[3].TextureCoordinate = new Vector2(1, 0);
    }

私はこのように初期化します:

protected override void Initialize()
{
    graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
    basicEffect = new BasicEffect(graphics.GraphicsDevice);
    base.Initialize();
}

この方法で平面をレンダリングします。

Vector3 transformedReference = Vector3.Transform(new Vector3(0, 0, 10), aRotationInt);
Vector3 cameraLookat = firstPersonVector + transformedReference;
view = Matrix.CreateLookAt(firstPersonVector, cameraLookat, Vector3.Up);

basicEffect.View = view;
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
     pass.Apply();
     graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, allVertices, 0, 2);
}

これはうまくいきます。しかし、ビューに回転を適用すると、ストリップが時々消えます。その後、1 度の多かれ少なかれ回転が適用されて再表示されます。

パターンが見つかりません。37 度または 315 度などで発生する可能性があります。GraphicsDevice RasterizerState を CullMode.None に設定しました。誰でも助けてくれますか?:

4

0 に答える 0