void InsertEntityNotificationHandler(simengine.InsertSimulationEntity ins) { // TT - Unique entity class required // _entity = (simengine.DifferentialDriveEntity)ins.Body; _entity = (simengine.TTDifferentialDriveEntity)ins.Body; _entity.ServiceContract = Contract.Identifier; // create default state based on the physics entity if (_entity.ChassisShape != null) _state.DistanceBetweenWheels = _entity.ChassisShape.BoxState.Dimensions.X; _state.LeftWheel.MotorState.PowerScalingFactor = _entity.MotorTorqueScaling; _state.RightWheel.MotorState.PowerScalingFactor = _entity.MotorTorqueScaling; }
void DeleteEntityNotificationHandler(simengine.DeleteSimulationEntity del) { _entity = null; }
/* public double ConvertQuaternion(Quaternion q) { AxisAngle a = new AxisAngle(); a = Quaternion.ToAxisAngle(q); if (float.IsNaN(a.Angle)) return 0; else if (Math.Sign(a.Axis.Y) < 0) return 2.0 * Math.PI - a.Angle; return a.Angle; } */ void InsertEntityNotificationHandlerFirstTime(simengine.InsertSimulationEntity ins) { InsertEntityNotificationHandler(ins); base.Start(); // Listen on the main port for requests and call the appropriate handler. MainPortInterleave.CombineWith( new Interleave( new TeardownReceiverGroup(), new ExclusiveReceiverGroup( Arbiter.Receive<simengine.InsertSimulationEntity>(true, _notificationTarget, InsertEntityNotificationHandler), Arbiter.Receive<simengine.DeleteSimulationEntity>(true, _notificationTarget, DeleteEntityNotificationHandler) ), new ConcurrentReceiverGroup() ) ); }