Jump to content

Handing input controls while Editor running application logic


photo

Recommended Posts

Hi,

While Editor is running and application logic is on, I would like to handle input from keyboard.

Currently I am using a "Usage Example\Basic Object Movements" example from documentation 

int init() 
{
  engine.visualizer.setEnabled(1);
  Player player = new PlayerSpectator();
  player.setPosition(Vec3(0.0f,-3.401f,1.5f));
  player.setDirection(Vec3(0.0f,1.0f,-0.4f));
  engine.game.setPlayer(player);
  
  int index = engine.editor.findNode("Player");
  if (index != -1) 
  {
    sphere = engine.editor.getNode(index);
  }
  
  engine.controls.setStateKey(CONTROLS_STATE_AUX_0, 'p');
  return 1;
}

// start of the main loop
int update() 
{
  if (sphere != NULL)
  {
    float ifps = engine.game.getIFps();
    float angle = ifps * 90.0f;
    
    // get the current world transform matrix of the mesh
    Mat4 worldTransform = sphere.getWorldTransform();
    
    // get the direction vector
    Vec3 direction = Vec3(worldTransform.col1);
    
    engine.visualizer.renderDirection(sphere.getWorldPosition(), vec3(direction), vec4(1.0f, 0.0f, 0.0f, 1.0f), 0.1f, 0);
    
    if (engine.controls.getState(CONTROLS_STATE_AUX_0))
    {
      Vec3 delta_movement = direction * movement_speed * ifps;
      sphere.setWorldPosition(sphere.getWorldPosition() + delta_movement);
    }
    
    mat4 transform = sphere.getTransform() * rotateZ(angle);
    sphere.setTransform(transform);
  }
  return 1;
}

 

but input is ignored when I am running a project in Editor.

If I run the project from the DSK browser it works as expected.

How can I handle the same input while the editor is executing application logic. Otherwise I have to keep running the project which is not the best experience while developing?

 

Thanks,

Andrew

Link to comment
×
×
  • Create New...