private void OnWindowStatisticsSingleDisplayUpdateHandler(WindowStatistics.OnSingleDisplayUpdate onSingleDisplayUpdate) { Globals.GlobalWinFormsServicePort.FormInvoke( delegate() { _windowStatistics.SingleUpdateDisplayValues(onSingleDisplayUpdate); } ); }
/// <summary> /// Build the the physical model /// </summary> /// <param name="device">A reference to the used graphics graphics device</param> /// <param name="physicsEngine">A reference to the used physics engine</param> private void ProgrammaticallyBuildModel(xnagrfx.GraphicsDevice device, PhysicsEngine physicsEngine) { // Create central box BoxShapeProperties centerBoxChassisProperties = new BoxShapeProperties( 0.2f, // 200g new Pose(new Vector3(0, CHASSIS_DIMENSIONS_HEIGHT / 2, 0)), new Vector3(0.06f, CHASSIS_DIMENSIONS_HEIGHT, 0.06f) ); //State.PhysicsPrimitives.Add(new BoxShape(centerBoxChassisProperties)); // Create box shape dynamically for each multicopter arm float angleOffset = (2 * xna.MathHelper.Pi) / Globals.Instance.multicopterPropellerCount[multicopterType]; Vector3 multicopterCenter = new Vector3(ARM_CHASSIS_DIMENSIONS.X / 2, ARM_CHASSIS_DIMENSIONS.Y / 2 - 0.004f, 0.0f); for (int i = 0; i < Globals.Instance.multicopterPropellerCount[multicopterType]; i++) { BoxShapeProperties chassisShapeProperties = new BoxShapeProperties( MULTICOPTER_ARM_MASS, new Pose(MathHelper.RotateAroundAxis_Y(multicopterCenter, new Vector3(), angleOffset * i), Quaternion.FromAxisAngle(0.0f, -1.0f, 0.0f, angleOffset * i)), ARM_CHASSIS_DIMENSIONS ); // Set the material properties // -> Restitution = how bouncy the material is // -> Static friction = Friction between non-moving surfaces // -> Dynamic friction = Friction betwwen moving surfaces chassisShapeProperties.Material = new MaterialProperties("high friction", 0.1f, 1.0f, 20.0f); chassisShapeProperties.Name = State.Name + " Arm chassis " + i; // Add the chassis descriptions State.PhysicsPrimitives.Add(new BoxShape(chassisShapeProperties)); } // Gesamtmasse des Multicopters im Statistics Fenster anzeigen WindowStatistics.OnSingleDisplayUpdate onSingleDisplayUpdate = new WindowStatistics.OnSingleDisplayUpdate(); onSingleDisplayUpdate.multicopterWeight = Globals.Instance.multicopterPropellerCount[multicopterType] * MULTICOPTER_ARM_MASS; windowStatisticsEventsPort.Post(onSingleDisplayUpdate); // Create and insert the physics entity base.CreateAndInsertPhysicsEntity(physicsEngine); // Increase physics fidelity base.PhysicsEntity.SolverIterationCount = 60; }