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:
/**
* @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?