History

ModelScriptingInterface::meshToOBJ takes a list of MeshProxys instead of just one

Seth Alves committed 9 years ago

Commit 91e542a1 parent 9e8fcc06 files · +36 −15Browse files

Showing the changes to libraries/script-engine/src/ModelScriptingInterface.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ModelScriptingInterface.cpp+24−2
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 //
1111
1212 #include <QScriptEngine>
13+#include <QScriptValueIterator>
1314 #include <QtScript/QScriptValue>
1415 #include "ModelScriptingInterface.h"
1516 #include "OBJWriter.h"
@@ -27,10 +28,31 @@ void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) { · 11 unmodified lines
2728 out = qobject_cast<MeshProxy*>(value.toQObject());
2829 }
2930
30−QString ModelScriptingInterface::meshToOBJ(MeshProxy* const &in) {
31+QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) {
32+ return engine->toScriptValue(in);
33+}
34+
35+void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out) {
36+ QScriptValueIterator itr(value);
37+ while(itr.hasNext()) {
38+ itr.next();
39+ MeshProxy* meshProxy = qscriptvalue_cast<MeshProxyList::value_type>(itr.value());
40+ if (meshProxy) {
41+ out.append(meshProxy);
42+ }
43+ }
44+}
45+
46+QString ModelScriptingInterface::meshToOBJ(MeshProxyList in) {
3147 bool success;
3248 QString filename = "/tmp/okokok.obj";
33− success = writeOBJToFile(filename, in->getMeshPointer());
49+
50+ QList<MeshPointer> meshes;
51+ foreach (const MeshProxy* meshProxy, in) {
52+ meshes.append(meshProxy->getMeshPointer());
53+ }
54+
55+ success = writeOBJToFile(filename, meshes);
3456 if (!success) {
3557 return "";
3658 }