Exemple #1
0
 public bool DeleteFromRegistry(ModelMeshPart mesh, TransformMatrix worldMatrix)
 {
     for (var i = 0; i < Index; i++)
     {
         MeshLibrary meshLib = _meshLib[i];
         if (meshLib.HasMesh(mesh))
         {
             if (meshLib.DeleteFromRegistry(worldMatrix)) //if true, we can delete it from registry
             {
                 for (var j = i; j < Index - 1; j++)
                 {
                     //slide down one
                     _meshLib[j] = _meshLib[j + 1];
                 }
                 Index--;
             }
             break;
         }
     }
     if (Index <= 0)
     {
         return(true);            //this material is no longer needed.
     }
     return(false);
 }
Exemple #2
0
        public void Register(ModelMeshPart mesh, TransformMatrix worldMatrix, BoundingSphere boundingSphere)
        {
            bool found = false;

            //Check if we already have a model like that, if yes put it in there!
            for (var i = 0; i < Index; i++)
            {
                MeshLibrary meshLib = _meshLib[i];
                if (meshLib.HasMesh(mesh))
                {
                    meshLib.Register(worldMatrix);
                    found = true;
                    break;
                }
            }

            //We have no Lib yet, make a new one.
            if (!found)
            {
                _meshLib[Index] = new MeshLibrary();
                _meshLib[Index].SetMesh(mesh);
                _meshLib[Index].SetBoundingSphere(boundingSphere);
                _meshLib[Index].Register(worldMatrix);
                Index++;
            }

            //If we exceeded our array length, make the array bigger.
            if (Index >= _meshLib.Length)
            {
                MeshLibrary[] tempLib = new MeshLibrary[Index + 1];
                _meshLib.CopyTo(tempLib, 0);
                _meshLib = tempLib;
            }
        }