public void StaticActorMsgTest() { IRemotePhysicsMessenger testMessenger; RemotePhysicsConfiguration defaultConfig; IRemotePhysicsPacketManager testPacketManager; IRemotePhysicsPacketManager testUdpPacketManager; Thread serverThread; // Indicate that the test isn't done, and the server thread should not be shut down m_testDone = false; // Create the mock server Console.WriteLine("Launching server thread..."); serverThread = new Thread(new ThreadStart(MockServer)); serverThread.Start(); // Create the configuration that will be used for the test; the default values are sufficient defaultConfig = new RemotePhysicsConfiguration(); // Create the packet manager that will be used for receiving messages testPacketManager = new RemotePhysicsTCPPacketManager(defaultConfig); testUdpPacketManager = new RemotePhysicsUDPPacketManager(defaultConfig); // Create the messenger that will be used to receive messages testMessenger = new RemotePhysicsAPPMessenger(); testMessenger.Initialize(defaultConfig, testPacketManager, testUdpPacketManager); testMessenger.StaticActorUpdated += new UpdateStaticActorHandler(StaticUpdated); // Send out a static actor update testMessenger.SetStaticActor(m_testStaticID, m_position, m_orientation); // Wait for the results to be sent back while (!m_staticResultsReceived) { // Sleep a bit Thread.Sleep(2000); } // Indicate that the test is done, so that the server thread can clean up m_testDone = true; // Wait for the mock server to clean up Thread.Sleep(2000); // Compare the results Assert.AreEqual(m_testStaticID, m_resultStaticID); Assert.AreEqual(m_position.X, m_resultPosition.X); Assert.AreEqual(m_position.Y, m_resultPosition.Y); Assert.AreEqual(m_position.Z, m_resultPosition.Z); Assert.AreEqual(m_orientation.X, m_resultOrientation.X); Assert.AreEqual(m_orientation.Y, m_resultOrientation.Y); Assert.AreEqual(m_orientation.Z, m_resultOrientation.Z); Assert.AreEqual(m_orientation.W, m_resultOrientation.W); }
// Initializes the physics scene /// <summary> /// Initializes the physics scene. /// </summary> /// <param name="meshmerizer">The mesher to be used for creating /// meshes from shape descriptions</param> /// <param name="config">The configuration settings to be used to /// configure the scene</param> /// <param name="regionExtent">The size of the scene in Open Simulator /// units</param> public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) { OpenMetaverse.Vector3 gravityVector; // Create a configuration, which will be used for initializing the // scene, using the "RemotePhysics" section of the given // configuration file RemoteConfiguration.Initialize(config.Configs["RemotePhysics"]); // Initialize the dimensions of this scene m_regionExtents = regionExtent; // Initialize the mesher SceneMesher = meshmerizer; // Create the dictionary that will map physics objects to their // respective IDs PhysicsObjects = new Dictionary <uint, RemotePhysicsObject>(); // Create the dictionaries that keep track of which objects have // collisions or don't have collisions ObjectsWithCollisions = new HashSet <RemotePhysicsObject>(); ObjectsWithNoMoreCollisions = new HashSet <RemotePhysicsObject>(); // The simulation time has not been updated yet m_lastSimulatedTime = 0.0f; // Create the packet manager that will maintain a connection // with the remote physics server m_remotePacketManager = new RemotePhysicsTCPPacketManager(RemoteConfiguration); // Create the packet manager that will be used for UDP // communications with the remote physics server m_remoteUdpPacketManager = new RemotePhysicsUDPPacketManager(RemoteConfiguration); // Create the messaging system that will allow this scene to // communicate with the remote physics server m_remoteMessenger = new RemotePhysicsAPPMessenger(); m_remoteMessenger.Initialize(RemoteConfiguration, m_remotePacketManager, m_remoteUdpPacketManager); RemoteMessenger = m_remoteMessenger; // Initialize the lists that will track which objects were updated // duing this and the last step m_updatedObjects = new List <RemotePhysicsObject>(); m_lastUpdatedObjects = new List <RemotePhysicsObject>(); // Send the logon message m_remoteMessenger.Logon(RemoteConfiguration.SimulationID, RegionName); // Set the callbacks that listen for updates from the remote engine m_remoteMessenger.OnDynamicActorUpdateEvent += new UpdateDynamicActorHandler(DynamicActorUpdated); m_remoteMessenger.OnActorsCollidedEvent += new ActorsCollidedHandler(ActorsCollided); m_remoteMessenger.OnDynamicActorMassUpdateEvent += new UpdateDynamicActorMassHandler(ActorMassUpdated); m_remoteMessenger.OnTimeAdvancedEvent += new TimeAdvancedHandler(TimeAdvanced); // Send the message to the remote physics engine that creates // the remote scene and establishes the ground plane gravityVector = new OpenMetaverse.Vector3(0.0f, 0.0f, RemoteConfiguration.Gravity); m_remoteMessenger.InitializeWorld(gravityVector, RemoteConfiguration.DefaultFriction, RemoteConfiguration.DefaultFriction, RemoteConfiguration.CollisionMargin, RemoteConfiguration.DefaultRestitution, m_groundPlaneID, RemoteConfiguration.GroundPlaneHeight, new OpenMetaverse.Vector3(0.0f, 0.0f, 1.0f)); // Indicate that the scene is now initialized m_initialized = true; }