1
votes

I have made an application in XNA 3.1 in which a model is being loaded in picture box in windows form, which is working just fine: below is the code for Game1 class.
Now I tried to load multiple models in that for that I refered to an application of WinFormControlLoading, here I want to know that to write instead of modelviewcontrol line or where do I call the LoadContent function which calls my model

void LoadModel(string fileName)
{
    Cursor = Cursors.WaitCursor;

    string buildError = contentBuilder.Build();

    if (string.IsNullOrEmpty(buildError))
    {
        // If the build succeeded, use the ContentManager to
        // load the temporary .xnb file that we just created.
       modelViewerControl.Model = contentManager.Load<Model>("Model");
    }
    else
    {
        // If the build failed, display an error message.
        MessageBox.Show(buildError, "Error");
    }

    Cursor = Cursors.Arrow;
}

In this line error occurs

modelViewerControl.Model = contentManager.Load<Model>("Model");

when i changed my Game1 class function of LoadContent to public like

Game1 game;
game.LoadContent = contentManager.Load<Model>("Model");

I get error of

Error 1 'WindowsGame1.Game1.LoadContent()': cannot change access modifiers when overriding 'protected' inherited member 'Microsoft.Xna.Framework.Game.LoadContent()'

How I solve this?
Any help would be appreciated.

1

1 Answers

1
votes

I don't know in which class you are doing this, but this class has to inherit from GameComponent or DrawableGameComponent, in this way you can use the ContentManager like this:

Game.Content.Load<Model>("Model");