Register    Login    Forum    FAQ    PinSimDB.org

Board index » Future Pinball » BAM corner




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Sun Jul 08, 2018 2:12 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
ravarcade wrote:

This image may help you understand above properties:
Image
Image


Why is contact point based on VSpeed arrow and not angled vector arrow?

Is there a way to know the angle of the vector?

It seems to me that the ball vector angle and flipper angle are both useful to account for...

In above image it looks like ball won't even contact flipper at all?

Rav, can you provide simple demo tables with

1. Prehit coding of flippers based on contact point only.

If contactpoint=. ..then ....

2. Based on vector speed only

If ball speed=.....then....


3. Using elastic coeffient instead of omega

If contactpoint=.......then elasticity=.....



So we can see the how the code works...I need to see the actual syntax in a demo table

Don't worry about the actual result ...when we play demos, we can tweak the numbers once we understand the code

This is awesome !
Thanks Rav


Last edited by Gimli on Tue Jul 10, 2018 9:52 am, edited 1 time in total.

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

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 911
Quote:
Why is contact point based on VSpeed arrow and not angled vector arrow?

ContactPoint is always point on line between point P0 and P1 closest to ball.
If ball is in contact with flipper and ContactPoint is in range <0.0, ..., 1.0>, it is point of contact.
If ContactPoint is outside this range, ball can touch only one of cylinders. If ContactPoint < 0.0 then it is "bigger cylinder" if > 1.0 it is "tip" of flipper.
Ball.Velocity (speed vector) will only point at correct "contactpoint" if that vector is perpedicular to line P0 - P1. In other conditions is uselses.

Also, _prehit() will be executed just before ball hit flipper. In that last moment "Hit" property will be set to TRUE and ContactPoint will point exactly place where ball is touching flipper.
Quote:
Is there a way to know the angle of the vector?

Yes. It is visible at image. You need only calc arcus tanges of BallHSpeed, BallVSpeed.
Before i put here needed function, you should know, that it is not reliable.
If in one frame ball move vector is pointing at flipper (BallVSpeed > 0), ball in that frame will hit flipper and flipper is in move, when in next frame:
- ball may be still in contact with flipper (but not alway will be, ball may be faster than flipper)
- ball move vector will point "UP" (BallVSpeed < 0.0), away from flipper
In that case that ball move vector is more/less "reflection" vector from previous frame + effect of flipper move.

Here is correct arcus tangens function with "example":
Code:
Const RadToDeg = 57.295779513082320876798154814105

' Convert X, Y to angle.
' Need example? See Atn2Example.
Function Atn2(x, y)
   If x > 0 Then
      Atn2 = Atn(y / x) * RadToDeg
   ElseIf x < 0 Then
      Atn2 = 180 - RadToDeg * Atn(y / -x)
   ElseIf y > 0 Then
      Atn2 = 90
   Else
      Atn2 = -90
   End If
   Atn2 = Atn2+90
End Function

Sub Atn2Example()
  AddDebugText Atn2(    0,   -100) ' Up          = 0
  AddDebugText Atn2(   10,   -100)
  AddDebugText Atn2(  100,   -100) ' Up/Right    = 45
  AddDebugText Atn2(  100,    -10)
  AddDebugText Atn2(  100,      0) ' Right       = 90
  AddDebugText Atn2(  100,     10)
  AddDebugText Atn2(  100,    100) ' Down/Right  = 135
  AddDebugText Atn2(   10,    100)
  AddDebugText Atn2(    0,    100) ' Down        = 180
  AddDebugText Atn2(  -10,    100)
  AddDebugText Atn2( -100,    100) ' Down/Left   = 225
  AddDebugText Atn2( -100,     10)
  AddDebugText Atn2( -100,      0) ' Left        = 270
  AddDebugText Atn2( -100,    -10)
  AddDebugText Atn2( -100,   -100) ' Up/Left     = 315
  AddDebugText Atn2(  -10,   -100)
End Sub
' Atn2Example  ' <-- unrem this line to see Atn2 example

You would use this Atn2 function like this:
Dim ball_to_flipper_angle
ball_to_flipper_angle = - Atn2( LeftFlipperExt.BallHSpeed, LeftFlipperExt.BallVSpeed )


Quote:
It seems to me that the ball vector angle and flipper angle are both useful to account for...

Yes, but i think it will be hard to make any good decision based on ball move angle vector and flipper angle.
I think BallVSpeed and BallHSpeed is better. First both values are just ball move vector in relation to flipper.
In relation to flipper:
- if BallVSpeed > 0.0 then ball is goin "down" to flipper. Also force how much ball will push flipper is proportional to BallVSpeed (not Ball speed, because angle will change that force)
- if BallVSpeed < 0.0 then ball is moving away from flipper
- if BallHSpeed == 0 then ball move vectore is perpedicular to flipper surface
- if BallHSpeed < 0.0 ball is moving to LEFT
- if BallHSpeed > 0.0 ball is moving to RIGHT.
In short, it is not easy to get same information based on flipper angle and ball move vector.

Quote:
In above image it looks like ball won't even contact flipper at all?

Probably will not. Maybe if flipper will be in move "up". My image is just exaple how that vectors and points P0 & P1 looks. If i put it on image with ball touching flipper all would look harderd to understand.

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

Tomorrow i will put samples with "prehit" subroutines.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-233, released: Jul 15, 2018


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

Joined: Tue May 01, 2012 11:13 pm
Posts: 318
Location: Abbotsford
Is Flipper angle in BAM? I was thinking flipper angle would be very useful to what I want to do as I wish to set omega values based on the degree of angle for the tip shots of the flipper, that increase the omega as the flipper increases it's swing. It's also important for when the flipper is released as well (at least what I am thinking about)

I think I understand this all at least. pretty high end stuff for a lot of us, and Math has never been a good subject for me. Maybe once we have working scripts you can check it out and write the mathematical formula to simplify it?

_________________
_____________________________________

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: Mon Jul 09, 2018 7:10 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
Sorry to Belabor this guy's, but I think it is important to be clear
Quote:
.ContactPoint is always point on line between point P0 and P1

I understand this
Quote:
If ball is in contact with flipper and ContactPoint is in range <0.0, ..., 1.0>, it is point of contact.
If ContactPoint is outside this range, ball can touch only one of cylinders. If ContactPoint < 0.0 then it is "bigger cylinder" if >

I understand this

Quote:
.Velocity (speed vector) will only point at correct "contactpoint" if that vector is perpedicular to line P0 - P1. In other conditions is uselses.


I do not follow this at all...surely the effective/composite velocity vector IS the only one that ever truly makes contact?

In my understanding vertical speed vector can predict when it will make contact only but not where

But perhaps you are picturing the following:

1. Ball striking flipper:
The prehit value is taken so close in time to actual collision that Effective/composite Velocity vector and Vertical speed vector haven't diverged much and the values are similar

2.Ball rolling along flipper: The vectors are being constrained artificially by the flipper itself...in this case contact happens precisely at P0 and is continuous until flipper is activated or ball reaches P1

3. Flipper activation is totally unpredictable and based the players whims
So vertical vector more reliable

So in the end, I suppose Vertical may be a better reference .....as true contact point is variable and elusive :)


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Mon Jul 09, 2018 12:43 pm 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 911
@Gimli:
See image.
Image

You have 3 ball trajectory. So, 3 balls will hit flipper. They will hit it in exacly same point (contact point). They have 3 different "speed vectors".
Only for ball #2 (green) "speed vector" point at contact point. Only because it is perpendicular to flipper.
Vectors for ball #1 and #3 are not pointing at correct contact point (and error is big, bigger than ball radius).
Lets say all balls moves with same speed.
Ball #2 will hit flipper with biggest force because again speed vector is perpendicular to flipper.
Force from ball #1 and #3 is smalle and can be easly calculater if you split "speed vetor" to 2 vectors: one perpendicular to flipper (BallVSpeed) and one parallel to flipper (BallHSpeed). This is what BAM do. Split that vector into 2 parts.

@blue:
Flipper angle from "FlipperExt" can be read any time, so you can use it to change omega, but:
- don't use FP timers to check flipper angle - it will not be realiable. I will add subroutine call, lets say "NewtonPhysicsFrameTick()" executed for every physics simulation step. So, you will be able to check and moddify omega for evey simulation step.
- i belive you can make flippers omega accelerating after user press button with current "flipper charts"....
- if FPS in XML is set to default 256 and flipper moves from StartAngle to StartAngle+Swing in 50 ms you will have 12 or 13 steps in simulation.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-233, released: Jul 15, 2018


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Mon Jul 09, 2018 1:26 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
Thx Rav!
I notice control-c gives "sub BAM_init" but has no values pasted when I use control-v in script

Code:
Sub BAM_Init()
End Sub


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Tue Jul 10, 2018 7:55 am 
Offline

Joined: Mon Mar 25, 2013 4:02 pm
Posts: 911
@Gimli:
In version priori to v229 BAM will create FlippeExt only for flippers with changed params. New version will make all correct.

@everyone:
BAM beta v229.
https://www.ravarcade.pl/beta/BAM.dll

Big changes:
- Improved ball hit detection (for "prehit" events).
- Fixed flipper omega change in "prehit" events (in older BAM version it was applien for next frame, not current).
- Params of flipper changed in "prehit" events are restored to previous values for next physics simulation frame. So, if you change something (like omega or mass of flipper) in prehit subroutine, change is not permanent. It will be used only for this collision. This is important change. With it programing is much easier. Don't forgot, if you change flipper params in BAM_Init or in timer expired even, then change is be permanent.
- Improved flipper testing tools
- Added call to "NewtonPhysicsTick" subroutine for every simulation frame.

Now is most interesting part!
Demo table:
https://www.ravarcade.pl/beta/FlipperExt-Demo.fpt

Inside are a lot of comments, so here is only brief list:
- Table is clean empty FP table with all thins done in script.
- (@Blue) Physics XML is inside script. It is FP default physics with modified flipper rotation speed chart. I want to have flipper rotation accelerating when user press and hold flipper button.
This part is not related to FlipperExt/Settings/PreHit demo.
- Inside there are 4 versions "OnPreHitFlipperExtSettings" subroutines (and 4 debug versions with some output to fp debug window (F9)). You will need to modify script to select different version.
- You will find NewtonPhysicsTick subroutine inside used to detect change of ball speed after hit.
- Please use "Flipper testing tool" with this settings:
Image
You will quickly see change in ball trajectory for different OnPreHitFlipperExtSettings subroutines.

Well... i belive all works suprisly well.
Here are my thoughts on what I understand about FP:
- direction of ball move after ball hit flipper depends only on position of ball on playfield. Change in omega, mass, elasticCoef don't change direction... but only speed of ball.
- if you use flipper rotation speed chart like in my demo table to get flipper rotation accelerate after user press and hold flipper, when flipper will drag ball some time and direction of ball movement may change.
- change Mass of flipper in "prehit". It will change how ball behaves only in first contact with flipper. If ball is dragged by flipper, when omega will have bigger impact on ball speed, not flipper mass. So, in my demo table, for "massWeakTip", if you remove physics XML from begin, ball will in most time behave like for "weaktip" (omega change), because for most collisions ball will be not "dragged" by flipper after first hit.
- if you change omega a lot, it is better to change it after you check "hit" property. Otherwise you will see how flipper slow downs/speed ups when ball only fly near flipper.
- you can change elastiCoef with SetMaterial for every "prehit" event. I do it after check for "hit" property only to have nice "debug" info. It don't have impact how flipper moves.

_________________
http://www.ravarcade.pl
Better Arcade Mode
current BAM version: v1.4-233, released: Jul 15, 2018


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper , Physics and Material Property Mod
 Post Posted: Tue Jul 10, 2018 8:29 am 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
Wow Rav !
That sounds awesome !
I won't have much time for a week or so , but I am excited to check it out !
Thank you


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper Breakthrough !!
 Post Posted: Tue Jul 10, 2018 8:07 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
Very cool
You can simply copy and paste
the code from the demo into any table

Just don't use an external XML file , you can replace
the included script based XML though


Top 
 Profile  
 
 Post subject: Re: BAM Dynamic Flipper Breakthrough !!
 Post Posted: Wed Jul 11, 2018 12:44 pm 
Offline

Joined: Mon Jan 27, 2014 12:36 pm
Posts: 2057
Location: Ontario, Canada
viewtopic.php?f=3&t=97&p=86685&hilit=is+demo#p86685

Rav,
there is a weird glitch when you hold the ball with the left flipper,
in Dynamic Omega demo in the monster bash table I am tweaking.

see post above

Thanks
Rav! :D


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

Board index » Future Pinball » BAM corner


Who is online

Users browsing this forum: No registered users and 3 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: