mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:17:02 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into metavoxels
This commit is contained in:
commit
8ba2cf9a8b
4 changed files with 45 additions and 19 deletions
|
@ -235,6 +235,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
|
// make sure we don't call the idle timer any more
|
||||||
|
delete idleTimer;
|
||||||
|
|
||||||
// ask the audio thread to quit and wait until it is done
|
// ask the audio thread to quit and wait until it is done
|
||||||
_audio.thread()->quit();
|
_audio.thread()->quit();
|
||||||
_audio.thread()->wait();
|
_audio.thread()->wait();
|
||||||
|
|
|
@ -29,10 +29,13 @@ int main(int argc, const char * argv[]) {
|
||||||
QCoreApplication::addLibraryPath(QT_RELEASE_PLUGIN_PATH);
|
QCoreApplication::addLibraryPath(QT_RELEASE_PLUGIN_PATH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int exitCode;
|
||||||
|
{
|
||||||
Application app(argc, const_cast<char**>(argv), startup_time);
|
Application app(argc, const_cast<char**>(argv), startup_time);
|
||||||
|
|
||||||
qDebug( "Created QT Application.\n" );
|
qDebug( "Created QT Application.\n" );
|
||||||
int exitCode = app.exec();
|
exitCode = app.exec();
|
||||||
|
}
|
||||||
qDebug("Normal exit.\n");
|
qDebug("Normal exit.\n");
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -582,6 +582,7 @@ class ExtractedMesh {
|
||||||
public:
|
public:
|
||||||
FBXMesh mesh;
|
FBXMesh mesh;
|
||||||
QMultiHash<int, int> newIndices;
|
QMultiHash<int, int> newIndices;
|
||||||
|
QVector<QHash<int, int> > blendshapeIndexMaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MeshData {
|
class MeshData {
|
||||||
|
@ -780,7 +781,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
QVector<QString> jointRightFingertipIDs(jointRightFingertipNames.size());
|
QVector<QString> jointRightFingertipIDs(jointRightFingertipNames.size());
|
||||||
|
|
||||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||||
QHash<QByteArray, QPair<int, float> > blendshapeIndices;
|
typedef QPair<int, float> WeightedIndex;
|
||||||
|
QMultiHash<QByteArray, WeightedIndex> blendshapeIndices;
|
||||||
for (int i = 0;; i++) {
|
for (int i = 0;; i++) {
|
||||||
QByteArray blendshapeName = FACESHIFT_BLENDSHAPES[i];
|
QByteArray blendshapeName = FACESHIFT_BLENDSHAPES[i];
|
||||||
if (blendshapeName.isEmpty()) {
|
if (blendshapeName.isEmpty()) {
|
||||||
|
@ -788,16 +790,16 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
}
|
}
|
||||||
QList<QVariant> mappings = blendshapeMappings.values(blendshapeName);
|
QList<QVariant> mappings = blendshapeMappings.values(blendshapeName);
|
||||||
if (mappings.isEmpty()) {
|
if (mappings.isEmpty()) {
|
||||||
blendshapeIndices.insert(blendshapeName, QPair<int, float>(i, 1.0f));
|
blendshapeIndices.insert(blendshapeName, WeightedIndex(i, 1.0f));
|
||||||
} else {
|
} else {
|
||||||
foreach (const QVariant& mapping, mappings) {
|
foreach (const QVariant& mapping, mappings) {
|
||||||
QVariantList blendshapeMapping = mapping.toList();
|
QVariantList blendshapeMapping = mapping.toList();
|
||||||
blendshapeIndices.insert(blendshapeMapping.at(0).toByteArray(),
|
blendshapeIndices.insert(blendshapeMapping.at(0).toByteArray(),
|
||||||
QPair<int, float>(i, blendshapeMapping.at(1).toFloat()));
|
WeightedIndex(i, blendshapeMapping.at(1).toFloat()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QHash<QString, QPair<int, float> > blendshapeChannelIndices;
|
QMultiHash<QString, WeightedIndex> blendshapeChannelIndices;
|
||||||
|
|
||||||
foreach (const FBXNode& child, node.children) {
|
foreach (const FBXNode& child, node.children) {
|
||||||
if (child.name == "Objects") {
|
if (child.name == "Objects") {
|
||||||
|
@ -1033,7 +1035,10 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
// try everything after the dot
|
// try everything after the dot
|
||||||
name = name.mid(name.lastIndexOf('.') + 1);
|
name = name.mid(name.lastIndexOf('.') + 1);
|
||||||
}
|
}
|
||||||
blendshapeChannelIndices.insert(getID(object.properties), blendshapeIndices.value(name));
|
QString id = getID(object.properties);
|
||||||
|
foreach (const WeightedIndex& index, blendshapeIndices.values(name)) {
|
||||||
|
blendshapeChannelIndices.insert(id, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1059,19 +1064,29 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
// assign the blendshapes to their corresponding meshes
|
// assign the blendshapes to their corresponding meshes
|
||||||
foreach (const ExtractedBlendshape& extracted, blendshapes) {
|
foreach (const ExtractedBlendshape& extracted, blendshapes) {
|
||||||
QString blendshapeChannelID = parentMap.value(extracted.id);
|
QString blendshapeChannelID = parentMap.value(extracted.id);
|
||||||
QPair<int, float> index = blendshapeChannelIndices.value(blendshapeChannelID);
|
|
||||||
QString blendshapeID = parentMap.value(blendshapeChannelID);
|
QString blendshapeID = parentMap.value(blendshapeChannelID);
|
||||||
QString meshID = parentMap.value(blendshapeID);
|
QString meshID = parentMap.value(blendshapeID);
|
||||||
ExtractedMesh& extractedMesh = meshes[meshID];
|
ExtractedMesh& extractedMesh = meshes[meshID];
|
||||||
|
foreach (const WeightedIndex& index, blendshapeChannelIndices.values(blendshapeChannelID)) {
|
||||||
extractedMesh.mesh.blendshapes.resize(max(extractedMesh.mesh.blendshapes.size(), index.first + 1));
|
extractedMesh.mesh.blendshapes.resize(max(extractedMesh.mesh.blendshapes.size(), index.first + 1));
|
||||||
|
extractedMesh.blendshapeIndexMaps.resize(extractedMesh.mesh.blendshapes.size());
|
||||||
FBXBlendshape& blendshape = extractedMesh.mesh.blendshapes[index.first];
|
FBXBlendshape& blendshape = extractedMesh.mesh.blendshapes[index.first];
|
||||||
|
QHash<int, int>& blendshapeIndexMap = extractedMesh.blendshapeIndexMaps[index.first];
|
||||||
for (int i = 0; i < extracted.blendshape.indices.size(); i++) {
|
for (int i = 0; i < extracted.blendshape.indices.size(); i++) {
|
||||||
int oldIndex = extracted.blendshape.indices.at(i);
|
int oldIndex = extracted.blendshape.indices.at(i);
|
||||||
for (QMultiHash<int, int>::const_iterator it = extractedMesh.newIndices.constFind(oldIndex);
|
for (QMultiHash<int, int>::const_iterator it = extractedMesh.newIndices.constFind(oldIndex);
|
||||||
it != extractedMesh.newIndices.constEnd() && it.key() == oldIndex; it++) {
|
it != extractedMesh.newIndices.constEnd() && it.key() == oldIndex; it++) {
|
||||||
|
QHash<int, int>::iterator blendshapeIndex = blendshapeIndexMap.find(it.value());
|
||||||
|
if (blendshapeIndex == blendshapeIndexMap.end()) {
|
||||||
|
blendshapeIndexMap.insert(it.value(), blendshape.indices.size());
|
||||||
blendshape.indices.append(it.value());
|
blendshape.indices.append(it.value());
|
||||||
blendshape.vertices.append(extracted.blendshape.vertices.at(i) * index.second);
|
blendshape.vertices.append(extracted.blendshape.vertices.at(i) * index.second);
|
||||||
blendshape.normals.append(extracted.blendshape.normals.at(i) * index.second);
|
blendshape.normals.append(extracted.blendshape.normals.at(i) * index.second);
|
||||||
|
} else {
|
||||||
|
blendshape.vertices[*blendshapeIndex] += extracted.blendshape.vertices.at(i) * index.second;
|
||||||
|
blendshape.normals[*blendshapeIndex] += extracted.blendshape.normals.at(i) * index.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,6 +263,9 @@ bool Model::render(float alpha) {
|
||||||
|
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
glAlphaFunc(GL_GREATER, 0.5f);
|
||||||
|
|
||||||
for (int i = 0; i < networkMeshes.size(); i++) {
|
for (int i = 0; i < networkMeshes.size(); i++) {
|
||||||
const NetworkMesh& networkMesh = networkMeshes.at(i);
|
const NetworkMesh& networkMesh = networkMeshes.at(i);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, networkMesh.indexBufferID);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, networkMesh.indexBufferID);
|
||||||
|
@ -443,6 +446,8 @@ bool Model::render(float alpha) {
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
// bind with 0 to switch back to normal operation
|
// bind with 0 to switch back to normal operation
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
Loading…
Reference in a new issue