コード例 #1
0
    void readNativeData()
    {
        bool ret = false;

        PrintDebugLog("sessionid = " + sessionid);
        bool finishLoading = WaveVR_Utils.Assimp.getSectionCount(sessionid, ref sectionCount);

        if (!finishLoading || sectionCount == 0)
        {
            PrintDebugLog("failed to load mesh");
            return;
        }

        FBXInfo     = new FBXInfo_t[sectionCount];
        SectionInfo = new MeshInfo_t[sectionCount];
        for (int i = 0; i < sectionCount; i++)
        {
            FBXInfo[i]     = new FBXInfo_t();
            SectionInfo[i] = new MeshInfo_t();

            FBXInfo[i].meshName = Marshal.AllocHGlobal(256);
        }

        ret = WaveVR_Utils.Assimp.getMeshData(sessionid, FBXInfo);
        if (!ret)
        {
            for (int i = 0; i < sectionCount; i++)
            {
                Marshal.FreeHGlobal(FBXInfo[i].meshName);
            }

            SectionInfo = null;
            FBXInfo     = null;
            WaveVR_Utils.Assimp.releaseMesh(sessionid);
            return;
        }

        for (uint i = 0; i < sectionCount; i++)
        {
            SectionInfo[i]._vectice = new Vector3[FBXInfo[i].verticeCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._vectice[j] = new Vector3();
            }
            SectionInfo[i]._normal = new Vector3[FBXInfo[i].normalCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._normal[j] = new Vector3();
            }
            SectionInfo[i]._uv = new Vector2[FBXInfo[i].uvCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._uv[j] = new Vector2();
            }
            SectionInfo[i]._indice = new int[FBXInfo[i].indiceCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._indice[j] = new int();
            }

            bool active = false;

            bool tret = WaveVR_Utils.Assimp.getSectionData(sessionid, i, SectionInfo[i]._vectice, SectionInfo[i]._normal, SectionInfo[i]._uv, SectionInfo[i]._indice, ref active);
            if (!tret)
            {
                continue;
            }

            SectionInfo[i]._active = active;

            PrintDebugLog("i = " + i + ", name = " + Marshal.PtrToStringAnsi(FBXInfo[i].meshName) + ", active = " + SectionInfo[i]._active);
            PrintDebugLog("i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m0 + " , " + FBXInfo[i].matrix.m1 + " , " + FBXInfo[i].matrix.m2 + " , " + FBXInfo[i].matrix.m3 + "] ");
            PrintDebugLog("i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m4 + " , " + FBXInfo[i].matrix.m5 + " , " + FBXInfo[i].matrix.m6 + " , " + FBXInfo[i].matrix.m7 + "] ");
            PrintDebugLog("i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m8 + " , " + FBXInfo[i].matrix.m9 + " , " + FBXInfo[i].matrix.m10 + " , " + FBXInfo[i].matrix.m11 + "] ");
            PrintDebugLog("i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m12 + " , " + FBXInfo[i].matrix.m13 + " , " + FBXInfo[i].matrix.m14 + " , " + FBXInfo[i].matrix.m15 + "] ");
            PrintDebugLog("i = " + i + ", vertice count = " + FBXInfo[i].verticeCount + ", normal count = " + FBXInfo[i].normalCount + ", uv count = " + FBXInfo[i].uvCount + ", indice count = " + FBXInfo[i].indiceCount);
        }

        bLoadMesh = true;
    }
コード例 #2
0
    void readNativeData()
    {
        bLoadMesh = false;
        bool ret = false;

        Log.d(LOG_TAG, "sessionid = " + sessionid);
        bool finishLoading = WaveVR_Utils.Assimp.getSectionCount(sessionid, ref sectionCount);

        if (!finishLoading || sectionCount == 0)
        {
            Log.d(LOG_TAG, "failed to load mesh");
            return;
        }

        FBXInfo     = new FBXInfo_t[sectionCount];
        SectionInfo = new MeshInfo_t[sectionCount];
        for (int i = 0; i < sectionCount; i++)
        {
            FBXInfo[i]     = new FBXInfo_t();
            SectionInfo[i] = new MeshInfo_t();

            FBXInfo[i].meshName = Marshal.AllocHGlobal(64);
        }

        Log.d(LOG_TAG, "getMeshData start, sectionCount = " + sectionCount);
        ret = WaveVR_Utils.Assimp.getMeshData(sessionid, FBXInfo);
        Log.d(LOG_TAG, "getMeshData end");
        if (!ret)
        {
            for (int i = 0; i < sectionCount; i++)
            {
                Marshal.FreeHGlobal(FBXInfo[i].meshName);
            }

            SectionInfo = null;
            FBXInfo     = null;
            WaveVR_Utils.Assimp.releaseMesh(sessionid);
            return;
        }

        Log.d(LOG_TAG, "log and create array start");
        for (uint i = 0; i < sectionCount; i++)
        {
            SectionInfo[i]._vectice = new Vector3[FBXInfo[i].verticeCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._vectice[j] = new Vector3();
            }
            SectionInfo[i]._normal = new Vector3[FBXInfo[i].normalCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._normal[j] = new Vector3();
            }
            SectionInfo[i]._uv = new Vector2[FBXInfo[i].uvCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._uv[j] = new Vector2();
            }
            SectionInfo[i]._indice = new int[FBXInfo[i].indiceCount];
            for (int j = 0; j < FBXInfo[i].verticeCount; j++)
            {
                SectionInfo[i]._indice[j] = new int();
            }

            bool tret = WaveVR_Utils.Assimp.getSectionData(sessionid, i, SectionInfo[i]._vectice, SectionInfo[i]._normal, SectionInfo[i]._uv, SectionInfo[i]._indice);
            if (!tret)
            {
                continue;
            }

            Log.d(LOG_TAG, "i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m0 + " , " + FBXInfo[i].matrix.m1 + " , " + FBXInfo[i].matrix.m2 + " , " + FBXInfo[i].matrix.m3 + "] ");
            Log.d(LOG_TAG, "i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m4 + " , " + FBXInfo[i].matrix.m5 + " , " + FBXInfo[i].matrix.m6 + " , " + FBXInfo[i].matrix.m7 + "] ");
            Log.d(LOG_TAG, "i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m8 + " , " + FBXInfo[i].matrix.m9 + " , " + FBXInfo[i].matrix.m10 + " , " + FBXInfo[i].matrix.m11 + "] ");
            Log.d(LOG_TAG, "i = " + i + ", relative transform = [" + FBXInfo[i].matrix.m12 + " , " + FBXInfo[i].matrix.m13 + " , " + FBXInfo[i].matrix.m14 + " , " + FBXInfo[i].matrix.m15 + "] ");
            Log.d(LOG_TAG, "i = " + i + ", vertice count = " + FBXInfo[i].verticeCount + ", normal count = " + FBXInfo[i].normalCount + ", uv count = " + FBXInfo[i].uvCount + ", indice count = " + FBXInfo[i].indiceCount);
        }
        Log.d(LOG_TAG, "log and create array end");

        bLoadMesh = true;
    }