e.Texture = texture;
e.TextureEnabled = true;
I get a nicely lit green sphere, but otherwise it's just a black circle.
The model was made in blender and exported to an xfile. I've tried it both with the normals flipped/not flipped and with the texture applied in blender and not (wasn't sure if it'd make a difference) as well as both left and right handed system.
// Load the model/texture
public override void Initialize(GraphicsDeviceManager g)
{
ball = c.Load<Model>(@"Content\Models\ball");
texture = c.Load<Texture2D>(@"Content\Models\tmppolar");
}
//...
public override void Render(GraphicsDeviceManager graphics)
{
Matrix[] transforms;
GraphicsDevice g = graphics.GraphicsDevice;
transforms = new Matrix[ball.Bones.Count];
ball.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in ball.Meshes)
{
foreach (BasicEffect e in mesh.Effects)
{
// Lighting
e.LightingEnabled = true;
e.DirectionalLight0.Enabled = true;
e.DirectionalLight0.Direction = new Vector3(0.0f, -1.0f, 0.0f);
e.DirectionalLight0.DiffuseColor = new Vector3(1.0f, 1.0f, 1.0f);
// Material
e.SpecularPower = 10.0f;
e.AmbientLightColor = new Vector3(1.0f, 1.0f, 1.0f);
e.DiffuseColor = new Vector3(0.4f, 0.5f, 0.3f);
// Texturing
e.Texture = texture;
e.TextureEnabled = true;
// Matricies/Transforms
e.World = transforms[mesh.ParentBone.Index];
e.View = Program.camera.View;
e.Projection = Program.camera.Projection;
}
mesh.Draw();
}
transformation = Matrix.CreateRotationX(modelXRotation); // reset rotation matrix
transformation = Matrix.CreateRotationZ(modelZRotation); // reset rotation matrix
}
Any help would be great.