Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » BAM corner




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: BAM - Camera contoled in script
 Post Posted: Tue Mar 20, 2018 7:03 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 898
beta BAM.dll: http://www.ravarcade.pl/beta/BAM.dll

Small warning.
Next weekend i have to move "ravarcade.pl" to another hosting service.
It may creates troubles with access to my site.

This feature require BAM_VERSION >= 198.

Part 1.
BEFORE YOU START DO ANYTHING WITH CAMERA IN SCRIPT.

xBAM.Camera.Mode
Simple read only property.
= 0 if game is running in "Desktop Mode"
= 1 if game is running in "Cab Mode" (Arcade Mode)
= 2 if game is running in "VR Mode"
Because you should not use in script "magic numbers" i added constants:
xBAM_Camera_Desktop = 0
xBAM_Camera_Cabinet = 1
xBAM_Camera_VR = 2
Script:
Code:
If xBAM.Camera.Mode = xBAM_Camera_Desktop Then
'  Do something if user plays in "Desktop Mode"
End If


xBAM.AspectRatio
Simple read only property.
Equal to screen width dived by screen height.
So, if you play on screen in res 1920 x 1080 then xBAM.AspectRatio is equal to 1.7777.. (16/9)
If you have rotated screen (in FP Video/Rendering Options) it will be equal to 0.5625 (9/16)

xBAM.ScriptControl
Simple read only property.
= True if script can change camera
= False if script can't change camera
I think, that user will be confused if something start to happend with game camera without warning. So, i belive script have to ASK user for permision to do anything with camera.
When game starts xBAM.ScriptControl= False.

xBAM.RequestForControl
Procedure. No params.
Script should call it, if xBAM.ScriptControl = False and want to take control on camera.
Code:
If xBAM.Camera.ScriptControl = FALSE Then
   xBAM.Camera.RequestForControl
End If

User will see:
Image
User can with fippers Allow or Deny.

Congratulation. Now you have 4 new thing in script and still cant do anything with camera.

Part 2.
DESKTOP MODE.

xBAM.Camera.DesktopSet eyeX, eyeY, eyeZ, atX, atY, atZ, FOV, delay
Procedure.
You can define camera with 3 things:
- point from where you look (eye)
- point you are looking at (at)
- field-of-view (fov)
last param, delay, is time in ms whan camera should be set.

Code:
xBAM.Camera.DesktopSet     232,   961.2,   373.8,     232,   694.2,       0,      80,     2000

Note. It will not do anything with camera if xBAM.ScriptControl = FALSE.

xBAM.Camera.DesktopRelease delay
Procedure.
One pram: delay in ms.
Most likely you will want to change camera only for some time. So, you will want to change camre back to settings used by user. This procedure allow you to "release camera" or give back control over it to FP/BAM.

Bigger example:
Code:
Sub FuturePinball_KeyPressed(ByVal KeyCode)
   If KeyCode >= 30 And KeyCode <= 33 And xBAM.Camera.ScriptControl = FALSE Then
      xBAM.Camera.RequestForControl
   End If

   If KeyCode = 30 Then
      xBAM.Camera.DesktopSet     232,   961.2,   373.8,     232,   694.2,       0,      80,     2000
   End If
   If KeyCode = 31 Then
      xBAM.Camera.DesktopSet   361.2,    1068,   480.6,     258,   640.8,       0,      60,     2000
   End If
   If KeyCode = 32 Then
      xBAM.Camera.DesktopSet       0,   854.4,   213.6,     258,   694.2,       0,      90,     2000
   End If
   If KeyCode = 33 Then
      xBAM.Camera.DesktopSet       0,   854.4,   213.6,     Bumper1.X, Bumper1.Y ,       0,      20,     1000
   End If
   If KeyCode = 34 Then
      xBAM.Camera.DesktopRelease 100
   End If

We use 4 keys: A,S,D,F and G.
A,S,D,F are used to set 1 of 4 predefined camera settings.
Note: In last "camera settings" you can see "Bumper1.X, Bumper1.Y". So, if you have Bumper1 on table, when camera will look at it.
G is used to release constol camera.
Also, when you press keys A,S,D,F and script don't have control over camer, user will see "request".

Finall tip.
In BAM menu you will find "Camera" menu. (only if menu type is "advanced" and you are in "Desktop Mode").
Here you can edit settings. You have 3 "global camera presets" (values stored in "BAM/reality.dat"). They are accessible on all tables and 3 "local camera presets" for current table (values are stored in "TableName.cfg").
You can prest CTRL-C. It will put in clipboard text ready to paste in script editor.

xBAM.Camera.DesktopSetLookAt eyeX, eyeY, eyeZ, atX, atY, atZ, FOV, delay
Procedure.
Same params as for xBAM.Camera.DesktopSet.
You can set different camera params for case, when user press TAB or LookAtBackbox is executed.
IMPORTANT! Call xBAM.Camera.DesktopSetLookAt right after xBAM.Camera.DesktopSet, because xBAM.Camera.DesktopSet will reset camare params.
Code sample:
Code:
Sub FuturePinball_KeyPressed(ByVal KeyCode)
   If KeyCode = 30 Then
      LookAtBackbox
   End If
   If KeyCode = 31 Then
      LookAtPlayfield
   End If

   If (KeyCode = 32 OR KeyCode = 33) AND xBAM.Camera.ScriptControl = FALSE Then
      xBAM.Camera.RequestForControl
   End If
   If KeyCode = 32 Then      
      xBAM.Camera.DesktopSet          -582,     734,     500,    -582,    -5.8,       0,      50,     400
      xBAM.Camera.DesktopSetLookAt    -582,     934,     500,    -582,     -66,     330,      44,     400
   End If

   If KeyCode = 33 Then      
      xBAM.Camera.DesktopSet          1338,     934,     500,    1308,     634,       0,      50,     400
      xBAM.Camera.DesktopSetLookAt    1338,     934,     500,    1308,     634,       0,      40,     400
   End If

Key A - will call "LookAtBackbox",
Key S - will call "LookAtPlayfield",
Key D - will set cam params to look at "moon patrol" cab in default FP game room
Key F - will set cam params to look at "donkey kong" in default FP game room
TAB key will change little bit look at that both toys in game room, but cam will not look at backbox

Part 3.
DESKTOP CAMERA ANIMATION - HOW TO USE BAM MENU.

See, video: https://youtu.be/hnIiXPnxQwE
Go to: [DEV Options] -> [Desktop Camera Animation]
First 10 lines is list of camera params. Same as for xBAM.Camera.DesktopSet eyeX, eyeY, eyeZ, atX, atY, atZ, FOV, delay.
You can add new, delete, edit all params. If there is more than 10, it will scroll.
At end of list there is button "insert". Press enter and it will add new entry.

Keyboard shortcuts:
- SHIFT+ENTER - it will copy settings of current camera (that what you see now on screen). You can use Manual Camera (F11). I did it on video above
- SHIFT+INSERT - it will add new camera settings to list just before line of current select line. So, you can add now position in list not only at end, but also in middle or at begin of list
- SHIFT+DELETE - will remove current postion from list
- CTRL-C - will copy whole camera animation to clippbord in form ready to paste in script

Lines in menu:
- Play - will play current sequence. It must have 3 or more lines.
- Optimize Cam Speed - you can set how long it takes to move camera to next point in list. Because distance between 2 positions on list can varry, it is not easu to guess how long it takes to move camera. This command will calc total camera move distance and will set all delays on list based on distance between points. It will also keep total animation time constants. So, it will make camera move speed "more constant". This move can't be constant, but will be less vary.
- Slot - you can select one of 5 slots. You can use Save and Load command to save and load sequences. That sequences are stored in "default.seq" in BAM dir. They are also stored in form "ready to paste in script".

Now, it is time to create own animation, edit it, play with it, save it and take a look at content of "default.seq".

Part 3.
DESKTOP CAMERA ANIMATION - SCRIPT COMMANDS

You can create up to 100 animations. Every animation have own integer number assigned. That number is between 0 and 99. Only first 5 are stored in "default.seq". You can have more in script.

If you look at "default.seq" with stored animation, you will see something like this:
Code:
' ===================== DESKTOP CAMERA ANIMATION ======================
If BAM_VERSION > 205 Then
  xBAM.Camera.DesktopSequenceBegin 0
    xBAM.Camera.DesktopSequenceAddEntry   483.5,   958.5,   156.5,   373.3,     745,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   513.6,   736.1,   121.2,   288.6,   876.2,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   314.9,   674.3,      60,   479.4,   860.9,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry     298,   843.7,   125.6,   418.3,   783.1,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   439.3,   923.1,   125.6,   222.8,   825.8,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   364.1,  1006.7,   100.2,   207.7,   888.4,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   206.8,   950.2,      40,   112.4,   837.3,       0,      65,    1000
    xBAM.Camera.DesktopSequenceAddEntry    58.8,   853.4,    86.1,    87.3,   711.7,       0,      75,    1000
    xBAM.Camera.DesktopSequenceAddEntry    87.5,   723.4,    95.8,   272.3,   395.3,       0,      40,    1000
    xBAM.Camera.DesktopSequenceAddEntry   341.4,   625.4,   105.8,   423.5,  -106.8,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   515.3,   570.7,     132,    64.5,   298.7,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   261.3,   411.5,   119.2,     397,  -313.8,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   -80.2,   387.4,   223.6,   243.7,    30.2,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   -46.7,   253.9,   176.8,   386.4,    50.1,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   155.1,     100,   194.2,     313,   204.9,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   422.8,   108.4,   223.5,   350.4,   268.8,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   464.6,     236,   141.5,   319.3,   628.7,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   361.1,   452.7,   116.1,   226.4,     685,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   180.3,   711.5,    96.7,   114.7,   792.5,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry   150.4,   846.9,     174,   103.9,   829.3,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry     126,   936.1,   374.6,    82.7,   835.3,       0,      50,    1000
  xBAM.Camera.DesktopSequenceEnd

  xBAM.Camera.DesktopSequenceBegin 1
    xBAM.Camera.DesktopSequenceAddEntry   106.5,   252.3,   246.1,   104.4,   223.8,       0,      50,    1000
    xBAM.Camera.DesktopSequenceAddEntry  -148.9,   249.7,   227.4,  -149.8,   193.3,       0,      50,    1000
  xBAM.Camera.DesktopSequenceEnd

  xBAM.Camera.DesktopSequenceBegin 2
  xBAM.Camera.DesktopSequenceEnd

  xBAM.Camera.DesktopSequenceBegin 3
  xBAM.Camera.DesktopSequenceEnd

  xBAM.Camera.DesktopSequenceBegin 4
  xBAM.Camera.DesktopSequenceEnd
End If
' =====================================================================

This looks like script :). You can copy it to your own script. Now about commands.

xBAM.Camera.DesktopSequenceBegin animationId
Procedure.
One param. Animation Id number. Integer value in range: 0 ... 99
This command must be caller before you add new camera position entry to list.
It will also delete previous sequence stored at given animationId. So, remember to edit it, when you add something to script.
If you press CTRL-C in menu, BAM will set put in clipboard all needed commands to create whole sequence, but at begin you will have:
Code:
  xBAM.Camera.DesktopSequenceBegin 10

Remember to change that 10 if you want to have more animations


xBAM.Camera.DesktopSequenceAddEntry eyeX, eyeY, eyeZ, atX, atY, atZ, FOV, delay
Procedure.
Same params as for xBAM.Camera.DesktopSet.
This procedure will add one entry to camera animation.

xBAM.Camera.DesktopSequenceEnd
Procedure.
Call it after last entry.

xBAM.Camera.DesktopSequencePlay animationId
Procedure.
One param. Animation Id number. Integer value in range: 0 ... 99
Finally you can play animation from script.

If you call xBAM.Camera.DesktopSet, xBAM.Camera.DesktopSetLookAt or xBAM.Camera.DesktopRelease during played animation, when animation will be stoped.
Same thing will happend, when user will press keys like F1 .. F8.

---- update: mar 31 2018 ---
- TAB key and script commands LookAtBacbkox, LookAtPlayfield works with new camera.
- new xBAM.Camera.DesktopSetLookAt command, see info above.

to set camera params when TAB key is pressed or LookAtBackbox is executer. Same params as xBAM.Camera.DesktopSet command. Must be executer right after xBAM.Camera.DesktopSet, because xBAM.Camera.DesktopSet it will set "default" params for camera, when TAB is pressed.
Only in script you can set different params for camera when TAB key is pressed.

----- update: apr 17 2018 ---
- added Desktop Camera Animations

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-223, released: Jun 16, 2018


Last edited by ravarcade on Tue Apr 17, 2018 3:40 pm, edited 2 times in total.

Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Tue Mar 20, 2018 9:12 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2014
Location: Ontario, Canada
That's AWESOME RAV !!!!
Thank you so much for all your work !!! :shock:

I look forward to giving this a try


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Tue Mar 20, 2018 10:32 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1572
Location: Arkansas, USA
Wow! This looks like it will be cool!

George


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Tue Mar 20, 2018 10:45 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 303
Location: Abbotsford
wow, well done. Thanks for doing this as a separate post as well, makes it a lot easier to find. Yet another toy to include down the road.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Wed Mar 21, 2018 9:42 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2014
Location: Ontario, Canada
Here's a demo table using Rav's code from above
https://www.dropbox.com/s/ze71l7sk9coas ... a.fpt?dl=0

"A", "S", "D" and "F" keys will move camera as per code
"G" key resets camera to you previous FP camera position
Repeated pressing of "C" cycles through BAM camera angles from BAM menu

I also set camera to move when Left and right slingshot are hit.

Initial questions for RAV:
1. This feature is for Desktop mode only ? Correct?
2. Is it manditory to use the "right flipper allow screen" that is triggered by "xBAM.Camera.RequestForControl "or can you just use code "xBAM.Camera.ScriptControl = True"
to bypass the "right flipper allow screen"".
When I try "xBAM.Camera.ScriptControl = True" I get an error....

3. minor English Grammar fix
it should be "Game wants to take over camera control"
or even "Permission for Game to take over camera control"

This is amazing and works very well !
Thans Rafal

Cheers :D


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Wed Mar 21, 2018 10:38 am 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 898
Gimli wrote:
1. This feature is for Desktop mode only ? Correct?

Yes. Right now i have no idea how to handle it in Cab or VR mode. I will work on it after i finish Desktop Mode.
Gimli wrote:
2. Is it manditory to use the "right flipper allow screen" that is triggered by "xBAM.Camera.RequestForControl "or can you just use code "xBAM.Camera.ScriptControl = True"
to bypass the "right flipper allow screen"".
When I try "xBAM.Camera.ScriptControl = True" I get an error....


Request for user permission is mandatory.
I don't want to add "permissions" to BAM menu and i think, that user should be aware what will happend.
In future maybe i will add more "request for" things, so it is important to create "user friendly" interface for this.
I will add callback subroutine with user answer for script.

--------------
Grammar fix added.

... and please don't use it to create animations with camera. I will make different tool for this.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-223, released: Jun 16, 2018


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Wed Mar 21, 2018 1:53 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1572
Location: Arkansas, USA
ravarcade wrote:
Request for user permission is mandatory.
I don't want to add "permissions" to BAM menu and i think, that user should be aware what will happend.
In future maybe i will add more "request for" things, so it is important to create "user friendly" interface for this.
I will add callback subroutine with user answer for script.

--------------
Grammar fix added.

... and please don't use it to create animations with camera. I will make different tool for this.


To be honest, I tend to get dizzy when the camera moves so I think I would like to know what the PC is doing.

George


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Thu Mar 22, 2018 6:12 am 
Offline
User avatar

Joined: Sun May 08, 2011 4:57 pm
Posts: 1063
Location: Turin-ITALY
I manually changed the dll.
The strange thing is that it gives me the error: "Could not locate Bam.dll".
Greetings

Gianfranco


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Fri Mar 23, 2018 7:56 am 
Offline
User avatar

Joined: Sun May 08, 2011 4:57 pm
Posts: 1063
Location: Turin-ITALY
I publish Rafal's answer to my problem. :o

Ravarcade wrote:
Damn stupid windows. :)
I'm 100% sure, that BAM.dll is ok. I think, that you renamed files and at some point you did not have "BAM.dll" but "BAM.dll.dll".

In File Explorer windows by default "hide file extensions of know files" is enabled.
For example:
MyDocument.doc
will be displayed in File Explorer as:
MyDocument

You will not see ".doc".

Now if you select this file with mouse and press F2 to change file name, then type "MyDocument.doc" you will not have on disk file "MyDocument.doc" but "MyDocument.doc.doc". Because file explorer will hide file extendsion ".doc" you will see "MyDocument.doc".

So, when you for example:
first rename "BAM.dll" and type "BAM-old.dll" you get on disk "BAM-old.dll.dll".

Here is tutorial how to disable this "hide known extensions":
https://www.youtube.com/watch?v=wxIIskKmUQA


Thank Rafal


Top 
 Profile  
 
 Post subject: Re: BAM - Camera contoled in script
 Post Posted: Sat Mar 31, 2018 2:03 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 898
New beta with some fixes.
https://www.ravarcade.pl/beta/BAM.dll

- TAB key and script commands LookAtBacbkox, LookAtPlayfield works with new camera.
- new xBAM.Camera.DesktopSetLookAt command to set camera params when TAB key is pressed or LookAtBackbox is executer. Same params as xBAM.Camera.DesktopSet command. Must be executer right after xBAM.Camera.DesktopSet, because xBAM.Camera.DesktopSet it will set "default" params for camera, when TAB is pressed.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-223, released: Jun 16, 2018


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

Board index » Future Pinball » BAM corner


Who is online

Users browsing this forum: No registered users and 4 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: