diff --git a/src/JsonRPCPlugin.cpp b/src/JsonRPCPlugin.cpp index 4e3c723..395b015 100644 --- a/src/JsonRPCPlugin.cpp +++ b/src/JsonRPCPlugin.cpp @@ -148,14 +148,32 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap par //disable the normals on all loaded clouds! ccHObject::Container clouds; newGroup->filterChildren(clouds, true, CC_TYPES::POINT_CLOUD); - for (ccHObject* cloud : clouds) - { - if (cloud) - { + for (ccHObject* cloud : clouds) { + if (cloud) { static_cast(cloud)->showNormals(false); } } + // apply matrix if possible + QList transformation = params["transformation"].toList(); + if(transformation.size() == 4*4) { + std::vector values(4*4); + bool success; + for(unsigned i; i < 4*4; ++i) { + double d = transformation[i].toDouble(&success); + qDebug() << transformation[i].toString() << transformation[i].toDouble(); + if(!success) { + break; + } + values[((i%4)*4)+(i/4)] = d; + } + if(success) { + ccGLMatrix mat = ccGLMatrix(values.data()); + qDebug() << "apply matrix: " << mat.toString(); + newGroup->setGLTransformation(mat); + } + } + m_app->addToDB(newGroup); need_redraw = true; result = JsonRPCResult::success(0); diff --git a/test/client_open.py b/test/client_open.py index 50ea237..091cdef 100755 --- a/test/client_open.py +++ b/test/client_open.py @@ -6,7 +6,7 @@ import websockets async def hello(): uri = "ws://localhost:6001" async with websockets.connect(uri) as websocket: - await websocket.send('{"jsonrpc": "2.0", "method": "open2", "params": {"filename": "/home/adib/Dokumente/teapt.ply"}, "id": 4}') + await websocket.send('{"jsonrpc": "2.0", "method": "open", "params": {"filename": "/home/adib/Dokumente/teapot.ply"}, "id": 4}') result = await websocket.recv() print("result: ", result) diff --git a/test/client_open_matrix.py b/test/client_open_matrix.py new file mode 100755 index 0000000..72cfdee --- /dev/null +++ b/test/client_open_matrix.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import asyncio +import websockets + +async def hello(): + uri = "ws://localhost:6001" + async with websockets.connect(uri) as websocket: + await websocket.send('{"jsonrpc": "2.0", "method": "open", \ + "params": { \ + "filename": "/home/adib/Dokumente/teapot.ply", \ + "filter":"PLY mesh (*.ply)", \ + "silent":true, \ + "transformation": [-0.5732937009507673, 0.8193193174792813, 0.007084582014166903, -161.35002666963268, \ + -0.8193308300123949, -0.5733179603522832, 0.001873784980341508, 320.67951255557966, \ + 0.005596946702519333, -0.004730387192182964, 0.9999731500865392, -230.60935194531334, \ + 0.0, 0.0, 0.0, 1.0]}, \ + "id": 4}') + result = await websocket.recv() + print("result: ", result) + +asyncio.get_event_loop().run_until_complete(hello()) + + +