public void Process() { client.Process(); if (client.IsConnected) { int addCount = 0; foreach (BallObject ball in BallArray) { if (!ball.IsInjected) { ball.IsInjected = true; InjectRequestMessage injectRequestMessage = new InjectRequestMessage(); injectRequestMessage.ObjectFragment.ObjectId = ball.ObjectId; injectRequestMessage.ObjectFragment.OwnerId = client.ParticipantId; injectRequestMessage.ObjectFragment.ObjectName = ball.ObjectName; injectRequestMessage.ObjectFragment.TypeName = "Ball"; injectRequestMessage.ObjectFragment.BoundingSphereRadius = ball.ObjectBoundingSphereRadius; injectRequestMessage.ObjectFragment.Mass = ball.Mass; injectRequestMessage.ObjectFragment.Location.X = ball.Location.X; injectRequestMessage.ObjectFragment.Location.Y = ball.Location.Y; injectRequestMessage.ObjectFragment.Location.Z = ball.Location.Z; OmModelPrimitiveExt modelPrimitiveExt = new OmModelPrimitiveExt(); modelPrimitiveExt.ModelUrl = "http://assets.bubblecloud.org/Collada/Duck/duck_triangulate.dae"; modelPrimitiveExt.Scale = 0.01f; injectRequestMessage.SetExtension(modelPrimitiveExt); //injectRequestMessage.ObjectFragment.SetExtensionData(new byte[50]); client.InjectObject(injectRequestMessage); addCount++; if (addCount > 5) { break; } } } for (int i = 0; i < 20; i++) { BallArray[updateIndex].OrbitAngle += 0.01f; BallArray[updateIndex].Location.X = (float)(BallArray[updateIndex].OrbitRadius * Math.Cos(BallArray[updateIndex].OrbitAngle)); BallArray[updateIndex].Location.Y = 0.5f; BallArray[updateIndex].Location.Z = (float)(BallArray[updateIndex].OrbitRadius * Math.Sin(BallArray[updateIndex].OrbitAngle)); if (client.CloudCache.GetObject(BallArray[updateIndex].ObjectId) != null) { MovementEventMessage movementEvent = new MovementEventMessage(); movementEvent.ObjectIndex = client.CloudCache.GetObject(BallArray[updateIndex].ObjectId).RemoteObjectIndex; movementEvent.Location.X = BallArray[updateIndex].Location.X; movementEvent.Location.Y = BallArray[updateIndex].Location.Y; movementEvent.Location.Z = BallArray[updateIndex].Location.Z; client.MoveObject(movementEvent); } this.updateIndex++; if (this.updateIndex >= NumberOfObjects) { this.updateIndex = 0; } } } }
public void MovementEvent() { CloudService serviceAlpha = new CloudService(serviceAlphaAssetCacheUrl, serviceAlphaAddress, serviceAlphaHubPort, serviceAlphaServerPort, serviceAlphaProgram, serviceAlphaProgramMajorVersion, serviceAlphaProgramMinorVersion); CloudBubble bubbleOne = new CloudBubble(bubbleOneId, bubbleOneName, bubbleOneRange, bubbleOnePerceptionRange); serviceAlpha.AddBubble(bubbleOne); bubbleOne.AddAllowedRemoteHubAddress(serviceBetaAddress); serviceAlpha.AddBubbleLink(bubbleOneId, bubbleTwoId, serviceBetaAddress, serviceBetaHubPort, bubbleOneTwoDeltaX, bubbleOneTwoDeltaY, bubbleOneTwoDeltaZ, true, true); CloudService serviceBeta = new CloudService(serviceBetaAssetCacheUrl, serviceBetaAddress, serviceBetaHubPort, serviceBetaServerPort, serviceBetaProgram, serviceBetaProgramMajorVersion, serviceBetaProgramMinorVersion); CloudBubble bubbleTwo = new CloudBubble(bubbleTwoId, bubbleTwoName, bubbleTwoRange, bubbleTwoPerceptionRange); bubbleTwo.AddAllowedRemoteHubAddress(serviceAlphaAddress); serviceBeta.AddBubble(bubbleTwo); CloudBubble bubbleThree = new CloudBubble(bubbleThreeId, bubbleThreeName, bubbleThreeRange, bubbleThreePerceptionRange); bubbleThree.AddAllowedRemoteHubAddress(serviceAlphaAddress); bubbleThree.AddAllowedRemoteHubAddress(serviceBetaAddress); serviceBeta.AddBubble(bubbleThree); serviceBeta.AddBubbleLink(bubbleTwoId, bubbleThreeId, serviceBetaAddress, serviceBetaHubPort, bubbleTwoThreeDeltaX, bubbleTwoThreeDeltaY, bubbleTwoThreeDeltaZ, true, true); serviceAlpha.Startup(false); serviceBeta.Startup(false); CloudView viewOne = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion); viewOne.Connect(serviceAlphaAddress, serviceAlphaServerPort, bubbleOneId, "", "", participantIdentityProviderUrl, participantNameOne, participantPassphraseOne, objectId, false); CloudView viewTwo = new CloudView(1000, clientProgramName, clientProgramMajorVersion, clientProgramMinorVersion); viewTwo.Connect(serviceBetaAddress, serviceBetaServerPort, bubbleThreeId, "", "", participantIdentityProviderUrl, participantNameTwo, participantPassphraseTwo, objectId, false); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Assert.IsTrue(viewOne.IsConnected); Assert.IsTrue(viewTwo.IsConnected); InjectRequestMessage injectRequestMessage = new InjectRequestMessage(); injectRequestMessage.ObjectFragment.ObjectId = objectId; injectRequestMessage.ObjectFragment.ObjectIndex = objectIndex; injectRequestMessage.ObjectFragment.ObjectName = objectName; injectRequestMessage.ObjectFragment.TypeId = objectTypeId; injectRequestMessage.ObjectFragment.TypeName = objectTypeName; injectRequestMessage.ObjectFragment.OwnerId = viewOne.ParticipantId; injectRequestMessage.ObjectFragment.ParentObjectId = objectParentObjectId; injectRequestMessage.ObjectFragment.Mass = objectMass; injectRequestMessage.ObjectFragment.BoundingSphereRadius = objectBoundingSphereRadius; injectRequestMessage.ObjectFragment.Location.X = objectLocationX; injectRequestMessage.ObjectFragment.Location.Y = objectLocationY; injectRequestMessage.ObjectFragment.Location.Z = objectLocationZ; injectRequestMessage.ObjectFragment.Velocity.X = objectVelocityX; injectRequestMessage.ObjectFragment.Velocity.Y = objectVelocityY; injectRequestMessage.ObjectFragment.Velocity.Z = objectVelocityZ; injectRequestMessage.ObjectFragment.Acceleration.X = objectAccelerationX; injectRequestMessage.ObjectFragment.Acceleration.Y = objectAccelerationY; injectRequestMessage.ObjectFragment.Acceleration.Z = objectAccelerationZ; injectRequestMessage.ObjectFragment.Orientation.X = objectOrientationX; injectRequestMessage.ObjectFragment.Orientation.Y = objectOrientationY; injectRequestMessage.ObjectFragment.Orientation.Z = objectOrientationZ; injectRequestMessage.ObjectFragment.Orientation.W = objectOrientationW; injectRequestMessage.ObjectFragment.AngularVelocity.X = objectAngularVelocityX; injectRequestMessage.ObjectFragment.AngularVelocity.Y = objectAngularVelocityY; injectRequestMessage.ObjectFragment.AngularVelocity.Z = objectAngularVelocityZ; injectRequestMessage.ObjectFragment.AngularVelocity.W = objectAngularVelocityW; injectRequestMessage.ObjectFragment.AngularAcceleration.X = objectAngularAccelerationX; injectRequestMessage.ObjectFragment.AngularAcceleration.Y = objectAngularAccelerationY; injectRequestMessage.ObjectFragment.AngularAcceleration.Z = objectAngularAccelerationZ; injectRequestMessage.ObjectFragment.AngularAcceleration.W = objectAngularAccelerationW; injectRequestMessage.ObjectFragment.ExtensionDialect = objectExtensionDialect; injectRequestMessage.ObjectFragment.ExtensionDialectMajorVersion = objectExtensionDialectMajorVersion; injectRequestMessage.ObjectFragment.ExtensionDialectMinorVersion = objectExtensionDialectMinorVersion; injectRequestMessage.ObjectFragment.SetExtensionData(objectExtensionData); viewOne.InjectObject(injectRequestMessage); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); CloudObject bubbleOneCloudObject = bubbleOne.CloudCache.GetObject(objectId); Assert.IsNotNull(bubbleOneCloudObject); CloudObject bubbleTwoCloudObject = bubbleTwo.CloudCache.GetObject(objectId); Assert.IsNotNull(bubbleTwoCloudObject); CloudObject bubbleThreeCloudObject = bubbleThree.CloudCache.GetObject(objectId); Assert.IsNotNull(bubbleThreeCloudObject); CloudObject viewOneCloudObject = viewOne.CloudCache.GetObject(objectId); Assert.IsNotNull(viewOneCloudObject); CloudObject viewTwoCloudObject = viewTwo.CloudCache.GetObject(objectId); Assert.IsNotNull(viewTwoCloudObject); MovementEventMessage movement = new MovementEventMessage(); movement.ObjectIndex = viewOneCloudObject.LocalObjectIndex; movement.Location.X = modifiedObjectLocationX; movement.Location.Y = modifiedObjectLocationY; movement.Location.Z = modifiedObjectLocationZ; movement.Orientation.X = objectOrientationX; movement.Orientation.Y = objectOrientationY; movement.Orientation.Z = objectOrientationZ; movement.Orientation.W = objectOrientationW; viewOne.MoveObject(movement); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Assert.AreEqual(modifiedObjectLocationX - bubbleOneTwoDeltaX - bubbleTwoThreeDeltaX, bubbleThreeCloudObject.Location.X); Assert.AreEqual(modifiedObjectLocationY - bubbleOneTwoDeltaY - bubbleTwoThreeDeltaY, bubbleThreeCloudObject.Location.Y); Assert.AreEqual(modifiedObjectLocationZ - bubbleOneTwoDeltaZ - bubbleTwoThreeDeltaZ, bubbleThreeCloudObject.Location.Z); Assert.AreEqual(objectOrientationX, bubbleThreeCloudObject.Orientation.X); Assert.AreEqual(objectOrientationY, bubbleThreeCloudObject.Orientation.Y); Assert.AreEqual(objectOrientationZ, bubbleThreeCloudObject.Orientation.Z); Assert.AreEqual(objectOrientationW, bubbleThreeCloudObject.Orientation.W); EjectRequestMessage ejectRequestMessage = new EjectRequestMessage(); ejectRequestMessage.ObjectId = objectId; viewOne.EjectObject(ejectRequestMessage); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Assert.IsNull(bubbleOne.CloudCache.GetObject(objectId)); Assert.IsNull(bubbleTwo.CloudCache.GetObject(objectId)); Assert.IsNull(bubbleThree.CloudCache.GetObject(objectId)); Assert.IsNull(viewOne.CloudCache.GetObject(objectId)); Assert.IsNull(viewTwo.CloudCache.GetObject(objectId)); viewOne.Disconnect(); viewTwo.Disconnect(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); Thread.Sleep(10); serviceAlpha.Process(); serviceBeta.Process(); viewOne.Process(); viewTwo.Process(); serviceAlpha.Shutdown(); serviceBeta.Shutdown(); }