UPBGE / upbge

UPBGE, the best integrated game engine in Blender
https://upbge.org
Other
1.39k stars 177 forks source link

Seek advice on new sensor integration #1784

Closed wetoo-cando closed 1 year ago

wetoo-cando commented 1 year ago

Dear UPBGE-devs,

I would like to integrate a new sensor that gives full and continuous 6DoF (x,y,z and rotation rx,ry,rz) control over object poses. A haptic device such as the Geomagic touch (https://www.3dsystems.com/haptics-devices/touch-x) could be used to control the 6DoFs.

For haptic device drivers, the Chai3d C++ library could be used.

Now I am trying to understand how the integration on the UPBGE side should look like. I looked at the SCA_MouseSensor as a reference. The mouse sensor has a movement mode, where the 2D (x,y) co-ordinates are read into upbge.

In SCA_MouseSensor.cpp:

mousedev->GetInput(SCA_IInputDevice::MOUSEX);
mousedev->GetInput(SCA_IInputDevice::MOUSEY);

where GetInput() is defined in SCA_IInputDevice.cpp as:

SCA_InputEvent &SCA_IInputDevice::GetInput(SCA_IInputDevice::SCA_EnumInputs inputcode)
{
  return m_inputsTable[inputcode];
}

However I could not trace how/where this m_inputsTable gets filled with mouse (x, y) values. Can anyone help me understand this?

Thank you!

wetoo-cando commented 1 year ago

Ok I think I figured out how the mouse sensor works. The mouse cursor events are caught by the blender GHOST module, the mouse position is extracted from the event, and the m_inputsTable is updated. Here is the call stack:

image

The mouse, being a standard input device for PCs (next to the keyboard) is handled at the OS-level. Perhaps the Joystick code is a better reference for my objective rather than the mouse. I'll look into that now.

youle31 commented 1 year ago

Hi, sorry for not being helpful but it would require investigations and work and i've not motivation. I will convert this to discussion as we keep this place for bug reports. Thanks for comprehension.