/// <summary> /// Provides the 3d layer with information about the lot /// </summary> /// <param name="model"></param> public void LoadHouse(HouseModel model) { /** Add terrain **/ Components.Add(new TerrainComponent(RenderState)); var cube1 = new CubeComponent(Color.Red, new Vector3(3.0f, 3.0f, 3.0f)); cube1.Position = new Vector3(32.0f * 3, 0.0f, 32.0f * 3); Components.Add(cube1); }
/// <summary> /// Setup the initial rendering objects for this house /// model /// </summary> /// <param name="model"></param> public void LoadHouse(HouseModel model) { /** Get all the first floor tiles **/ var floors = model.GetFloors().Where(x => x.Level == 0); foreach (var floor in floors) { Floor.AddComponent(floor); } var walls = model.GetWalls().Where(x => x.Level == 0); walls.Reverse(); foreach (var wall in walls) { Walls.AddComponent(wall); } //Walls.AddComponent(new DummyZSprite(@"E:\Temp\tso\tower_")); //Walls.AddComponent(new DummyZSprite(@"E:\Temp\tso\chair_")); }
/// <summary> /// Load a house from its definition /// </summary> /// <param name="house"></param> public void LoadHouse(HouseData house) { RenderState.Size = house.Size; /** * Camera should be at the edge of the screen looking onto the * center point of the lot at a 30 degree angle */ /** Size is how many tiles, the last tile has a size too so the actual vertex position is +1) **/ var worldEdge = house.Size + 1.0f; var radius = RenderState.TileToWorld((worldEdge / 2.0f)); var opposite = (float)Math.Cos(MathHelper.ToRadians(30.0f)) * radius; Camera.Position = new Vector3(radius * 2, opposite, radius * 2); Camera.Target = new Vector3(radius, 0.0f, radius); //Camera.Translation = new Vector3(-radius, 0.0f, -radius); Camera.Zoom = 178; /** * Setup the 2D space */ Model = new HouseModel(); Model.LoadHouse(house); Scene2D.LoadHouse(Model); Scene3D.LoadHouse(Model); //Center point of the center most tile ViewCenter = new Vector2((RenderState.Size / 2.0f)+30, (RenderState.Size / 2.0f)+30); }