コード例 #1
0
    void Update()
    {
        // Note - our gameObject is *not* the gameObject that we are watching here, that's a
        // different gameObject which is provided by the CurrentModelProvider.
        if (this.isMulticastingTransforms)
        {
            var transform = this.gameObject.transform;

            if (!this.currentRotation.HasValue ||
                !this.currentRotation.Value.EqualToTolerance(transform.localRotation, ROTATION_TOLERANCE) ||
                !this.currentTranslation.Value.EqualToTolerance(transform.localPosition, POSITION_TOLERANCE) ||
                !this.currentScale.Value.EqualToTolerance(transform.localScale, SCALE_TOLERANCE))
            {
                // We need to broadcast.
                Debug.Log("We have a change in transform to talk about");
                this.currentRotation    = transform.localRotation;
                this.currentTranslation = transform.localPosition;
                this.currentScale       = transform.localScale;

                NetworkMessagingProvider.SendTransformChangeMessage(
                    (Guid)this.ModelIdentifier.Identifier,
                    (Vector3)this.currentScale,
                    (Quaternion)this.currentRotation,
                    (Vector3)this.currentTranslation);
            }
        }
    }
コード例 #2
0
    void Start()
    {
        // This does nothing if we have no IP address connected to a network
        NetworkMessagingProvider.NewModelOnNetwork += this.OnNewModelFromNetwork;
        NetworkMessagingProvider.Initialise();

#if ENABLE_WINMD_SUPPORT
        this.StartSpeechCommandHandlingAsync();
#endif // ENABLE_WINMD_SUPPORT
    }
コード例 #3
0
    void OnRemoveSpeechCommand()
    {
        if (FocusWatcher.HasFocusedObject)
        {
            var focusedObject = FocusWatcher.FocusedObject;

            // Send network message saying we have got rid of this object in case others
            // are displaying it.
            var modelIdentifier = focusedObject.GetComponent <ModelIdentifier>();
            NetworkMessagingProvider.SendDeletedModelMessage(modelIdentifier.Identifier);

            focusedObject.GetComponent <ModelUpdatesManager>().Destroy();
        }
    }
コード例 #4
0
    async void OnOpenSpeechCommand()
    {
        var filePath = await this.PickFileFrom3DObjectsFolderAsync();

        if (!string.IsNullOrEmpty(filePath))
        {
            var modelDetails = await this.ImportGLTFModelFromFileAsync(filePath);

            if (modelDetails != null)
            {
                // Our new model comes out of the file load.
                var newModel = modelDetails.GameObject;

                // Give the new model a new identity.
                var modelIdentifier = newModel.AddComponent <ModelIdentifier>();

                // Make it focusable.
                newModel.AddComponent <FocusWatcher>();

                // Add positioning.
                var positioningManager = newModel.AddComponent <ModelPositioningManager>();
                positioningManager.InitialiseSizeAndPositioning(
                    this.RootParentProvider.RootParent);

                // Add manipulations to the new model so it can be moved around.
                var manipManager = newModel.AddComponent <ModelUpdatesManager>();
                manipManager.AddHandManipulationsToModel();

                // Add an anchor to the new model's parent such that we can then
                // anchor the parent while moving the model around within it
                // (anchored components can't move).
                var anchorManager = newModel.AddComponent <AnchorManager>();
                anchorManager.AddAnchorToModelParent();

                // Write out all the files that were part of loading this model
                // into a file in case they need sharing in future.
                await FileStorageManager.StoreFileListAsync(
                    (Guid)modelIdentifier.Identifier, modelDetails.FileLoader);

                // And export the anchor into the file system as well.
                // TODO: this will currently wait "for ever" for the world anchor to be
                // located which might be wildly optimistic, we should probably add some
                // notion of a timeout on that here too.
                var exportedAnchorBits = await anchorManager.ExportAnchorAsync();

                if (exportedAnchorBits != null)
                {
                    // Store that into the file system so that the web server can later
                    // serve it up on request.
                    await FileStorageManager.StoreExportedWorldAnchorAsync(
                        (Guid)modelIdentifier.Identifier,
                        exportedAnchorBits);

                    // Message out to the network that we have a new model that they
                    // can optionally grab if they want to.
                    NetworkMessagingProvider.SendNewModelMessage(
                        (Guid)modelIdentifier.Identifier);
                }
            }
        }
    }