Merge branch 'master' of github.com:worklist/hifi into assignment

This commit is contained in:
Stephen Birarda 2013-09-23 09:57:22 -07:00
commit daa5493973
6 changed files with 28 additions and 5 deletions

View file

@ -35,6 +35,7 @@
#include <QMenuBar> #include <QMenuBar>
#include <QMouseEvent> #include <QMouseEvent>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkDiskCache>
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <QWheelEvent> #include <QWheelEvent>
#include <QSettings> #include <QSettings>
@ -208,6 +209,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_window->setMenuBar(Menu::getInstance()); _window->setMenuBar(Menu::getInstance());
_networkAccessManager = new QNetworkAccessManager(this); _networkAccessManager = new QNetworkAccessManager(this);
QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager);
cache->setCacheDirectory("interfaceCache");
_networkAccessManager->setCache(cache);
QRect available = desktop()->availableGeometry(); QRect available = desktop()->availableGeometry();
_window->resize(available.size()); _window->resize(available.size());

View file

@ -699,6 +699,10 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
SKIN_COLOR[1] - _bodyBall[b].touchForce * 0.2f, SKIN_COLOR[1] - _bodyBall[b].touchForce * 0.2f,
SKIN_COLOR[2] - _bodyBall[b].touchForce * 0.1f); SKIN_COLOR[2] - _bodyBall[b].touchForce * 0.1f);
if (b == BODY_BALL_NECK_BASE && _head.getBlendFace().isActive()) {
continue; // don't render the neck if we have a face model
}
if ((b != BODY_BALL_HEAD_TOP ) if ((b != BODY_BALL_HEAD_TOP )
&& (b != BODY_BALL_HEAD_BASE )) { && (b != BODY_BALL_HEAD_BASE )) {
glPushMatrix(); glPushMatrix();

View file

@ -118,7 +118,9 @@ void BlendFace::setModelURL(const QUrl& url) {
if (!url.isValid()) { if (!url.isValid()) {
return; 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(downloadProgress(qint64,qint64)), SLOT(handleModelDownloadProgress(qint64,qint64)));
connect(_modelReply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleModelReplyError())); 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) { void BlendFace::handleModelDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
if (bytesReceived < bytesTotal) { if (bytesReceived < bytesTotal && !_modelReply->isFinished()) {
return; return;
} }

View file

@ -30,6 +30,8 @@ public:
BlendFace(Head* owningHead); BlendFace(Head* owningHead);
~BlendFace(); ~BlendFace();
bool isActive() const { return _iboID != 0; }
bool render(float alpha); bool render(float alpha);
Q_INVOKABLE void setModelURL(const QUrl& url); Q_INVOKABLE void setModelURL(const QUrl& url);

View file

@ -567,6 +567,10 @@ void MyAvatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
alpha); alpha);
} }
if (b == BODY_BALL_NECK_BASE && _head.getBlendFace().isActive()) {
continue; // don't render the neck if we have a face model
}
if ((b != BODY_BALL_HEAD_TOP ) if ((b != BODY_BALL_HEAD_TOP )
&& (b != BODY_BALL_HEAD_BASE )) { && (b != BODY_BALL_HEAD_BASE )) {
glPushMatrix(); glPushMatrix();

View file

@ -272,7 +272,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
if (object.properties.at(2) == "Mesh") { if (object.properties.at(2) == "Mesh") {
FBXGeometry mesh; FBXGeometry mesh;
QVector<glm::vec3> vertices; QVector<glm::vec3> normals;
QVector<int> polygonIndices; QVector<int> polygonIndices;
foreach (const FBXNode& data, object.children) { foreach (const FBXNode& data, object.children) {
if (data.name == "Vertices") { if (data.name == "Vertices") {
@ -284,12 +284,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node) {
} else if (data.name == "LayerElementNormal") { } else if (data.name == "LayerElementNormal") {
foreach (const FBXNode& subdata, data.children) { foreach (const FBXNode& subdata, data.children) {
if (subdata.name == "Normals") { if (subdata.name == "Normals") {
mesh.normals = createVec3Vector( normals = createVec3Vector(subdata.properties.at(0).value<QVector<double> >());
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 // convert the polygons to quads and triangles
for (const int* beginIndex = polygonIndices.constData(), *end = beginIndex + polygonIndices.size(); for (const int* beginIndex = polygonIndices.constData(), *end = beginIndex + polygonIndices.size();
beginIndex != end; ) { beginIndex != end; ) {