private void OnSceneObjectCreated(SceneObjectInfoModel infoModel)
 {
     if (SceneObjectCreated != null)
     {
         SceneObjectCreated(infoModel);
     }
 }
        public async Task TransformSceneObject(SceneObjectModel sceneObject)
        {
            var infoModel = new SceneObjectInfoModel(sceneObject.Id, _sceneId);

            infoModel.Transformation = new TransformationInfoModel()
            {
                TranslateX = sceneObject.Transformation.TranslateX,
                TranslateY = sceneObject.Transformation.TranslateY,
                TranslateZ = sceneObject.Transformation.TranslateZ,
                RotateX    = sceneObject.Transformation.RotateX,
                RotateY    = sceneObject.Transformation.RotateY,
                RotateZ    = sceneObject.Transformation.RotateZ,
                ScaleX     = sceneObject.Transformation.ScaleX,
                ScaleY     = sceneObject.Transformation.ScaleY,
                ScaleZ     = sceneObject.Transformation.ScaleZ
            };

            try
            {
                await _proxy.Invoke("TransformSceneObject", infoModel);
            }
            catch (InvalidOperationException)
            {
                throw new UserNotAuthorizedException(string.Format(CultureInfo.CurrentUICulture, "The user '{0}' is not authorized or known in the system.", LoggedInUserName), LoggedInUserName);
            }
        }
 private void OnSceneObjectTransformed(SceneObjectInfoModel infoModel)
 {
     if (SceneObjectTransformed != null)
     {
         SceneObjectTransformed(infoModel);
     }
 }
Example #4
0
        private void OnSceneObjectTransformed(SceneObjectInfoModel model)
        {
            var objectToTransform = (from objectFound in _objects
                                     where objectFound.Id == model.Id
                                     select objectFound).FirstOrDefault();

            if (objectToTransform == null)
            {
                throw new InvalidOperationException(string.Format("Changed scene object ('{0}') cannot be found in the local scene.", model.Id));
            }

            var transformation = objectToTransform.Transformation;

            transformation.TranslateX = model.Transformation.TranslateX;
            transformation.TranslateY = model.Transformation.TranslateY;
            transformation.TranslateZ = model.Transformation.TranslateZ;

            transformation.RotateX = model.Transformation.RotateX;
            transformation.RotateY = model.Transformation.RotateY;
            transformation.RotateZ = model.Transformation.RotateZ;

            transformation.ScaleX = model.Transformation.ScaleX;
            transformation.ScaleY = model.Transformation.ScaleY;
            transformation.ScaleZ = model.Transformation.ScaleZ;
        }
Example #5
0
        public void TransformSceneObject(SceneObjectInfoModel sceneObject)
        {
            if (sceneObject == null)
            {
                throw new ArgumentException("No object model passed to the server. Parameter 'sceneObject' must not be 'null'.");
            }

            var scene = s_scenes[sceneObject.SceneId];

            var sceneObjectFound = (from model in scene.SceneObjectInfoModels
                                    where model.Id == sceneObject.Id
                                    select model).FirstOrDefault();

            sceneObjectFound.Transformation = sceneObject.Transformation;

            Clients.OthersInGroup(scene.Id.ToString()).SceneObjectTransformed(sceneObjectFound);
        }
Example #6
0
        public void CreateSceneObject(SceneObjectInfoModel sceneObject)
        {
            if (sceneObject == null)
            {
                throw new ArgumentException("No object model passed to the server. Parameter 'sceneObject' must not be 'null'.");
            }

            if (!s_scenes.ContainsKey(sceneObject.SceneId))
            {
                throw new InvalidOperationException(string.Format("Scene with id '{0}' does not exist.", sceneObject.SceneId));
            }

            var scene = s_scenes[sceneObject.SceneId];

            scene.SceneObjectInfoModels.Add(sceneObject);

            Clients.OthersInGroup(scene.Id.ToString()).SceneObjectCreated(sceneObject);
        }
        public async Task CreateSceneObject(SceneObjectModel sceneObject)
        {
            var type = SceneObjectType.Light;

            if (sceneObject.SceneElement is Teapot)
            {
                type = SceneObjectType.Teapot;
            }
            else if (sceneObject.SceneElement is Cube)
            {
                type = SceneObjectType.Cube;
            }
            else if (sceneObject.SceneElement is Cylinder)
            {
                type = SceneObjectType.Cylinder;
            }
            else if (sceneObject.SceneElement is Disk)
            {
                type = SceneObjectType.Disk;
            }
            else if (sceneObject.SceneElement is Sphere)
            {
                type = SceneObjectType.Sphere;
            }

            var infoModel = new SceneObjectInfoModel(sceneObject.Id, _sceneId)
            {
                SceneObjectType = type
            };

            try
            {
                await _proxy.Invoke("CreateSceneObject", infoModel);
            }
            catch (InvalidOperationException)
            {
                throw new UserNotAuthorizedException(string.Format(CultureInfo.CurrentUICulture, "The user '{0}' is not authorized or known in the system.", LoggedInUserName), LoggedInUserName);
            }
        }
Example #8
0
        private void OnSceneObjectCreated(SceneObjectInfoModel infoModel)
        {
            SceneObjectModel model = null;

            switch (infoModel.SceneObjectType)
            {
            case SceneObjectType.Teapot:
                model = new SceneObjectModel(new Teapot()
                {
                    Name = infoModel.Name
                }, infoModel.Id);
                break;

            case SceneObjectType.Cube:
                model = new SceneObjectModel(new Cube()
                {
                    Name = infoModel.Name
                }, infoModel.Id);
                break;

            case SceneObjectType.Cylinder:
                model = new SceneObjectModel(new Cylinder()
                {
                    Name = infoModel.Name
                }, infoModel.Id);
                break;

            case SceneObjectType.Disk:
                model = new SceneObjectModel(new Disk()
                {
                    Name = infoModel.Name
                }, infoModel.Id);
                break;

            case SceneObjectType.Sphere:
                model = new SceneObjectModel(new Sphere()
                {
                    Name = infoModel.Name
                }, infoModel.Id);
                break;

            default:
                break;
            }

            if (infoModel.Transformation != null)
            {
                var transformation = model.Transformation;

                transformation.TranslateX = infoModel.Transformation.TranslateX;
                transformation.TranslateY = infoModel.Transformation.TranslateY;
                transformation.TranslateZ = infoModel.Transformation.TranslateZ;

                transformation.RotateX = infoModel.Transformation.RotateX;
                transformation.RotateY = infoModel.Transformation.RotateY;
                transformation.RotateZ = infoModel.Transformation.RotateZ;

                transformation.ScaleX = infoModel.Transformation.ScaleX;
                transformation.ScaleY = infoModel.Transformation.ScaleY;
                transformation.ScaleZ = infoModel.Transformation.ScaleZ;
            }

            DispatcherHelper.RunAsync(() => SceneObjectModels.Add(model));
        }