Swap yaw and pitch in camera computation. Add functions to convert view matrix to camera position, and camera position to camera yaw pitch roll.
This commit is contained in:
@@ -93,10 +93,10 @@ protected:
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.45;
|
||||
float pitch = 287;
|
||||
float yaw = 16.2;
|
||||
float pitch = -16.2;
|
||||
float yaw = 287;
|
||||
float targetPos[3]={2.05,0.02,0.53};//-3,2.8,-2.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
|
||||
|
||||
}
|
||||
|
||||
@@ -273,6 +273,30 @@ void PhysicsClientExample::prepareAndSubmitCommand(int commandId)
|
||||
///request an image from a simulated camera, using a software renderer.
|
||||
|
||||
b3SharedMemoryCommandHandle commandHandle = b3InitRequestCameraImage(m_physicsClientHandle);
|
||||
|
||||
float cameraPos[3] = {1.0, 1.0, 1.0};
|
||||
float cameraTarget[3] = {2.0, 1.0, 1.0};
|
||||
float cameraUp[3] = {0.0, 0.0, 1.0};
|
||||
float viewMat[16];
|
||||
b3ComputeViewMatrixFromPositions(cameraPos, cameraTarget, cameraUp, viewMat);
|
||||
printf("viewMat: %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f\n", viewMat[0], viewMat[1], viewMat[2], viewMat[3], viewMat[4], viewMat[5], viewMat[6], viewMat[7], viewMat[8], viewMat[9], viewMat[10], viewMat[11], viewMat[12], viewMat[13], viewMat[14], viewMat[15]);
|
||||
float cameraPos2[3];
|
||||
float cameraTarget2[3];
|
||||
float cameraUp2[3];
|
||||
b3ComputePositionFromViewMatrix(viewMat, cameraPos2, cameraTarget2, cameraUp2);
|
||||
printf("cameraPos2: %f, %f, %f\n", cameraPos2[0], cameraPos2[1], cameraPos2[2]);
|
||||
printf("cameraTarget2: %f, %f, %f\n", cameraTarget2[0], cameraTarget2[1], cameraTarget2[2]);
|
||||
printf("cameraUp2: %f, %f, %f\n", cameraUp2[0], cameraUp2[1], cameraUp2[2]);
|
||||
|
||||
float cameraDistance;
|
||||
float cameraYaw;
|
||||
float cameraPitch;
|
||||
b3ComputeYawPitchRollFromPosition(cameraPos2, cameraTarget2, cameraUp2, 2, &cameraDistance, &cameraYaw, &cameraPitch);
|
||||
printf("camera distance: %f\n", cameraDistance);
|
||||
printf("camera yaw: %f\n", cameraYaw);
|
||||
printf("camera pitch: %f\n", cameraPitch);
|
||||
|
||||
b3ComputeViewMatrixFromYawPitchRoll(cameraTarget2, 1.0, -90.0, 0.0, 0.0, 2, viewMat);
|
||||
//b3RequestCameraImageSelectRenderer(commandHandle,ER_BULLET_HARDWARE_OPENGL);
|
||||
|
||||
float viewMatrix[16];
|
||||
|
||||
Reference in New Issue
Block a user