public Instance3D[] GetObjectList(ObjectType type) { // NOTE: (From Mono) // Why not just create an Instance3DCollection here and add the items to it? // It would most likely be faster than having to go through the collection twice. Instance3D[] list = null; int type_count = 0; for (int i = 0; i < this.Count; i++) { if (this[i].ObjectType == type) { type_count++; } } list = new Instance3D[type_count]; type_count = 0; for (int i = 0; i < this.Count; i++) { if (this[i].ObjectType == type) { list[type_count++] = this[i]; } } return(list); }
/// <summary> /// Removes an object from the collection. /// </summary> /// <param name="name">The name of the Instance3D to remove from the collection.</param> public void Remove(string name) { Instance3D instance = (table[name] as Instance3D); distanceSortArray = new int[this.Count]; //table.Remove(name); InnerList.Remove(instance); }
public void Debug_LoadTestMesh() { Model3D cube = new Model3D("default cube"); cube.LoadDirectionModel(); m_Cube = new Instance3D(cube); //m_Cube.SetTranslation(0,0,5); //m_Cube.SetRotation((float)Math.PI/4, (float)Math.PI/4, (float)Math.PI/4); }
public void InitDebug() { Model3D cube = new Model3D("default cube"); cube.LoadDirectionModel(); debugObject = new Instance3D(cube); //debugObject.SetTranslation(0,0,5); //debugObject.SetRotation((float)Math.PI/4, (float)Math.PI/4, (float)Math.PI/4); }
public void AddSelection(Instance3D item) { if (activeSelection != null) { activeSelection.EditMode = EditMode.NotSelected; } activeSelection = item; activeSelection.EditMode = EditMode.Selected; }
public bool LoadModelTag(TagFileName tfn) { try { int index = MdxRender.MM.RegisterModel(tfn); m_ActiveModel = new Instance3D(MdxRender.MM.GetModel(index)); m_ActiveModel.Model.LevelOfDetail = eLOD.CAUSES_FIRES; MdxRender.Camera.UpdateCameraByBoundingBox(ref m_ActiveModel.Model.m_BoundingBox, 2.0f, 5.0f); m_PreviewMode = PreviewMode.Model; } catch { } return(false); }
public int Compare(object x, object y) { Instance3D instanceX = (x as Instance3D); Instance3D instanceY = (y as Instance3D); // NOTE: This is kind of a bad design to explicitly access the static // camera object here. Not sure if passing the camera in the constructor // would be any better though. float distanceX = MdxRender.Camera.GetObjectDistance( instanceX.Translation.X, instanceX.Translation.Y, instanceX.Translation.Z); float distanceY = MdxRender.Camera.GetObjectDistance( instanceY.Translation.X, instanceY.Translation.Y, instanceY.Translation.Z); if (distanceX < distanceY) { return(-1); } if (distanceX > distanceY) { return(1); } return(0); }
public bool ContainsChild(Instance3D instance) { return(this.children.Contains(instance)); }
public void AddChild(Instance3D child) { children.Add(child); child.Parent = this; }
/// <summary> /// Indicates if the specified object is contained in the collection. /// </summary> /// <param name="instance">The Instance3D to search for.</param> public bool Contains(Instance3D instance) { return(InnerList.Contains(instance)); }
/// <summary> /// Removes an object from the collection. /// </summary> /// <param name="instance">The Instance3D to remove from the collection.</param> public void Remove(Instance3D instance) { InnerList.Remove(instance); distanceSortArray = new int[this.Count]; //table.Remove(instance.Name); }
/// <summary> /// Adds an object to the collection. /// </summary> /// <param name="instance">The Instance3D to add to the collection.</param> public void Add(Instance3D instance) { InnerList.Add(instance); distanceSortArray = new int[this.Count]; //table.Add(instance.Name, instance); }
public void MouseUp(int MouseX, int MouseY) { Vector3 PickRayDirection = new Vector3(); Vector3 PickRayOrigin = new Vector3(); MdxRender.CalculatePickRayWorld(MouseX, MouseY, out PickRayDirection, out PickRayOrigin); #region 2D Selection Box //see if we need to do a 2D select box multiSelectBox.MouseUp(MouseX, MouseY); if (multiSelectBox.Mode != MultiSelectMode.Disabled) { if (multiSelectBox.Mode != MultiSelectMode.Disabled) { ArrayList tmp = multiSelectBox.UpdateFrustumSelection(this); bool bFoundDuplicate = false; Instance3D inst, tmp_inst; //add 2d select box selection list to master selection list for (int s = 0; s < tmp.Count; s++) { tmp_inst = (Instance3D)tmp[s]; //check for duplication for (int k = 0; k < selectionList.Count; k++) { inst = (Instance3D)selectionList[k]; if (tmp_inst == inst) { bFoundDuplicate = true; break; } } if (bFoundDuplicate == false) { selectionList.Add(tmp[s]); } } } } #endregion //debug code if (activeSelection == null) { foreach (Instance3D instance in this) { if (instance.MouseUp(PickRayOrigin, PickRayDirection, false) == true) { activeSelection = instance; } } if ((selectionList.Count != 0) && (multiSelectBox.Mode == MultiSelectMode.Disabled)) { foreach (Instance3D item in this) { item.Selected = false; } selectionList.Clear(); } //if(m_DebugObject1.MouseUp(PickRayOrigin, PickRayDirection, false)) // m_ActiveSelection = m_DebugObject1; } else { activeSelection.MakeEditInactive(); if (activeSelection.MouseUp(PickRayOrigin, PickRayDirection, true) == false) { if (activeSelection.EditMode == EditMode.NotSelected) { activeSelection = null; } } } UpdateSelectionLeader(); }