RemoteGUIHelperTCP.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. #include "RemoteGUIHelperTCP.h"
  2. #include "../CommonInterfaces/CommonExampleInterface.h"
  3. #include "../CommonInterfaces/CommonGUIHelperInterface.h"
  4. #include "Bullet3Common/b3Logging.h"
  5. #include "GraphicsSharedMemoryCommands.h"
  6. #include "GraphicsSharedMemoryBlock.h"
  7. #include "Bullet3Common/b3Scalar.h"
  8. #include "LinearMath/btMinMax.h"
  9. #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
  10. #include "BulletCollision/CollisionShapes/btCollisionShape.h"
  11. #include "Bullet3Common/b3AlignedObjectArray.h"
  12. #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
  13. #include "ActiveSocket.h"
  14. #include <string>
  15. static unsigned int b3DeserializeInt3(const unsigned char* input)
  16. {
  17. unsigned int tmp = (input[3] << 24) + (input[2] << 16) + (input[1] << 8) + input[0];
  18. return tmp;
  19. }
  20. static bool gVerboseNetworkMessagesClient3 = true;//false;
  21. const char* cmd2txt[]=
  22. {
  23. "GFX_CMD_INVALID",
  24. "GFX_CMD_0",
  25. "GFX_CMD_SET_VISUALIZER_FLAG",
  26. "GFX_CMD_UPLOAD_DATA",
  27. "GFX_CMD_REGISTER_TEXTURE",
  28. "GFX_CMD_REGISTER_GRAPHICS_SHAPE",
  29. "GFX_CMD_REGISTER_GRAPHICS_INSTANCE",
  30. "GFX_CMD_SYNCHRONIZE_TRANSFORMS",
  31. "GFX_CMD_REMOVE_ALL_GRAPHICS_INSTANCES",
  32. "GFX_CMD_REMOVE_SINGLE_GRAPHICS_INSTANCE",
  33. "GFX_CMD_CHANGE_RGBA_COLOR",
  34. "GFX_CMD_GET_CAMERA_INFO",
  35. //don't go beyond this command!
  36. "GFX_CMD_MAX_CLIENT_COMMANDS",
  37. };
  38. struct RemoteGUIHelperTCPInternalData
  39. {
  40. // GUIHelperInterface* m_guiHelper;
  41. bool m_waitingForServer;
  42. std::string m_hostName;
  43. int m_port;
  44. GraphicsSharedMemoryStatus m_lastServerStatus;
  45. CActiveSocket m_tcpSocket;
  46. bool m_isConnected;
  47. b3AlignedObjectArray<unsigned char> m_tempBuffer;
  48. GraphicsSharedMemoryStatus m_lastStatus;
  49. GraphicsSharedMemoryCommand m_command;
  50. double m_timeOutInSeconds;
  51. b3AlignedObjectArray<char> m_stream;
  52. RemoteGUIHelperTCPInternalData(const char* hostName, int port)
  53. : m_waitingForServer(false),
  54. m_hostName(hostName),
  55. m_port(port),
  56. m_timeOutInSeconds(60.)
  57. {
  58. m_isConnected = false;
  59. connect();
  60. }
  61. virtual ~RemoteGUIHelperTCPInternalData()
  62. {
  63. disconnect();
  64. }
  65. virtual bool isConnected()
  66. {
  67. return m_isConnected;
  68. }
  69. bool canSubmitCommand() const
  70. {
  71. if (m_isConnected && !m_waitingForServer)
  72. {
  73. return true;
  74. }
  75. return false;
  76. }
  77. struct GraphicsSharedMemoryCommand* getAvailableSharedMemoryCommand()
  78. {
  79. static int sequence = 0;
  80. m_command.m_sequenceNumber = sequence++;
  81. return &m_command;
  82. }
  83. bool submitClientCommand(const GraphicsSharedMemoryCommand& command)
  84. {
  85. if (gVerboseNetworkMessagesClient3)
  86. printf("submitClientCommand: %d %s\n", command.m_type, cmd2txt[command.m_type]);
  87. /// at the moment we allow a maximum of 1 outstanding command, so we check for this
  88. // once the server processed the command and returns a status, we clear the flag
  89. // "m_data->m_waitingForServer" and allow submitting the next command
  90. btAssert(!m_waitingForServer);
  91. if (!m_waitingForServer)
  92. {
  93. int sz = 0;
  94. unsigned char* data = 0;
  95. m_tempBuffer.clear();
  96. sz = sizeof(GraphicsSharedMemoryCommand);
  97. data = (unsigned char*)&command;
  98. //printf("submit command of type %d\n", command.m_type);
  99. m_tcpSocket.Send((const uint8*)data, sz);
  100. m_waitingForServer = true;
  101. return true;
  102. }
  103. return false;
  104. }
  105. const GraphicsSharedMemoryStatus* processServerStatus()
  106. {
  107. bool hasStatus = false;
  108. //int serviceResult = enet_host_service(m_client, &m_event, 0);
  109. int maxLen = 4 + sizeof(GraphicsSharedMemoryStatus) + GRAPHICS_SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE;
  110. int rBytes = m_tcpSocket.Receive(maxLen);
  111. if (rBytes <= 0)
  112. return 0;
  113. //append to tmp buffer
  114. //recBytes
  115. unsigned char* d2 = (unsigned char*)m_tcpSocket.GetData();
  116. int curSize = m_tempBuffer.size();
  117. m_tempBuffer.resize(curSize + rBytes);
  118. for (int i = 0; i < rBytes; i++)
  119. {
  120. m_tempBuffer[curSize + i] = d2[i];
  121. }
  122. int packetSizeInBytes = -1;
  123. if (m_tempBuffer.size() >= 4)
  124. {
  125. packetSizeInBytes = b3DeserializeInt3(&m_tempBuffer[0]);
  126. }
  127. if (m_tempBuffer.size() == packetSizeInBytes)
  128. {
  129. unsigned char* data = &m_tempBuffer[0];
  130. if (gVerboseNetworkMessagesClient3)
  131. {
  132. printf("A packet of length %d bytes received\n", m_tempBuffer.size());
  133. }
  134. hasStatus = true;
  135. GraphicsSharedMemoryStatus* statPtr = (GraphicsSharedMemoryStatus*)&data[4];
  136. #if 0
  137. if (statPtr->m_type == CMD_STEP_FORWARD_SIMULATION_COMPLETED)
  138. {
  139. GraphicsSharedMemoryStatus dummy;
  140. dummy.m_type = CMD_STEP_FORWARD_SIMULATION_COMPLETED;
  141. m_lastStatus = dummy;
  142. m_stream.resize(0);
  143. }
  144. else
  145. #endif
  146. {
  147. m_lastStatus = *statPtr;
  148. int streamOffsetInBytes = 4 + sizeof(GraphicsSharedMemoryStatus);
  149. int numStreamBytes = packetSizeInBytes - streamOffsetInBytes;
  150. m_stream.resize(numStreamBytes);
  151. for (int i = 0; i < numStreamBytes; i++)
  152. {
  153. m_stream[i] = data[i + streamOffsetInBytes];
  154. }
  155. }
  156. m_tempBuffer.clear();
  157. m_waitingForServer = false;
  158. if (gVerboseNetworkMessagesClient3)
  159. printf("processServerStatus: %d\n", m_lastStatus.m_type);
  160. return &m_lastStatus;
  161. }
  162. return 0;
  163. }
  164. bool connect()
  165. {
  166. if (m_isConnected)
  167. return true;
  168. m_tcpSocket.Initialize();
  169. m_isConnected = m_tcpSocket.Open(m_hostName.c_str(), m_port);
  170. if (m_isConnected)
  171. {
  172. m_tcpSocket.SetSendTimeout(m_timeOutInSeconds, 0);
  173. m_tcpSocket.SetReceiveTimeout(m_timeOutInSeconds, 0);
  174. }
  175. int key = GRAPHICS_SHARED_MEMORY_MAGIC_NUMBER;
  176. m_tcpSocket.Send((uint8*)&key, 4);
  177. m_tcpSocket.SetBlocking();
  178. return m_isConnected;
  179. }
  180. void disconnect()
  181. {
  182. const char msg[16] = "disconnect";
  183. m_tcpSocket.Send((const uint8*)msg, 10);
  184. m_tcpSocket.Close();
  185. m_isConnected = false;
  186. }
  187. };
  188. RemoteGUIHelperTCP::RemoteGUIHelperTCP(const char* hostName, int port)
  189. {
  190. m_data = new RemoteGUIHelperTCPInternalData(hostName, port);
  191. if (m_data->canSubmitCommand())
  192. {
  193. removeAllGraphicsInstances();
  194. }
  195. }
  196. RemoteGUIHelperTCP::~RemoteGUIHelperTCP()
  197. {
  198. delete m_data;
  199. }
  200. void RemoteGUIHelperTCP::setVisualizerFlag(int flag, int enable)
  201. {
  202. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  203. if (cmd)
  204. {
  205. cmd->m_updateFlags = 0;
  206. cmd->m_visualizerFlagCommand.m_visualizerFlag = flag;
  207. cmd->m_visualizerFlagCommand.m_enable = enable;
  208. cmd->m_type = GFX_CMD_SET_VISUALIZER_FLAG;
  209. m_data->submitClientCommand(*cmd);
  210. }
  211. const GraphicsSharedMemoryStatus* status = 0;
  212. while ((status = m_data->processServerStatus()) == 0)
  213. {
  214. }
  215. }
  216. void RemoteGUIHelperTCP::createRigidBodyGraphicsObject(btRigidBody* body, const btVector3& color)
  217. {
  218. printf("todo: createRigidBodyGraphicsObject\n");
  219. }
  220. bool RemoteGUIHelperTCP::getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3], float hor[3], float vert[3], float* yaw, float* pitch, float* camDist, float camTarget[3]) const
  221. {
  222. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  223. if (cmd)
  224. {
  225. cmd->m_updateFlags = 0;
  226. cmd->m_type = GFX_CMD_GET_CAMERA_INFO;
  227. m_data->submitClientCommand(*cmd);
  228. }
  229. const GraphicsSharedMemoryStatus* status = 0;
  230. while ((status = m_data->processServerStatus()) == 0)
  231. {
  232. }
  233. if (status->m_type == GFX_CMD_GET_CAMERA_INFO_COMPLETED)
  234. {
  235. *width = status->m_getCameraInfoStatus.width;
  236. *height = status->m_getCameraInfoStatus.height;
  237. for (int i = 0; i < 16; i++)
  238. {
  239. viewMatrix[i] = status->m_getCameraInfoStatus.viewMatrix[i];
  240. projectionMatrix[i] = status->m_getCameraInfoStatus.projectionMatrix[i];
  241. }
  242. for (int i = 0; i < 3; i++)
  243. {
  244. camUp[i] = status->m_getCameraInfoStatus.camUp[i];
  245. camForward[i] = status->m_getCameraInfoStatus.camForward[i];
  246. hor[i] = status->m_getCameraInfoStatus.hor[i];
  247. vert[i] = status->m_getCameraInfoStatus.vert[i];
  248. camTarget[i] = status->m_getCameraInfoStatus.camTarget[i];
  249. }
  250. *yaw = status->m_getCameraInfoStatus.yaw;
  251. *pitch = status->m_getCameraInfoStatus.pitch;
  252. *camDist = status->m_getCameraInfoStatus.camDist;
  253. return true;
  254. }
  255. return false;
  256. }
  257. void RemoteGUIHelperTCP::createCollisionObjectGraphicsObject(btCollisionObject* body, const btVector3& color)
  258. {
  259. if (body->getUserIndex() < 0)
  260. {
  261. btCollisionShape* shape = body->getCollisionShape();
  262. btTransform startTransform = body->getWorldTransform();
  263. int graphicsShapeId = shape->getUserIndex();
  264. if (graphicsShapeId >= 0)
  265. {
  266. // btAssert(graphicsShapeId >= 0);
  267. //the graphics shape is already scaled
  268. float localScaling[4] = {1.f, 1.f, 1.f, 1.f};
  269. float colorRGBA[4] = {(float)color[0], (float)color[1], (float)color[2], (float)color[3]};
  270. float pos[4] = {(float)startTransform.getOrigin()[0], (float)startTransform.getOrigin()[1], (float)startTransform.getOrigin()[2], (float)startTransform.getOrigin()[3]};
  271. float orn[4] = {(float)startTransform.getRotation()[0], (float)startTransform.getRotation()[1], (float)startTransform.getRotation()[2], (float)startTransform.getRotation()[3]};
  272. int graphicsInstanceId = registerGraphicsInstance(graphicsShapeId, pos, orn, colorRGBA, localScaling);
  273. body->setUserIndex(graphicsInstanceId);
  274. }
  275. }
  276. }
  277. void RemoteGUIHelperTCP::createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)
  278. {
  279. printf("todo; createCollisionShapeGraphicsObject\n");
  280. }
  281. void RemoteGUIHelperTCP::syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld)
  282. {
  283. }
  284. void RemoteGUIHelperTCP::syncPhysicsToGraphics2(const btDiscreteDynamicsWorld* rbWorld)
  285. {
  286. b3AlignedObjectArray<GUISyncPosition> updatedPositions;
  287. int numCollisionObjects = rbWorld->getNumCollisionObjects();
  288. {
  289. B3_PROFILE("write all InstanceTransformToCPU2");
  290. for (int i = 0; i < numCollisionObjects; i++)
  291. {
  292. //B3_PROFILE("writeSingleInstanceTransformToCPU");
  293. btCollisionObject* colObj = rbWorld->getCollisionObjectArray()[i];
  294. btCollisionShape* collisionShape = colObj->getCollisionShape();
  295. btVector3 pos = colObj->getWorldTransform().getOrigin();
  296. btQuaternion orn = colObj->getWorldTransform().getRotation();
  297. int index = colObj->getUserIndex();
  298. if (index >= 0)
  299. {
  300. GUISyncPosition p;
  301. p.m_graphicsInstanceId = index;
  302. for (int q = 0; q < 4; q++)
  303. {
  304. p.m_pos[q] = pos[q];
  305. p.m_orn[q] = orn[q];
  306. }
  307. updatedPositions.push_back(p);
  308. }
  309. }
  310. }
  311. if (updatedPositions.size())
  312. {
  313. syncPhysicsToGraphics2(&updatedPositions[0], updatedPositions.size());
  314. }
  315. }
  316. void RemoteGUIHelperTCP::syncPhysicsToGraphics2(const GUISyncPosition* positions, int numPositions)
  317. {
  318. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  319. if (cmd)
  320. {
  321. uploadData((unsigned char*)positions, numPositions * sizeof(GUISyncPosition), 0);
  322. cmd->m_updateFlags = 0;
  323. cmd->m_syncTransformsCommand.m_numPositions = numPositions;
  324. cmd->m_type = GFX_CMD_SYNCHRONIZE_TRANSFORMS;
  325. m_data->submitClientCommand(*cmd);
  326. }
  327. const GraphicsSharedMemoryStatus* status = 0;
  328. while ((status = m_data->processServerStatus()) == 0)
  329. {
  330. }
  331. }
  332. void RemoteGUIHelperTCP::render(const btDiscreteDynamicsWorld* rbWorld)
  333. {
  334. }
  335. void RemoteGUIHelperTCP::createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld)
  336. {
  337. }
  338. int RemoteGUIHelperTCP::uploadData(const unsigned char* data, int sizeInBytes, int slot)
  339. {
  340. int chunkSize = 1024;// GRAPHICS_SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE;
  341. int remainingBytes = sizeInBytes;
  342. int offset = 0;
  343. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  344. cmd->m_updateFlags = 0;
  345. cmd->m_type = GFX_CMD_UPLOAD_DATA;
  346. cmd->m_uploadDataCommand.m_numBytes = sizeInBytes;
  347. cmd->m_uploadDataCommand.m_dataOffset = offset;
  348. cmd->m_uploadDataCommand.m_dataSlot = slot;
  349. m_data->submitClientCommand(*cmd);
  350. const GraphicsSharedMemoryStatus* status = 0;
  351. while ((status = m_data->processServerStatus()) == 0)
  352. {
  353. }
  354. while (remainingBytes > 0)
  355. {
  356. int curBytes = btMin(remainingBytes, chunkSize);
  357. m_data->m_tcpSocket.Send((const uint8*)data+offset, curBytes);
  358. if (gVerboseNetworkMessagesClient3)
  359. printf("sending %d bytes\n", curBytes);
  360. remainingBytes -= curBytes;
  361. offset += curBytes;
  362. }
  363. if (gVerboseNetworkMessagesClient3)
  364. printf("send all bytes!\n");
  365. status = 0;
  366. while ((status = m_data->processServerStatus()) == 0)
  367. {
  368. }
  369. return 0;
  370. }
  371. int RemoteGUIHelperTCP::registerTexture(const unsigned char* texels, int width, int height)
  372. {
  373. int textureId = -1;
  374. //first upload all data
  375. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  376. if (cmd)
  377. {
  378. int sizeInBytes = width * height * 3; //rgb
  379. uploadData(texels, sizeInBytes, 0);
  380. cmd->m_updateFlags = 0;
  381. cmd->m_type = GFX_CMD_REGISTER_TEXTURE;
  382. cmd->m_registerTextureCommand.m_width = width;
  383. cmd->m_registerTextureCommand.m_height = height;
  384. m_data->submitClientCommand(*cmd);
  385. const GraphicsSharedMemoryStatus* status = 0;
  386. while ((status = m_data->processServerStatus()) == 0)
  387. {
  388. }
  389. if (status->m_type == GFX_CMD_REGISTER_TEXTURE_COMPLETED)
  390. {
  391. textureId = status->m_registerTextureStatus.m_textureId;
  392. }
  393. }
  394. return textureId;
  395. }
  396. int RemoteGUIHelperTCP::registerGraphicsShape(const float* vertices, int numvertices, const int* indices, int numIndices, int primitiveType, int textureId)
  397. {
  398. int shapeId = -1;
  399. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  400. if (cmd)
  401. {
  402. uploadData((unsigned char*)vertices, numvertices * 9 * sizeof(float), 0);
  403. uploadData((unsigned char*)indices, numIndices * sizeof(int), 1);
  404. cmd->m_type = GFX_CMD_REGISTER_GRAPHICS_SHAPE;
  405. cmd->m_updateFlags = 0;
  406. cmd->m_registerGraphicsShapeCommand.m_numVertices = numvertices;
  407. cmd->m_registerGraphicsShapeCommand.m_numIndices = numIndices;
  408. cmd->m_registerGraphicsShapeCommand.m_primitiveType = primitiveType;
  409. cmd->m_registerGraphicsShapeCommand.m_textureId = textureId;
  410. m_data->submitClientCommand(*cmd);
  411. const GraphicsSharedMemoryStatus* status = 0;
  412. while ((status = m_data->processServerStatus()) == 0)
  413. {
  414. }
  415. if (status->m_type == GFX_CMD_REGISTER_GRAPHICS_SHAPE_COMPLETED)
  416. {
  417. shapeId = status->m_registerGraphicsShapeStatus.m_shapeId;
  418. }
  419. }
  420. return shapeId;
  421. }
  422. int RemoteGUIHelperTCP::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
  423. {
  424. int graphicsInstanceId = -1;
  425. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  426. if (cmd)
  427. {
  428. cmd->m_type = GFX_CMD_REGISTER_GRAPHICS_INSTANCE;
  429. cmd->m_updateFlags = 0;
  430. cmd->m_registerGraphicsInstanceCommand.m_shapeIndex = shapeIndex;
  431. for (int i = 0; i < 4; i++)
  432. {
  433. cmd->m_registerGraphicsInstanceCommand.m_position[i] = position[i];
  434. cmd->m_registerGraphicsInstanceCommand.m_quaternion[i] = quaternion[i];
  435. cmd->m_registerGraphicsInstanceCommand.m_color[i] = color[i];
  436. cmd->m_registerGraphicsInstanceCommand.m_scaling[i] = scaling[i];
  437. }
  438. m_data->submitClientCommand(*cmd);
  439. const GraphicsSharedMemoryStatus* status = 0;
  440. while ((status = m_data->processServerStatus()) == 0)
  441. {
  442. }
  443. if (status->m_type == GFX_CMD_REGISTER_GRAPHICS_INSTANCE_COMPLETED)
  444. {
  445. graphicsInstanceId = status->m_registerGraphicsInstanceStatus.m_graphicsInstanceId;
  446. }
  447. }
  448. return graphicsInstanceId;
  449. }
  450. void RemoteGUIHelperTCP::removeAllGraphicsInstances()
  451. {
  452. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  453. if (cmd)
  454. {
  455. cmd->m_updateFlags = 0;
  456. cmd->m_type = GFX_CMD_REMOVE_ALL_GRAPHICS_INSTANCES;
  457. m_data->submitClientCommand(*cmd);
  458. const GraphicsSharedMemoryStatus* status = 0;
  459. while ((status = m_data->processServerStatus()) == 0)
  460. {
  461. }
  462. }
  463. }
  464. void RemoteGUIHelperTCP::removeGraphicsInstance(int graphicsUid)
  465. {
  466. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  467. if (cmd)
  468. {
  469. cmd->m_updateFlags = 0;
  470. cmd->m_type = GFX_CMD_REMOVE_SINGLE_GRAPHICS_INSTANCE;
  471. cmd->m_removeGraphicsInstanceCommand.m_graphicsUid = graphicsUid;
  472. m_data->submitClientCommand(*cmd);
  473. const GraphicsSharedMemoryStatus* status = 0;
  474. while ((status = m_data->processServerStatus()) == 0)
  475. {
  476. }
  477. }
  478. }
  479. void RemoteGUIHelperTCP::changeRGBAColor(int instanceUid, const double rgbaColor[4])
  480. {
  481. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  482. if (cmd)
  483. {
  484. cmd->m_updateFlags = 0;
  485. cmd->m_type = GFX_CMD_CHANGE_RGBA_COLOR;
  486. cmd->m_changeRGBAColorCommand.m_graphicsUid = instanceUid;
  487. for (int i = 0; i < 4; i++)
  488. {
  489. cmd->m_changeRGBAColorCommand.m_rgbaColor[i] = rgbaColor[i];
  490. }
  491. m_data->submitClientCommand(*cmd);
  492. const GraphicsSharedMemoryStatus* status = 0;
  493. while ((status = m_data->processServerStatus()) == 0)
  494. {
  495. }
  496. }
  497. }
  498. Common2dCanvasInterface* RemoteGUIHelperTCP::get2dCanvasInterface()
  499. {
  500. return 0;
  501. }
  502. CommonParameterInterface* RemoteGUIHelperTCP::getParameterInterface()
  503. {
  504. return 0;
  505. }
  506. CommonRenderInterface* RemoteGUIHelperTCP::getRenderInterface()
  507. {
  508. return 0;
  509. }
  510. CommonGraphicsApp* RemoteGUIHelperTCP::getAppInterface()
  511. {
  512. return 0;
  513. }
  514. void RemoteGUIHelperTCP::setUpAxis(int axis)
  515. {
  516. GraphicsSharedMemoryCommand* cmd = m_data->getAvailableSharedMemoryCommand();
  517. if (cmd)
  518. {
  519. cmd->m_updateFlags = 0;
  520. cmd->m_upAxisYCommand.m_enableUpAxisY = axis == 1;
  521. cmd->m_type = GFX_CMD_0;
  522. m_data->submitClientCommand(*cmd);
  523. const GraphicsSharedMemoryStatus* status = 0;
  524. while ((status = m_data->processServerStatus()) == 0)
  525. {
  526. }
  527. }
  528. }
  529. void RemoteGUIHelperTCP::resetCamera(float camDist, float yaw, float pitch, float camPosX, float camPosY, float camPosZ)
  530. {
  531. }
  532. void RemoteGUIHelperTCP::copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],
  533. unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels,
  534. float* depthBuffer, int depthBufferSizeInPixels,
  535. int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
  536. int startPixelIndex, int width, int height, int* numPixelsCopied)
  537. {
  538. if (numPixelsCopied)
  539. *numPixelsCopied = 0;
  540. }
  541. void RemoteGUIHelperTCP::setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])
  542. {
  543. }
  544. void RemoteGUIHelperTCP::setProjectiveTexture(bool useProjectiveTexture)
  545. {
  546. }
  547. void RemoteGUIHelperTCP::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
  548. {
  549. }
  550. void RemoteGUIHelperTCP::drawText3D(const char* txt, float posX, float posZY, float posZ, float size)
  551. {
  552. }
  553. void RemoteGUIHelperTCP::drawText3D(const char* txt, float position[3], float orientation[4], float color[4], float size, int optionFlag)
  554. {
  555. }
  556. int RemoteGUIHelperTCP::addUserDebugLine(const double debugLineFromXYZ[3], const double debugLineToXYZ[3], const double debugLineColorRGB[3], double lineWidth, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid)
  557. {
  558. return -1;
  559. }
  560. int RemoteGUIHelperTCP::addUserDebugPoints(const double debugPointPositionXYZ[3], const double debugPointColorRGB[3], double pointSize, double lifeTime, int trackingVisualShapeIndex, int replaceItemUid, int debugPointNum)
  561. {
  562. return -1;
  563. }
  564. void RemoteGUIHelperTCP::removeUserDebugItem(int debugItemUniqueId)
  565. {
  566. }
  567. void RemoteGUIHelperTCP::removeAllUserDebugItems()
  568. {
  569. }