google / google/draco

Discussion on sub-objects and materials

Open
#89 29 comments 0 reactions 1 assignee Claimed by @ondys View on GitHub
documentation
Dominant language
C++
Stars
7.5k
Forks
1.1k
Avg merge
47m
Merged PRs (30d)
1

Description

Hi,

I'm bringing in an obj model with sub-objects. the suObjectAttribute works fine to assign points back to the correct sub-objects, but uv's don't come out properly. here's what I'm doing:

for (var i = 0, k = 0, l = 0; i < numVertexCoordinates; i += 3, k++, l +=2) {

// Get sub object id
subObjectId = subObjAttributeData.GetValue(k);

// Positions
// globalToLocalMap[] is a map to match each global point index to its corresponding index on a sub-object

subObjectBuffers[subObjectId].vertices[globalToLocalMap[k]*3] = -posAttributeData.GetValue(i);
subObjectBuffers[subObjectId].vertices[globalToLocalMap[k]*3+1] = posAttributeData.GetValue(i + 1);
subObjectBuffers[subObjectId].vertices[globalToLocalMap[k]*3+2] = posAttributeData.GetValue(i + 2);

// Normals
if (normalAttId != -1) {
subObjectBuffers[subObjectId].normals[globalToLocalMap[k]*3] = norAttributeData.GetValue(i);
subObjectBuffers[subObjectId].normals[globalToLocalMap[k]*3+1] = norAttributeData.GetValue(i + 1);
subObjectBuffers[subObjectId].normals[globalToLocalMap[k]*3+2] = norAttributeData.GetValue(i + 2);
}
// Uv's
if (texCoordAttId != -1) {
subObjectBuffers[subObjectId].uvs[globalToLocalMap[k]*2] = textCoordAttributeData.GetValue(l);
subObjectBuffers[subObjectId].uvs[globalToLocalMap[k]*2+1] = textCoordAttributeData.GetValue(l + 1);
}
}

result:
https://puu.sh/v58lD/bf2c2363d9.png

thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.