broke out nether, heightfading, depth, and edgelines from base primitive
This commit is contained in:
68
overviewer_core/src/primitives/height-fading.c
Normal file
68
overviewer_core/src/primitives/height-fading.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
typedef struct {
|
||||
PyObject *black_color;
|
||||
PyObject *white_color;
|
||||
} PrimitiveHeightFading;
|
||||
|
||||
static int
|
||||
height_fading_start(void *data, RenderState *state, PyObject *support) {
|
||||
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
||||
|
||||
self->black_color = PyObject_GetAttrString(support, "black_color");
|
||||
self->white_color = PyObject_GetAttrString(support, "white_color");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
height_fading_finish(void *data, RenderState *state) {
|
||||
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
||||
|
||||
Py_DECREF(self->black_color);
|
||||
Py_DECREF(self->white_color);
|
||||
}
|
||||
|
||||
static void
|
||||
height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
||||
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
||||
|
||||
/* do some height fading */
|
||||
PyObject *height_color = self->white_color;
|
||||
|
||||
/* negative alpha => darkness, positive => light */
|
||||
float alpha = (1.0 / (1 + expf((70 - state->z) / 11.0))) * 0.6 - 0.55;
|
||||
|
||||
if (alpha < 0.0) {
|
||||
alpha *= -1;
|
||||
height_color = self->black_color;
|
||||
}
|
||||
|
||||
alpha_over_full(state->img, height_color, mask_light, alpha, state->imgx, state->imgy, 0, 0);
|
||||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_height_fading = {
|
||||
"height-fading", sizeof(PrimitiveHeightFading),
|
||||
height_fading_start,
|
||||
height_fading_finish,
|
||||
NULL,
|
||||
NULL,
|
||||
height_fading_draw,
|
||||
};
|
||||
Reference in New Issue
Block a user