Beispiel #1
0
 public PAKFile(PAKResourcePool pool, PAKDirectory parent, PAKArchiveEntry entry)
 {
     this.pool  = pool;
     Parent     = parent;
     Path       = entry.path;
     this.entry = entry;
 }
Beispiel #2
0
        private void LoadActorNow(IResource resource)
        {
            if (resource.Equals(CurrentResource))
            {
                return;
            }
            CurrentResource = null;

            using var contentStream = resource.OpenContent();
            if (contentStream == null)
            {
                throw new IOException($"Could not open actor at {resource.Path.ToPOSIXString()}");
            }
            description = ActorExDescription.ReadNew(contentStream);

            body = new Part(localDiContainer, description.body.model, description.body.animations);
            body.location.Parent = actorLocation;
            wings = null;
            if (description.HasWings)
            {
                wings = new Part(localDiContainer, description.wings.model, description.wings.animations);
                wings.location.Parent = body.skeleton.Bones[description.attachWingsToBone];
            }

            controls.ResetView();
            fbArea.IsDirty  = true;
            CurrentResource = resource;
        }
Beispiel #3
0
 public CombinedDirectory(IResourcePool pool, IResource?parent, FilePath path, IEnumerable <IResource> sources)
 {
     this.sources = sources.ToArray();
     Path         = path;
     Pool         = pool;
     Parent       = parent;
 }
Beispiel #4
0
        private void LoadEffectNow(IResource resource)
        {
            if (resource.Equals(CurrentResource))
            {
                return;
            }
            CurrentResource = null;
            emptyEffect     = new EffectCombiner();

            effectRenderer?.Dispose();
            effectRenderer = new EffectCombinerRenderer(diContainer, resource);
            effectRenderer.Location.LocalPosition = Vector3.Zero;
            effectRenderer.Location.LocalRotation = Quaternion.Identity;

            editor.ClearInfoSections();
            editor.AddInfoSection("Info", HandleInfoContent);
            editor.AddInfoSection("Playback", HandlePlaybackContent);
            foreach (var(partRenderer, i) in effectRenderer.Parts.Indexed())
            {
                var part = Effect.parts[i];
                editor.AddInfoSection($"{part.Type} \"{part.Name}\"", part switch
                {
                    MovingPlanes mp => () => HandlePart(mp, (MovingPlanesRenderer)partRenderer),
                    RandomPlanes rp => () => HandlePart(rp, (RandomPlanesRenderer)partRenderer),
                    ParticleEmitter pe => () => HandlePart(pe, (ParticleEmitterRenderer)partRenderer),
                    BeamStar bs => () => HandlePart(bs, (BeamStarRenderer)partRenderer),
                    _ => () => { } // ignore for now
                }, defaultOpen: false, () => HandlePartPreContent(i));
Beispiel #5
0
        private void LoadModelNow(IResource resource)
        {
            if (resource.Equals(CurrentResource))
            {
                return;
            }
            CurrentResource = null;
            var texturePaths = new[]
            {
                textureLoader.GetTexturePathFromModel(resource.Path),
                new FilePath("resources/textures/models"),
                new FilePath("resources/textures/worlds"),
            };

            geometryBuffers = new ClumpBuffers(diContainer, resource);
            AddDisposable(geometryBuffers);

            foreach (var oldTexture in materials.Select(m => m.MainTexture.Texture))
            {
                imGuiRenderer.RemoveImGuiBinding(oldTexture);
            }

            materials = new ModelStandardMaterial[geometryBuffers.SubMeshes.Count];
            foreach (var(rwMaterial, index) in geometryBuffers.SubMeshes.Select(s => s.Material).Indexed())
            {
                var material = materials[index] = new ModelStandardMaterial(diContainer);
                (material.MainTexture.Texture, material.Sampler.Sampler) = textureLoader.LoadTexture(texturePaths, rwMaterial);
                material.LinkTransformsTo(camera);
                material.World.Ref    = Matrix4x4.Identity;
                material.Uniforms.Ref = ModelStandardMaterialUniforms.Default;
                material.Uniforms.Ref.vertexColorFactor = 0.0f; // they seem to be set to some gray for models?
                material.Uniforms.Ref.tint = rwMaterial.color.ToFColor();
                AddDisposable(material);
            }
            modelMaterialEdit.Materials = materials;

            skeletonRenderer = null;
            if (geometryBuffers.Skin != null)
            {
                var skeleton = new Skeleton(geometryBuffers.Skin);
                skeletonRenderer = new DebugSkeletonRenderer(diContainer.ExtendedWith(camera, locationBuffer), geometryBuffers, skeleton);
                AddDisposable(skeletonRenderer);
            }

            collider = geometryBuffers.RWGeometry.FindChildById(zzio.rwbs.SectionId.CollisionPLG, true) == null
                ? null
                : new GeometryTreeCollider(geometryBuffers.RWGeometry, location: null);

            controls.ResetView();
            HighlightSplit(-1);
            fbArea.IsDirty  = true;
            CurrentResource = resource;
            Window.Title    = $"Model Viewer - {resource.Path.ToPOSIXString()}";
        }
Beispiel #6
0
        public LorahostTheme(IResource?header, string?copyright, string?title, string?subtitle, string?action, string?actionTitle)
        {
            _Copyright   = copyright;
            _Title       = title;
            _Subtitle    = subtitle;
            _Action      = action;
            _ActionTitle = actionTitle;

            var resources = Layout.Create()
                            .Fallback(Modules.IO.Resources.From(ResourceTree.FromAssembly("Lorahost.resources")));

            if (header != null)
            {
                resources.Add("header.jpg", Download.From(header).Type(ContentType.ImageJpg));
            }

            Resources = resources;

            ErrorHandler = ModScriban.Template <ErrorModel>(Resource.FromAssembly("Error.html")).Build();

            Renderer = ModScriban.Template <WebsiteModel>(Resource.FromAssembly("Template.html")).Build();
        }
Beispiel #7
0
 public bool TryConvertToResourceInstance(ResourceDocument resourceDocument, [NotNullWhen(true)] out IResource?resourceInstance)
 {
     return(TryConvertToResourceInstanceImpl(resourceDocument, out resourceInstance));
 }
Beispiel #8
0
 protected abstract bool TryConvertToResourceInstanceImpl(ResourceDocument resourceDocument, [NotNullWhen(true)] out IResource?resourceInstance);
Beispiel #9
0
 public CombinedDirectory(IResourcePool pool, IResource?parent, string pathText, IEnumerable <IResource> sources) : this(pool, parent, new FilePath(pathText), sources)
 {
 }
Beispiel #10
0
 public FileResource(FileResourcePool pool, IResource?parent, FilePath path)
 {
     Path      = path;
     Parent    = parent;
     this.pool = pool;
 }
Beispiel #11
0
 public DirectoryResource(FileResourcePool pool, IResource?parent, string pathText) : this(pool, parent, new FilePath(pathText))
 {
 }
Beispiel #12
0
 public LorahostBuilder Header(IResource headerProvider)
 {
     _Header = headerProvider;
     return(this);
 }
Beispiel #13
0
 public PAKDirectory(PAKArchiveResourcePool pool, IResource?parent, FilePath path)
 {
     this.pool = pool;
     Path      = path;
     Parent    = parent;
 }
Beispiel #14
0
 public PAKDirectory(PAKArchiveResourcePool pool, IResource?parent, string pathText) : this(pool, parent, new FilePath(pathText))
 {
 }
Beispiel #15
0
 public InMemoryDirectory(IResourcePool pool, IResource?parent, FilePath path)
 {
     Pool   = pool;
     Path   = path;
     Parent = parent;
 }
Beispiel #16
0
 public InMemoryDirectory(IResourcePool pool, IResource?parent, string pathText) : this(pool, parent, new FilePath(pathText))
 {
 }