public bool Load(Stream gat, Stream gnd, Stream rsw) { Logger.WriteLine("Loading altitude..."); _altitude = new Altitude(); if (!_altitude.Load(gat)) return false; Logger.WriteLine("Loading ground..."); _ground = new Ground(_graphicsDevice); if (!_ground.Load(gnd)) return false; Logger.WriteLine("Loading world..."); _world = new World(_graphicsDevice); if (!_world.Load(rsw, this)) return false; Logger.WriteLine("Creating ground vertex buffer..."); _ground.SetupVertices(); Logger.WriteLine("Building lightmaps..."); BuildLightmaps(); _effect.Parameters["Lightmap"].SetValue(_lightmap); _effect.Parameters["AmbientColor"].SetValue(new Vector3(1, 1, 1)); _effect.Parameters["DiffuseColor"].SetValue(new Vector3(0, 0, 0)); // FIXME: Where I put the light? O_O _effect.Parameters["LightPosition"].SetValue(new Vector3(0, 0, 0)); return true; }
public void Load(Ground owner, BinaryReader br, byte majorVersion, byte minorVersion) { Load(owner, br, majorVersion, minorVersion, 0); }
public void CalculateNormal(Ground ground) { Vector3 b1 = default(Vector3); Vector3 b2 = default(Vector3); b1 = new Vector3(ground.Zoom, _height[1], ground.Zoom) - new Vector3(ground.Zoom, _height[3], ground.Zoom); b2 = new Vector3(ground.Zoom, _height[2], ground.Zoom) - new Vector3(ground.Zoom, _height[3], ground.Zoom); _normal = new Vector3[5]; _normal[0] = Vector3.Cross(b1, b2); _normal[0].Normalize(); }
public void Load(Ground owner, BinaryReader br, byte majorVersion, byte minorVersion, int texture) { _texCoord = new Vector2[4]; if (majorVersion == 0 && minorVersion == 0) { _texCoord[0].X = br.ReadSingle(); _texCoord[0].Y = br.ReadSingle(); _texCoord[1].X = br.ReadSingle(); _texCoord[1].Y = br.ReadSingle(); _texCoord[2].X = br.ReadSingle(); _texCoord[2].Y = br.ReadSingle(); _texCoord[3].X = br.ReadSingle(); _texCoord[3].Y = br.ReadSingle(); _texture = texture; _lightmap = 0; // Is it white?? Seems too bright... _color = Color.White; } else { _texCoord[0].X = br.ReadSingle(); _texCoord[1].X = br.ReadSingle(); _texCoord[2].X = br.ReadSingle(); _texCoord[3].X = br.ReadSingle(); _texCoord[0].Y = br.ReadSingle(); _texCoord[1].Y = br.ReadSingle(); _texCoord[2].Y = br.ReadSingle(); _texCoord[3].Y = br.ReadSingle(); _texture = br.ReadInt16(); _lightmap = br.ReadInt16(); int r = br.ReadByte(); int g = br.ReadByte(); int b = br.ReadByte(); int a = br.ReadByte(); _color = new Color(r, g, b, a); } }