public override void AcceptDragDrop(object Input, object DraggedItem, PropertyGrid Properties, ListView Scene) { XHeightMap heightmap = (XHeightMap)Input; if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "Params" && DraggedItem is XEnvironmentParameters) { heightmap.Params = (XEnvironmentParameters)DraggedItem; } else if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "HeightMap" && DraggedItem is ContentItem) { heightmap.HeightMap = ((ContentItem)DraggedItem).GenerateFilename().Replace("\\Content", "Content"); } else if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "RTexture" && DraggedItem is ContentItem) { heightmap.RTexture = ((ContentItem)DraggedItem).GenerateFilename().Replace("\\Content", "Content"); } else if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "GTexture" && DraggedItem is ContentItem) { heightmap.GTexture = ((ContentItem)DraggedItem).GenerateFilename().Replace("\\Content", "Content"); } else if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "BTexture" && DraggedItem is ContentItem) { heightmap.BTexture = ((ContentItem)DraggedItem).GenerateFilename().Replace("\\Content", "Content"); } else if (Tools.GetPropertyAtPoint(Properties.PointToClient(Cursor.Position), Properties).Label == "TextureMap" && DraggedItem is ContentItem) { heightmap.TextureMap = ((ContentItem)DraggedItem).GenerateFilename().Replace("\\Content", "Content"); } UpdateObjectProperties(heightmap, Properties, Scene); }
public override void UpdateObjectProperties(object Input, PropertyGrid Properties, ListView Scene) { XHeightMap heightmap = (XHeightMap)Input; if (!string.IsNullOrEmpty(heightmap.HeightMap) && !string.IsNullOrEmpty(heightmap.TextureMap) && heightmap.Params != null) { try { heightmap.Load(X.Content); } catch { MessageBox.Show("There was a problem loading one of the heightmap's files. Check that the file exists and has been built with the Texture importer and processor.", "File Error"); } } base.UpdateObjectProperties(Input, Properties, Scene); }
public override void WriteToXML(System.Xml.XmlWriter writer, object obj) { XHeightMap heightmap = (XHeightMap)obj; writer.WriteStartElement("sceneitem"); writer.WriteAttributeString("Type", this.type.ToString()); writer.WriteAttributeString("AutoDraw", heightmap.AutoDraw.ToString()); writer.WriteAttributeString("BTexture", heightmap.BTexture); writer.WriteAttributeString("ComponentID", heightmap.ComponentID.ToString()); writer.WriteAttributeString("DrawOrder", heightmap.DrawOrder.ToString()); writer.WriteAttributeString("GTexture", heightmap.GTexture); writer.WriteAttributeString("HeightMap", heightmap.HeightMap); writer.WriteAttributeString("Name", heightmap.Name); writer.WriteAttributeString("Params", heightmap.Params.ComponentID.ToString()); writer.WriteAttributeString("RTexture", heightmap.RTexture); writer.WriteAttributeString("TextureMap", heightmap.TextureMap); writer.WriteEndElement(); }
public override void LoadFromXML(System.Xml.XmlNode node, ListView scene, ref Dictionary <uint, List <uint> > Depends) { XHeightMap heightmap = new XHeightMap(ref X, node.Attributes["HeightMap"].InnerText, null, node.Attributes["RTexture"].InnerText, node.Attributes["GTexture"].InnerText, node.Attributes["BTexture"].InnerText, node.Attributes["TextureMap"].InnerText); heightmap.AutoDraw = bool.Parse(node.Attributes["AutoDraw"].InnerText); heightmap.DrawOrder = int.Parse(node.Attributes["DrawOrder"].InnerText); heightmap.ComponentID = uint.Parse(node.Attributes["ComponentID"].InnerText); heightmap.Name = node.Attributes["Name"].InnerText; List <uint> dep = new List <uint>(); dep.Add(uint.Parse(node.Attributes["Params"].InnerText)); Depends.Add(heightmap.ComponentID, dep); if (!string.IsNullOrEmpty(heightmap.TextureMap) && !string.IsNullOrEmpty(heightmap.HeightMap) && heightmap.Params != null) { heightmap.Load(X.Content); } X_Editor.Tools.AddXComponentToSceneList(scene, heightmap, group); }
public override ListViewItem SetupListViewItem(ListViewItem item, XComponent component) { XHeightMap heightmap = new XHeightMap(ref X, null, null, null, null, null, null); return(base.SetupListViewItem(item, heightmap)); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { //Load engine base content X.LoadContent(); //Game base elements menus.Load(Content); // load scene objects/content //sky = new XDynamicSky(ref X,X.Environment); //XSkyBox sky = new XSkyBox(ref X, @"Content\XEngine\Textures\Sky\front", @"Content\XEngine\Textures\Sky\back", @"Content\XEngine\Textures\Sky\left", @"Content\XEngine\Textures\Sky\right", @"Content\XEngine\Textures\Sky\top", @"Content\XEngine\Textures\Sky\bottom"); XSkyBox sky = new XSkyBox(ref X, @"Content\XEngine\Textures\Sky\GreenWaterSky"); heightmap = new XHeightMap(ref X, @"Content\Images\Heightmaps\Level2", X.Environment, @"Content\Textures\Grass", @"Content\Textures\Sand", null, @"Content\Images\Terrainmaps\Island1"); //resources.AddComponent(environment); resources.AddComponent(heightmap); resources.AddComponent(sky); model = new XModel(ref X, @"Content\Models\cube"); resources.AddComponent(model); Chassis = new XModel(ref X, @"Content\Models\chassis"); Wheel = new XModel(ref X, @"Content\Models\wheel"); resources.AddComponent(Chassis); resources.AddComponent(Wheel); housemodel = new XModel(ref X, @"Content\Models\spider"); resources.AddComponent(housemodel); resources.Load(); //Car = new XCar(ref X, Chassis, Wheel, true, true, 30.0f, 5.0f, 4.7f, 5.0f, 0.20f, 0.4f, 0.05f, 0.45f, 0.3f, 1, 520.0f, Math.Abs(X.Gravity.Y), new Vector3(-10, heightmap.Heights.GetHeight(new Vector3(-10, 3, 0))+5, 0)); Car = new XCar(ref X, Chassis, Wheel, true, // front wheel drive true, // rear wheel drive 35.0f, // max steering angle 5f, // steering rate 3.6f, // front lateral traction 3.1f, // rear lateral traction 1f, // front longintudinal traction 2f, // rear longitudinal traction 2.5f, // handbrake rear lateral traction .75f, // handbrake rear longitudinal traction 6f, // starting slide factor 15f, // threshold 1 slide factor 30f, // threshold 2 slide factor .7f, // slip threshold 1 10.0f, // slip threshold 2 2.0f, // slide speed factor 1.7f, // traction loss factor on slip 0.3f, // suspension travel 0.45f, // wheel radius -0.10f, // wheel mounting point 0.6f, // spring rate 0.6f, // shock dampening 2, // wheel rays 2.5f, // roll resistance 300.0f, // top speed 1200.0f, // torque X.Physics.Gravity.Length(), // gravity new Vector3(-10, heightmap.Heights.GetHeight(new Vector3(-10, 3, 0)) + 5, 0) ); Car.Load(X.Content); trees = new XTreeSystem(ref X, @"Content\Images\Treemaps\Level1", heightmap); trees.Load(Content); trees.GenerateTrees(freeCamera); input.Load(); base.LoadContent(); }