/// <summary> /// Registers the mesh trianlge with the specified index with the tree. /// </summary> /// <returns> /// True if the trianlge was registered and false otherwise. The only /// scenario in which the method can return false is when the triangle /// is degenerate. /// </returns> private bool RegisterTriangle(int triangleIndex) { // Retrieve the triangle from the mesh. If it is degenerate, we return false. Triangle3D triangle = _octave3DMesh.GetTriangle(triangleIndex); if (triangle.IsDegenerate) { return(false); } // Create the triangle node data and instruct the tree to add this node var meshSphereTreeTriangle = new MeshSphereTreeTriangle(triangleIndex); _sphereTree.AddTerminalNode(triangle.GetEncapsulatingSphere(), meshSphereTreeTriangle); return(true); }
/// <summary> /// Registers the specified object with the tree. /// </summary> public void RegisterGameObject(GameObject gameObject) { if (!CanGameObjectBeRegisteredWithTree(gameObject)) { return; } // Build the object's sphere Box objectWorldBox = gameObject.GetWorldBox(); Sphere objectSphere = objectWorldBox.GetEncpasulatingSphere(); // Add the object as a terminal node. Also store the node in the dictionary so that we can // use it when it's needed. SphereTreeNode <GameObject> objectNode = _sphereTree.AddTerminalNode(objectSphere, gameObject); _gameObjectToNode.Add(gameObject, objectNode); }
/// <summary> /// Registers the specified object with the tree. /// </summary> public void RegisterGameObject(GameObject gameObject) { Light[] lights = gameObject.GetComponents <Light>(); foreach (var light in lights) { Octave3DScene.Get().RegisterSceneLight(light); } if (!CanGameObjectBeRegisteredWithTree(gameObject)) { return; } // Build the object's sphere Box objectWorldBox = gameObject.GetWorldBox(); Sphere objectSphere = objectWorldBox.GetEncpasulatingSphere(); // Add the object as a terminal node. Also store the node in the dictionary so that we can // use it when it's needed. SphereTreeNode <GameObject> objectNode = _sphereTree.AddTerminalNode(objectSphere, gameObject); _gameObjectToNode.Add(gameObject, objectNode); }