diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-05 19:11:34 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-05 19:11:34 +0000 |
| commit | 91e4c2252b1a07df013cde773d1cead3712bca43 (patch) | |
| tree | 29af0b7c51da9ef48b0c2d66f779f3b43a755e64 | |
| parent | da2d792186d53794d25438c157ac039adbb8c1a6 (diff) | |
| download | zcatch-91e4c2252b1a07df013cde773d1cead3712bca43.tar.gz zcatch-91e4c2252b1a07df013cde773d1cead3712bca43.zip | |
added rotate to editor. fixed so that the game handles envelopes
| -rw-r--r-- | data/maps/dm1.map | bin | 3448 -> 4399 bytes | |||
| -rw-r--r-- | src/game/client/gc_render.cpp | 18 | ||||
| -rw-r--r-- | src/game/client/gc_render_map.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/gc_render_obj.cpp | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 24 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.hpp | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_layer_quads.cpp | 29 |
7 files changed, 75 insertions, 2 deletions
diff --git a/data/maps/dm1.map b/data/maps/dm1.map index d595402a..9c00f947 100644 --- a/data/maps/dm1.map +++ b/data/maps/dm1.map Binary files differdiff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp index 285b6c1c..f201a87c 100644 --- a/src/game/client/gc_render.cpp +++ b/src/game/client/gc_render.cpp @@ -261,6 +261,24 @@ static void envelope_eval(float time_offset, int env, float *channels) channels[1] = 0; channels[2] = 0; channels[3] = 0; + + ENVPOINT *points; + + { + int start, num; + map_get_type(MAPITEMTYPE_ENVPOINTS, &start, &num); + if(num) + points = (ENVPOINT *)map_get_item(start, 0, 0); + } + + int start, num; + map_get_type(MAPITEMTYPE_ENVELOPE, &start, &num); + + if(env >= num) + return; + + MAPITEM_ENVELOPE *item = (MAPITEM_ENVELOPE *)map_get_item(start+env, 0, 0); + render_eval_envelope(points+item->start_point, item->num_points, 4, client_localtime()+time_offset, channels); } void render_layers(float center_x, float center_y, int pass) diff --git a/src/game/client/gc_render_map.cpp b/src/game/client/gc_render_map.cpp index 4728f771..d5e7f1a0 100644 --- a/src/game/client/gc_render_map.cpp +++ b/src/game/client/gc_render_map.cpp @@ -102,7 +102,7 @@ void render_quads(QUAD *quads, int num_quads, void (*eval)(float time_offset, in eval(q->pos_env_offset/1000.0f, q->pos_env, channels); offset_x = channels[0]; offset_y = channels[1]; - rot = channels[2]; + rot = channels[2]/360.0f*pi*2; } if(q->color_env >= 0) diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp index 1e1d6430..39705444 100644 --- a/src/game/client/gc_render_obj.cpp +++ b/src/game/client/gc_render_obj.cpp @@ -380,7 +380,7 @@ void render_player( if (player.weapon == WEAPON_HAMMER) { // Static position for hammer - p = position; + p = position + vec2(state.attach.x, state.attach.y); p.y += data->weapons[iw].offsety; // if attack is under way, bash stuffs if(direction.x < 0) diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 5e530ea8..3d1b5320 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -430,6 +430,30 @@ static void do_toolbar(RECT toolbar) for(int i = 0; i < brush.layers.len(); i++) brush.layers[i]->brush_flip_y(); } + + // rotate buttons + ui_vsplit_l(&toolbar, 20.0f, &button, &toolbar); + + ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar); + static int rotation_amount = 90; + rotation_amount = ui_do_value_selector(&rotation_amount, &button, "", rotation_amount, 1, 360, 2.0f); + + ui_vsplit_l(&toolbar, 5.0f, &button, &toolbar); + ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar); + static int ccw_button = 0; + if(do_editor_button(&ccw_button, "CCW", enabled, &button, draw_editor_button_l, 0, "[R] Rotates the brush counter clockwise") || inp_key_down('R')) + { + for(int i = 0; i < brush.layers.len(); i++) + brush.layers[i]->brush_rotate(-rotation_amount/360.0f*pi*2); + } + + ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar); + static int cw_button = 0; + if(do_editor_button(&cw_button, "CW", enabled, &button, draw_editor_button_r, 0, "[T] Rotates the brush clockwise") || inp_key_down('T')) + { + for(int i = 0; i < brush.layers.len(); i++) + brush.layers[i]->brush_rotate(rotation_amount/360.0f*pi*2); + } } // quad manipulation diff --git a/src/game/editor/ed_editor.hpp b/src/game/editor/ed_editor.hpp index 2bbc4e08..cddc9c92 100644 --- a/src/game/editor/ed_editor.hpp +++ b/src/game/editor/ed_editor.hpp @@ -147,6 +147,7 @@ public: virtual void brush_place(LAYER *brush, float x, float y) {} virtual void brush_flip_x() {} virtual void brush_flip_y() {} + virtual void brush_rotate(float amount) {} virtual void render() {} virtual int render_properties(RECT *toolbox) { return 0; } @@ -450,6 +451,7 @@ public: virtual void brush_place(LAYER *brush, float wx, float wy); virtual void brush_flip_x(); virtual void brush_flip_y(); + virtual void brush_rotate(float amount); virtual int render_properties(RECT *toolbox); diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp index 316d2e1f..da7e70b8 100644 --- a/src/game/editor/ed_layer_quads.cpp +++ b/src/game/editor/ed_layer_quads.cpp @@ -157,6 +157,35 @@ void LAYER_QUADS::brush_flip_y() { } +void rotate(vec2 *center, vec2 *point, float rotation) +{ + float x = point->x - center->x; + float y = point->y - center->y; + point->x = x * cosf(rotation) - y * sinf(rotation) + center->x; + point->y = x * sinf(rotation) + y * cosf(rotation) + center->y; +} + +void LAYER_QUADS::brush_rotate(float amount) +{ + vec2 center; + get_size(¢er.x, ¢er.y); + center.x /= 2; + center.y /= 2; + + for(int i = 0; i < quads.len(); i++) + { + QUAD *q = &quads[i]; + + for(int p = 0; p < 5; p++) + { + vec2 pos(fx2f(q->points[p].x), fx2f(q->points[p].y)); + rotate(¢er, &pos, amount); + q->points[p].x = f2fx(pos.x); + q->points[p].y = f2fx(pos.y); + } + } +} + void LAYER_QUADS::get_size(float *w, float *h) { *w = 0; *h = 0; |