save default VR camera tuning, requires MIDI controller
tweak some values in VR demo
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
//@todo(erwincoumans) those globals are hacks for a VR demo, move this to Python/pybullet!
|
||||
extern btVector3 gLastPickPos;
|
||||
btVector3 gVRTeleportPos1(0,0,0);
|
||||
btScalar gVRTeleportRotZ = 0;
|
||||
btQuaternion gVRTeleportOrn(0, 0, 0,1);
|
||||
extern btVector3 gVRGripperPos;
|
||||
extern btQuaternion gVRGripperOrn;
|
||||
@@ -46,10 +47,47 @@ extern btScalar simTimeScalingFactor;
|
||||
|
||||
extern bool gVRGripperClosed;
|
||||
|
||||
#if B3_USE_MIDI
|
||||
const char* startFileNameVR = "0_VRDemoSettings.txt";
|
||||
|
||||
#include <vector>
|
||||
|
||||
//remember the settings (you don't want to re-tune again and again...)
|
||||
static void saveCurrentSettingsVR()
|
||||
{
|
||||
FILE* f = fopen(startFileNameVR, "w");
|
||||
if (f)
|
||||
{
|
||||
fprintf(f, "--camPosX= %f\n", gVRTeleportPos1[0]);
|
||||
fprintf(f, "--camPosY= %f\n", gVRTeleportPos1[1]);
|
||||
fprintf(f, "--camPosZ= %f\n", gVRTeleportPos1[2]);
|
||||
fprintf(f, "--camRotZ= %f\n", gVRTeleportRotZ);
|
||||
fclose(f);
|
||||
}
|
||||
};
|
||||
|
||||
static void loadCurrentSettingsVR(b3CommandLineArgs& args)
|
||||
{
|
||||
int currentEntry = 0;
|
||||
FILE* f = fopen(startFileNameVR, "r");
|
||||
if (f)
|
||||
{
|
||||
char oneline[1024];
|
||||
char* argv[] = { 0,&oneline[0] };
|
||||
|
||||
while (fgets(oneline, 1024, f) != NULL)
|
||||
{
|
||||
char *pos;
|
||||
if ((pos = strchr(oneline, '\n')) != NULL)
|
||||
*pos = '\0';
|
||||
args.addArgs(2, argv);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
};
|
||||
#if B3_USE_MIDI
|
||||
|
||||
|
||||
static float getParamf(float rangeMin, float rangeMax, int midiVal)
|
||||
{
|
||||
float v = rangeMin + (rangeMax - rangeMin)* (float(midiVal / 127.));
|
||||
@@ -70,9 +108,10 @@ void midiCallback(double deltatime, std::vector< unsigned char > *message, void
|
||||
{
|
||||
if (message->at(1) == 16)
|
||||
{
|
||||
float rotZ = getParamf(-3.1415, 3.1415, message->at(2));
|
||||
gVRTeleportOrn = btQuaternion(btVector3(0, 0, 1), rotZ);
|
||||
b3Printf("gVRTeleportOrn rotZ = %f\n", rotZ);
|
||||
gVRTeleportRotZ= getParamf(-3.1415, 3.1415, message->at(2));
|
||||
gVRTeleportOrn = btQuaternion(btVector3(0, 0, 1), gVRTeleportRotZ);
|
||||
saveCurrentSettingsVR();
|
||||
b3Printf("gVRTeleportOrn rotZ = %f\n", gVRTeleportRotZ);
|
||||
}
|
||||
|
||||
if (message->at(1) == 32)
|
||||
@@ -85,6 +124,7 @@ void midiCallback(double deltatime, std::vector< unsigned char > *message, void
|
||||
if (message->at(1) == i)
|
||||
{
|
||||
gVRTeleportPos1[i] = getParamf(-2, 2, message->at(2));
|
||||
saveCurrentSettingsVR();
|
||||
b3Printf("gVRTeleportPos[%d] = %f\n", i,gVRTeleportPos1[i]);
|
||||
|
||||
}
|
||||
@@ -927,7 +967,7 @@ public:
|
||||
virtual void processCommandLineArgs(int argc, char* argv[])
|
||||
{
|
||||
b3CommandLineArgs args(argc,argv);
|
||||
|
||||
loadCurrentSettingsVR(args);
|
||||
if (args.GetCmdLineArgument("camPosX", gVRTeleportPos1[0]))
|
||||
{
|
||||
printf("camPosX=%f\n", gVRTeleportPos1[0]);
|
||||
@@ -1665,8 +1705,10 @@ void PhysicsServerExample::vrControllerButtonCallback(int controllerId, int butt
|
||||
return;
|
||||
|
||||
if (gGraspingController < 0)
|
||||
{
|
||||
gGraspingController = controllerId;
|
||||
|
||||
gEnableKukaControl = true;
|
||||
}
|
||||
if (controllerId != gGraspingController)
|
||||
{
|
||||
if (button == 1 && state == 0)
|
||||
|
||||
Reference in New Issue
Block a user