public Scene3D GetScene3D(Object3D ob) { for (int i = 0; i < m_Object3DList.Count; i++) { if (m_Object3DList[i] is Scene3D) { Scene3D sc = (Scene3D)m_Object3DList[i]; for (int j = 0; j < sc.m_Object3DRefList.Count; j++) { if (sc.m_Object3DRefList[i] == ob) { return(sc); } } } } return(null); }
public void AddObject3D(string SceneKeyName, Object3D obj3D) { if (CheckName(obj3D.m_Keyname)) { throw new Exception("SceneTree::AddScene3D:the " + SceneKeyName + " identifier is already used."); } Scene3D sc = GetScene3D(SceneKeyName); if (sc == null) { throw new Exception("SceneTree::AddObject3D:This scene " + SceneKeyName + " does not exist"); } else { int iPos = m_Object3DList.Add(obj3D); // add the reference sc.AddObject3DRef(m_Object3DList[iPos]); } }
public void DeleteObject3D(ref Object3D ob) { Scene3D sc = GetScene3D(ob); if (sc == null) { throw new Exception("SceneTree::DeleteObject3D:This Object is not a part of a scene"); } SceneNode sn = GetSceneNode(sc); if (sn == null) { throw new Exception("SceneTree::DeleteObject3D:This SceneNode is not existing"); } // Remove the objectRef from the scene3D Object obRef = m_Object3DList[m_Object3DList.IndexOf(ob)]; sc.m_Object3DRefList.Remove(obRef); // Remove the Object from the main list m_Object3DList.Remove(ob); // Destroy the object ob = null; }