public BallApi CreateBall(Player player, IBallCreationPosition ballCreator, float radius, float mass) { // calculate mass and scale var m = player.TableToWorld; var localPos = ballCreator.GetBallCreationPosition(_table).ToUnityFloat3(); var localVel = ballCreator.GetBallCreationVelocity(_table).ToUnityFloat3(); localPos.z += radius; //float4x4 model = player.TableToWorld * Matrix4x4.TRS(localPos, Quaternion.identity, new float3(radius)); var worldPos = m.MultiplyPoint(localPos); var scale3 = new Vector3( m.GetColumn(0).magnitude, m.GetColumn(1).magnitude, m.GetColumn(2).magnitude ); var scale = (scale3.x + scale3.y + scale3.z) / 3.0f; // scale is only scale (without radiusfloat now, not vector. var material = BallMaterial.CreateMaterial(); var mesh = GetSphereMesh(); // create ball entity EngineProvider<IPhysicsEngine>.Get() .BallCreate(mesh, material, worldPos, localPos, localVel, scale, mass, radius); return null; }
public Ball CreateBall(IBallCreationPosition ballCreator, float radius = 25f, float mass = 1) { var ball = _physics.CreateBall(ballCreator, this, radius, mass); BallCreated?.Invoke(this, new BallCreationArgs(ball.Name, ball.State.Pos, radius)); return(ball); }
public Ball CreateBall(IBallCreationPosition ballCreator, Player player, float radius = 25f, float mass = 1f) { var ballId = Ball.IdCounter++; var data = new BallData(ballId, radius, mass, _table.Data.DefaultBulbIntensityScaleOnBall); var state = new BallState("Ball${ballId}", ballCreator.GetBallCreationPosition(_table)); state.Pos.Z += data.Radius; var ball = new Ball(data, state, ballCreator.GetBallCreationVelocity(_table), player, _table); ballCreator.OnBallCreated(this, ball); Balls.Add(ball); _movers.Add(ball.Mover); // balls are always added separately to this list! _hitObjectsDynamic.Add(ball.Hit); _hitOcTreeDynamic.FillFromVector(_hitObjectsDynamic); return(ball); }
public void CreateBall(IBallCreationPosition ballCreator, float radius, float mass, in Entity kickerRef)
public void CreateBall(IBallCreationPosition ballCreator, float radius = 25f, float mass = 1f) { CreateBall(ballCreator, radius, mass, Entity.Null); }
public Ball CreateBall(IBallCreationPosition ballCreator, float radius = 25f, float mass = 1) { return(_physics.CreateBall(ballCreator, this, radius, mass)); }