public Sun(PlaneTexture planeTex, List<Texture2D> frames) { this.planeTex = planeTex; this.frames = frames; timer = new Timer(100, true, () => { frame = Math.Abs(frame - 1); }); timer.Start(); //planeTex.effect.EmissiveColor = new Vector3(1, 1, 1); planeTex.effect.LightingEnabled = true; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Effect renderEffect = Content.Load<Effect>("3dRender"); Model playermodel = Content.Load<Model>("shredgodpose"); Model rampModel = Content.Load<Model>("bowl"); desModel = Content.Load<Model>("desert"); Texture2D sunF1 = Content.Load<Texture2D>("sun1"); Texture2D sunF2 = Content.Load<Texture2D>("sun2"); fly = Content.Load<Song>("flylike"); ScoreBoard.Init(Content, graphics.GraphicsDevice.Viewport); SoundEffect skate = Content.Load<SoundEffect>("skate"); var sunPT = new PlaneTexture(sunF1, new Vector3(0, -10000, 0), 8, graphics.GraphicsDevice); var sunFrames = new List<Texture2D>(); sunFrames.Add(sunF1); sunFrames.Add(sunF2); Data.sun = new Sun(sunPT, sunFrames); var tcloudmod = Content.Load<Model>("cloud"); var cloudMod1 = Content.Load<Model>("cloud1"); var cloudMod2 = Content.Load<Model>("cloud2"); var cloudMod3 = Content.Load<Model>("cloud3"); startScreen = Content.Load<Texture2D>("startscreen"); startScale = Math.Max(graphics.GraphicsDevice.Viewport.Width / (float)startScreen.Width, graphics.GraphicsDevice.Viewport.Height / (float)startScreen.Height); startNoSelect = Content.Load<Texture2D>("start"); startSelect = Content.Load<Texture2D>("startglow"); exitNoSelect = Content.Load<Texture2D>("exit"); exitSelect = Content.Load<Texture2D>("exitglow"); Texture2D[] stars = new Texture2D[3]; stars[0] = Content.Load<Texture2D>("stars"); stars[1] = Content.Load<Texture2D>("stars2"); stars[2] = Content.Load<Texture2D>("stars3"); desWorldMat = Matrix.CreateRotationX(MathHelper.PiOver2); desWorldMat *= Matrix.CreateScale(20); float width = 1f; Data.proj = Matrix.CreatePerspective(width, width / graphics.GraphicsDevice.Viewport.AspectRatio, .5f, 100000f); renderHelper = new RenderHelper(renderEffect, graphics.GraphicsDevice, Data.proj); var windsound = Content.Load<SoundEffect>("wind"); var phoneTs = new List<Texture2D>(); for (int i = 0; i < 10; i++) phoneTs.Add(Content.Load<Texture2D>("gameboy" + (i + 1))); var phoneEs = new List<Texture2D>(); for (int i = 0; i < 4; i++) phoneEs.Add(Content.Load<Texture2D>("enterpass" + (i + 1))); var phoneIs = new List<Texture2D>(); for (int i = 0; i < 5; i++) phoneIs.Add(Content.Load<Texture2D>("input" + i)); var noB = Content.Load<SoundEffect>("no"); var yesB = Content.Load<SoundEffect>("yes"); var searching = Content.Load<SoundEffect>("searching"); var found = Content.Load<SoundEffect>("found"); var success = Content.Load<SoundEffect>("sucess"); Data.player = new Player(new Vector3(-1.9f * 8, -100, 0), playermodel, skate, windsound, phoneTs, phoneIs, phoneEs,yesB, noB,searching,found,success); Data.ramp = new Ramp(rampModel, 1.14014f, new Vector3(0, 0, 0)); var satMod = Content.Load<Model>("satellite"); Data.sattelite = new Sattelite(satMod, new Vector3(500,-500,200)); var cloudPos = new Vector3(0, -400, 0); Random rand = new Random(); for (int i = 0; i < 30; i++) { Model cloudMod; double r = rand.NextDouble(); if (r < .3) cloudMod = cloudMod1; else if (r < .6) cloudMod = cloudMod2; else cloudMod = cloudMod3; var xOffset = rand.Next(-1000, 5000); var yOffset = rand.Next(0, 2000); var zOffset = rand.Next(-1000, 5000); var pos = cloudPos + new Vector3(xOffset, -yOffset, zOffset); float speed = .5f * (float)rand.NextDouble(); float scale = 100 + 500 * (float)rand.NextDouble() * yOffset / 4000; Data.clouds.Add(new Cloud(cloudMod, pos, speed, scale)); } var starPos = new Vector3(0, -16000, 0); for (int i = 0; i < 10; i++) { var xOffset = rand.Next(-10000, 10000); var yOffset = rand.Next(0, 4000); var zOffset = rand.Next(-10000, 10000); var pos = starPos + new Vector3(xOffset, -yOffset, zOffset); Data.stars.Add(new PlaneTexture(stars[0], pos, 5f, graphics.GraphicsDevice)); } }
public void renderPlaneTex(PlaneTexture planeTex) { planeTex.effect.Projection = proj; planeTex.effect.View = Data.player.camera.view; foreach (EffectPass pass in planeTex.effect.CurrentTechnique.Passes) { pass.Apply(); graphics.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleStrip, planeTex.verts, 0, 2); } }