I'm trying to use the asteroid model from the SpaceWar template, but when I try and render the model, it comes out being mostly transparent. I've copied all the content over from SpaceWar, but it still doesn't work. I used almost the exact same code on one of the spaceships, and it worked fine. Can someone tell me what I'm doing wrong
Here's all of unfinished code for the asteroid...
#region Using Statements
using
System;using
System.Collections.Generic;using
System.Text;using
Microsoft.Xna.Framework;using
Microsoft.Xna.Framework.Audio;using
Microsoft.Xna.Framework.Content;using
Microsoft.Xna.Framework.Graphics;using
Microsoft.Xna.Framework.Input;using
Microsoft.Xna.Framework.Storage;#endregion
namespace
SpaceGame{
class Asteroid{
private Model M_Asteroid; private Vector3 position; private float rotateX, rotateY, rotation; private float scale; public Asteroid(){
rotateX = 0.0f;
rotateY = 0.0f;
rotation = 0.05f;
scale = 0.3f;
}
public void UpdateAsteroid(){
rotateX += rotation;
rotateY += rotation;
}
public void LoadModel(ContentManager content){
M_Asteroid = content.Load<
Model>("Content/Models/asteroid2");}
public void DrawModel(Vector3 cameraPosition, float aspectRatio){
Matrix[] transforms = new Matrix[M_Asteroid.Bones.Count];M_Asteroid.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in M_Asteroid.Meshes){
foreach (BasicEffect effect in mesh.Effects){
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] *
Matrix.CreateRotationX(rotateX) * Matrix.CreateRotationY(rotateY);effect.View =
Matrix.CreateLookAt(cameraPosition, Vector3.Zero, new Vector3(0.0f, 1.0f, 0.0f));effect.Projection =
Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f);}
mesh.Draw();
}
}
}
}