XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

problems getting models to display textures

Last post 10/04/2009 19:57 by Dustyargh. 2 replies.
  • 29/03/2009 22:20

    problems getting models to display textures

    I am trying to get some assets to display correctly in my game, but the best i can get is a gray box, the texture file is in the content directory but i have not added a reference in the content pipeline, is there anything wrong with my draw method?



            private void DrawModel()
            {
                Matrix worldMatrix = Matrix.CreateScale(0.01f,0.01f, 0.01f);

                Matrix[] Transforms = new Matrix[shipModel.Bones.Count];
                shipModel.CopyAbsoluteBoneTransformsTo(Transforms);
                foreach (ModelMesh mesh in shipModel.Meshes)
                {
                    foreach (Effect currentEffect in mesh.Effects)
                    {
                        currentEffect.CurrentTechnique = currentEffect.Techniques["Textured];
                        currentEffect.Parameters["xTexture"].SetValue(logo);   
                        currentEffect.Parameters["xWorld"].SetValue(Transforms[mesh.ParentBone.Index] * worldMatrix);
                        currentEffect.Parameters["xView"].SetValue(viewMatrix);
                        currentEffect.Parameters["xProjection"].SetValue(projectionMatrix);
                        currentEffect.Parameters["xEnableLighting"].SetValue(true);
                        currentEffect.Parameters["xLightDirection"].SetValue(lightDirection);
                        currentEffect.Parameters["xAmbient"].SetValue(0.5f);
                    }
                    mesh.Draw();
                }
            }

  • 30/03/2009 21:29 In reply to

    Re: problems getting models to display textures

    have you resollved this?  if not...

    can we see you effect (.fx) file, as well as how logo is created?  you most likely need to add the texture file to your content project, unless you're loading them on the fly.

    Coming soon! Zulu Hour.
  • 10/04/2009 19:57 In reply to

    Re: problems getting models to display textures

    *** sorry thought i had already replied to this, must have misclicked the post button, yeah it turned out that i was refering to a local variable for the texture rather than the global which i had defined earlier, schoolboy error :(
Page 1 of 1 (3 items) Previous Next