Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Minimap::blitMinimapPixelsToImageRadar(video::IImage *map_image)
- {
- int halfmap = data->map_size / 2;
- int reticleSize = data->map_size * 0.3;
- int reticleSize2 = data->map_size - reticleSize;
- int reticleSizeN = data->map_size * 0.8;
- video::SColor c(240, 0, 0, 0);
- for (s16 x = 0; x < data->map_size; x++)
- for (s16 z = 0; z < data->map_size; z++) {
- MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];
- if ((z > reticleSizeN) && (x == halfmap))
- c.setGreen(255); // North
- else if ((x > reticleSize2) && (z == halfmap))
- c.setGreen(160); // East
- else if ((z < reticleSize) && (x == halfmap))
- c.setGreen(120); // South
- else if ((x < reticleSize) && (z == halfmap))
- c.setGreen(160); // West
- else if ((x == halfmap) && (z == halfmap))
- c.setGreen(0); // Player dot
- else if (mmpixel->air_count > 0)
- c.setGreen(core::clamp(core::round32(32 + mmpixel->air_count * 8), 0, 255));
- else
- c.setGreen(0);
- map_image->setPixel(x, data->map_size - z - 1, c);
- }
- }
- void Minimap::blitMinimapPixelsToImageSurface(
- video::IImage *map_image, video::IImage *heightmap_image)
- {
- int halfmap = data->map_size / 2;
- int reticleSize = data->map_size * 0.3;
- int reticleSize2 = data->map_size - reticleSize;
- int reticleSizeN = data->map_size * 0.8;
- // This variable creation/destruction has a 1% cost on rendering minimap
- video::SColor tilecolor;
- for (s16 x = 0; x < data->map_size; x++)
- for (s16 z = 0; z < data->map_size; z++) {
- MinimapPixel *mmpixel = &data->minimap_scan[x + z * data->map_size];
- const ContentFeatures &f = m_ndef->get(mmpixel->n);
- const TileDef *tile = &f.tiledef[0];
- // Color of the 0th tile (mostly this is the topmost)
- if(tile->has_color)
- tilecolor = tile->color;
- else
- mmpixel->n.getColor(f, &tilecolor);
- if ((z > reticleSizeN) && (x == halfmap))
- tilecolor.set(240, 0, 255, 0); // North
- else if ((x > reticleSize2) && (z == halfmap))
- tilecolor.set(240, 0, 160, 0); // East
- else if ((z < reticleSize) && (x == halfmap))
- tilecolor.set(240, 0, 120, 0); // South
- else if ((x < reticleSize) && (z == halfmap))
- tilecolor.set(240, 0, 160, 0); // West
- else if ((x == halfmap) && (z == halfmap))
- tilecolor.set(240, 0, 255, 0); // Player dot
- else tilecolor.set(240,
- tilecolor.getRed() * f.minimap_color.getRed() / 255,
- tilecolor.getGreen() * f.minimap_color.getGreen() / 255,
- tilecolor.getBlue() * f.minimap_color.getBlue() / 255 );
- map_image->setPixel(x, data->map_size - z - 1, tilecolor);
- u32 h = mmpixel->height;
- heightmap_image->setPixel(x,data->map_size - z - 1,
- video::SColor(255, h, h, h));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement