コード例 #1
0
        public static Type GetTypeByName(string name)
        {
            if (!m_actorDescriptors.ContainsKey(name))
            {
                return(typeof(Actor));
            }

            WActorDescriptor desc = m_actorDescriptors[name];

            if (desc.ActorClassType == null)
            {
                return(typeof(Actor));
            }

            return(Type.GetType($"WindEditor.{ desc.ActorClassType }"));
        }
コード例 #2
0
ファイル: ResourceManager.cs プロジェクト: magcius/Winditor
        public static J3D LoadActorByName(string actorName)
        {
            // Stop to check if we've already loaded this model.
            var existRef = m_j3dList.Find(x => string.Compare(x.FilePath, actorName, StringComparison.InvariantCultureIgnoreCase) == 0);

            if (existRef != null)
            {
                existRef.ReferenceCount++;
                return(existRef.Asset);
            }

            if (actorName == null)
            {
                return(null);
            }

            // Check to see if we have an Actor Descriptor for this actor.
            if (!m_actorDescriptors.ContainsKey(actorName))
            {
                return(null);
            }

            WActorDescriptor descriptor = m_actorDescriptors[actorName];

            // Check to see that this actor descriptor specifies a model path.
            if (string.IsNullOrEmpty(descriptor.ModelPath) || string.IsNullOrEmpty(descriptor.ArchiveName))
            {
                return(null);
            }

            string archivePath = Path.Combine(Properties.Settings.Default.RootDirectory, "res/Object/", descriptor.ArchiveName + ".arc");

            // Check to see that the archive exists
            if (!File.Exists(archivePath))
            {
                return(null);
            }

            // Finally, open the archive so we can look insdie of it to see if it exists.
            VirtualFilesystemDirectory archive     = ArchiveUtilities.LoadArchive(archivePath);
            VirtualFilesystemFile      archiveFile = archive.GetFileAtPath(descriptor.ModelPath);

            if (archiveFile == null)
            {
                Console.WriteLine("LoadActorByName failed because the specified path \"{0}\" does not exist in archive \"{1}\"!", descriptor.ModelPath, descriptor.ArchiveName);
                return(null);
            }

            // Now that we finally have the file, we can try to load a J3D from it.
            byte[] j3dData = archiveFile.Data;

            J3D j3d = new J3D(archiveFile.Name);

            using (EndianBinaryReader reader = new EndianBinaryReader(j3dData, Endian.Big))
                j3d.LoadFromStream(reader, Properties.Settings.Default.DumpTexturesToDisk, Properties.Settings.Default.DumpShadersToDisk);

            j3d.SetHardwareLight(0, m_mainLight);
            j3d.SetHardwareLight(1, m_secondaryLight);

            // Apply patches for Wind Waker by default, since they don't seem to break anything else.
            j3d.SetTextureOverride("ZBtoonEX", "resources/textures/ZBtoonEX.png");
            j3d.SetTextureOverride("ZAtoon", "resources/textures/ZAtoon.png");
            j3d.SetColorWriteOverride("eyeLdamA", false);
            j3d.SetColorWriteOverride("eyeLdamB", false);
            j3d.SetColorWriteOverride("mayuLdamA", false);
            j3d.SetColorWriteOverride("mayuLdamB", false);
            j3d.SetColorWriteOverride("eyeRdamA", false);
            j3d.SetColorWriteOverride("eyeRdamB", false);
            j3d.SetColorWriteOverride("mayuRdamA", false);
            j3d.SetColorWriteOverride("mayuRdamB", false);

            existRef          = new TSharedRef <J3D>();
            existRef.FilePath = actorName;
            existRef.Asset    = j3d;
            existRef.ReferenceCount++;

            m_j3dList.Add(existRef);

            return(j3d);
        }