mirror of
https://gitlab.com/theadib/JSonRPCPlugin.git
synced 2026-08-29 15:40:24 +08:00
add option to apply transformation matrix to object after open
This commit is contained in:
+22
-4
@@ -148,14 +148,32 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap<QString, QVariant> 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<ccGenericPointCloud*>(cloud)->showNormals(false);
|
||||
}
|
||||
}
|
||||
|
||||
// apply matrix if possible
|
||||
QList<QVariant> transformation = params["transformation"].toList();
|
||||
if(transformation.size() == 4*4) {
|
||||
std::vector<double> 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);
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
|
||||
Executable
+25
@@ -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())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user