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
10//10//
11 11
12#include <QScriptEngine>12#include <QScriptEngine>
13#include <QScriptValueIterator>
13#include <QtScript/QScriptValue>14#include <QtScript/QScriptValue>
14#include "ModelScriptingInterface.h"15#include "ModelScriptingInterface.h"
15#include "OBJWriter.h"16#include "OBJWriter.h"
@@ -27,10 +28,31 @@ void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) { · 11 unmodified lines
27 out = qobject_cast<MeshProxy*>(value.toQObject());28 out = qobject_cast<MeshProxy*>(value.toQObject());
28}29}
29 30
30QString ModelScriptingInterface::meshToOBJ(MeshProxy* const &in) {31QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) {
32 return engine->toScriptValue(in);
33}
34
35void 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
46QString ModelScriptingInterface::meshToOBJ(MeshProxyList in) {
31 bool success;47 bool success;
32 QString filename = "/tmp/okokok.obj";48 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);
34 if (!success) {56 if (!success) {
35 return "";57 return "";
36 }58 }