Programming wand buttons

Discussion in 'Technical support' started by goreckibdg, Aug 29, 2016.

  1. goreckibdg New Member

    Hi,
    I would like to ask how to program wand buttons in Quazar to create simple interaction with objects like enable/disable lights or open/close doors? Is it possible to do all of this by using flowgraph?
  2. michal.twardowski Moderator

    First, the wand should be visible as a device of type VRPN Button in the Controls -> Devices tab of the Quazar3D Immersive Manager. Make sure that this is working and that as you press wand buttons you can see it in the Controls -> Devices tab. Then within the Controls tab, switch to the Control state trigger section ( at the bottom of the window ). Now choose the ‘Add control state trigger’ button. You will see that the control state trigger has been inserted. Choose the right device in the first combo box ( wand button device ), set the number of the button that you want to use. In the end, from the second checkbox choose the control state that you will use in your application. Just make sure that the control state that you choose is not in the conflict state with any previously added control state triggers. Now whenever you press the choosen wand button the control state will be changed and sent to the application and you should also see the log message about control state change in the console at the bottom of the Quazar3D Immersive Manager.

    Inside the application you check the control state in the following way:
    Int engine.controls.getState(int state);
    As a state parameter you can pass an integer or you can use engine defines such as CONTROLS_STATE_FORWARD, CONTROLS_STATE_BACKWARD, etc.

    For more information please refer to the script manual ( where you can find the documentation of other engine.controls.* functions ) and scripts from the cave template ( eg CaveLaser.QSF where this method is used to change the color of the cave laser upon the press of one of the wands buttons).
  3. screame3r New Member

    Hi, I've got similar problem. I would like to add an action on pressing the same button that changes the color of the cave laser.
    I'm working on the CaveLaser.QSF file. My code looks like this:
    Code:
    [...]
    ObjectMeshDynamic ray = class_cast("ObjectMeshDynamic", m_ray);
    if(ray!=NULL)
    {
    m_Fired = engine.controls.getState(m_WandFireControl);
    if (m_Fired){
      ray.setMaterialParameter("color_scale", m_ColorFired, 0);
      int ret[4];
      Object actiontest=engine.world.getIntersection(getP0(),getP1(),1,ret);
      if(actiontest!=NULL){
      actiontest.setEnabled(0);
      }
    }
      else [...]
    Rest of the code isn't changed from the original CaveLaser.QSF, so getP0() and getP1() are taken straight from controller readings.

    The goal I'm trying to achieve is to disable an object after pointing at it and pressing the "fire" button.
    All my objects's masks are set to 00000001, and their "Mask Dialog" is set to 0.
    Objects won't disappear though. Why is this code wrong? I can't type "ffffffff" in "int mask" because ffffffff is not an int. (engine.world.getIntersection function)
    Parsing ffffffff to an int causes whole program to crash.

Share This Page