mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Set normals based on indices, cache face models.
This commit is contained in:
parent
ddb0d916ae
commit
133ba3a00a
3 changed files with 18 additions and 5 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <QMenuBar>
|
||||
#include <QMouseEvent>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkDiskCache>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QWheelEvent>
|
||||
#include <QSettings>
|
||||
|
@ -208,6 +209,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_window->setMenuBar(Menu::getInstance());
|
||||
|
||||
_networkAccessManager = new QNetworkAccessManager(this);
|
||||
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
|
||||
cache->setCacheDirectory("interfaceCache");
|
||||
_networkAccessManager->setCache(cache);
|
||||
|
||||
QRect available = desktop()->availableGeometry();
|
||||
_window->resize(available.size());
|
||||
|
|
|
@ -118,7 +118,9 @@ void BlendFace::setModelURL(const QUrl& url) {
|
|||
if (!url.isValid()) {
|
||||
return;
|
||||
}
|
||||
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(QNetworkRequest(url));
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
_modelReply = Application::getInstance()->getNetworkAccessManager()->get(request);
|
||||
connect(_modelReply, SIGNAL(downloadProgress(qint64,qint64)), SLOT(handleModelDownloadProgress(qint64,qint64)));
|
||||
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError()));
|
||||
}
|
||||
|
@ -163,7 +165,7 @@ void BlendFace::setRig(const fsMsgRig& rig) {
|
|||
}
|
||||
|
||||
void BlendFace::handleModelDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
||||
if (bytesReceived < bytesTotal) {
|
||||
if (bytesReceived < bytesTotal && !_modelReply->isFinished()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
|
|||
if (object.properties.at(2) == "Mesh") {
|
||||
FBXGeometry mesh;
|
||||
|
||||
QVector<glm::vec3> vertices;
|
||||
QVector<glm::vec3> normals;
|
||||
QVector<int> polygonIndices;
|
||||
foreach (const FBXNode& data, object.children) {
|
||||
if (data.name == "Vertices") {
|
||||
|
@ -284,12 +284,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
|
|||
} else if (data.name == "LayerElementNormal") {
|
||||
foreach (const FBXNode& subdata, data.children) {
|
||||
if (subdata.name == "Normals") {
|
||||
mesh.normals = createVec3Vector(
|
||||
subdata.properties.at(0).value<QVector<double> >());
|
||||
normals = createVec3Vector(subdata.properties.at(0).value<QVector<double> >());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the (base) normals correspond to the polygon indices, for some reason
|
||||
mesh.normals.resize(mesh.vertices.size());
|
||||
for (int i = 0, n = polygonIndices.size(); i < n; i++) {
|
||||
int index = polygonIndices.at(i);
|
||||
mesh.normals[index < 0 ? (-index - 1) : index] = normals[i];
|
||||
}
|
||||
|
||||
// convert the polygons to quads and triangles
|
||||
for (const int* beginIndex = polygonIndices.constData(), *end = beginIndex + polygonIndices.size();
|
||||
beginIndex != end; ) {
|
||||
|
|
Loading…
Reference in a new issue