From cff7bb703e8b397dc88c25efd363a440d21744b3 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 24 Jul 2015 14:08:30 -0700 Subject: [PATCH] Test evolution. --- tests/rig/src/RigTests.cpp | 48 ++++++++++++++++++++++++-------------- tests/rig/src/RigTests.h | 3 +-- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/tests/rig/src/RigTests.cpp b/tests/rig/src/RigTests.cpp index 95ddc86b3f..c5622ac501 100644 --- a/tests/rig/src/RigTests.cpp +++ b/tests/rig/src/RigTests.cpp @@ -61,25 +61,34 @@ void RigTests::initTestCase() { // So here we do neither. Using as much as we can from AvatarData (which is in the avatar and further requires network and audio), and // duplicating whatever other code we need from (My)Avatar. Ugh. We may refactor that later, but right now, cleaning this up is not on our critical path. - // Joint mapping from fst - auto avatar = std::make_shared(); + // Joint mapping from fst. FIXME: Do we need this??? + /*auto avatar = std::make_shared(); QEventLoop loop; // Create an event loop that will quit when we get the finished signal QObject::connect(avatar.get(), &AvatarData::jointMappingLoaded, &loop, &QEventLoop::quit); avatar->setSkeletonModelURL(QUrl("https://hifi-public.s3.amazonaws.com/marketplace/contents/4a690585-3fa3-499e-9f8b-fd1226e561b1/e47e6898027aa40f1beb6adecc6a7db5.fst")); // Zach fst - loop.exec(); // Blocking all further tests until signalled. + loop.exec();*/ // Blocking all further tests until signalled. // Joint geometry from fbx. +#define FROM_FILE "/Users/howardstearns/howardHiFi/Zack.fbx" +#ifdef FROM_FILE + QFile file(FROM_FILE); + QCOMPARE(file.open(QIODevice::ReadOnly), true); + FBXGeometry geometry = readFBX(file.readAll(), QVariantHash()); +#else QUrl fbxUrl("https://s3.amazonaws.com/hifi-public/models/skeletons/Zack/Zack.fbx"); - QNetworkReply* netReply = OBJReader().request(fbxUrl, false); // Just a convenience hack for synchronoud http request - QCOMPARE(netReply->isFinished() && (netReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200), true); - FBXGeometry geometry = readFBX(netReply->readAll(), QVariantHash()); - QCOMPARE(geometry.joints.count(), avatar->getJointNames().count()); + QNetworkReply* reply = OBJReader().request(fbxUrl, false); // Just a convenience hack for synchronoud http request + auto fbxHttpCode = !reply->isFinished() ? -1 : reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + QCOMPARE(fbxHttpCode, 200); + FBXGeometry geometry = readFBX(reply->readAll(), QVariantHash()); +#endif + //QCOMPARE(geometry.joints.count(), avatar->getJointNames().count()); QVector jointStates; for (int i = 0; i < geometry.joints.size(); ++i) { - const FBXJoint& joint = geometry.joints[i]; + // Note that if the geometry is stack allocated and goes away, so will the joints. Hence the heap copy here. + FBXJoint* joint = new FBXJoint(geometry.joints[i]); JointState state; - state.setFBXJoint(&joint); + state.setFBXJoint(joint); jointStates.append(state); } @@ -88,14 +97,17 @@ void RigTests::initTestCase() { std::cout << "Rig is ready " << geometry.joints.count() << " joints " << std::endl; } -/*void RigTests::dummyPassTest() { - bool x = true; - std::cout << "dummyPassTest x=" << x << std::endl; - QCOMPARE(x, true); +void reportJoint(int index, JointState joint) { // Handy for debugging + std::cout << "\n"; + std::cout << index << " " << joint.getFBXJoint().name.toUtf8().data() << "\n"; + std::cout << " pos:" << joint.getPosition() << "/" << joint.getPositionInParentFrame() << " from " << joint.getParentIndex() << "\n"; + std::cout << " rot:" << safeEulerAngles(joint.getRotation()) << "/" << safeEulerAngles(joint.getRotationInParentFrame()) << "/" << safeEulerAngles(joint.getRotationInBindFrame()) << "\n"; + std::cout << "\n"; } -void RigTests::dummyFailTest() { - bool x = false; - std::cout << "dummyFailTest x=" << x << std::endl; - QCOMPARE(x, true); -}*/ +void RigTests::initialPoseArmsDown() { + for (int i = 0; i < _rig->getJointStateCount(); i++) { + JointState joint = _rig->getJointState(i); + reportJoint(i, joint); + } +} diff --git a/tests/rig/src/RigTests.h b/tests/rig/src/RigTests.h index 1ce692b858..4280c0a8fa 100644 --- a/tests/rig/src/RigTests.h +++ b/tests/rig/src/RigTests.h @@ -46,8 +46,7 @@ class RigTests : public QObject { private slots: void initTestCase(); - /*void dummyPassTest(); - void dummyFailTest();*/ + void initialPoseArmsDown(); private: RigPointer _rig;