예제 #1
0
        private void LoadDesignTimeModel()
        {
            var cube = new Cube()
            {
                Name = "Cube 1"
            };

            SceneObjectModels.Add(cube);

            var teapot = new Teapot()
            {
                Name = "Teapot 1"
            };

            SceneObjectModels.Add(teapot);

            var sphere = new Sphere()
            {
                Name = "Sphere 1"
            };

            SceneObjectModels.Add(sphere);
        }
예제 #2
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));
        }