Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I wanted to add a ground so I can know the position of a helicopter in the world. But the ground appeared in a weird way:

http://i.stack.imgur.com/yTSuW.jpg

The ground had the following texture:

http://i.stack.imgur.com/pdpxB.png

EDIT: Sorry, I forgot to post the code:

public class ImportModel
{
    public Vector3 Position { get; set; }
    public Vector3 Rotation { get; set; }
    public Vector3 Scale { get; set; }
    Model Model;
    Matrix[] modeltransforms;
    GraphicsDevice GraphicDevice;
    ContentManager Content;
    BoundingSphere sphere;
    bool boundingimplemented = false;
    public ImportModel(string model, GraphicsDevice gd, ContentManager cm, Vector3 position, Vector3 rot, Vector3 sca)
    {
        GraphicDevice = gd;
        Content = cm;
        Position = position;
        Rotation = rot;
        Scale = sca;
        Model = Content.Load<Model>(model);
        modeltransforms = new Matrix[Model.Bones.Count];
        Model.CopyAbsoluteBoneTransformsTo(modeltransforms);
    }
    public void Draw(Camera camera)
    {
        Matrix baseworld = Matrix.CreateScale(Scale) * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) * Matrix.CreateTranslation(Position);
        foreach (ModelMesh mesh in Model.Meshes)
        {
            Matrix localworld = modeltransforms[mesh.ParentBone.Index] * baseworld;
            foreach (ModelMeshPart meshpart in mesh.MeshParts)
            {
                BasicEffect effect = (BasicEffect)meshpart.Effect;
                effect.World = localworld;
                effect.View = camera.View;
                effect.Projection = camera.Projection;
                effect.EnableDefaultLighting();
            }
            mesh.Draw();
        }
    }
    public BoundingSphere BoundingSphere
    {
        get
        {
            if (!boundingimplemented)
            {
                foreach (ModelMesh mesh in Model.Meshes)
                {
                    BoundingSphere transformed = mesh.BoundingSphere.Transform(
                    modeltransforms[mesh.ParentBone.Index]);
                    sphere = BoundingSphere.CreateMerged(sphere, transformed);
                }
                Matrix worldTransform = Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Position);
                BoundingSphere transforme = sphere;
                transforme = transforme.Transform(worldTransform);
                return transforme;
            }
            else
            {
                Matrix worldTransform = Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Position);
                BoundingSphere transformed = sphere;
                transformed = transformed.Transform(worldTransform);
                return transformed;
            }
        }
    }
}

Then I call the class from the Game1 class:

ImportModel ground = new ImportModel("ground", GraphicsDevice, Content, Vector3.Zero, Vector3.Zero, new Vector3(20f));

EDIT2:This is how the scene looks from top:

i.stack.imgur.com/Hs983.jpg

share|improve this question
    
nobody's going to help you if you don't post any code, even the pictures you posted are terribly lit, if lit at all actually, light the scene properly and point the camera at the ground so people can see what's going on, and post your rendering code –  dreta Jul 5 '12 at 10:41
    
ok i may be missing something, but have you even set the texture? –  dreta Jul 5 '12 at 11:52
    
I used the ground.x from this sample create.msdn.com/en-US/education/catalog/sample/avatar_shadows –  Belos Jul 5 '12 at 12:22

1 Answer 1

You must set effect.Texture to a Texture2D object that contains your checkers texture and you have previously loaded with the ContentManager.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.