Trying to Load Model

Dec 28, 2011 at 3:03 PM

Firstly, I'd like to say that I appreciate all the effort that has gone into this engine... it truly is a great effort. 

I'd love to be able to use the QuickStart Engine for a game I'm developing for XBox, but I've run into an issue trying to load custom models.  Here's the error I'm getting:

File contains Microsoft.Xna.Framework.Graphics.Model but trying to load as QuickStart.Graphics.StaticModel

Here are the lines of code used for loading the model:

BaseEntity newEntity2 = new BaseEntity(this.game, new Vector3(1200.0f, 220.0f, 700.0f), Matrix.CreateRotationX(0.0f), 15.0f);           
RenderComponent newRenderComponent2 = new RenderComponent(newEntity2, "Models/test", "Material/SimpleColored");            this.game.SceneManager.AddEntity(newEntity2);

I've tried exporting .fbx and .x files from Blender, but neither has worked.  Any help would be appreciated.

Thanks,
Bob 

Coordinator
Dec 28, 2011 at 3:07 PM

After placing the model into your content project you need to single-click on the asset, then in the properties window set 'Content Processor' to 'QuickStart Static Model Processor'

Dec 28, 2011 at 5:56 PM

Wow... can't believe I overlooked that.  Thanks.  

Dec 28, 2011 at 6:48 PM

Any idea of how to modify one of the effects files to work with a multi-textured model?  Looks as if all the effects files only work with models of one texture accept for Terrain, which cannot be used for my purposes. 

Coordinator
Dec 28, 2011 at 7:49 PM
bobw2829 wrote:

Any idea of how to modify one of the effects files to work with a multi-textured model?  Looks as if all the effects files only work with models of one texture accept for Terrain, which cannot be used for my purposes. 

The StaticModel class uses a vertex type that only stores a single set of texture coordinates. If you want a multi-textured model you'd need to create a new content processor (you could almost copy the static model verbatim), that reads and saves an extra set of texture coordinates (or more if you'd like). You'd also need to create your own shader to accept multiple textures and render each one. Or if you'd like you can simply alter StaticModel to suit your game. The vertex declaration is at the top of StaticModel.cs, and that file is in the Graphics folder in the main project. There is another copy of that structure in StaticModelContent.cs in the Model folder in the QuickStart.ContentPipeline project. And the part that actually reads from the model is in the ProcessNode function in the StaticModelProcessor.cs file. You can see in that method where it refers to the texture coordinate by name.

It is something I've considered working on, but the demand for it has been low, especially compared to other missing features like skinned animation, GUI, or a level editor.

If you have any more questions about it let me know and I'll do what I can, the content processors are one of the few parts of the engine I didn't write, and I'm not as familiar with them as I would like to be but I'll do my best to help.