Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » BAM corner




Post new topic Reply to topic  [ 86 posts ]  Go to page 1, 2, 3, 4, 5 ... 9  Next
Author Message
 Post subject: BAM Dynamic Flipper Breakthrough !!
 Post Posted: Thu Jun 28, 2018 12:42 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2113
Location: Ontario, Canada
Calling GeorgeH, blindpeser, blue, smoke,Popotte, Franzleo, Wild, Flug and everyone in the FP realm...Dynamic Flipper Coding...proof of concept

We can use Bam ball tracking to predict ball speed, position and direction and then code variable flipper response
accordingly

"Galileo ! Galileo, let me go!
Definition of Dynamics in Physics:

"Dynamics can be subdivided into kinematics, which describes motion, without regard to its causes, in terms of position, velocity, and acceleration; and kinetics, which is concerned with the effect of forces and torques on the motion of bodies having mass. The foundations of dynamics were laid at the end of the 16th century by Galileo Galilei who, by experimenting with a smooth ball rolling down an inclined plane, derived the law of motion for falling bodies"


We are implementing dynamic flipper control ( but eventually it can be applied to any FP hit event)


Thanks to Rav !! :D


https://www.dropbox.com/s/141hs0nc1fle0 ... t.rar?dl=0

See line 483
Code:
'''''''''''''''''''''''''''''''''''Dynamic Flipper Mod'''''''''''''''''''''''''''''
       Dim RightFlipperExt
   Set RightFlipperExt       = xBAM.Flipper("RightFlipper")
   Dim LeftFlipperExt
   Set LeftFlipperExt       = xBAM.Flipper("LeftFlipper")

Dim prehitidx
prehitidx = 0
Sub RightFlipper_prehit()
   
   If xBAM.Ball.Speed < 300 then
   RightFlipperExt.Mass      =      20000
   RightFlipperExt.Omega     =        40
   End if
   If xBAM.Ball.Speed > 300 then
   RightFlipperExt.Mass      =      20000
   RightFlipperExt.Omega     =       25
   End if
   prehitidx = prehitidx + 1
   AddDebugText "on pre hit: " & prehitidx
   AddDebugText "xBAM.Ball.Speed: " & xBAM.Ball.Speed
End Sub

Sub LeftFlipper_prehit()
   
   If xBAM.Ball.Speed < 300then
   LeftFlipperExt.Mass      =      20000
   LeftFlipperExt.Omega     =        40
   End if
   If xBAM.Ball.Speed > 300 then
   LeftFlipperExt.Mass      =      20000
   LeftFlipperExt.Omega     =        25
   End if
   prehitidx = prehitidx + 1
   AddDebugText "on pre hit: " & prehitidx
   AddDebugText "xBAM.Ball.Speed: " & xBAM.Ball.Speed
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


If you play in debug mode pressing F9 from table editor, you will see "prehit" numbers as
ball approaches flipper and the corresponding ball speeds.

I set just 2 omega values for flippers based on ball speed.
You can play with these number to see the difference.

Anyways, this is just proof of concept and rav has also provided code for not just tracking of ball speed , but also direction and position. So lots of potential :D

You can code Sub xxxx_prehit()
routines in this way for any collidable table object and even include code to change
material properties


Cheers

Addendum July 12, 2018
Demo .

https://www.dropbox.com/s/tk96zghzzc7t5 ... c.rar?dl=0


Last edited by Gimli on Mon Jul 16, 2018 7:57 pm, edited 16 times in total.

Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Thu Jun 28, 2018 5:07 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1685
Location: Arkansas, USA
I assume it is possible to set more than 2 omegas based on ball speed?

What does "prehitidx" do in the script?

Even though I am no expert on script, I think I might be able to figure this stuff out.

Do you know if there is a way to display ball speed on screen while playing? It would help to figure out the break points to change omega based on speed.

George


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Thu Jun 28, 2018 5:13 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2113
Location: Ontario, Canada
GeorgeH, see my response to you on Monster Bash thread re:adding more flipper options to code

According to Rav:
Quote:
This is almost 100% control i can give to table-devs.

set different material params for every single object on table.
You have command in BAM:
xBAM.Physics.SetMaterial "objectname", elasticCoef, softnessCoef, staticFriction, kineticFriction
You can set same params as in xml for single wall, flipper, rubber....
If you use FlipperExt interface to set mass or omega for single flipper, you can also use shorter SetMaterial command, like this:
RightFlipperExt.SetMaterial elasticCoef, softnessCoef, staticFriction, kineticFriction


If you play in Debug mode you will see the speed values as the ball approaches flipper only,
but I am sure rav could enable continuous viewing of ball speed somehow....maybe just create a timer with
AddDebugText "xBAM.Ball.Speed: " & xBAM.Ball.Speed

PrehitId is just a counter every time BAM takes a speed reading....

The code above in the demo table is quite simple and just has 2 speed settings per flipper,
but the sky is the limit.....


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Fri Jun 29, 2018 11:11 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2113
Location: Ontario, Canada
https://www.dropbox.com/s/141hs0nc1fle0 ... t.rar?dl=0

Link updated:
Play in Debug mode ( press F9 from table editor to load)

1.Ball speed , Flipper Mass and Flipper Omega display when you use flippers
2.Phantom Flippers fixed. Phantom Flipper Settings will be displayed when they activate
3.Press "B" on Keyboard to activate continuous Ball Speed Monitoring
4.Press"V" on keyboard to inactivate continuous Ball Speed Monitoring


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sat Jun 30, 2018 9:43 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2113
Location: Ontario, Canada
Ravarcade is a genius !
Dynamic coding may be the fix we have been looking for :)
Hopefully our coders blue , Smoke , Franzleo, Popotte, flug ,Wild can help us investigate this ?

Here is a reply from Rav
regarding BAM ball tracking of position and direction
Quote:
.Here is sample code:
Code:
Dim RadToDeg
RadToDeg = 57.295779513082320876798154814105

Function Atn2(x, y)
If x > 0 Then
Atn2 = Atn(y / x) * RadToDeg
ElseIf x < 0 Then
Atn2 = Sgn(y) * (180 - RadToDeg * Atn(Abs(y / x)))
ElseIf y = 0 Then
Atn2 = 0
Else
Atn2 = 180
End If
Atn2 = Atn2+90
End Function

Dim prehitidx
prehitidx = 0
Sub RightFlipper_prehit()
prehitidx = prehitidx + 1
AddDebugText "xy: " & xBAM.Ball.Position.X & ", " & xBAM.Ball.Position.Y & " S:" & xBAM.Ball.Speed
AddDebugText "vel: " & xBAM.Ball.Velocity.X & ", " & xBAM.Ball.Velocity.Y & " dir: " & Atn2(xBAM.Ball.Velocity.X, xBAM.Ball.Velocity.Y)
End Sub

in xBAM.Ball you have:
- Position (3d vector, but Z is probalby useless for you). It may be used to calc position relative to flipper. Like this:
Code:
Dim dX, dY
dX = xBAM.Ball.Position.X - FlipperRight.X
dY = xBAM.Ball.Position.Y - FlipperRight.Y

- GlobalPosition - same as above, but for mini-playfield. No use for you. If ball and flipper is on miniplayfield you will use only Position like above.
- Velocity (3d vector, again Z is useless for you). It may help to decide if ball will hit hard flipper or is just rolling over it. See how in example i calc "direction" with Atn2 subroutine.
- Speed (scalar) - this is what you ask, but i think you need to use direction too.

- HitSpeed same thing as Speed in "_prehit" subroutine.
- Exist (= true or false) for ball. in "_prehit" always true


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sun Jul 01, 2018 1:23 am 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
I would love too, but I can't understand any of the sample code. :(

I think Rav forgets that we are just not as good as he is with scripting and advanced math, well, me at least. ;(

still, will give it a shot.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sat Jul 07, 2018 9:53 pm 
Offline

Joined: Thu Aug 16, 2012 11:12 pm
Posts: 1685
Location: Arkansas, USA
Blue, I think you are better at that I am, at least you understand script better than I.

I have experimented with the interface between the XML file and this new script for the flippers. I previously tried setting the flipper omega and mass in the XML file to 0 and got an error where I had to reboot my PC. Then, I tried deleting the heading and values in the XML file for flipper omega and mass and the table crashed during table loading. All I know is when the script has coding for the flippers mass and omega, the table flippers perform differently when you have an XML file and when there is no XML file.

George


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sun Jul 08, 2018 12:06 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 930
BAM beta, v227
https://www.ravarcade.pl/beta/BAM.dll

- added material properties to Flippers menu in BAM. You can set in menu different material params for every flipper, not only mass and omega. So, you can for example change elasticCoef.
- a lot new properties added to FlipperExt. That properties should be readed in _prehit() subroutines.
------------------------------------------------------------
So, to get all info about "RightFlipper" you will need 2 thins:
1. Create RightFlipperExt object:
Code:
Dim RightFlipperExt   ' global object, more less same thing as RightFlipper object in script

Sub BAM_Init()
    Set RightFlipperExt  = xBAM.Flipper("RightFlipper")
    ' .... more line of
End Sub

Note:
- we define RightFlipperExt outside BAM_Init subroutine. It will be used in RightFlipper_prehit.
- if you use BAM menu and CTRL+C to get flippers setting, you only need to move line with "Dim RightFlipperExt" before line with Sub BAM_Init()

2. you need RightFlipper_prehit subroutine:
Code:
Sub RightFlipper_prehit()
  ' here you will read new properties and you will set flipper params just before ball hit it
End Sub


----------------------------------------------

List of new properties in FlipperExt:
- Angle - ... current flipper angle
- ContacPoint - float value, between ~-0.3 and +1.3. Point on flipper between P0 and P1
- BallHSpeed - ball horisontal speed, Notice: Horizontal to flipper upper surface
- BallVSpeed - ball vertical speed, This is better info how "hard" ball will hit flipper.
- Hit - flag: True or False - guessed by BAM collision with flipper in current processed frame.

That image may help you understand above properties:
Image
Image

Now, why ContactPoint may be smaller tham 0? Ball may hit bigger cylinder of flipper .
ContactPoint may be also higher than 1.0. Ball may hit smaller cylinder (tip of flipper).
"Hit" flag is not 100% accurate. You should use it if you want to moddify flipper omega, because moddification of omega will change rotation of flipper.
If you want to moddify "elasticCoef", you can do it allways.
-----
Here is my sample code used to learn how that new properties works:
Code:
Dim RightFlipperExt, LeftFlipperExt
Sub BAM_Init()
  Set RightFlipperExt = xBAM.Flipper("RightFlipper")
  Set LeftFlipperExt = xBAM.Flipper("LeftFlipper")
End Sub

' variables used for statistic
Dim prehitidx, hitAll, hitPositive, lastNC
prehitidx = 0
hitAll = 0
hitPositive = 0
lastNC = 0

' ---------------------- right flipper -----------------
Sub RightFlipper_prehit()

   ' everything bellow is just demo - debug
   prehitidx = prehitidx + 1
   If lastNC + 1 <> xBAM.NewtonCounter Then
      AddDebugText "R: -H-"  & xBAM.NewtonCounter & ", " & RightFlipperExt.ContactPoint
   End If
   lastNC = xBAM.NewtonCounter

   If RightFlipperExt.Hit Then
      hitAll = hitAll + 1
      If RightFlipperExt.BallVSpeed > 0 Then
         hitPositive = hitPositive + 1
      End If
      AddDebugText "R: Stat: " & prehitidx & " / " & hitAll & " / " & hitPositive
      AddDebugText "PreHit at frame: " & xBAM.NewtonCounter
      AddDebugText "ContactPoint: " & RightFlipperExt.ContactPoint
      AddDebugText "Ball Speed H: " & RightFlipperExt.BallHSpeed & " V: " & RightFlipperExt.BallVSpeed
   End If
End Sub

' ---------------------- left flipper -----------------

Sub LeftFlipper_prehit()
   ' everything bellow is just demo - debug
   prehitidx = prehitidx + 1
   If lastNC + 1 <> xBAM.NewtonCounter Then
      AddDebugText "L: -H-"  & xBAM.NewtonCounter & ", " & LeftFlipperExt.ContactPoint
   End If
   lastNC = xBAM.NewtonCounter

   If LeftFlipperExt.Hit Then
      hitAll = hitAll + 1
      If LeftFlipperExt.BallVSpeed > 0 Then
         hitPositive = hitPositive + 1
      End If
      AddDebugText "L: Stat: " & prehitidx & " / " & hitAll & " / " & hitPositive
      AddDebugText "PreHit at frame: " & xBAM.NewtonCounter
      AddDebugText "ContactPoint: " & LeftFlipperExt.ContactPoint
      AddDebugText "Ball Speed H: " & LeftFlipperExt.BallHSpeed & " V: " & LeftFlipperExt.BallVSpeed
   End If
End Sub

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


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sun Jul 08, 2018 12:53 pm 
Offline

Joined: Thu Nov 24, 2016 7:46 pm
Posts: 137
WOWser! Man, Rav! This is the confirmation I was waiting for! The material thing is nice, but that contactpoint variation is the holy shit this software needed so bad! the ball speed parameters are a big help as well! You are a true genius. This means a lot of work now. Hopefully Bob, blue, George and maybe me are going to create reference values that work on every table ever made on FP.

We should create a thread and post our progress and experiences there. Would be fantastic if we could work together to get this thing done. This is truly the main upgrade I was hoping for (+ roms implementation).


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sun Jul 08, 2018 1:27 pm 
Offline

Joined: Tue May 01, 2012 11:13 pm
Posts: 330
Location: Abbotsford
I suggested this on vpinball, that we all get together and release a standard code that is automated, so people can just cut and paste into their script and it works (with object creation on top of course) VPX does this, so I don't see why we don't either.

We certainly could fold in things like smokes stuff, ball shadows etc. They would have to be generic though, as flippers from manufacturers and era are very different from each other, but at the very least, get the angles better and the ball behavior to be more realistic.

I will do what I can with the limited time I have lately.

_________________
_____________________________________

Latest projects and rants at My Facebook Page
_____________________________________

Latest Project: FPx Template Engine


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 86 posts ]  Go to page 1, 2, 3, 4, 5 ... 9  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:  
cron