在XNA 4.0中3D点到3D地图的列表

时间:2017-09-02 14:22:27

标签: c# xna

如何根据提供的3D点将3D点列表转换为平滑平面?

基本上,我有这个公式和目标图像see here 我能把它放在XNA上。但是,我看起来像狗屎see here,请给我一些建议。谢谢。 以下是代码的一部分:

private void pointPositionCalculation()
    {
        for (int x = -(nrofPointsX / 2); x < nrofPointsX/2 ; x++) 
        {
            for (int z =-(nrofPointsZ / 2); z < nrofPointsZ/2; z++)
            {
                // the given equation for surface. 
                float y = (float)(0.3f * Math.Sin(3 * Math.Sqrt((x - 5)*(x -5) + (z - 5)*(z-5)) + 0.5f * Math.Cos(x + z)));

                originalSurface.Add(new Vector3(x, y, z));

            }
        }


        //Find the max Y value
        float maxY = originalSurface[0].Y;
        for (int i = 0; i < originalSurface.Count; i++)
        {
            if (originalSurface[i].Y > maxY) maxY = originalSurface[i].Y;
        }
        //Find the min Y value
        float minY = originalSurface[0].Y;
        for (int i = 0; i < originalSurface.Count; i++)
        {
            if (originalSurface[i].Y < minY) minY = originalSurface[i].Y;
        }


        //Change the range of surface
        float oldRange = maxY - minY;
        float newRange = 2.0f; //Defined new Range
        for (int i = 0; i < nrofPointsX*nrofPointsZ; i++)
        {
            float newValueY = (((originalSurface[i].Y - minY) * newRange) / oldRange);
            surface.Add(new Vector3(originalSurface[i].X, newValueY, originalSurface[i].Z));
        }
    }

此外,你能告诉我如何从这些点获得平稳的飞机吗?

0 个答案:

没有答案