Пример #1
0
        // Add texture to the mapping
        public void addTexture(AtlasTexture texture)
        {
            float xDiv = (texture.uvSubDivisions.x > 0) ? texture.uvSubDivisions.x : 1;
            float yDiv = (texture.uvSubDivisions.y > 0) ? texture.uvSubDivisions.y : 1;

            float subSizeX = 1.0f / xDiv;
            float subSizeY = 1.0f / yDiv;

            float textelOffset = subSizeX / 64.0f;

            // create a map entry for every atlas image, increment count
            for (uint i = 0; i < xDiv; ++i)
            {
                for (uint p = 0; p < yDiv; ++p)
                {
                    TileTexture vTexture = new TileTexture();
                    vTexture.material = texture.material;

                    // Bottom Left
                    vTexture.textureCoords[0].x = (i * subSizeX) + textelOffset;
                    vTexture.textureCoords[0].y = (p * subSizeY) + textelOffset;

                    // Top Left
                    vTexture.textureCoords[1].x = (i * subSizeX) + textelOffset;
                    vTexture.textureCoords[1].y = ((p * subSizeY) + subSizeY) - textelOffset;

                    // Top Right
                    vTexture.textureCoords[2].x = ((i * subSizeX) + subSizeX) - textelOffset;
                    vTexture.textureCoords[2].y = ((p * subSizeY) + subSizeY) - textelOffset;

                    // Bottom Right
                    vTexture.textureCoords[3].x = ((i * subSizeX) + subSizeX) - textelOffset;
                    vTexture.textureCoords[3].y = (p * subSizeY) + textelOffset;

                    this.voxelDataMap.Add(_textureIDCount, vTexture);

                    _textureIDCount++;
                }
            }
        }
Пример #2
0
 public void setTexture(TileTexture Texture)
 {
     this.material = Texture;
 }