public void GetDragon ()
		{
			EntityInfo newEntity = new EntityInfo
			{
				Position = Vector3.zero,
				Orientation = Quaternion.identity,
				IsLocallyCreated = true
			};

			int createCall = communicator.Call ("NVC.getDragon");
			communicator.AddReplyHandler (createCall, delegate(CallReply reply) {
				newEntity.Guid = reply.RetValue.ToString ();
				
				if (EntityCreated != null)
					EntityCreated (this, new EntityCreatedEventArgs (newEntity.Guid, newEntity));
			});
		}
		public void CreateEntityAt (Vector3 position)
		{
			EntityInfo newEntity = new EntityInfo
            {
                Position = position,
                Orientation = Quaternion.identity,
                IsLocallyCreated = true
            };

			int createCall = communicator.Call ("editing.createEntityAt", newEntity.Position);
			communicator.AddReplyHandler (createCall, delegate(CallReply reply) {
				newEntity.Guid = reply.RetValue.ToString ();

				if (EntityCreated != null)
					EntityCreated (this, new EntityCreatedEventArgs (newEntity.Guid, newEntity));
			});
		}
		public void UpdateBones (EntityInfo e, List<Transform> transforms)
		{
			var pos = new List<Vector3> ();
			var rot = new List<Quaternion> ();
			foreach(var t in transforms)
			{
				if (t == null) {
					pos.Add(Vector3.zero);
					rot.Add(Quaternion.identity);
					continue;
				}
				pos.Add(t.localPosition);
				rot.Add(t.localRotation);
			}

			communicator.Call ("NVC.updateBones", e.Guid,  pos, rot, Timestamps.UnixTimestamp);

			Debug.Log("updateBones " + e.Guid);
		}
 public NewObjectEventArgs(EntityInfo newObjectInfo)
 {
     entityInfo = newObjectInfo;
 }
		public void RotateEntity (EntityInfo info)
		{
			clientDriver.RotateEntity (info);
		}
		public void MoveEntity (EntityInfo info)
		{
			clientDriver.MoveEntity (info);
		}
		public void UpdateBones (EntityInfo e, List<Transform> t)
		{
			worldManager.UpdateBones (e, t);
		}
 public EntityCreatedEventArgs(string guid, EntityInfo info)
 {
     entityGuid = guid;
     entityInfo = info;
 }
 public void RotateEntity(EntityInfo info)
 {
     communicator.Call("location.updateOrientation", info.Guid, info.Orientation, Timestamps.UnixTimestamp);
 }
        private void HandleNewObject(JToken entityInfo)
        {
            EntityInfo info = new EntityInfo {
                Guid = entityInfo["guid"].ToString()
            };

            if (entityInfo["location"] != null && entityInfo["location"]["position"] != null)
                info.Position = entityInfo["location"]["position"].ToObject<Vector>();
            else
                info.Position = new Vector { x = 0, y = 0, z = 0 };

            if (entityInfo["location"] != null && entityInfo["location"]["orientation"] != null)
                info.Orientation = entityInfo["location"]["orientation"].ToObject<Quat>();
            else
                info.Orientation = new Quat { x = 0, y = 0, z = 0, w = 1 };

            logger.Info("New entity: {0}", info.Guid);

            lock (Entities)
                Entities.Add(info);
        }
        void RotateEntity(EntityInfo info)
        {
            AxisAngle aa = new AxisAngle();
            aa.FromQuaternion(info.Orientation);
            aa.Angle += 0.1;

            if (aa.Angle > 2 * Math.PI)
                aa.Angle = 0;

            info.Orientation = aa.ToQuaternion();

            communicator.Call("location.updateOrientation", info.Guid, info.Orientation, Timestamps.UnixTimestamp);
        }
 void MoveEntity(EntityInfo info)
 {
     info.Position.x = Timestamps.FloatMilliseconds;
     communicator.Call("location.updatePosition", info.Guid, info.Position, Timestamps.UnixTimestamp);
 }
Esempio n. 13
0
 public EntityCreatedEventArgs(string guid, EntityInfo info)
 {
     entityGuid = guid;
     entityInfo = info;
 }
		private void HandleNewObject (Dictionary<string, object> entityInfo)
		{
			EntityInfo newEntity = new EntityInfo {
                Guid = entityInfo["guid"].ToString()
            };

			if (entityInfo ["location"] != null) {
				Dictionary<string, Dictionary<string, object>> locationValues = entityInfo ["location"] as Dictionary<string, Dictionary<string, object>>;
                
				if (locationValues ["location"] ["position"] != null)
					newEntity.Position = (Vector3)locationValues ["location"] ["position"];
				else
					newEntity.Position = Vector3.zero;

				if (locationValues ["location"] ["orientation"] != null)
					newEntity.Orientation = (Quaternion)locationValues ["location"] ["orientation"];
				else
					newEntity.Orientation = Quaternion.identity;
			}
            

			lock (Entities)
				Entities.Add (newEntity);

			if (ReceivedNewObject != null)
				ReceivedNewObject (this, new NewObjectEventArgs (newEntity));
		}
		public void MoveEntity (EntityInfo info)
		{
			communicator.Call ("location.updatePosition", info.Guid, info.Position, Timestamps.UnixTimestamp);
		}
 public void MoveEntity(EntityInfo info)
 {
     communicator.Call("location.updatePosition", info.Guid, info.Position, Timestamps.UnixTimestamp);
 }
		public void RotateEntity (EntityInfo info)
		{
			communicator.Call ("location.updateOrientation", info.Guid, info.Orientation, Timestamps.UnixTimestamp);
		}
        public void CreateEntity()
        {
            EntityInfo newEntity = new EntityInfo
            {
                Position = new Vector
                {
                    x = random.NextDouble() * 20 - 10,
                    y = random.NextDouble() * 20 - 10,
                    z = random.NextDouble() * 20 - 10
                },
                Orientation = new Quat { x = 0, y = 0, z = 0, w = 1 },
                IsLocallyCreated = true
            };

            int createCall = communicator.Call("editing.createEntityAt", newEntity.Position);
            communicator.AddReplyHandler(createCall, delegate(CallReply reply)
            {
                newEntity.Guid = reply.RetValue.ToString();
                lock (Entities)
                    Entities.Add(newEntity);
                logger.Info("Created entity: {0}", newEntity.Guid);
            });
        }