protected override void OnCreateControl() { base.OnCreateControl(); m_testData.Scale = new Vector3(1.0f, 1.0f, 1.0f); m_testData.Translate = new Vector3(0.0f, 50.0f, 0.0f); m_lot = m_data.CreateNewLevelObjectType(); m_lot.ModelFileName = "C:\\Users\\Legend\\Documents\\Visual Studio 2008\\Projects\\LevelDesigner\\LevelDesigner\\Content\\tiny.x"; rdr_renderPane.ChangeViewMode(RenderPane.ViewMode.eTypeViewer); rdr_renderPane.ShowObjectType(m_lot, m_data); m_testData.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.OnTestDataPropChanged); prp_properties.SelectedObject = m_testData; }
private void Init(LevelObjectData data) { /* Create the link between the instance and it's type */ m_lot = data.GetObjectTypeByGuid(m_lo.TypeId.ToString()); if (m_lot == null) { /* ERROR: Could not find the type in the data definition */ System.Diagnostics.Debug.Assert(false); return; } if (m_lot.ModelFileName.Length > 0) { Model model = null; data.FetchModel(m_lot.ModelFileName, m_services, out model); System.Diagnostics.Debug.Assert(model != null); m_model = model; List<Effect> list = new List<Effect>(); foreach (ModelMesh mesh in m_model.Meshes) { m_sphereBounds.Center += mesh.BoundingSphere.Center; m_sphereBounds.Radius = Math.Max(m_sphereBounds.Radius, mesh.BoundingSphere.Radius); foreach (Effect effect in mesh.Effects) { list.Add(effect); } } m_sphereBounds.Center /= m_model.Meshes.Count; m_effects = new ReadOnlyCollection<Effect>(list); } }
private void ShowObjectTypeInViewPane(LevelObjectType lot) { if (lot == null) { rdr_renderPane.ChangeViewMode(RenderPane.ViewMode.eDisabled); return; } rdr_renderPane.ShowObjectType(lot, m_data); }
private void CreateNewObjectInstance(LevelObjectType lot) { LevelObject lo = m_data.CreateNewLevelObjectInstance(); lo.TypeId = lot.TypeID; /* Add new object to level definition */ m_data.AddObjectToLvl(lo, false); /* Update Dialog with new item */ lst_lvlObjs.Items.Add(lo.Name); DirtyData(true); }
public void AddObjectTypeToPalette(LevelObjectType lot, bool remove) { if (!remove) { bool done = false; while (!done) { try { objectPalette.Add(lot.Name, lot); done = true; } catch (ArgumentException) { /* Given name is already taken, try to create a new name */ String name = lot.Name.Substring(0, lot.Name.Length-1); name += GetNextTypeIdx().ToString(); lot.Name = name; } } if (ObjectTypeAdded != null) { LevelEventArgs e = new LevelEventArgs(); e.lot = lot; ObjectTypeAdded(this, e); } } else { objectPalette.Remove(lot.Name); if (ObjectTypeRemoved != null) { LevelEventArgs e = new LevelEventArgs(); e.lot = lot; ObjectTypeRemoved(this, e); } } }
public LevelObjectType LoadTypeFile(System.IO.Stream stream) { System.IO.BinaryReader br = new System.IO.BinaryReader(stream); /* Verify the Type Being Loaded Matches the Current Application Version */ String currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); String fileVersion = br.ReadString(); if (fileVersion != currentVersion) { /* ERROR: File Version Out of Date */ throw new IncorrectFileVersionException(); } /* Read Type */ LevelObjectType lot = new LevelObjectType(); lot.TypeID = new Guid(br.ReadString()); lot.Name = br.ReadString(); lot.ShaderId = br.ReadString(); lot.ModelFileName = br.ReadString(); /* Type Parent Transforms */ lot.Translation = FileOps.ReadVec3(br); lot.Rotation = FileOps.ReadVec3(br); lot.Scaling = FileOps.ReadVec3(br); return lot; }
public int GetObjectTypeList(out LevelObjectType[] types) { types = new LevelObjectType[objectPalette.Count]; int index = 0; foreach (KeyValuePair<String, LevelObjectType> kv in objectPalette) { types[index] = kv.Value; index++; } /* return the number of items in the array */ return index; }
public void EnsureObjectType(LevelObjectType lot, System.IO.Stream stream) { System.Diagnostics.Debug.Assert(lot.IsDirty); System.IO.BinaryWriter bw = new System.IO.BinaryWriter(stream); /* File Version Stamp */ bw.Write(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); /* Object Type Attributes */ bw.Write(lot.TypeID.ToString()); bw.Write(lot.Name); bw.Write(lot.ShaderId); bw.Write(lot.ModelFileName); /* Object Type Parent Transforms */ FileOps.WriteVec3(lot.Translation, bw); FileOps.WriteVec3(lot.Rotation, bw); FileOps.WriteVec3(lot.Scaling, bw); }
public LevelObjectType CreateNewLevelObjectType() { /* Generate a New Unique ID */ int typeIdx = GetNextTypeIdx(); Guid typeId = Guid.NewGuid(); /* Create a fake name * (TODO: this can come from create type dialog) */ String name = "NEWTYPE" + typeIdx; /* Create the new level object */ LevelObjectType lot = new LevelObjectType(); lot.Index = typeIdx; lot.TypeID = typeId; lot.name = name; lot.shaderId = "default"; lot.IsDirty = true; lot.ModelFileName = "none"; lot.scale.Scales = new Vector3(1.0f, 1.0f, 1.0f); lot.rotation.Order = RotationEuler.EOrder.eOrder_ZYX; return lot; }
public void ShowObjectType(LevelObjectType type, LevelObjectData data) { DrawableLevelObjectType drawLot = new DrawableLevelObjectType(type, data, Services); ChangeViewMode(ViewMode.eTypeViewer); ResetView(); m_scene.Add(type.Name, drawLot); }