コード例 #1
0
 public ModelLoadManager(Vector3 spawnPosition, Transform globalSpawnParent, BoundingBoxId boundingBoxId, bool remotelySpawned)
 {
     shader                 = ModelLoadSettings.Instance.shader;
     boundingBoxPrefab      = ModelLoadSettings.Instance.boundingBox;
     spawnEulerAngles       = new Vector3(0, 180, 0);
     this.spawnPosition     = spawnPosition;
     this.globalSpawnParent = globalSpawnParent;
     this.remotelySpawned   = remotelySpawned;
     this.boundingBoxId     = boundingBoxId;
 }
コード例 #2
0
    public void LoadModelForAll(string modelName)
    {
        Vector3 spawnPosition      = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
        Vector3 localSpawnPosition = worldAnchor.InverseTransformPoint(spawnPosition); // get coordinates in world-anchor-local space

        BoundingBoxId id = new BoundingBoxId();

        CustomMessages.Instance.SendModelSpawn(modelName, id, localSpawnPosition); // broadcast spawn event

        ModelLoadManager manager = new ModelLoadManager(localSpawnPosition, worldAnchor, id, false);

        manager.Load(modelName); // load model
    }
コード例 #3
0
    public void RemoteModelSpawned(NetworkInMessage msg)
    {
        Debug.Log("Received remote model spawn");
        long userId = msg.ReadInt64();

        if (userId != SharingStage.Instance.Manager.GetLocalUser().GetID())
        {
            string           modelName     = msg.ReadString();
            int              localBoxId    = msg.ReadInt32();
            BoundingBoxId    boundingBoxId = new BoundingBoxId(userId, localBoxId);
            Vector3          spawnPosition = CustomMessages.Instance.ReadVector3(msg);
            ModelLoadManager manager       = new ModelLoadManager(spawnPosition, worldAnchor, boundingBoxId, true);
            manager.Load(modelName);
        }
    }
コード例 #4
0
        public void SendModelDelete(BoundingBoxId boundingBoxId)
        {
            // If we are connected to a session, broadcast the bounding box transform
            if (serverConnection != null && serverConnection.IsConnected())
            {
                // Create an outgoing network message to contain all the info we want to send
                NetworkOutMessage msg = CreateMessage((byte)TestMessageID.ModelDelete);

                msg.Write(boundingBoxId.UserId);
                msg.Write(boundingBoxId.BoxId);

                // Send the message as a broadcast, which will cause the server to forward it to all other users in the session.
                serverConnection.Broadcast(
                    msg,
                    MessagePriority.Immediate,
                    MessageReliability.UnreliableSequenced,
                    MessageChannel.Default);
            }
        }
コード例 #5
0
    private static void ReceivedRemoteTransformChange(NetworkInMessage msg)
    {
        long          userId             = msg.ReadInt64(); // this is the user ID
        long          boxUser            = msg.ReadInt64();
        int           localBoundingBoxId = msg.ReadInt32();
        BoundingBoxId boundingBoxId      = new BoundingBoxId(boxUser, localBoundingBoxId);
        Vector3       newPosition        = CustomMessages.Instance.ReadVector3(msg);
        Quaternion    newRotation        = CustomMessages.Instance.ReadQuaternion(msg);
        Vector3       newScale           = CustomMessages.Instance.ReadVector3(msg);

        if (TransformationManager.instances.ContainsKey(boundingBoxId.ToString()))
        {
            TransformationManager.instances[boundingBoxId.ToString()].OnRemoteTransformChanged(newPosition, newRotation, newScale);
        }
        else
        {
            Debug.LogError("Received transform from an unknown bounding box: " + boundingBoxId.ToString());
        }
    }
コード例 #6
0
    private void OnRemoteDestroy(NetworkInMessage msg)
    {
        long userId = msg.ReadInt64();

        if (userId != SharingStage.Instance.Manager.GetLocalUser().GetID())
        {
            long          boxUser       = msg.ReadInt64();
            int           boxNumber     = msg.ReadInt32();
            BoundingBoxId boundingBoxId = new BoundingBoxId(boxUser, boxNumber);
            Debug.Log("Received remote destroy for " + boundingBoxId.ToString());
            if (TransformationManager.instances.ContainsKey(boundingBoxId.ToString()))
            {
                BoundingBoxActions actions = TransformationManager.instances[boundingBoxId.ToString()].gameObject.GetComponent <BoundingBoxActions>();
                actions.DeleteLocalObject();
            }
            else
            {
                Debug.Log("Delete command for unknown bounding box: " + boundingBoxId.ToString());
            }
        }
    }