Exemplo n.º 1
0
        public void Initialize(Vector2 position, Vector2 windowSize, float chunkWorldSize)
        {
            m_renderWindow = new SlidingWindow(position, windowSize, Vector2.zero, Vector2.one * chunkWorldSize);

            m_rect       = m_renderWindow.GetWindow();
            m_windowSize = m_rect.size;

            m_chunks = new VoxelChunk[m_windowSize.x * m_windowSize.y];
            m_dirty  = new bool[m_chunks.Length];

            for (int y = 0; y < m_windowSize.y; y++)
            {
                for (int x = 0; x < m_windowSize.x; x++)
                {
                    int cx = m_rect.origin.x + x;
                    int cy = m_rect.origin.y + y;

                    VoxelChunk chunk = VoxelChunk.Create(transform, string.Format("[{0},{1}]", cx, cy), m_settings, m_chunkSize + 1, m_chunkSize + 1);

                    float chunkX = cx * m_settings.voxelSize * m_chunkSize;
                    float chunkY = cy * m_settings.voxelSize * m_chunkSize;

                    chunk.nextPosition = new Vector3(chunkX, chunkY);

                    m_chunks[y * m_windowSize.x + x] = chunk;
                }
            }
        }
Exemplo n.º 2
0
        public void Slide(Vector2 newPosition)
        {
            IntPoint delta = m_renderWindow.Slide(newPosition);

            m_rect = m_renderWindow.GetWindow();

            m_windowShift.x += delta.x;
            m_windowShift.y += delta.y;
        }