Exemplo n.º 1
0
	// Use this for initialization
	void Start () 
    {
      
        int numChunksTotal = (int)(m_numberOfChunks.x * m_numberOfChunks.y * m_numberOfChunks.z);
        m_chunkList = new List<Chunk>(numChunksTotal);
        switch(m_chosenPass)
        {
            case Passes.NAIVE:
                m_passes = new BasePass[2];
                m_passes[0] = new BuildDensityPass();
                m_passes[1] = new NaiveGenVerticesPass();
                break;
            case Passes.APPENDING:
                m_passes = new BasePass[3];
                m_passes[0] = new BuildDensityPass();
                m_passes[1] = new ListNonemptyCellsPass();
                m_passes[2] = new AppendGenVerticesPass();
                break;
            case Passes.NONEMPTY:
                m_passes = new BasePass[3];
                m_passes[0] = new BuildDensityPass();
                m_passes[1] = new ListNonemptyCellsPass();
                m_passes[2] = new NonemptyGenVerticesPass();
                break;
            case Passes.NONEMPTY_MEDICAL:
                m_passes = new BasePass[3];
                m_passes[0] = new BuildDensityMedicalPass();
                m_passes[1] = new ListNonemptyCellsPass();
                m_passes[2] = new AppendGenVerticesPass();
                break;
            case Passes.INDICES:
                m_passes = new BasePass[4];
                m_passes[0] = new BuildDensityPass();
                m_passes[1] = new ListNonemptyCellsPass();
                m_passes[2] = new SplatGenVerticesPass();
                m_passes[3] = new GenIndicesPass();
                break;
            case Passes.INDICES_MEDICAL:
                m_passes = new BasePass[4];
                m_passes[0] = new BuildDensityMedicalPass();
                m_passes[1] = new ListNonemptyCellsPass();
                m_passes[2] = new SplatGenVerticesPass();
                m_passes[3] = new GenIndicesPass();
                break;
        }

        m_densityTexture = Helper.CreateDensityTexture(32);

        float startTime = Time.realtimeSinceStartup;
        m_worldGameObject = new GameObject("World");
        CreateChunks();
        //if ((m_chosenPass == Passes.APPENDING || m_chosenPass == Passes.NONEMPTY) && m_chunkList.Count > 1)
        //{
        //    int prev = m_chunkList[0].triangleCount;
        //    for (int i = 1; i < m_chunkList.Count; i++)
        //    {
        //        int temp = m_chunkList[i].triangleCount;
        //        m_chunkList[i].triangleCount = prev;
        //        prev = temp;
        //    }
        //    m_chunkList[0].triangleCount = prev;
        //}
        float endTime = Time.realtimeSinceStartup;
         
        if (DEBUG)
        {
            print("Total Creation time:" + (float)(endTime - startTime));
            print("Chunk Creation time: " + m_totalChunkCreationTime);
            print("Mesh Creation time:" + m_totalMeshCreationTime);
            print("Number of chunks generated: " + m_chunkList.Count);

            print("Chunks per second: " + (float)(m_chunkList.Count / m_totalChunkCreationTime));
        }
        
	
	}
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        int numChunksTotal = (int)(m_numberOfChunks.x * m_numberOfChunks.y * m_numberOfChunks.z);

        m_chunkList = new List <Chunk>(numChunksTotal);
        switch (m_chosenPass)
        {
        case Passes.NAIVE:
            m_passes    = new BasePass[2];
            m_passes[0] = new BuildDensityPass();
            m_passes[1] = new NaiveGenVerticesPass();
            break;

        case Passes.APPENDING:
            m_passes    = new BasePass[3];
            m_passes[0] = new BuildDensityPass();
            m_passes[1] = new ListNonemptyCellsPass();
            m_passes[2] = new AppendGenVerticesPass();
            break;

        case Passes.NONEMPTY:
            m_passes    = new BasePass[3];
            m_passes[0] = new BuildDensityPass();
            m_passes[1] = new ListNonemptyCellsPass();
            m_passes[2] = new NonemptyGenVerticesPass();
            break;

        case Passes.NONEMPTY_MEDICAL:
            m_passes    = new BasePass[3];
            m_passes[0] = new BuildDensityMedicalPass();
            m_passes[1] = new ListNonemptyCellsPass();
            m_passes[2] = new AppendGenVerticesPass();
            break;

        case Passes.INDICES:
            m_passes    = new BasePass[4];
            m_passes[0] = new BuildDensityPass();
            m_passes[1] = new ListNonemptyCellsPass();
            m_passes[2] = new SplatGenVerticesPass();
            m_passes[3] = new GenIndicesPass();
            break;

        case Passes.INDICES_MEDICAL:
            m_passes    = new BasePass[4];
            m_passes[0] = new BuildDensityMedicalPass();
            m_passes[1] = new ListNonemptyCellsPass();
            m_passes[2] = new SplatGenVerticesPass();
            m_passes[3] = new GenIndicesPass();
            break;
        }

        m_densityTexture = Helper.CreateDensityTexture(32);

        float startTime = Time.realtimeSinceStartup;

        m_worldGameObject = new GameObject("World");
        CreateChunks();
        //if ((m_chosenPass == Passes.APPENDING || m_chosenPass == Passes.NONEMPTY) && m_chunkList.Count > 1)
        //{
        //    int prev = m_chunkList[0].triangleCount;
        //    for (int i = 1; i < m_chunkList.Count; i++)
        //    {
        //        int temp = m_chunkList[i].triangleCount;
        //        m_chunkList[i].triangleCount = prev;
        //        prev = temp;
        //    }
        //    m_chunkList[0].triangleCount = prev;
        //}
        float endTime = Time.realtimeSinceStartup;

        if (DEBUG)
        {
            print("Total Creation time:" + (float)(endTime - startTime));
            print("Chunk Creation time: " + m_totalChunkCreationTime);
            print("Mesh Creation time:" + m_totalMeshCreationTime);
            print("Number of chunks generated: " + m_chunkList.Count);

            print("Chunks per second: " + (float)(m_chunkList.Count / m_totalChunkCreationTime));
        }
    }