b3SharedMemoryStatusHandle b3ProcessServerStatus(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; const SharedMemoryStatus* stat = cl->processServerStatus(); return (b3SharedMemoryStatusHandle) stat; }
void MyCallback(int buttonId, bool buttonState, void* userPtr) { PhysicsClient* cl = (PhysicsClient*) userPtr; switch (buttonId) { case CMD_LOAD_URDF: { cl->submitCommand(CMD_LOAD_URDF); break; } case CMD_REQUEST_ACTUAL_STATE: { cl->submitCommand(CMD_REQUEST_ACTUAL_STATE); break; } case CMD_STEP_FORWARD_SIMULATION: { cl->submitCommand(CMD_STEP_FORWARD_SIMULATION); break; } case CMD_SHUTDOWN: { cl->submitCommand(CMD_SHUTDOWN); break; } default: { b3Error("Unknown buttonId"); btAssert(0); } }; }
void b3GetCameraImageData(b3PhysicsClientHandle physClient, struct b3CameraImageData* imageData) { PhysicsClient* cl = (PhysicsClient* ) physClient; if (cl) { cl->getCachedCameraImage(imageData); } }
int b3CanSubmitCommand(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; if (cl) { return (int)cl->canSubmitCommand(); } return false; }
b3SharedMemoryStatusHandle b3ProcessServerStatus(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; if (cl && cl->isConnected()) { const SharedMemoryStatus* stat = cl->processServerStatus(); return (b3SharedMemoryStatusHandle) stat; } return 0; }
b3SharedMemoryCommandHandle b3RemovePickingConstraint(b3PhysicsClientHandle physClient) { PhysicsClient *cl = (PhysicsClient *)physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand *command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_REMOVE_PICKING_CONSTRAINT_BODY; return (b3SharedMemoryCommandHandle)command; }
b3SharedMemoryCommandHandle b3CreateBoxShapeCommandInit(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_CREATE_BOX_COLLISION_SHAPE; command->m_updateFlags =0; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3RequestActualStateCommandInit(b3PhysicsClientHandle physClient, int bodyUniqueId) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type =CMD_REQUEST_ACTUAL_STATE; command->m_requestActualStateInformationCommandArgument.m_bodyUniqueId = bodyUniqueId; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3InitStepSimulationCommand(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_STEP_FORWARD_SIMULATION; command->m_updateFlags = 0; return (b3SharedMemoryCommandHandle) command; }
///request an image from a simulated camera, using a software renderer. b3SharedMemoryCommandHandle b3InitRequestCameraImage(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type =CMD_REQUEST_CAMERA_IMAGE_DATA; command->m_requestPixelDataArguments.m_startPixelIndex = 0; command->m_updateFlags = 0;//REQUEST_PIXEL_ARGS_USE_HARDWARE_OPENGL; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3CreatePoseCommandInit(b3PhysicsClientHandle physClient, int bodyIndex) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_INIT_POSE; command->m_updateFlags =0; command->m_initPoseArgs.m_bodyUniqueId = bodyIndex; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3InitPhysicsParamCommand(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_SEND_PHYSICS_SIMULATION_PARAMETERS; command->m_updateFlags = 0; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3JointControlCommandInit( b3PhysicsClientHandle physClient, int controlMode) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_SEND_DESIRED_STATE; command->m_sendDesiredStateCommandArgument.m_controlMode = controlMode; command->m_sendDesiredStateCommandArgument.m_bodyUniqueId = 0; command->m_updateFlags = 0; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3ApplyExternalForceCommandInit(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_APPLY_EXTERNAL_FORCE; command->m_updateFlags = 0; command->m_externalForceArguments.m_numForcesAndTorques = 0; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3InitRequestDebugLinesCommand(b3PhysicsClientHandle physClient, int debugMode) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type =CMD_REQUEST_DEBUG_LINES; command->m_requestDebugLinesArguments.m_debugMode = debugMode; command->m_requestDebugLinesArguments.m_startingLineIndex = 0; return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3CreateSensorCommandInit(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_CREATE_SENSOR; command->m_updateFlags = 0; command->m_createSensorArguments.m_numJointSensorChanges = 0; command->m_createSensorArguments.m_bodyUniqueId = 0; return (b3SharedMemoryCommandHandle) command; }
void b3GetDebugLines(b3PhysicsClientHandle physClient, struct b3DebugLines* lines) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(lines); if (lines) { lines->m_numDebugLines = cl->getNumDebugLines(); lines->m_linesFrom = cl->getDebugLinesFrom(); lines->m_linesTo = cl->getDebugLinesTo(); lines->m_linesColor = cl->getDebugLinesColor(); } }
b3SharedMemoryCommandHandle b3JointControlCommandInit2( b3PhysicsClientHandle physClient, int bodyUniqueId, int controlMode) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_SEND_DESIRED_STATE; command->m_sendDesiredStateCommandArgument.m_controlMode = controlMode; command->m_sendDesiredStateCommandArgument.m_bodyUniqueId = bodyUniqueId; command->m_updateFlags = 0; for (int i=0;i<MAX_DEGREE_OF_FREEDOM;i++) { command->m_sendDesiredStateCommandArgument.m_hasDesiredStateFlags[i] = 0; } return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3PickBody(b3PhysicsClientHandle physClient, double rayFromWorldX, double rayFromWorldY, double rayFromWorldZ, double rayToWorldX, double rayToWorldY, double rayToWorldZ) { PhysicsClient *cl = (PhysicsClient *)physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand *command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_PICK_BODY; command->m_pickBodyArguments.m_rayFromWorld[0] = rayFromWorldX; command->m_pickBodyArguments.m_rayFromWorld[1] = rayFromWorldY; command->m_pickBodyArguments.m_rayFromWorld[2] = rayFromWorldZ; command->m_pickBodyArguments.m_rayToWorld[0] = rayToWorldX; command->m_pickBodyArguments.m_rayToWorld[1] = rayToWorldY; command->m_pickBodyArguments.m_rayToWorld[2] = rayToWorldZ; return (b3SharedMemoryCommandHandle)command; }
b3SharedMemoryCommandHandle b3CreatePoseCommandInit(b3PhysicsClientHandle physClient, int bodyIndex) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_INIT_POSE; command->m_updateFlags =0; command->m_initPoseArgs.m_bodyUniqueId = bodyIndex; //a bit slow, initialing the full range to zero... for (int i=0;i<MAX_DEGREE_OF_FREEDOM;i++) { command->m_initPoseArgs.m_hasInitialStateQ[i] = 0; } return (b3SharedMemoryCommandHandle) command; }
b3SharedMemoryCommandHandle b3LoadSdfCommandInit(b3PhysicsClientHandle physClient, const char* sdfFileName) { PhysicsClient* cl = (PhysicsClient* ) physClient; b3Assert(cl); b3Assert(cl->canSubmitCommand()); struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand(); b3Assert(command); command->m_type = CMD_LOAD_SDF; int len = strlen(sdfFileName); if (len<MAX_SDF_FILENAME_LENGTH) { strcpy(command->m_sdfArguments.m_sdfFileName,sdfFileName); } else { command->m_sdfArguments.m_sdfFileName[0] = 0; } command->m_updateFlags = SDF_ARGS_FILE_NAME; return (b3SharedMemoryCommandHandle) command; }
void MyCallback(int buttonId, bool buttonState, void* userPtr) { PhysicsClient* cl = (PhysicsClient*) userPtr; switch (buttonId) { case CMD_LOAD_URDF: case CMD_CREATE_BOX_COLLISION_SHAPE: case CMD_REQUEST_ACTUAL_STATE: case CMD_STEP_FORWARD_SIMULATION: case CMD_SHUTDOWN: case CMD_SEND_BULLET_DATA_STREAM: { cl->submitCommand(buttonId); break; } default: { b3Error("Unknown buttonId"); btAssert(0); } }; }
int b3GetJointInfo(b3PhysicsClientHandle physClient, int bodyIndex, int linkIndex, struct b3JointInfo* info) { PhysicsClient* cl = (PhysicsClient* ) physClient; return cl->getJointInfo(bodyIndex, linkIndex,*info); }
int b3GetNumJoints(b3PhysicsClientHandle physClient, int bodyId) { PhysicsClient* cl = (PhysicsClient* ) physClient; return cl->getNumJoints(bodyId); }
int b3SubmitClientCommand(b3PhysicsClientHandle physClient, const b3SharedMemoryCommandHandle commandHandle) { struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle; PhysicsClient* cl = (PhysicsClient* ) physClient; return (int)cl->submitClientCommand(*command); }
int b3CanSubmitCommand(b3PhysicsClientHandle physClient) { PhysicsClient* cl = (PhysicsClient* ) physClient; return (int)cl->canSubmitCommand(); }