From 7d99a4ded9d3d24c24ea2d5bcc488469cf60fa4a Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 25 Jun 2014 15:47:30 -0700 Subject: BGE: New Mouse Actuator Disclaimer: The author of this patch is Geoffrey Gollmer (gomer). I only updated the patch to the current git master status, reworked several parts to fit well with current coding style and applied several fixes. This actuator allows users to show/hide the mouse cursor using logic bricks, as well as control object rotation with a mouse in the BGE. The mouse rotation is flexible enough to allow any type of mouse look, as well as banking for flight controls. {F94520} {F91859} Blend file for testing Mouse actuator (with default parameters and crosshair): {F94920} Reviewers: moguri Reviewed By: moguri CC: gomer, lordodin Differential Revision: https://developer.blender.org/D559 --- source/blender/editors/space_logic/logic_window.c | 68 +++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'source/blender/editors/space_logic') diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 7f0fadc07ef..b52d6265800 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -519,6 +519,8 @@ static const char *actuator_name(int type) return N_("Armature"); case ACT_STEERING: return N_("Steering"); + case ACT_MOUSE: + return N_("Mouse"); } return N_("Unknown"); } @@ -2177,6 +2179,68 @@ static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr) } } +static void draw_actuator_mouse(uiLayout *layout, PointerRNA *ptr) +{ + uiLayout *row, *col, *subcol, *split, *subsplit; + + uiItemR(layout, ptr, "mode", 0, NULL, 0); + + switch (RNA_enum_get(ptr, "mode")) { + case ACT_MOUSE_VISIBILITY: + row = uiLayoutRow(layout, 0); + uiItemR(row, ptr, "visible", UI_ITEM_R_TOGGLE, NULL, 0); + break; + + case ACT_MOUSE_LOOK: + /* X axis */ + row = uiLayoutRow(layout, 0); + col = uiLayoutColumn(row, 1); + + uiItemR(col, ptr, "use_axis_x", UI_ITEM_R_TOGGLE, NULL, 0); + + subcol = uiLayoutColumn(col, 1); + uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_axis_x")==1); + uiItemR(subcol, ptr, "sensitivity_x", 0, NULL, 0); + uiItemR(subcol, ptr, "threshold_x", 0, NULL, 0); + + uiItemR(subcol, ptr, "min_x", 0, NULL, 0); + uiItemR(subcol, ptr, "max_x", 0, NULL, 0); + + uiItemR(subcol, ptr, "object_axis_x", 0, NULL, 0); + + /* Y Axis */ + col = uiLayoutColumn(row, 1); + + uiItemR(col, ptr, "use_axis_y", UI_ITEM_R_TOGGLE, NULL, 0); + + subcol = uiLayoutColumn(col, 1); + uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_axis_y")==1); + uiItemR(subcol, ptr, "sensitivity_y", 0, NULL, 0); + uiItemR(subcol, ptr, "threshold_y", 0, NULL, 0); + + uiItemR(subcol, ptr, "min_y", 0, NULL, 0); + uiItemR(subcol, ptr, "max_y", 0, NULL, 0); + + uiItemR(subcol, ptr, "object_axis_y", 0, NULL, 0); + + /* Lower options */ + row = uiLayoutRow(layout, 0); + split = uiLayoutSplit(row, 0.5, 0); + + subsplit = uiLayoutSplit(split, 0.5, 1); + uiLayoutSetActive(subsplit, RNA_boolean_get(ptr, "use_axis_x")==1); + uiItemR(subsplit, ptr, "local_x", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(subsplit, ptr, "reset_x", UI_ITEM_R_TOGGLE, NULL, 0); + + subsplit = uiLayoutSplit(split, 0.5, 1); + uiLayoutSetActive(subsplit, RNA_boolean_get(ptr, "use_axis_y")==1); + uiItemR(subsplit, ptr, "local_y", UI_ITEM_R_TOGGLE, NULL, 0); + uiItemR(subsplit, ptr, "reset_y", UI_ITEM_R_TOGGLE, NULL, 0); + + break; + } +} + static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *box; @@ -2241,6 +2305,10 @@ static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) break; case ACT_STEERING: draw_actuator_steering(box, ptr); + break; + case ACT_MOUSE: + draw_actuator_mouse(box, ptr); + break; } } -- cgit v1.2.3