0

我现在面临这个问题。设法成功地将 fbx 模型加载到手机 7 上。不幸的是,模型在屏幕上似乎显得过大,并且模型的很大一部分离开了屏幕。我怀疑可以对以下代码进行更改,但由于我没有这方面的经验,我现在知道从哪里开始。请指教。或者,如果我最小化 fbx 模型的分辨率/大小会有所帮助吗?谢谢!

// set up the "camera"
        Vector3 cameraPosition = new Vector3(1, 1, 0);
        Vector3 cameraTarget = Vector3.Zero;
        Vector3 cameraUp = Vector3.UnitY;
        float nearClippingDistance = 0.1f;  // anything closer to cameraPosition than this won't be drawn
        float farClippingDistance = 1000f;  // anything farther from cameraPosition than this won't be drawn
        float fieldOfView = MathHelper.ToRadians(45.0f); // the vertical angle the "camera" can see
        float aspectRatio = (float)graphics.PreferredBackBufferWidth / (float)graphics.PreferredBackBufferHeight;

        world = Matrix.Identity;    // the model's transform; setting it to the identity means it will display at (0,0,0) with no rotation or scaling
        view = Matrix.CreateLookAt(cameraPosition, cameraTarget, cameraUp);     // put the camera at cameraPosition, looking at cameraTarget, with cameraUp as the vector pointing to the "sky"
        projection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, aspectRatio*40, nearClippingDistance, farClippingDistance);  // defines the perspective

        // set up the alternative cull mode so that our model draws properly
        RasterizerState rs = new RasterizerState();
        rs.CullMode = CullMode.CullClockwiseFace;
        GraphicsDevice.RasterizerState = rs;
4

1 回答 1

0

好的。找到了答案。问题在于相机的位置。

只需编辑 Vector 对象中的第三个参数,将其更改为 15。

Vector3 cameraPosition = new Vector3(1, 1, 15);

这是做什么的,它使相机远离物体,本质上使它看起来更小。

问题解决了。

于 2011-11-14T04:27:51.787 回答