0

I have tried making a DrawModel method using foreach loops:

void DrawModel(Model model, Vector3 modelPosition)
    {
        foreach (ModelMesh mesh in model.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.LightingEnabled = true;
                effect.EnableDefaultLighting();
                effect.PreferPerPixelLighting = true;

                effect.World = Matrix.CreateTranslation(modelPosition);
                effect.Projection = cameraProjectionMatrix;
                effect.View = cameraViewMatrix;
            }
            mesh.Draw();
        }

    }

any ideas on what I am missing?

daniel
  • 26
  • 4
  • That looks pretty close, was that copied from a sample? What exactly isn't working? Have you tried debugging it? – BradleyDotNET Sep 22 '14 at 20:50
  • I did and when I debugged it came with an error about "null exception" or something like that, and when I researched about foreach loops everything pretty much said that foreach loops had to exactly right or they wouldn't work. Other than that no I didn't really debug that much because I had other more important projects :( – daniel Nov 16 '14 at 01:15
  • Make sure to read http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it about that exception – BradleyDotNET Nov 16 '14 at 04:51

0 Answers0