0

我尝试将模型加载到 XNA。此模型已加载,但纹理加载不正确。图片:

在此处输入图像描述

两堵墙是正确的,但第三堵是条纹的,我现在不知道为什么。在 3dsMax 中,所有的墙都是核心的(在编辑模式和渲染中)这是我在 Draw() 中的函数:

Matrix[] transforms = new Matrix[capitol.Bones.Count];
capitol.CopyAbsoluteBoneTransformsTo(transforms);

foreach (ModelMesh mesh in capitol.Meshes)
{
     foreach (BasicEffect effect in mesh.Effects)
     {
          effect.Alpha = 1.0f;
          effect.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f);
          effect.SpecularColor = new Vector3(0.75f, 0.75f, 0.75f);
          effect.SpecularPower = 5.0f;
          effect.AmbientLightColor = new Vector3(0.5f, 0.5f, 0.5f);

          effect.DirectionalLight0.Enabled = true;
          effect.DirectionalLight0.DiffuseColor = Vector3.One;
          effect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(1.0f, -1.0f, -1.0f));
          effect.DirectionalLight0.SpecularColor = Vector3.One;

          effect.DirectionalLight1.Enabled = true;
          effect.DirectionalLight1.DiffuseColor = new Vector3(0.5f, 0.5f, 0.5f);
          effect.DirectionalLight1.Direction = Vector3.Normalize(new Vector3(-1.0f, -1.0f, 1.0f));
          effect.DirectionalLight1.SpecularColor = new Vector3(0.5f, 0.5f, 0.5f);

          effect.LightingEnabled = true;

          //effect.EnableDefaultLighting();
          effect.World = transforms[mesh.ParentBone.Index] 
                   * Matrix.CreateRotationY(90f)
                   * Matrix.CreateTranslation(modelPosition);

          effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
          effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(20.0f), aspectRatio, 1.0f, 50.0f);
    }
    // Draw the mesh, using the effects set above.
    mesh.Draw();
}

负载型号:

brick = Content.Load<Model>("models\\brick_model");
4

0 回答 0