beta version with ball shadows for testings:
https://www.ravarcade.pl/beta/BAM.dllIf you find errors or want to change default params for ball shadows when you have few days to let me know before it will be released.
https://youtu.be/N_AdMHrKdeo(video will be ready in ~1h)
New things:
- ball shadows (enabled by default)
- flipper shadows (more bellow)
- added new ball manipulation script functions
Demo table:
http://www.ravarcade.pl/beta/ballDemo9.fptAbout ball shadows:They are not "real" shadows. It is just added dark spot under ball. This method have no impact of performance and works allways. It may create some "errors" but in most cases it looks realy good.
There is no point in adding real shadows calculated for every light position. First, it may work only in new-renderer, second it will have huge impact of performance, third it may not look any better.
New ball shadows are enable by default. You can find options to change it in Addons menu.
- dark level - (default: 0.7) - if you want to disable shadows, set value to 0.0. It determines how dark is shadow.
- radius soft - (default: 1.8) - how far from ball shadow will be drawed [in ball radius units]. This is "soft" edge of shadow.
- radius hard - (default: 0.0) - "hard" edge of shadow. You "hard" = "soft" when whole spot under ball is uniform. If "hard" < "soft", between that 2 edges shadow will be blured.
Please play with that params. Maybe you will finde better default values.
Script:xBAM.SetBallShadows dark_level, radius_soft, radius_hard, maxLevelAbovePlayfield, removeShadowsFromInvisibleBall
Note, you have 2 more params than in BAM menu.
By default, when ball is above playfield, shadow under ball is smaller. If ball is ~13.5mm above (1 ball radius) shadow will disappear.
- maxLevelAbovePlayfield - (default value = 1.0) - you can increase how far from playfield ball shadow will diappear.
- removeShadowsFromInvisibleBall - (true/false, default true), If you have invisble balls on table (with opacity = 0.0), when ball will don't have shadow. So, in script you can set this to false and even invisible ball will have shadow. This is added in case if someone have wird ball on table with attached miniplayfield and wan't have shadow.
If you skip last 2 params in call to xBAM.SetBallShadows, when default value will be used.
Flippers shadows.Shadows under flippers are drawed ONLY if in script flipper have own "Ext" object.
If you want to add shadow to old table without any "dynamic flipper" stuffs you need add only
ONE line in script:
Code:
xBAM.CreateAllExt()
Shadows under flippers is drawed same way as for balls.
NEW CUSTOM BALLS IN SCRIPTGoal is to make custom ball manipulations easy and fun.
So, we have few new properties and functions in
BallInfo object.
Note:
Every time you call xBAM.BallCloseTo you get in return this object. Also in every
something_hit() subroutine you have access with xBAM.Ball to info what ball hit that "somthing" (like Sub LeftSlingshotRubber_Hit())
Here is list of new things:
- xBAM.Ball.
Id - unique id for every custom ball. It is =-1 if it is "normal" ball, not custom.
- xBAM.Ball.
Name - you can GET or SET ball "type".
In previous BAM version if you want to change ball texture you need to define ball "type" with xBAM.BallManager.DefineCustomBall and you need to pass this "type" as param to xBAM.BallManager.CreatCustomBall.
If you want to change how ball look in "_hit()" subroutine, you need call xBAM.BallManager.UpdateBall with custom ball "Id" and "Name" of ball type.
You would need a lot of code in script to trace custom ball "Id" and "Name".
Now it is simple. In _hit() subroutine to change that one ball you need only:
Code:
xBAM.Ball.Name = Ball_A
- xBAM.Ball.
UpdateBall red, green, blue, dirtTextrureName, reflectionTextureName, reflectionInPlayfieldTextureName - change custom ball look.
Now, you don't need to define custom ball with
xBAM.BallManager.DefineCustomBall, you can change look of one single custom ball any time in script.
You can change texture or color of ball. (ONLY CUSTOM BALL).
- xBAM.Ball.
Opacity - set ball opacity... like with xBAM.BallManager.SetBallOpacity function, but easy way
- xBAM.Ball.
SetBallOpacityWithEasing Opacity, Time, Easing - set ball opacity... like with xBAM.BallManager.SetBallOpacityWithEasing function, but easy way
- xBAM.Ball.
ExtTimer1[b], xBAM.Ball.[b]ExtTimer2[b], xBAM.Ball.[b]ExtTimer3[b] - every ball on table have 3 own timers. Unit is 1 second. You can use it in script. Also, [b]ExtTimer1 is starte when ball is created. So, when you read it you will get how long that one ball is on table. Every disable timer will return 0.0. Every enabled timer will return value bigger than 0.0.
- xBAM.Ball.
ResetExtTimer timerIdx - (timerIdx = 1 or 2 or 3), you can use this function to reset timer
- xBAM.Ball.
StopExtTimer timerIdx - (timerIdx = 1 or 2 or 3), stop timer.
About demo table1. In demo table you will see ball blinking red color for first 15 seconds.
I use ExtTime1 to count that 15 seconds and to calc at what part of interval we are. Color is changed smooth way base on time.
2. If ball hit left LeftSlingshotRubber i change ball color to green for 0.2 seconds and if ball hit RightSlingshotRubber i change to blue.
To do this i use ExtTimer2 to measue time and ExtInt2 to mark "left" or "right" slingshot rubber. So, in LeftSlingshotRubber_Hit() subroutine:
Code:
xBAM.Ball.ResetExtTimer 2
xBAM.Ball.ExtInt2 = 1 ' green flash
and in RightSlingshotRubber_Hit() subroutine:
Code:
xBAM.Ball.ResetExtTimer 2
xBAM.Ball.ExtInt2 = 2 ' blue flash
How it works:
1. All balls are create as "custom balls":
Code:
Sub CreateCustomBall (source)
Dim bi
Set bi = xBAM_BallManager.CreatCustomBall(0)
Source.CreateBall bi.Red, bi.Green, bi.Blue, bi.BallNumber
End Sub
Note: i don't define any "custom ball" with xBAM.BallManager.DefineCustomBall, i just pass 0 (zero) as argument to xBAM_BallManager.CreatCustomBall. I can change ball textures any time i want.
2. DrawFrameTick subroutine. This is same type subroutine as NewtonPhysicsTick. If you have that subroutine in script it will be called right before new frame will be rendered.
This is new thing added to BAM.
Code:
Sub DrawFrameTick()
xBAM.EnumBalls 100, 0, "BlinkBalls"
End Sub
Line xBAM.EnumBalls orders BAM to call BlinkBalls subroutine once for every ball on table with "BallInfo" object as argument. So, if we have 3 balls on table, BlinkBalls will be called 3 times.
In previous BAM you can do exacly same thing with NewtonPhysicsTick, but NewtonPhysicsTick will be called 5 or 6 times for 1 drawed frame. It will be just waste of time.
3. BlinkBalls subroutine.
Here we make ball blink for 15 second after ball creation:
Code:
Const BlinkInterval = 0.5 ' sec
Const BLinkDuration = 15.0 ' sec
Dim a
If ball.ExtTimer1 > 0.0 Then ' ExtTimer1 is not 0.0 when it is started after ball creation
If ball.ExtTimer1 > BlinkDuration Then
ball.UpdateBall 192, 192, 192
ball.Opacity = 1.0
ball.StopExtTimer 1
Else
a = ball.ExtTimer1 / BlinkInterval
a = (a - CLng(a)) * 2.0
If a < 0 Then a = -a
ball.UpdateBall 60 + CInt(192*a), 60, 60
End If
End If
So, in first "If" we check if ExtTimer1 is still running. If so, we check if that 15 seconds passed.... If, so set ball color to normal values and we disbale timer with ball.StopExtTimer 1.
If ExtTimer1 value is between 0 and 15 second we change ball color with ball.UpdateBall subroutine.
Second part of BlinkBalls is used to "flash" ball after slinshot rubber is hit.
Only difference is we use ExtTimer2 to count time (0.2 sec) after _hit() event and we set ball color base on ExtInt2 value.
Code:
Const FlashDuration = 0.2
If ball.ExtTimer2 > 0.0 Then
If ball.ExtTimer2 > FlashDuration Then
ball.StopExtTimer 2
ball.UpdateBall 192, 192, 192
Else
Select case ball.ExtInt2
case 1
ball.UpdateBall 60, 255, 60
case 2
ball.UpdateBall 60, 60, 255
case else
ball.UpdateBall 255, 255, 255
End Select
End If
End If
----------------
Have fun with new BAM beta.