summaryrefslogtreecommitdiff
path: root/examples/SharedMemory
diff options
context:
space:
mode:
Diffstat (limited to 'examples/SharedMemory')
-rw-r--r--examples/SharedMemory/PhysicsClientC_API.cpp47
-rw-r--r--examples/SharedMemory/PhysicsClientC_API.h6
-rw-r--r--examples/SharedMemory/PhysicsClientTCP.cpp1
-rw-r--r--examples/SharedMemory/PhysicsServerCommandProcessor.cpp26
-rw-r--r--examples/SharedMemory/PhysicsServerExample.cpp7
-rw-r--r--examples/SharedMemory/SharedMemoryCommands.h18
-rw-r--r--examples/SharedMemory/SharedMemoryPublic.h8
7 files changed, 111 insertions, 2 deletions
diff --git a/examples/SharedMemory/PhysicsClientC_API.cpp b/examples/SharedMemory/PhysicsClientC_API.cpp
index b116999d6..b89d618f5 100644
--- a/examples/SharedMemory/PhysicsClientC_API.cpp
+++ b/examples/SharedMemory/PhysicsClientC_API.cpp
@@ -2551,3 +2551,50 @@ int b3StateLoggingStop(b3SharedMemoryCommandHandle commandHandle, int loggingUid
return 0;
}
+
+///configure the 3D OpenGL debug visualizer (enable/disable GUI widgets, shadows, position camera etc)
+b3SharedMemoryCommandHandle b3InitConfigureOpenGLVisualizer(b3PhysicsClientHandle physClient)
+{
+ PhysicsClient* cl = (PhysicsClient*)physClient;
+ b3Assert(cl);
+ b3Assert(cl->canSubmitCommand());
+ struct SharedMemoryCommand* command = cl->getAvailableSharedMemoryCommand();
+ b3Assert(command);
+
+ command->m_type = CMD_CONFIGURE_OPENGL_VISUALIZER;
+ command->m_updateFlags = 0;
+
+ return (b3SharedMemoryCommandHandle)command;
+}
+
+void b3ConfigureOpenGLVisualizerSetVisualizationFlags(b3SharedMemoryCommandHandle commandHandle, int flag, int enabled)
+{
+ struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
+ b3Assert(command);
+ b3Assert(command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER);
+ if (command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER)
+ {
+ command->m_updateFlags |= COV_SET_FLAGS;
+ command->m_configureOpenGLVisualizerArguments.m_setFlag = flag;
+ command->m_configureOpenGLVisualizerArguments.m_setEnabled = enabled;
+ }
+}
+
+void b3ConfigureOpenGLVisualizerSetViewMatrix(b3SharedMemoryCommandHandle commandHandle, float cameraDistance, float cameraPitch, float cameraYaw, const float cameraTargetPosition[3])
+{
+ struct SharedMemoryCommand* command = (struct SharedMemoryCommand*) commandHandle;
+ b3Assert(command);
+ b3Assert(command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER);
+
+ if (command->m_type == CMD_CONFIGURE_OPENGL_VISUALIZER)
+ {
+ command->m_updateFlags |= COV_SET_CAMERA_VIEW_MATRIX;
+ command->m_configureOpenGLVisualizerArguments.m_cameraDistance = cameraDistance;
+ command->m_configureOpenGLVisualizerArguments.m_cameraPitch = cameraPitch;
+ command->m_configureOpenGLVisualizerArguments.m_cameraYaw = cameraYaw;
+ command->m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[0] = cameraTargetPosition[0];
+ command->m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[1] = cameraTargetPosition[1];
+ command->m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[2] = cameraTargetPosition[2];
+ }
+}
+
diff --git a/examples/SharedMemory/PhysicsClientC_API.h b/examples/SharedMemory/PhysicsClientC_API.h
index b22b9635c..61638bb7f 100644
--- a/examples/SharedMemory/PhysicsClientC_API.h
+++ b/examples/SharedMemory/PhysicsClientC_API.h
@@ -98,7 +98,13 @@ b3SharedMemoryCommandHandle b3InitRequestDebugLinesCommand(b3PhysicsClientHandle
///Get the pointers to the physics debug line information, after b3InitRequestDebugLinesCommand returns
///status CMD_DEBUG_LINES_COMPLETED
void b3GetDebugLines(b3PhysicsClientHandle physClient, struct b3DebugLines* lines);
+
+///configure the 3D OpenGL debug visualizer (enable/disable GUI widgets, shadows, position camera etc)
+b3SharedMemoryCommandHandle b3InitConfigureOpenGLVisualizer(b3PhysicsClientHandle physClient);
+void b3ConfigureOpenGLVisualizerSetVisualizationFlags(b3SharedMemoryCommandHandle commandHandle, int flag, int enabled);
+void b3ConfigureOpenGLVisualizerSetViewMatrix(b3SharedMemoryCommandHandle commandHandle, float cameraDistance, float cameraPitch, float cameraYaw, const float cameraTargetPosition[3]);
+
/// Add/remove user-specific debug lines and debug text messages
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddLine3D(b3PhysicsClientHandle physClient, double fromXYZ[3], double toXYZ[3], double colorRGB[3], double lineWidth, double lifeTime);
b3SharedMemoryCommandHandle b3InitUserDebugDrawAddText3D(b3PhysicsClientHandle physClient, const char* txt, double positionXYZ[3], double colorRGB[3], double textSize, double lifeTime);
diff --git a/examples/SharedMemory/PhysicsClientTCP.cpp b/examples/SharedMemory/PhysicsClientTCP.cpp
index 443fc3bef..9ad9fdab9 100644
--- a/examples/SharedMemory/PhysicsClientTCP.cpp
+++ b/examples/SharedMemory/PhysicsClientTCP.cpp
@@ -175,7 +175,6 @@ bool TcpNetworkedPhysicsProcessor::processCommand(const struct SharedMemoryComma
sz = sizeof(SharedMemoryCommand);
data = (unsigned char*)&clientCmd;
}
- int res;
m_data->m_tcpSocket.Send((const uint8 *)data,sz);
diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
index 0f7139257..3a6341e36 100644
--- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
+++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp
@@ -507,7 +507,7 @@ struct MinitaurStateLogger : public InternalStateLogger
if (m_logFileHandle)
{
- btVector3 pos = m_minitaurMultiBody->getBasePos();
+ //btVector3 pos = m_minitaurMultiBody->getBasePos();
MinitaurLogRecord logData;
//'t', 'r', 'p', 'y', 'q0', 'q1', 'q2', 'q3', 'q4', 'q5', 'q6', 'q7', 'u0', 'u1', 'u2', 'u3', 'u4', 'u5', 'u6', 'u7', 'xd', 'mo'
@@ -3385,6 +3385,30 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
hasStatus = true;
break;
}
+
+ case CMD_CONFIGURE_OPENGL_VISUALIZER:
+ {
+ SharedMemoryStatus& serverCmd = serverStatusOut;
+ serverCmd.m_type =CMD_CLIENT_COMMAND_COMPLETED;
+
+ hasStatus = true;
+ if (clientCmd.m_updateFlags&COV_SET_FLAGS)
+ {
+ m_data->m_guiHelper->setVisualizerFlag(clientCmd.m_configureOpenGLVisualizerArguments.m_setFlag,
+ clientCmd.m_configureOpenGLVisualizerArguments.m_setEnabled);
+ }
+ if (clientCmd.m_updateFlags&COV_SET_CAMERA_VIEW_MATRIX)
+ {
+ m_data->m_guiHelper->resetCamera( clientCmd.m_configureOpenGLVisualizerArguments.m_cameraDistance,
+ clientCmd.m_configureOpenGLVisualizerArguments.m_cameraPitch,
+ clientCmd.m_configureOpenGLVisualizerArguments.m_cameraYaw,
+ clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[0],
+ clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[1],
+ clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[2]);
+ }
+ break;
+ }
+
case CMD_REQUEST_CONTACT_POINT_INFORMATION:
{
SharedMemoryStatus& serverCmd =serverStatusOut;
diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp
index 520a6d904..cb05ce921 100644
--- a/examples/SharedMemory/PhysicsServerExample.cpp
+++ b/examples/SharedMemory/PhysicsServerExample.cpp
@@ -504,6 +504,13 @@ class MultiThreadedOpenGLGuiHelper : public GUIHelperInterface
public:
+
+ void setVisualizerFlag(int flag, int enable)
+ {
+ m_childGuiHelper->setVisualizerFlag(flag,enable);
+ }
+
+
GUIHelperInterface* m_childGuiHelper;
int m_uidGenerator;
diff --git a/examples/SharedMemory/SharedMemoryCommands.h b/examples/SharedMemory/SharedMemoryCommands.h
index 5bc2a508d..52a2ea53d 100644
--- a/examples/SharedMemory/SharedMemoryCommands.h
+++ b/examples/SharedMemory/SharedMemoryCommands.h
@@ -643,6 +643,23 @@ struct StateLoggingResultArgs
int m_loggingUniqueId;
};
+enum InternalOpenGLVisualizerUpdateFlags
+{
+ COV_SET_CAMERA_VIEW_MATRIX=1,
+ COV_SET_FLAGS=2,
+};
+
+struct ConfigureOpenGLVisualizerRequest
+{
+ double m_cameraDistance;
+ double m_cameraPitch;
+ double m_cameraYaw;
+ double m_cameraTargetPosition[3];
+
+ int m_setFlag;
+ int m_setEnabled;
+};
+
struct SharedMemoryCommand
{
int m_type;
@@ -685,6 +702,7 @@ struct SharedMemoryCommand
struct LoadBunnyArgs m_loadBunnyArguments;
struct VRCameraState m_vrCameraStateArguments;
struct StateLoggingRequest m_stateLoggingArguments;
+ struct ConfigureOpenGLVisualizerRequest m_configureOpenGLVisualizerArguments;
};
};
diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h
index 526a4ec4d..7fa209856 100644
--- a/examples/SharedMemory/SharedMemoryPublic.h
+++ b/examples/SharedMemory/SharedMemoryPublic.h
@@ -49,6 +49,7 @@ enum EnumSharedMemoryClientCommand
CMD_SET_VR_CAMERA_STATE,
CMD_SYNC_BODY_INFO,
CMD_STATE_LOGGING,
+ CMD_CONFIGURE_OPENGL_VISUALIZER,
//don't go beyond this command!
CMD_MAX_CLIENT_COMMANDS,
@@ -126,6 +127,7 @@ enum EnumSharedMemoryServerStatus
CMD_STATE_LOGGING_COMPLETED,
CMD_STATE_LOGGING_START_COMPLETED,
CMD_STATE_LOGGING_FAILED,
+
//don't go beyond 'CMD_MAX_SERVER_COMMANDS!
CMD_MAX_SERVER_COMMANDS
};
@@ -398,4 +400,10 @@ enum EnumRenderer
//ER_FIRE_RAYS=(1<<18),
};
+enum EnumConfigureOpenGLVisualizer
+{
+ COV_ENABLE_GUI=1,
+ COV_ENABLE_SHADOWS,
+ COV_ENABLE_WIREFRAME,
+};
#endif//SHARED_MEMORY_PUBLIC_H