Exemple #1
0
        /// <summary>
        /// Loads a binary prefab based on the <paramref name="assetsElement"/>.
        /// </summary>
        /// <param name="assetsElement">XML containing the path to the binary prefab.</param>
        /// <param name="package">GamePack of the level.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assetsElement"/> is null</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="assetsElement"/> xml element is not valid, either is not the <see cref="EntityXml.Inst.Assets"/> element
        /// or has a wrong type specified</exception>
        /// <exception cref="IOException">When the file specified by the path in the <see cref="AssetsElementXml.Inst.Path"/> cannot be opened</exception>
        /// <exception cref="ResourceLoadingException"> Thrown when the file could not be found </exception>
        public BinaryPrefabAssetContainer(XElement assetsElement, GamePack package)
        {
            CheckWithType(assetsElement, AssetsXml.BinaryPrefabType);
            var relativePath = GetPath(assetsElement);

            this.file = package.PackageManager.GetFile(relativePath, true);
        }
Exemple #2
0
        private CSharpCompilation Compile(string fileName)
        {
            var cache = Application.ResourceCache;
            CSharpCompilation compilation = null;

            Urho.IO.File file         = cache.GetFile(fileName);
            byte[]       sourceBuffer = null;
            if (file != null)
            {
                uint size = file.Size;
                sourceBuffer = new byte[size];
                file.Read(sourceBuffer, size);
            }
            file.Dispose();

            string sourceCode = System.Text.Encoding.UTF8.GetString(sourceBuffer);

            string componentName = fileName;
            int    fileExtPos    = fileName.LastIndexOf(".");

            if (fileExtPos >= 0)
            {
                componentName = fileName.Substring(0, fileExtPos);
            }


            compilation = CSharpCompilation.Create(componentName, new[] { CSharpSyntaxTree.ParseText(sourceCode) },
                                                   new[]
            {
                MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location),
                MetadataReference.CreateFromFile(typeof(Console).Assembly.Location),
                MetadataReference.CreateFromFile(SystemRuntime.Location),
                MetadataReference.CreateFromFile(MSCoreLib.Location),
                MetadataReference.CreateFromFile(UrhoDotNet.Location),
            },
                                                   new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));

            return(compilation);
        }
Exemple #3
0
 public UrhoFileStream(Urho.IO.File file)
 {
     this.file = file;
 }
Exemple #4
0
        private async Task MariusCvStitch()
        {
            _currentMapping = _dataExchangeService.Payload["CurrentMapping"] as Mapping;

            await _downloadCache.GetAndCacheFile(_currentMapping.Measurements.First().ImageUrl);

            var img1Path = _currentMapping.Measurements.First().ImageUrl;
            var img2Path = _currentMapping.Measurements.ElementAt(1).ImageUrl;

            var imageStitcher = Mvx.Resolve<IImageStitcher>();
            var panoBytes = await imageStitcher.StitchImages(new List<string>() { img1Path, img2Path });

            Directory.CreateDirectory($"/data/data/de.marius.depthviewer/files/_Caches/Pictures.MvvmCross/");
            var docsDirPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var path = Path.Combine(docsDirPath, $"s{DateTime.Now.Millisecond}s.jpg");

            System.IO.File.WriteAllBytes(path, panoBytes);

            InvokeOnMain(() =>
            {
                var stitchNode = _scene.CreateChild("StitchedNode");
                stitchNode.Position = new Vector3(0, 0, -2);
                stitchNode.SetScale(1.0f);
                //await PlaceSpriteInNode(path, stitchNode);
                // Display in sprite
                var sprite = new Sprite2D();
                var imgFile = new File(Context, path, FileMode.Read);
                sprite.Load(imgFile);

                StaticSprite2D staticSprite2D = stitchNode.CreateComponent<StaticSprite2D>();
                //staticSprite2D.Color = (new Color(NextRandom(1.0f), NextRandom(1.0f), NextRandom(1.0f), 1.0f));
                staticSprite2D.BlendMode = BlendMode.Alpha;
                staticSprite2D.Sprite = sprite;
            });
        }