added basic mineral overlay
right now, it only highlights diamond ore
This commit is contained in:
2
setup.py
2
setup.py
@@ -55,7 +55,7 @@ except:
|
|||||||
pil_include = []
|
pil_include = []
|
||||||
|
|
||||||
# used to figure out what files to compile
|
# used to figure out what files to compile
|
||||||
render_modes = ['normal', 'overlay', 'lighting', 'night', 'spawn', 'cave']
|
render_modes = ['normal', 'overlay', 'lighting', 'night', 'spawn', 'cave', 'mineral']
|
||||||
|
|
||||||
c_overviewer_files = ['src/main.c', 'src/composite.c', 'src/iterate.c', 'src/endian.c', 'src/rendermodes.c']
|
c_overviewer_files = ['src/main.c', 'src/composite.c', 'src/iterate.c', 'src/endian.c', 'src/rendermodes.c']
|
||||||
c_overviewer_files += map(lambda mode: 'src/rendermode-%s.c' % (mode,), render_modes)
|
c_overviewer_files += map(lambda mode: 'src/rendermode-%s.c' % (mode,), render_modes)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extesion
|
// increment this value if you've made a change to the c extesion
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 5
|
#define OVERVIEWER_EXTENSION_VERSION 6
|
||||||
|
|
||||||
/* Python PIL, and numpy headers */
|
/* Python PIL, and numpy headers */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|||||||
104
src/rendermode-mineral.c
Normal file
104
src/rendermode-mineral.c
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Minecraft Overviewer.
|
||||||
|
*
|
||||||
|
* Minecraft Overviewer is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* Minecraft Overviewer is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "overviewer.h"
|
||||||
|
|
||||||
|
struct OreColor {
|
||||||
|
unsigned char blockid;
|
||||||
|
unsigned char r, g, b, a;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* put more valuable ores first -- they take precedence */
|
||||||
|
static struct OreColor orecolors[] = {
|
||||||
|
{56 /* Diamond Ore */, 32, 230, 220, 200},
|
||||||
|
|
||||||
|
/* end of list marker */
|
||||||
|
{0, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void get_color(void *data, RenderState *state,
|
||||||
|
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
||||||
|
|
||||||
|
int x = state->x, y = state->y, z_max = state->z, z;
|
||||||
|
//RenderModeMineral* self = (RenderModeMineral *)data;
|
||||||
|
*a = 0;
|
||||||
|
|
||||||
|
for (z = 0; z <= z_max; z++) {
|
||||||
|
int i, max_i = sizeof(orecolors) / sizeof(struct OreColor);
|
||||||
|
unsigned char blockid = getArrayByte3D(state->blocks, x, y, z);
|
||||||
|
|
||||||
|
for (i = 0; i < max_i && orecolors[i].blockid != 0; i++) {
|
||||||
|
if (orecolors[i].blockid == blockid) {
|
||||||
|
*r = orecolors[i].r;
|
||||||
|
*g = orecolors[i].g;
|
||||||
|
*b = orecolors[i].b;
|
||||||
|
*a = orecolors[i].a;
|
||||||
|
max_i = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rendermode_mineral_start(void *data, RenderState *state) {
|
||||||
|
RenderModeMineral* self;
|
||||||
|
|
||||||
|
/* first, chain up */
|
||||||
|
int ret = rendermode_overlay.start(data, state);
|
||||||
|
if (ret != 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* now do custom initializations */
|
||||||
|
self = (RenderModeMineral *)data;
|
||||||
|
|
||||||
|
/* setup custom color */
|
||||||
|
self->parent.get_color = get_color;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rendermode_mineral_finish(void *data, RenderState *state) {
|
||||||
|
/* first free all *our* stuff */
|
||||||
|
//RenderModeMineral* self = (RenderModeMineral *)data;
|
||||||
|
|
||||||
|
/* now, chain up */
|
||||||
|
rendermode_overlay.finish(data, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
rendermode_mineral_occluded(void *data, RenderState *state) {
|
||||||
|
/* no special occlusion here */
|
||||||
|
return rendermode_overlay.occluded(data, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rendermode_mineral_draw(void *data, RenderState *state, PyObject *src, PyObject *mask) {
|
||||||
|
/* draw normally */
|
||||||
|
rendermode_overlay.draw(data, state, src, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderModeInterface rendermode_mineral = {
|
||||||
|
"mineral", "draws a colored overlay showing where ores are located",
|
||||||
|
&rendermode_overlay,
|
||||||
|
sizeof(RenderModeMineral),
|
||||||
|
rendermode_mineral_start,
|
||||||
|
rendermode_mineral_finish,
|
||||||
|
rendermode_mineral_occluded,
|
||||||
|
rendermode_mineral_draw,
|
||||||
|
};
|
||||||
@@ -27,6 +27,7 @@ static RenderModeInterface *render_modes[] = {
|
|||||||
&rendermode_night,
|
&rendermode_night,
|
||||||
&rendermode_spawn,
|
&rendermode_spawn,
|
||||||
&rendermode_cave,
|
&rendermode_cave,
|
||||||
|
&rendermode_mineral,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -156,4 +156,11 @@ typedef struct {
|
|||||||
} RenderModeCave;
|
} RenderModeCave;
|
||||||
extern RenderModeInterface rendermode_cave;
|
extern RenderModeInterface rendermode_cave;
|
||||||
|
|
||||||
|
/* MINERAL */
|
||||||
|
typedef struct {
|
||||||
|
/* inherits from overlay */
|
||||||
|
RenderModeOverlay parent;
|
||||||
|
} RenderModeMineral;
|
||||||
|
extern RenderModeInterface rendermode_mineral;
|
||||||
|
|
||||||
#endif /* __RENDERMODES_H_INCLUDED__ */
|
#endif /* __RENDERMODES_H_INCLUDED__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user