コード例 #1
0
    public void LoadFile(string s)
    {
        // split the file into lines by detecting the breaklines
        string[] lines = s.Split("\n"[0]);

        foreach (string item in lines)
        {
            ReadLine(item);
        }

        //disassemble the obj to a non-indexed format and assemble them back to an indexed format, but only by vertex
        ArrayList tempArrayList = new ArrayList();
        for (int i = 0; i < _facesVertNormUV.Count; ++i)
        {
            if (_facesVertNormUV[i] != null)
            {
                PlacesByIndex indextemp = new PlacesByIndex(i);
                indextemp._places.Add(i);
                for (int j = 0; j < _facesVertNormUV.Count; ++j)
                {
                    if (_facesVertNormUV[j] != null)
                    {
                        if (i != j)
                        {
                            Vector3 iTemp = (Vector3)_facesVertNormUV[i];
                            Vector3 jTemp = (Vector3)_facesVertNormUV[j];
                            if (iTemp.x == jTemp.x && iTemp.y == jTemp.y)
                            {
                                indextemp._places.Add(j);
                                _facesVertNormUV[j] = null;
                            }
                        }
                    }
                }
                tempArrayList.Add(indextemp);
            }
        }
        //init the arrays
        _vertexArray = new Vector3[tempArrayList.Count];
        _uvArray = new Vector2[tempArrayList.Count];
        _normalArray = new Vector3[tempArrayList.Count];
        _triangleArray = new int[_facesVertNormUV.Count];

        //fill arrays
        int teller = 0;
        foreach (PlacesByIndex item in tempArrayList)
        {
            foreach (int item2 in item._places)
            {
                _triangleArray[item2] = teller;
            }
            Vector3 vTemp = (Vector3)_facesVertNormUV[item._index];
            _vertexArray[teller] = (Vector3)_vertexArrayList[(int)vTemp.x - 1];
            if (_uvArrayList.Count > 0)
            {
                Vector3 tVec = (Vector3)_uvArrayList[(int)vTemp.y - 1];
                _uvArray[teller] = new Vector2(tVec.x, tVec.y);
            }
            if (_normalArrayList.Count > 0)
            {
                _normalArray[teller] = (Vector3)_normalArrayList[(int)vTemp.z - 1];
            }
            teller++;
        }
    }
コード例 #2
0
    public void LoadFile(string s)
    {
        // split the file into lines by detecting the breaklines
        string[] lines = s.Split("\n"[0]);

        foreach (string item in lines)
        {
            ReadLine(item);
        }



        //disassemble the obj to a non-indexed format and assemble them back to an indexed format, but only by vertex
        ArrayList tempArrayList = new ArrayList();

        for (int i = 0; i < _facesVertNormUV.Count; ++i)
        {
            if (_facesVertNormUV[i] != null)
            {
                PlacesByIndex indextemp = new PlacesByIndex(i);
                indextemp._places.Add(i);
                for (int j = 0; j < _facesVertNormUV.Count; ++j)
                {
                    if (_facesVertNormUV[j] != null)
                    {
                        if (i != j)
                        {
                            Vector3 iTemp = (Vector3)_facesVertNormUV[i];
                            Vector3 jTemp = (Vector3)_facesVertNormUV[j];
                            if (iTemp.x == jTemp.x && iTemp.y == jTemp.y)
                            {
                                indextemp._places.Add(j);
                                _facesVertNormUV[j] = null;
                            }
                        }
                    }
                }
                tempArrayList.Add(indextemp);
            }
        }
        //init the arrays
        _vertexArray   = new Vector3[tempArrayList.Count];
        _uvArray       = new Vector2[tempArrayList.Count];
        _normalArray   = new Vector3[tempArrayList.Count];
        _triangleArray = new int[_facesVertNormUV.Count];

        //fill arrays
        int teller = 0;

        foreach (PlacesByIndex item in tempArrayList)
        {
            foreach (int item2 in item._places)
            {
                _triangleArray[item2] = teller;
            }
            Vector3 vTemp = (Vector3)_facesVertNormUV[item._index];
            _vertexArray[teller] = (Vector3)_vertexArrayList[(int)vTemp.x - 1];
            if (_uvArrayList.Count > 0)
            {
                Vector3 tVec = (Vector3)_uvArrayList[(int)vTemp.y - 1];
                _uvArray[teller] = new Vector2(tVec.x, tVec.y);
            }
            if (_normalArrayList.Count > 0)
            {
                _normalArray[teller] = (Vector3)_normalArrayList[(int)vTemp.z - 1];
            }
            teller++;
        }
    }
コード例 #3
0
    public void LoadFile(string s)
    {
        string[] lines = s.Split("\n"[0]);

        foreach (string item in lines)
        {
            ReadLine(item);
        }
        ArrayList tempArrayList = new ArrayList();

        for (int i = 0; i < _facesVertNormUV.Count; ++i)
        {
            if (_facesVertNormUV[i] != null)
            {
                PlacesByIndex indextemp = new PlacesByIndex(i);
                indextemp._places.Add(i);
                for (int j = 0; j < _facesVertNormUV.Count; ++j)
                {
                    if (_facesVertNormUV[j] != null)
                    {
                        if (i != j)
                        {
                            Vector3 iTemp = (Vector3)_facesVertNormUV[i];
                            Vector3 jTemp = (Vector3)_facesVertNormUV[j];
                            if (iTemp.x == jTemp.x && iTemp.y == jTemp.y)
                            {
                                indextemp._places.Add(j);
                                _facesVertNormUV[j] = null;
                            }
                        }
                    }
                }
                tempArrayList.Add(indextemp);
            }
        }
        _vertexArray   = new Vector3[tempArrayList.Count];
        _uvArray       = new Vector2[tempArrayList.Count];
        _normalArray   = new Vector3[tempArrayList.Count];
        _triangleArray = new int[_facesVertNormUV.Count];
        int teller = 0;

        foreach (PlacesByIndex item in tempArrayList)
        {
            foreach (int item2 in item._places)
            {
                _triangleArray[item2] = teller;
            }
            Vector3 vTemp = (Vector3)_facesVertNormUV[item._index];
            _vertexArray[teller] = (Vector3)_vertexArrayList[(int)vTemp.x - 1];
            if (_uvArrayList.Count > 0)
            {
                Vector3 tVec = (Vector3)_uvArrayList[(int)vTemp.y - 1];
                _uvArray[teller] = new Vector2(tVec.x, tVec.y);
            }
            if (_normalArrayList.Count > 0)
            {
                _normalArray[teller] = (Vector3)_normalArrayList[(int)vTemp.z - 1];
            }
            teller++;
        }
    }