question

Raashid Mohammed avatar image
0 Likes"
Raashid Mohammed asked Phil BoBo commented

Use Xbox controller to move the gameview operator

Hi

Model in the link below. It converts the operator into game mode where operator can move using keyboard up,down,left and right button

see link for more info

https://answers.flexsim.com/questions/30134/is-there-a-way-to-create-a-game-in-flexsim.html

Is there a way I can move the operator using Xbox controller in VR mode. both first and third person view

Thanks

Raashid

Choose One
vrxbox
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
6 Likes"
Phil BoBo answered Phil BoBo commented

Attached is an updated version of the model from the original question, modified to use the Xbox Input code from the default Perspective View in the custom 3D Game View.

That game model was purposefully built with a minimal amount of extra stuff in it so that it is easier to understand. Adding Xbox Inputs adds more complexity to the code, as described below:

The things added to this version to make the xbox input work:

  1. OnPreOpen was added to the view that calls stick(num, 20) to determine what xbox controllers are connected to the computer.
  2. Variables were added to the Perspective view to store what xbox controllers are connected and their last update time.
  3. A function called XboxInput was added with custom code to read the xbox inputs and use them to move the operator and viewpoint.
  4. OnPreDraw was updated to call the XboxInput function.
  5. The code to load/unload an item was moved to its own function so that the xbox A button and the spacebar handler can both call the function.

To handle Xbox input, I copied and modified stuff from the existing Perspective view code that is in the tree at VIEW:/standardviews/documentwindows/Perspective>eventfunctions/XboxInput

If you don't understand how referencing in the tree works, then this type of development may be more advanced than you can do by yourself right now. You may want to contact FlexSim for additional training or consulting work.


· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Raashid Mohammed avatar image Raashid Mohammed commented ·

Thanks Phil

We do have a PO for training for FLEXSIM. thinking of taking it on month of December

looks like it works. the GUI does not work for VR MODE

Is there a way we can also add VR mode to the perceptive view

Thanks

Raashid

I have OCULUS RIFT

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Raashid Mohammed commented ·

Attached is an updated version that adds a VR Mode button that turns on the Oculus Rift for the Perspective view in the custom Game View.

Changes in this version:

The button calls applicationcommand("switchviewvrmode", view, getchecked(c)), which toggles VR Mode on the specified view.

The XboxInput function handles re-centering the headset when you press the Back button:

if (wButtons & XINPUT_GAMEPAD_BACK)
    applicationcommand("recenteroculusrift");

The OnPreDraw sets a timer to repaint the view with the function IdleRepaint when in VR Mode or an Xbox controller is connected. (This makes the view continuously repaint when the model isn't running.)

1 Like 1 ·
Raashid Mohammed avatar image Raashid Mohammed Phil BoBo ♦♦ commented ·

Thanks Phil

This is super cool. the extent on what flexsim can do is mind boggling

Only thing is the when I move the right toggle thumb to turn and watch, the left toggle turns is right and right toggle turns it left. look like they are switched

Thanks again for everything so far

Regards

Raashid

0 Likes 0 ·
Show more comments
Ralf Gruber avatar image
0 Likes"
Ralf Gruber answered Raashid Mohammed edited

Raashid,

have you seen this:

https://answers.flexsim.com/questions/30260/how-i-can-use-and-configure-the-xbox-controller-in.html

This describes where the logic can be found to manipulate control through Xbox controller.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Raashid Mohammed avatar image Raashid Mohammed commented ·

Yes I did

I don't really understand what below sentence means in the answer

"If you want to change what the controller sticks and buttons do, you can modify the FlexScript code in the node VIEW:/standardviews/documentwindows/Perspective>eventfunctions/XboxInput"

But this is more on how can I link the xbox controller to the custom GUI

Thanks for quick reponse

Raashid

0 Likes 0 ·