Jump to content

use of 3d mouse


photo

Recommended Posts

Yes, it is possible, but you will need to implement custom input handling via C++ API. As for the editor, it is written in Unigine script, so it is fully customizable.

Link to comment

There might be an alternative approach for 3DConnexion SpaceMouse by using their new 3DxWare software. After installation 3D mouse movements can emulate key strokes, so existing keyboard player movement can be used. Nevertheless for propper use within Unigine editor some editor script modifications where neccessary as far as I can remenber (I think for propper mapping of editor camera rotation or so)

Link to comment

Had a look in my old code and actually SpaceMouse editor support used joystick emulation mode of 3DxWare. Required some modifcations of editor script file data/core/editor/editor_controls.h. Something like the following snippets

 

namespace Controls {

.....

ControlsJoystick joystick;

void control() {

// mouse controls

.....

// impulse
vec3 impulse = vec3_zero;

// joystick control
if( joystick != NULL )
{
   	joystick.updateEvents();

   	float x_lin = joystick.getAxis(6);
   	float y_lin = joystick.getAxis(5);
   	float z_lin = joystick.getAxis(4);

   	if 	( y_lin >  0.1f ) 	impulse += z * ( y_lin - 0.1f );
   	else if( y_lin < -0.1f ) 	impulse += z * ( y_lin + 0.1f );

   	if 	( x_lin >  0.1f ) 	impulse += x * ( x_lin - 0.1f );
   	else if( x_lin < -0.1f ) 	impulse += x * ( x_lin + 0.1f );

   	if 	( z_lin >  0.1f ) 	impulse += y * ( z_lin - 0.1f );
   	else if( z_lin < -0.1f ) 	impulse += y * ( z_lin + 0.1f );

   	float x_rot = joystick.getAxis(3);
   	float z_rot = joystick.getAxis(1);

   	if 	( x_rot >  0.1f )  theta -= 60.0f * ( x_rot - 0.1f ) * ifps;   
   	else if( x_rot < -0.1f )  theta -= 60.0f * ( x_rot + 0.1f ) * ifps;

   	if 	( z_rot >  0.1f )  phi   += 60.0f * ( z_rot - 0.1f ) * ifps;   
   	else if( z_rot < -0.1f )  phi   += 60.0f * ( z_rot + 0.1f ) * ifps;
}

// keyboard controls

....
}

/*

 */

void init() {
....

  	for( int i=0; i<16; i++ ) {
       	joystick = new ControlsJoystick(i);

       	if( joystick != NULL && joystick.isAvailable() )
       	{
           	break;
       	}

       	delete joystick; joystick = NULL;
   	}

 control();

}

void shutdown() {
....
   	delete joystick;
}

Link to comment
×
×
  • Create New...