lightmap Posted July 4, 2018 Share Posted July 4, 2018 (edited) Hello unigine 2.6.1 Create new empty c# project with vive plugin in public override int update() vec3 rv = Engine.get().runSystemFunction(new Variable("engine.vive.getControllerAxis"), new Variable(CONTROLLER_1), new Variable(CONTROLLER_AXIS_TRIGGER)).getVec3(); generates SEH Exception ! unlike this vec3 rv = Engine.get().runSystemFunction(new Variable("engine.vive.getDeviceVelocity"), new Variable(CONTROLLER_1)).getVec3(); generate no exceptions and returns some values vel 0,4556353 0,2165436 -1,201193 vel 0,5641288 0,2463633 -1,367568 vel 0,6263584 0,2581863 -1,44864 vel 0,7627151 0,2662821 -1,574767 vel 0,8405584 0,2536594 -1,624116 vel 0,9596373 0,2368724 -1,675604 vel 1,077188 0,2213359 -1,701966 vel 1,153416 0,2082534 -1,712195 vel 1,267702 0,1811903 -1,723481 vel 1,38089 0,1434988 -1,733821 vel 1,492906 0,09428582 -1,739649 vel 1,566095 0,05679275 -1,732 vel 1,668913 -0,003157673 -1,721756 vel 1,760774 -0,0640329 -1,700686 vel 1,845973 -0,1249946 -1,668746 How to receive 'getControllerAxis' values in c# for vive ? ok - it should return vec2? but have no method .getVec2() or how to translate to csharp this reflection = std::make_shared<Reflection>(interpreter, Variable("engine.vive")); Edited July 4, 2018 by lightmap Link to comment
silent Posted July 4, 2018 Share Posted July 4, 2018 Hi lightmap! This is bug in C# Wrapper - it's missing vec2/dvec2/ivec2 set/get methods. That's why you are getting this errors. Fix will be available in 2.7.2 SDK update. The only workaround availble is to use UnigineScript in combination with C#. Make some functions in the world UnigineScript file like it: vec3 getControllerAxis(int device, int axis) { return vec3(engine.vive.getControllerAxis(device, axis)); } And call it inside C# like this: Variable result_var = Engine.get().runWorldFunction(new Variable("getControllerAxis"), new Variable(device), new Variable(axis)); vec3 result_vec3 = result_var.getVec3(); Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lightmap Posted July 4, 2018 Author Share Posted July 4, 2018 thank you I recompiled AppVive and changed getControllerAxis prototype to vec3 also some defines seems wrong, ex: CONTROLLER_AXIS_TRACKPAD = 1; GetControllerAxis(CONTROLLER_1, CONTROLLER_AXIS_TRACKPAD); - track pad has no effect, but trigger has so defines become public const int CONTROLLER_AXIS_TRACKPAD = 0;//1; public const int CONTROLLER_AXIS_TRIGGER = 1;//3; Link to comment
unclebob Posted July 6, 2018 Share Posted July 6, 2018 Hi there! Please don't change these constants as they're actually axes types, not numbers or ids. The thing is that openvr API doesn't provide any semantics for their controller axes, so they are indexed from 0 to 4 and that's it. Unfortunately, you have to hardcode axes semantics in your app. Link to comment
lightmap Posted July 6, 2018 Author Share Posted July 6, 2018 (edited) Hello so there no defines for trigger and trackpad axes then ? public const int MAX_TRACKED_DEVICE_COUNT = 16; public const int TRACKED_DEVICE_INVALID = 0; public const int TRACKED_DEVICE_HMD = 1; public const int TRACKED_DEVICE_CONTROLLER = 2; public const int TRACKED_DEVICE_TRACKING = 4; public const int TRACKED_DEVICE_OTHER = 1000; public const int CONTROLLER_AXIS_NONE = 0; public const int CONTROLLER_AXIS_TRACKPAD = 1; public const int CONTROLLER_AXIS_JOYSTICK = 2; public const int CONTROLLER_AXIS_TRIGGER = 3; public const int CONTROLLER_STATE_AXIS_COUNT = 5; public const int BUTTON_SYSTEM = 0; public const int BUTTON_APPLICATIONMENU = 1; public const int BUTTON_GRIP = 2; public const int BUTTON_DPAD_LEFT = 3; public const int BUTTON_DPAD_UP = 4; public const int BUTTON_DPAD_RIGHT = 5; public const int BUTTON_DPAD_DOWN = 6; public const int BUTTON_A = 7; public const int BUTTON_STEAMVR_TOUCHPAD = 32; public const int BUTTON_STEAMVR_TRIGGER = 33; public const int BUTTON_DASHBOARD_BACK = 2; public const int BUTTON_MAX = 64; public const int BUTTON_AXIS0 = 32; public const int BUTTON_AXIS1 = 33; public const int BUTTON_AXIS2 = 34; public const int BUTTON_AXIS3 = 35; public const int BUTTON_AXIS4 = 36; and I must add constants like CONTROLLER_TRACKPAD_AXIS_ID = 0; CONTROLLER_TRIGGER_AXIS_ID = 1; and where then CONTROLLER_AXIS_TRACKPAD=1 should be used? same for BUTTON_AXIS0.. - for what it is - it may be universal for steamvr controllers but now more important is advice on engine.shutdown() memory releasing https://developer.unigine.com/forum/topic/4918-engine-shutdown-do-not-release-all-memory/ thanks Edited July 6, 2018 by lightmap Link to comment
Recommended Posts