コード例 #1
0
ファイル: TestMesh.cs プロジェクト: davidrathje/everzek
    //Loads the first bmp found in the pack, by default uses befallen.s3d
    void Start()
    {
        Debug.Log("Loading s3d");
        var archive = EQArchive.Load(GamePath + ArchiveName);

        Debug.Log("File count: " + archive.Files.Count);

        string extension = "";

        //Vector3[] newVertices;
        //Vector2[] newUV;
        //int[] newTriangles;

        //Mesh mesh = new Mesh();
        cube.GetComponent <MeshFilter>().mesh = CreateMesh(1, 2);
        //mesh.vertices = newVertices;
        //mesh.uv = newUV;
        //mesh.triangles = newTriangles;


        foreach (var file in archive.Files)
        {
//            Debug.Log(file.Key);
            if (!LoadFirstMesh)
            {
                if (file.Key.ToLower() == MeshToLoad.ToLower())
                {
                    //byte[] contents = file.Value.GetContents();
                    return;
                }
                continue;
            }

            extension = System.IO.Path.GetExtension(file.Key);
            if (extension == ".wld")
            {
                Debug.Log("Loading " + file.Key);
                byte[] contents = file.Value.GetContents();

                try
                {
                    Wld wld = new Wld(contents);
                    Debug.Log(wld);
                } catch (Exception e)
                {
                    Debug.LogError("Failed to load World: " + e.Message);
                    return;
                }

                return;
            }
            continue;
        }
        Debug.Log("Done");
    }
コード例 #2
0
ファイル: TestSound.cs プロジェクト: davidrathje/everzek
    //Loads the first bmp found in the pack, by default uses befallen.s3d
    void Start()
    {
        Debug.Log("Loading s3d");
        var archive = EQArchive.Load(GamePath + ArchiveName);

        Debug.Log("File count: " + archive.Files.Count);

        string extension = "";

        AudioSource asource = cube.GetComponent <AudioSource>();


        foreach (var file in archive.Files)
        {
            if (!LoadFirstSound)
            {
                if (file.Key.ToLower() == SoundToLoad.ToLower())
                {
                    //byte[] contents = file.Value.GetContents();

                    /*
                     * WAV wav = new WAV(contents);
                     * //asource.clip.SetData(wav.LeftChannel, 0);
                     * //asource.Play();
                     * //Debug.Log(audioClip);
                     * AudioClip audioClip = AudioClip.Create(SoundToLoad, wav.SampleCount, 1, wav.Frequency, false);
                     * audioClip.SetData(wav.LeftChannel, 0);
                     * asource.clip = audioClip;
                     */

                    asource.clip = WavUtility.ToAudioClip(@"D:\Documents\Desktop\boatbell.wav");
                    //asource.clip = WavUtility.ToAudioClip(contents,0, file.Key);

                    Debug.Log("Playing sound " + SoundToLoad);
                    return;
                }
                continue;
            }

            extension = System.IO.Path.GetExtension(file.Key);
            if (extension == ".wav")
            {
                byte[] contents = file.Value.GetContents();
                WAV    wav      = new WAV(contents);


                //asource.clip.SetData(wav.LeftChannel, 0);
                //asource.Play();
                //Debug.Log(audioClip);
                AudioClip audioClip = AudioClip.Create("testSound", wav.SampleCount, 1, wav.Frequency, false);
                audioClip.SetData(wav.LeftChannel, 0);
                asource.clip = audioClip;
                asource.Play();

                return;
            }
            continue;
            //Debug.Log(file.Key);
        }
        Debug.Log("Done");
    }
コード例 #3
0
ファイル: TestLoading.cs プロジェクト: davidrathje/everzek
    //Loads the first bmp found in the pack, by default uses befallen.s3d
    void Start()
    {
        MeshRenderer mesh;

        if (cube == null)
        {
            Debug.Log("Cube not set");
            return;
        }

        mesh = cube.GetComponent <MeshRenderer>();
        if (mesh == null)
        {
            Debug.Log("No mesh set");
            return;
        }

        Debug.Log("Loading s3d");
        var archive = EQArchive.Load(GamePath + ArchiveName);

        Debug.Log("File count: " + archive.Files.Count);

        string extension = "";

        foreach (var file in archive.Files)
        {
            if (!LoadFirstTexture)
            {
                if (file.Key.ToLower() == TextureToLoad.ToLower())
                {
                    byte[]    contents = file.Value.GetContents();
                    Texture2D tex      = new Texture2D(256, 256, TextureFormat.DXT1, false);
                    tex.LoadRawTextureData(contents);
                    tex.Apply();
                    mesh.material.mainTexture = tex;
                    Debug.Log("Loaded " + TextureToLoad);
                    return;
                }
                continue;
            }

            extension = System.IO.Path.GetExtension(file.Key);
            if (extension == ".bmp" || extension == ".dds")
            {
                Debug.Log("Bmp file: " + file.Key);
                byte[] contents = file.Value.GetContents();
                //todo: identify dimensions etc so i don't hardcore to 256x256
                //Debug.Log("Size: " + contents.Length);
                //Debug.Log("Size Header: "+ (contents[0] + contents[1] + contents[2] + contents[3]));
                //Debug.Log("Width: " + contents[4]+", Height: "+contents[5]);
                Texture2D tex = new Texture2D(256, 256, TextureFormat.DXT1, false);
                tex.LoadRawTextureData(contents);
                tex.Apply();
                mesh.material.mainTexture = tex;
                return;
            }
            continue;
            //Debug.Log(file.Key);
        }
        Debug.Log("Done");
    }