/// <summary> /// Set the billboard effect paramaters /// </summary> void setEffectParameters() { ChaseCamera camera = (ChaseCamera)((MyGame)Game).camera; effect.Parameters["ParticleTexture"].SetValue(texture); effect.Parameters["View"].SetValue(camera.View); effect.Parameters["Projection"].SetValue(camera.Projection); effect.Parameters["Size"].SetValue(billboardSize / 2f); effect.Parameters["Up"].SetValue(Mode == BillboardMode.Spherical ? camera.Up : Vector3.Up); effect.Parameters["Side"].SetValue(camera.Right); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); models.Add(new CModel(Content.Load <Model>("Ship"), new Vector3(1000, 1000, 1000), Vector3.Zero, new Vector3(0.4f), GraphicsDevice)); models.Add(new CModel(Content.Load <Model>("jula"), new Vector3(1000, 1000, 1000), Vector3.Zero, new Vector3(0.4f), GraphicsDevice)); models.Add(new CModel(Content.Load <Model>("ground"), new Vector3(0, 0, 0), Vector3.Zero, new Vector3(10f), GraphicsDevice)); PhongEffect = Content.Load <Effect>("MultiSpotLightEffect"); GouraudEffect = Content.Load <Effect>("MultiSpotLightEffectGouraud"); effect = PhongEffect; chaseLight = new ChaseLight(new Vector3(0, 200, -100), new Vector3(0, 200, 0), new Vector3(0, 0, 0)); mat = new MultiSpotLightMaterial(chaseLight); Random rand = new Random(); for (int i = -1; i < 2; i += 2) { for (int j = -1; j < 2; j += 2) { Vector3 additionalRotation = Vector3.Zero; if (i > 0) { additionalRotation += new Vector3(0, 1, 0) * (rand.Next() % 100 * .025f); } else { additionalRotation += new Vector3(0, -1, 0) * (rand.Next() % 100 * .025f); } models.Add(new CModel(Content.Load <Model>("deer"), new Vector3(0 + i * 4000, 0, 0 + j * 4000), Vector3.Zero + additionalRotation, Vector3.One, GraphicsDevice)); } } models.Add(new CModel(Content.Load <Model>("moon"), new Vector3(0, 10000, 10000), new Vector3(1.05f, 0, 1), new Vector3(500f), GraphicsDevice)); models.Add(new CModel(Content.Load <Model>("fireplace"), new Vector3(1000, 100, 1000), new Vector3(1.05f, 0, 1), new Vector3(50f), GraphicsDevice)); for (int i = -1; i < 2; i += 2) { for (int j = -1; j < 2; j += 2) { models.Add(new CModel(Content.Load <Model>("ball"), new Vector3(2000 * 1, 100, 2000 * j), new Vector3(1.05f, 0, 1), new Vector3(500f), GraphicsDevice)); } } for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { Vector3 additionalRotation = Vector3.Zero; float scale = 2; if (i > 0) { additionalRotation += new Vector3(0, 1, 0) * (rand.Next() % 100 * .025f); } else { additionalRotation += new Vector3(0, -1, 0) * (rand.Next() % 100 * .025f); } models.Add(new CModel(Content.Load <Model>("AlanTree"), new Vector3(0 + i * 6000, 0, 0 + j * 6000), Vector3.Zero + additionalRotation, new Vector3(scale, scale, scale), GraphicsDevice)); } } foreach (CModel cm in models) { cm.Material = mat; cm.SetModelEffect(effect, true); } cam1 = new ChaseCamera(new Vector3(0, 200, 2500), new Vector3(0, 200, 0), new Vector3(0, 0, 0), GraphicsDevice); cam2 = new TargetCamera( new Vector3(100, 15000, 100), Vector3.Zero, GraphicsDevice); cam3 = new TargetCamera( new Vector3(100, 15000, 100), Vector3.Zero, GraphicsDevice); switch (cameraChosen) { case 1: camera = cam1; break; case 2: camera = cam2; break; case 3: camera = cam3; break; default: throw new InvalidDataException("Z³y numer kamery"); } lastMouseState = Mouse.GetState(); }