Results 1 to 3 of 3

Thread: vcount 4

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    10

    vcount 4

    Hi!

    i am writing a parser for collada-files. I can already work with meshes. But only if the vcount-element contains the number 3. e. g.: <vcount>3 3 3 3 3 </vcount>

    Unfortunately i have problem with the number 4. e. g. <vcount>4 4 4 4 4 </vcount>

    In this case the image is not rendered completely. Some areas are missing.

    e. g. my test-model in Blender:


    But in my browser:


    A part of my javascript code:
    Code :
    /**
     * @param COLLADA_Mesh mesh
     * @return array 
     *    e. g.
     *       ['#Plane-mesh-positions']: [1, -1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0]
     *       ['#Plane-mesh-normals']: [0, 0, 1]
     */
    function getSourceValues(mesh) {
       var sourceValues = [];
     
       var meshSources = mesh.getSources(); // 1 ... n COOLADA_Source-objects
       var length = meshSources.length;
       for (var i = 0; i < length; ++i) {
          var meshSource = meshSources[i];
          var meshSourceArrayElement = meshSource.getArrayElement(); 
          // 0 ... 1 xxx_array, e. g. float_array => COLLADA_FloatArray-object
          if (
             meshSourceArrayElement != undefined &&
             meshSourceArrayElement instanceof COLLADA_FloatArray
          ) {
             var id = '#' + meshSource.getId();
             sourceValues[id] = meshSourceArrayElement.getValues();
          }
       }
       return sourceValues;
    }
    function getNormals(sourceValues, indices) {
       var vertexIndices = indices['VERTEX'].values; // xml-file vertices indices
       var normalIndices = indices['NORMAL'].values; // xml-file normal indices
     
       var normalValues = sourceValues[indices['NORMAL'].source]; // xml-file normal values
     
       var normals = []; // javascript webgl normal values
     
       var length = vertexIndices.length;
       for (var i = 0; i < length; ++i) {
          var vertexIndex = vertexIndices[i];
          var normalIndex = normalIndices[i];
     
          var count = 3;
          for (var j = 0; j < count; ++j) // x, y, z
             normals[vertexIndex * count + j] = normalValues[normalIndex * count + j];
       }
    I think that i have to define some more vertices. Is this correct?

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    10

    Re: vcount 4

    I think, i have found the problem. WebGL can only work with vcount = 3.

    So if i have a vcount = 4, i have to split it into 2 vcount = 3.

    E. g.:

    <input ... offset="0" />
    <input ... offset="1" />
    <vcount>4 3</vcount>


    0 1 2 3 4 5 6 7 8 9 10 11 12 13</p>

    xml-polygon 0:
    4 pairs: 0/1, 2/3, 4/5, 6/7
    => must be split into 2 webgl-polygons, e.g.:
    first webgl-polygon: 0/1, 2/3, 4/5
    second webgl-polygon: 0/1, 4/5, 6/7

    xml-polygon 1:
    3 pairs: 8/9 10/11 12/13
    => 1 webgl-polygon: the same polygon as the xml-polygon: 8/9, 10/11, 12/13

    Is this correct?

  3. #3
    Junior Member
    Join Date
    May 2012
    Posts
    10

    Re: vcount 4

    Everyting OK. Itīs working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •