0

我创建了一个 XNA 游戏背景作为模型,但里面包含更多模型。例如:“地面包含一个球”。现在,我想做的是进入地面并取回球并调整它的大小。

是否有可能这样做或者我需要分别导入地面和球然后调整它的大小(我希望这是最后一个选项)?

4

1 回答 1

1

我认为你的意思是你想ModelMesh在模型中缩放一个特定的。这可以使用一个Matrix数组来完成,该数组将包含特定于各个网格的变换。像这样的东西:

//In the class for the background, or the game class if there isn't one
Matrix[] specificTransforms;

//Initialize the array however you want, and assign the specific matrix for the ball to its corresponding index

//Loop through the meshes like usual but add this below your code that multiplies the transform matrices:
if (specificTransforms[(put your iterator variable here)] != null)
{
    (put your BasicEffect here).World *= specificTransforms[put your iterator variable here];
}

这会将网格的世界矩阵与您要应用于球的特定变换相结合。

这不是最好的方法,如果你发布你正在使用的代码,给你一个例子会更容易。除非你这样做,否则不能保证这会奏效。

于 2012-04-21T06:35:27.733 回答