NEW MiniPlayfields in BAM
Page 1 of 16

Author:  ravarcade [ Mon Aug 15, 2016 10:08 am ]
Post subject:  NEW MiniPlayfields in BAM

Link to BAM-beta with NEW MiniPlayfields:

Inside is "miniplayfield2.fpt".

A lot of new stuffs:
- Up to 16 mini-playfields
- New syntax for miniplafileds in script
- Fixed coords system: now all X / Y values in menu and in script are same as in FP editor
- Rotation of mini-playfields in all 3 axis
- You can move, rotate, scale mini-playfields in script during game
- SMOOTH ANIMATION. You can set TIME how fast mini-playfield will move/rotate/scale to target position.
- NICE ANIMATIONS. You can use miniplayfield to animate objects on playfield. You can set "easing" functions. Tree different functions. One for position change, one for rotation and one for scale. "Easing" functions are same as in JQuery. See:
- Attach miniplayfield position to ball. So you can use mini-playfield to "decorate" ball.
- PHYSICS. When you rotate mini-playfield, gravity force for ball on this playfield will push ball in correct direction.
- PHYSICS. When you shacke playfield and mini-playfield is rotated, again ball will be moved in correct direction.
- PHYSISC. BALL INERTIA. When you move/rotate mini-playfield it will have impact on ball movment. (It is not perfect, but work for me).
- CTRL-C. In mini-playfield BAM menu. You can use CTRL-C to get "code-snipet", ready to paste in script for: (1) mini-playfield-Create call, (2) set Easing, rotation order, inertia, (3) MoveTo command
- In script you can read current playfield position and rotation.
- You can rotate given deg number on any axis, like this:
MiniPlayField_1.Rotation.Z = MiniPlayField_1.Rotation.Z + 10

Later at this post i will write how to use it.
Now play for a while with demo-table.

All old mini-playfields still works.

================== TUTORIAL ===================


See screenshots:
(1) FP Editor:
(2) BAM Menu:
On screenshot (1) i marked rectangle with coors from FP editor. So top/left corner is X-min/Y-min, bottom/right is X-max/Y-max of box where are all objects used as mini-playfield. I marked also "center-point" of that mini-playfield. In example it is position of rubber.
All that values you will see in BAM-menu.

When you compare it to old-miniplayfields you should notice, that there is one more set of coords in menu for "center". That "center point" is very important thing. In most cases you will want to move mini-playfield to selected position. Now you can just set where in playfild should be that "center-point". In my "miniplayfield2.fpt" i want to have rubber ring from mini-playfield be in same position as peg on main playfield.
That way i can rotate, scale my mini-playfield anyway i like and my rubber ring will be alway on peg.

You may set that "center-point" outside of box with mini-playfield.

.... and now how to put it in script? Use CTRL-C when cursor in BAM menu is lines marked on second screnshout. Now CTRL-V in script editor. Result:
Dim MiniPlayField_0        '                             Xmin     Xmax     Ymin     Ymax     Zmin     Zmax     CenX     CenY     CenZ
Set MiniPlayField_0        = xBAM.CreateMiniPlayfield(   -592,     -72,     389,     924,     -15,     100,    -270,     580,       0)

(see screenshot:

So you have variable MiniPlayField_0 defined.
Later you may change name of that variable in script. But be carefull. CTRL-C in BAM menu will allways copy to clipboard code with original name.

You may noticed in BAM menu line with: "Idx: 0>". In that line you can switch between 16 mini-playfields. In BAM menu you may edit all 16.

See screenshot:

On screenshot i mark:
- rubber ring on mini-playfield (coords x: -270, y: 580)
- peg on playfiled (coords x: 200, y: 510)
If i keep miniplayfield scale = 1 and set Z values for both points to same value, rubber and peg will look like it was one single object from editor.
In my demo i did 2 things:
1. changed scale to 0.66
2. moved mini-playfield 15 [mm] up. (Z-center = 0, Target Z-Position = 15)

You can also change rotation on any axis and set time. On screenshot time is set to 1 second. It means, that if i execute command "MoveTo" with that params, playfield will move smoothly from current position and reach target position in 1 second.
When you press CTRL-C when cursor is in mared lines in menu, you will get this:

In demo table i have to modify this line. I set time to zero.
Remember to set Time to 0 when you want to setup starting position of mini-playfield.

Now realy cool stuffs in script.
Object created with xBAM.CreateMiniPlayfield have many properties. They may be used to move, rotate, scale mini-playfield.
- MiniPlayField_0.Position.X (or .Y, or .Z) - set it to move playfield to any position.
- MiniPlayField_0.Rotation.X (or .Y, or .Z) - set rotation of mini-playfield.
- MiniPlayField_0.Scale - set scale of mini-playfield.
- MiniPlayField_0.Time - same as last param in "MoveTo" coomand. When this param is set to value greater than 0, mini-playfield will be animated from current position to target position.

All values from .Position, .Rotation, .Scale you can read in script. When you reed that value during animation, you will get value between starting and ending position.
In many scenarios you will want to increase/decrease target value and you don't know if playfiled reach target position. So you may read previously set target position with:
.TargetPosition.X (or .Y, or .Z) ,
.TargetRotation.X (or .Y, or .Z) ,

[UPDATE Aug 27 2016]
... OR current position / rotation / scale, even if animation is played.
.CurrentPosition.X (or .Y, or .Z) ,
.CurrentRotation.X (or .Y, or .Z) ,

Difference between .Current-Something & .Target-Something:
- .Current-Something will return current position/rotation/scale. If animation is played it will be between starting and ending values.
- .Target-Something will return alway last value set in script.

You want to move object 100 mm up (Z axis) from current position and object should reach that position in 0.5 second:
MiniPlayField_0.Time = 0.5
MiniPlayField_0.Position.Z = MiniPlayField_0.CurrentPosition.Z + 100

If all moves should take 0.5 second you need to set .Time only once in script.
Lets say at begin MiniPlayField_0.Position.Z = 0.
You call that script once, after 250 ms playfiel Z position is 50 and you call script again. After another 500 ms mini-playfield will stop at Z = 150

So you call 2 time Z = Z + 100 and you ended with Z = +150.

If you want to change in second call Z value 200 you can use .TargetPosition instead .Position:
MiniPlayField_0.Position.Z = MiniPlayField_0.TargetPosition.Z + 100

You can set mini-playfield rotation for all 3 axis (X/Y/Z) by:
- MoveTo command
- .Rotation.X, .Rotation.Y, .Rotation.Z[b]

All angles are in degree in range -180 ... +180.
When you read rotation value, you will get always result in range -180 ... +180.
[b].Rotate.Z = 270
is also correct.
Lets say current angle is 170 deg.
When you set angle = 190, when BAM will animate rotation and mini-playfield angle will be set to 171, 172, ...., 189, 190.
When you set angle = -170, when BAM will animate rotation in oposite direction: 169, 168, .... -169, -170.
Angle value -170 is same as 190 but it will make playfield rotate in different direction.

There is one more important thing: RotationOrder.
Lets say, you want to rotate object. On X-axis 10 deg, on Y-axis 20 deg, on Z-axis 30 deg. Order in with you rotate object make difference. So when you rotate first on X, when Y, when Z will give different results than Z first, when Y, when X.
See my "miniplayfield2.fpt". I have 2 mini playfields. In script i rotate first one (with flippers) during game only on Z axis. Second playfield (attached to ball) is also rotated only on Z axis. Please note, that they rotate different way.
First one in order X -> Y -> Z
Second: Z -> Y -> X
I control order with that 2 line:
MiniPlayField_0.RotationOrder = xBAM.orderXYZ
MiniPlayField_1.RotationOrder = xBAM.orderZYX

You can quickly find all possible 6 orders: XYZ, XZY, YXZ, YZX, ZXY, ZYX.
You probably will want to rotate playfield only in one axis at end and set other 2 to constant values.
Best way to find right order is to test what happend in BAM menu (see Easing menu).

One more thing. xBAM.orderXYZ, xBAM.orderXZY, ... are just integer constants.
= xBAM.orderXYZ is same as = 0, = xBAM.orderXZY is same as = 1, ... and = xBAM.orderZYX is same as = 5
MiniPlayField_0.RotationOrder = xBAM.orderXYZ in script looks better (more descriptive) than MiniPlayField_0.RotationOrder = 0.

Easing function are realy simple. Lets say you have two values: A and B. You can use another param t (in range 0 ... 1) to calc values between A and B and make transition smooth. When you change t like linear function in time you will get linear transition between values A and B. ... but it don't have to be linear. See this page:
There is 31 functions (swing = easeInOutSin).
You can set different easing functions for:
- move: .EasingPosition
- rotation: .EasingRotation
- scale: .EasingScale
or set all 3 at once to same vaule: .Easing

Maybe i should describe that functions, but ...
This is another feature you shuld test with BAM menu first.
If you try to do it with my "miniplayfield2.fpt" do it before you start game. When game is running script will try to set values same time as you do it with menu and results may be wird.

To test it you need "starting position" and "target position" (you want to see mini-playfield in move).

In script you will to somthing like this:
' ----- setting of start position:
Dim MiniPlayField_0
Set MiniPlayField_0 = xBAM.CreateMiniPlayfield(-592, -72, 389, 924, -15, 100,  -270, 580, 0)

Call MiniPlayField_0.MoveTo(    200,     510,      15,       0,       0,       0,    0.66,       0)         

MiniPlayField_0.Time = 3.0
MiniPlayField_0.EasingPosition = xBAM.easeOutBounce
MiniPlayField_0.EasingRotation = xBAM.easeOutElastic
MiniPlayField_0.EasingScale    = xBAM.easeOutBack
MiniPlayField_0.RotationOrder  = xBAM.orderXYZ

' ---- Animate playfield: move to position A
Sub Move_Playfield_To_Position_A
Call MiniPlayField_0.MoveTo(    100,     510,      15,       0,       0,       90,    1.33,       0)         
End Sub

' ---- Animate playfield: move to position B (start position)
Sub Move_Playfield_To_Position_B
Call MiniPlayField_0.MoveTo(    200,     510,      15,       0,       0,       0,    0.66,       0)
End Sub

In menu to test same thing you need to:
1. Set starting position:
- Set X/Y/Z-Position to: 200 / 510 / 15
- Set X/Y/Z-Rotation to: 0 / 0 / 0
- Set Scale to 0.66
- Set Time to 3.0
- In Easing submenu set .... (you probably know what)
- Set start position <- select this line in menu and press enter. This line will change to "Replace start position".

2. Change settings to "target" position:
- Set X/Y/Z-Position to: 100 / 510 / 15
- Set X/Y/Z-Rotation to: 0 / 0 / 90
- Set Scale to 1.33

3. Press Play in BAM menu ... Animation will be played.

4. Change settings and try again... and again ... and again.

... and one more thing about xBAM.easeLinear, xBAM.easeInQuad, ... xBAM.easeSOMETHING. That are constant ineager too. You can peek values with AddDebugText.
MiniPlayField_0.EasingPosition = xBAM.easeOutBounce is same as MiniPlayField_0.EasingPosition = 29
Like with xBAM.orderSOMETHING i added it, because it look better in script and is more descriptive.

.... and CTRL-C
When you press that key combination inside Easing menu or when cursor is on line Easing: ..... it will put in clipbord code snipet like this:
MiniPlayField_0.EasingPosition = xBAM.easeOutBounce
MiniPlayField_0.EasingRotation = xBAM.easeOutElastic
MiniPlayField_0.EasingScale    = xBAM.easeOutBack
MiniPlayField_0.RotationOrder  = xBAM.orderXYZ
MiniPlayField_0.Inertia        = 100

Is is very simple. Every ball on playfield have Position. So why not set mini-playfield Position to ball position?
Well ... it is not funy to read ball position every frame and move playfield. You have very simple solution for this:
MiniPlayField_1.TrackedBall = ball

With BAM help to find ball on playfield close to give coords you need to call. xBAM.BallCloseTo(X,Y). In my "miniplayfield2.fpt" is use line like this:
MiniPlayField_1.TrackedBall = xBAM.BallCloseTo(440, 1000)

There is another way to get "ball" in BAM. When any ball hit object like bumper FP calls "Somthing_Hit()" subroutine. Inside it you can read "ball" varible and get FP ball id. FP will set that value befor it call this subroutine. Same way BAM will set "xBAM.Ball" variable to BAM-ball-object. That object you can assign to .TrackedBall.
So inside _Hit() subroutine you write:
MiniPlayField_1.TrackedBall = xBAM.Ball
Remember: It will work only inside _Hit() subroutine.

xBAM.BallCloseTo will work always.

Sometimes xBAM.BallCloseTo will not find any ball (when there is no ball on playfield). Don't worry about this. BAM will know, that returned value is empty.

.TrackedBallExist - this property of miniplayfield will be TRUE when .TrackedBall is assigned and ball exist. When you destroy ball (like with Drain.DestroyBall) BAM will know that. In that case .TrackedBall will be set to FALSE.
In script you may check this (like i do it in BallTrackerTimer_Expired subroutine):
If MiniPlayField_1.TrackedBallExist Then
   MiniPlayField_1.Rotation.Z = MiniPlayField_1.Rotation.Z + 160
   MiniPlayField_1.TrackedBall = xBAM.BallCloseTo(440, 1000)
End If

If you want stop tracking of ball, call .TrackedBallStop()
It will disable "ball tracking". After this you can call .MoveTo function to "hide" mini-playfield out of player sight.

When mini-playfield is attached to ball, you can't set position but you can still change rotation angle and scale. You can use "center point" set relative position of mini-playfield from Ball position.

MiniPlayField_1.TrackRotation = TRUE
After this, mini-playfield willbe rotate same way as ball. If mini-playfield is inside of ball or on ball surface all (ball+miniplayfield) will roll/rotate like one object. See "glass-ball-with-bumper" in miniplayfield3.fpt.

So, you can create custom ball with special textures or colors. Why not to make it transparent (or invisible)?
Here is code used to create "very special" ball:

You can set Opacity in 3 ways (Opacity = float value between 0 and 1):
- xBAM.BallOpacity = Opacity - before you create custom ball (same way as xBAM.BallMass = Mass). See CreateCustomBall in ballDemo8.fpt
- call xBAM.BallManager.SetBallOpacity(BallIdNumber, Opacity) - Set opacity of already created custom ball immediately. Call it any time after xBAM.BallManager.CreatCustomBall. You need to store Ball Id.
- call xBAM.BallManager.SetBallOpacityWithEasing(BallIdNumber, Opacity, Time, EasingFunction) - Same way as above, but ball opacity may change slowly, in given Time and with selected EasingFunction

Now: Why this?
For example you can create mini-playfield with DMD and display something above ball (miownkhan idea).
you can create mini-playfield with "ring" and create ball-like-saturn-with-rings.
.... you can create something more complicated....
... you can create BB-8 ball (my "bumper" floating over ball is poor imitation of BB-8).

Moving or rotating of playfield should have effect on ball move. But it is not simple thing. FP physics engine is not prepared for things like this. I create my own "fake-ball-inertia-simulation". It is not perfact, but ... well for me it work better than i expected.
At begin i was planing not to do it. So think of it as "nice side effect" of other tricks needed to make proper gravity and table-shacking.

In script you have only one value to controll ball inertia:
When you set it to 0, it will be disabled.
I set this to 100 as good value for me, but you probably have to adjust it for different physics.
You can have different value for different playfields.
My only advise: It is better to make it too week than too strong.

===================== END OF TUTORIAL ==============

Wow ... two months of coding, reasarch .... For me result is better than i expected.

Now time to fix errors and make put it in normal BAM release.

Question: Do we need "fake-magnetic-fields-to-push-or-pull-balls"?

Author:  Gimli [ Mon Aug 15, 2016 10:42 am ]
Post subject:  Re: NEW MiniPlayfields in BAM

:lol: :lol: :lol: Wowwwwww Ravarcade !!!!

I am looking forward to implement a shaking MP on the indiana jones table

Thank you so much !!!

I am on the verge on releasing Genisis Plus version of Genesis with some of these functions...

It is amazing how much stuff you have added :shock: :shock:

Author:  Gimli [ Tue Aug 16, 2016 3:56 pm ]
Post subject:  Re: NEW MiniPlayfields in BAM

:D Here is a prelimary test of the Shaking Path of Adventure miniplayfield in Indiana Jones!

It works :lol:

Thanks to deal with the ball handling

Author:  Gimli [ Tue Aug 16, 2016 6:52 pm ]
Post subject:  Re: NEW MiniPlayfields in BAM

Here's an updated video of my progress! :o
This is amazing Rav , you are genius!!

Author:  starac [ Wed Aug 17, 2016 4:12 am ]
Post subject:  Re: NEW MiniPlayfields in BAM

That's the real thing...
you are amazing :)

Author:  Gimli [ Sun Aug 21, 2016 9:19 am ]
Post subject:  Re: NEW MiniPlayfields in BAM

Attention administrators
Please make this a sticky

Author:  Gimli [ Wed Aug 24, 2016 3:11 pm ]
Post subject:  Re: NEW MiniPlayfields in BAM

With further development of Ravarcade's miniplayfield feature for BAM, it is possible that at some point down the road, a Path of Adventure that moves laterally with the flippers will be possible

Enjoy !

Ravarcade the Genius, has indeed enabled a toolset for miniplayfield's including rotation,
scaling and an animation (Shaking)

See this video:

There are likley many bugs still and I will send to the testers
(GeorgeH, Umpa, and Starac for help)


:shock: :shock: :shock:

Author:  smoke [ Fri Aug 26, 2016 3:52 am ]
Post subject:  Re: NEW MiniPlayfields in BAM

nice !!!

Author:  Gimli [ Sat Aug 27, 2016 2:58 pm ]
Post subject:  Re: NEW MiniPlayfields in BAM

Hi Ravarcade,

I am really loving the New Miniplayfield feature of BAM

A couple of things I noticed:

1.I can't run kinect in the new Bam.dll , BAM crashes when I switch from the "Happy Cab"to Kinect menu

2.I notice that the BAMsetup.exe lets you select which headtracking features you want.
Is it possible to have the setup.exe only include what you want ,in my case only Static Mode and Kinect ( ie not Future Pinball mode, HappyCab, wimote, facetrack etc...)

3.The POA texture on Indiana Jones doesn't show up for some reason on the miniplayfield so I went with a brick texture instead?

Thanks for you amazing work!

Author:  ravarcade [ Sat Aug 27, 2016 5:10 pm ]
Post subject:  Re: NEW MiniPlayfields in BAM

Gimli wrote:
1.I can't run kinect in the new Bam.dll , BAM crashes when I switch from the "Happy Cab"to Kinect menu

I will check it.

Gimli wrote:
2.I notice that the BAMsetup.exe lets you select which headtracking features you want.
Is it possible to have the setup.exe only include what you want ,in my case only Static Mode and Kinect ( ie not Future Pinball mode, HappyCab, wimote, facetrack etc...)

During setup you can select plugins you want to install. So you can uncheck all and left only Kinect selected.
So from your list, you already can remove freetrack or simplecam.

But you can't remove Future Pinball mode, HappyCab or WiiMode. Sorry.

Gimli wrote:
3.The POA texture on Indiana Jones doesn't show up for some reason on the miniplayfield so I went with a brick texture instead?

I think it is FP error, but there is simple solution, move whole POA (all objects in miniplayfield) from left side of table to right side. (It will be like move all X position +1000 units).

Description why there is problem:
FP uses coord system with top/left corrner to table as position 0,0. When you put objects on left side of table, they will have coords X < 0. In calculation for coords of surface texture, FP will replace all X < 0 with 0. Lika suface taxture is 1 pixel with widh.

I will send to you via PM table with fix.

Page 1 of 16 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group