我有 XNA 3.1,如何在 xna 3.1 中加载多个模型以从数组或按钮单击或切换任何内容进行渲染?我只需要加载多个 3d 模型进行渲染。
这是链接
我在哪里获得代码,但此代码在 4.0 中
Model[ ] modelArray;
protected override void LoadContent()
{
modelArray = new Model[3];
modelArray[0] = Content.Load<Model>("model1");
modelArray[1] = Content.Load<Model>("model2");
modelArray[2] = Content.Load<Model>("model3");
}
protected override void Draw(GameTime time)
{
GraphicsDevice.Clear(Color.LightBlue);
foreach (Model m in modelArray)
{
foreach (BasicEffect be in m.Effects)
{
be.World = YOURWORLDMATRIX;
be.View = YOURVIEWMATRIX;
be.Projection = YOURPROJECTIONMATRIX;
}
m.Draw();
}
base.Draw(time);
}
此行中发生错误,它们向我显示此错误:
ERROR1:'Microsoft.Xna.Framework.Graphics.Model' does not contain a definition for
'effects' and no extension method 'effects' accepting a first argument of type
'Microsoft.Xna.Framework.Graphics.Model' could be found (are you missing a
using directive or an assembly reference?)
Draw中也有同样的错误:
'Microsoft.Xna.Framework.Graphics.Model' does not contain a definition for 'draw'
and no
extension method 'draw' accepting a first argument of type
'Microsoft.Xna.Framework.Graphics.Model' could be found (are you missing a using
directive or an assembly reference?)
在这些行中
m.Effects
m.Draw();
有什么解决办法吗?