View Single Post
Old 2nd April 2012, 04:52 PM   #1
Draxxar
Junior Member
Junior member
 
Join Date: Mar 2012
Posts: 1
Default Loading .X file in C# XNA color0 error resolved

Hi,
I found this problem when following the following tutorial (from another site) on using XNA and C# to load .X files (tutorial here: http://www.riemers.net/eng/Tutorials...ries2/tut5.php). The problem is, if you open up AC3D and go to "object library" and "samples"... then open up, say, the "enterprise" model and then export that as a .X file to test in that tutorial you'll get a crash error that says something to the effect of a "color0" error. This happens even if you texture or color the mesh objects.
After looking into it the reason for the crash bug in the above mentioned tutorial is because that tutorial is using custom effects. So if you instead replace the code with a BasicEffect then you can load up pretty much any .X file exported from AC3D without any problems.

Example:
Code:
foreach (ModelMesh mesh in myModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                    effect.View = viewMatrix;//  fpsCam.ViewMatrix;
                    effect.Projection = projectionMatrix;//  fpsCam.ProjectionMatrix;
                    
                }                
                mesh.Draw();
            }
Attached Files
File Type: zip C_sharp_sourcecode.zip (5.3 KB, 328 views)
Draxxar is offline   Reply With Quote