public void DrawSkinModel(OBJ obj) { foreach (ModelMesh mesh in obj.Model.Meshes) { foreach (Effect effect in mesh.Effects) { effect.Parameters["Bones"].SetValue(obj.AnimationPlayer.GetSkinTransforms()); effect.Parameters["View"].SetValue(Camera.View); effect.Parameters["Projection"].SetValue(Camera.Projection); effect.Parameters["CameraPosition"].SetValue(Camera.Position); effect.Parameters["FogColor"].SetValue(FogColor); effect.Parameters["FogNear"].SetValue(1); effect.Parameters["FogFar"].SetValue(200); } mesh.Draw(); } }
public void DrawModel(OBJ obj) { Matrix[] transforms = new Matrix[obj.Model.Bones.Count]; obj.Model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in obj.Model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.View = Camera.View; effect.Projection = Camera.Projection; effect.World = obj.World * transforms[mesh.ParentBone.Index]; effect.DirectionalLight0.Direction = new Vector3(1, -1, 1); effect.DirectionalLight0.Enabled = true; effect.DirectionalLight0.DiffuseColor = LightColor; effect.DirectionalLight1.Direction = new Vector3(-1, -1, -1); effect.DirectionalLight1.Enabled = true; effect.DirectionalLight1.DiffuseColor = new Vector3(0.1f, 0.4f, 0.8f); effect.DirectionalLight2.Direction = new Vector3(-1, -1, 1); effect.DirectionalLight2.Enabled = true; effect.DirectionalLight2.DiffuseColor = new Vector3(0.7f, 0.5f, 0.3f); effect.FogEnabled = true; effect.FogEnd = 200; effect.FogStart = 1; effect.FogColor = FogColor; effect.DiffuseColor = new Vector3(0.9f, 0.9f, 0.9f); effect.SpecularColor = new Vector3(0.01f, 0.01f, 0.01f); effect.SpecularPower = 20; effect.LightingEnabled = true; effect.PreferPerPixelLighting = true; } mesh.Draw(); } }
protected override void LoadContent() { mBugtest = new Bug[30]; for (int i = 0; i < mBugtest.Length; i++) { mBugtest[i] = new Bug(this, new Vector3(mRand.Next(-100, 100), 0, mRand.Next(-100, 100)), mRand); } mCrosshair = Content.Load<Texture2D>("Textures/crosshair"); mScreen = Content.Load<Texture2D>("Textures/screen"); mGuntest = new OBJ(); mGuntest.Model = Content.Load<Model>("Models/gun/gun"); mGuntest.Scale = new Vector3(0.1f); mGuntest.SetWorld(); mGuntest.SkinningSetting("Idle"); mGuntest.AnimationSpeed = 0.06f; mTerrain = Content.Load<XNATerrain>("Terrain/heightmap-512"); mParticle.LoadContent(this); mSpriteBatch = new SpriteBatch(GraphicsDevice); }
protected override void LoadContent() { mBugtest = new Bug[30]; for (int i = 0; i < mBugtest.Length; i++) { mBugtest[i] = new Bug(this, new Vector3(mRand.Next(-100, 100), 0, mRand.Next(-100, 100)), mRand); } mCrosshair = Content.Load <Texture2D>("Textures/crosshair"); mScreen = Content.Load <Texture2D>("Textures/screen"); mGuntest = new OBJ(); mGuntest.Model = Content.Load <Model>("Models/gun/gun"); mGuntest.Scale = new Vector3(0.1f); mGuntest.SetWorld(); mGuntest.SkinningSetting("Idle"); mGuntest.AnimationSpeed = 0.06f; mTerrain = Content.Load <XNATerrain>("Terrain/heightmap-512"); mParticle.LoadContent(this); mSpriteBatch = new SpriteBatch(GraphicsDevice); }