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:
yunfeibai
2017-06-01 15:30:37 -07:00
parent 4388a6ea02
commit e6d1a8cf97
74 changed files with 347 additions and 281 deletions

Binary file not shown.

View File

@@ -39,10 +39,10 @@ struct BasicExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 4; float dist = 4;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -110,10 +110,10 @@ class BenchmarkDemo : public CommonRigidBodyMTBase
void resetCamera() void resetCamera()
{ {
float dist = 120; float dist = 120;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,10.46,0}; float targetPos[3]={0,10.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -371,8 +371,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 10.5; float dist = 10.5;
float pitch = 136; float pitch = -32;
float yaw = 32; float yaw = 136;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -55,7 +55,7 @@ struct GUIHelperInterface
virtual void setUpAxis(int axis)=0; virtual void setUpAxis(int axis)=0;
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)=0; virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)=0;
virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const
{ {
@@ -151,7 +151,7 @@ struct DummyGUIHelper : public GUIHelperInterface
virtual void setUpAxis(int axis) virtual void setUpAxis(int axis)
{ {
} }
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ) virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)
{ {
} }

View File

@@ -201,10 +201,10 @@ struct CommonGraphicsApp
{ {
// if (b3Fabs(xDelta)>b3Fabs(yDelta)) // if (b3Fabs(xDelta)>b3Fabs(yDelta))
// { // {
pitch -= xDelta*m_mouseMoveMultiplier; pitch -= yDelta*m_mouseMoveMultiplier;
// } else // } else
// { // {
yaw += yDelta*m_mouseMoveMultiplier; yaw -= xDelta*m_mouseMoveMultiplier;
// } // }
} }

View File

@@ -50,10 +50,10 @@ class AllConstraintDemo : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 27; float dist = 27;
float pitch = 720; float pitch = -30;
float yaw = 30; float yaw = 720;
float targetPos[3]={2,0,-10}; float targetPos[3]={2,0,-10};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
virtual bool keyboardCallback(int key, int state); virtual bool keyboardCallback(int key, int state);

View File

@@ -18,10 +18,10 @@ struct ConstraintPhysicsSetup : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 7; float dist = 7;
float pitch = 721; float pitch = -44;
float yaw = 44; float yaw = 721;
float targetPos[3]={8,1,-11}; float targetPos[3]={8,1,-11};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -55,10 +55,10 @@ struct Dof6Spring2Setup : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 722; float pitch = -35;
float yaw = 35; float yaw = 722;
float targetPos[3]={4,2,-11}; float targetPos[3]={4,2,-11};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -24,10 +24,10 @@ struct TestHingeTorque : public CommonRigidBodyBase
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={-1.34,3.4,-0.44}; float targetPos[3]={-1.34,3.4,-0.44};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -63,10 +63,10 @@ public:
void resetCamera() void resetCamera()
{ {
float dist = 11; float dist = 11;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -145,10 +145,10 @@ public:
void resetCamera() void resetCamera()
{ {
float dist = 11; float dist = 11;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
// Evaluation // Evaluation

View File

@@ -973,7 +973,7 @@ void OpenGLGuiHelper::setVisualizerFlag(int flag, int enable)
} }
void OpenGLGuiHelper::resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ) void OpenGLGuiHelper::resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)
{ {
if (getRenderInterface() && getRenderInterface()->getActiveCamera()) if (getRenderInterface() && getRenderInterface()->getActiveCamera())
{ {

View File

@@ -46,7 +46,7 @@ struct OpenGLGuiHelper : public GUIHelperInterface
virtual void setUpAxis(int axis); virtual void setUpAxis(int axis);
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ); virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ);
virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const; virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const;
virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16], virtual void copyCameraImageData(const float viewMatrix[16], const float projectionMatrix[16],

View File

@@ -35,10 +35,10 @@ struct BridgeExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -35,10 +35,10 @@ struct ChainExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -62,10 +62,10 @@ struct InclinedPlaneExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -58,10 +58,10 @@ struct MultiPendulumExample: public CommonRigidBodyBase {
virtual void applyPendulumForce(btScalar pendulumForce); virtual void applyPendulumForce(btScalar pendulumForce);
void resetCamera() { void resetCamera() {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3] = { 0, 0.46, 0 }; float targetPos[3] = { 0, 0.46, 0 };
m_guiHelper->resetCamera(dist, pitch, yaw, targetPos[0], targetPos[1], m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1],
targetPos[2]); targetPos[2]);
} }

View File

@@ -35,10 +35,10 @@ struct MultipleBoxesExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -58,10 +58,10 @@ struct NewtonsCradleExample: public CommonRigidBodyBase {
virtual void applyPendulumForce(btScalar pendulumForce); virtual void applyPendulumForce(btScalar pendulumForce);
void resetCamera() { void resetCamera() {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3] = { 0, 0.46, 0 }; float targetPos[3] = { 0, 0.46, 0 };
m_guiHelper->resetCamera(dist, pitch, yaw, targetPos[0], targetPos[1], m_guiHelper->resetCamera(dist, yaw, pitch, targetPos[0], targetPos[1],
targetPos[2]); targetPos[2]);
} }

View File

@@ -90,10 +90,10 @@ struct NewtonsRopeCradleExample : public CommonRigidBodyBase {
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
std::vector<btSliderConstraint*> constraints; std::vector<btSliderConstraint*> constraints;

View File

@@ -43,10 +43,10 @@ struct RigidBodyFromObjExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 11; float dist = 11;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -35,10 +35,10 @@ struct SimpleBoxExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -61,10 +61,10 @@ struct SimpleClothExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
void createSoftBody(const btScalar size, const int num_x, const int num_z, const int fixed=1+2); void createSoftBody(const btScalar size, const int num_x, const int num_z, const int fixed=1+2);

View File

@@ -35,10 +35,10 @@ struct SimpleJointExample : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -144,10 +144,10 @@ class ForkLiftDemo : public CommonExampleInterface
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 8; float dist = 8;
float pitch = -45; float pitch = -32;
float yaw = 32; float yaw = -45;
float targetPos[3]={-0.33,-0.72,4.5}; float targetPos[3]={-0.33,-0.72,4.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]);
} }
/*static DemoApplication* Create() /*static DemoApplication* Create()

View File

@@ -90,10 +90,10 @@ public:
void resetCamera() void resetCamera()
{ {
float dist = 41; float dist = 41;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -21,10 +21,10 @@ struct GyroscopicSetup : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 20; float dist = 20;
float pitch = 180; float pitch = -16;
float yaw = 16; float yaw = 180;
float targetPos[3]={-2.4,0.4,-0.24}; float targetPos[3]={-2.4,0.4,-0.24};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -67,10 +67,10 @@ class BspDemo : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 43; float dist = 43;
float pitch = -175; float pitch = -12;
float yaw = 12; float yaw = -175;
float targetPos[3]={4,-25,-6}; float targetPos[3]={4,-25,-6};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -22,10 +22,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 9.5; float dist = 9.5;
float pitch = -2.8; float pitch = -20;
float yaw = 20; float yaw = -2.8;
float targetPos[3]={-0.2,-1.4,3.5}; float targetPos[3]={-0.2,-1.4,3.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]);
} }
}; };

View File

@@ -41,10 +41,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 16; float dist = 16;
float pitch = -140; float pitch = -28;
float yaw = 28; float yaw = -140;
float targetPos[3]={-4,-3,-3}; float targetPos[3]={-4,-3,-3};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -38,10 +38,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 3.5;
float pitch = -136; float pitch = -28;
float yaw = 28; float yaw = -136;
float targetPos[3]={0.47,0,-0.64}; float targetPos[3]={0.47,0,-0.64};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -29,10 +29,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 18; float dist = 18;
float pitch = 120; float pitch = -46;
float yaw = 46; float yaw = 120;
float targetPos[3]={-2,-2,-2}; float targetPos[3]={-2,-2,-2};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -50,10 +50,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 3.5;
float pitch = -136; float pitch = -28;
float yaw = 28; float yaw = -136;
float targetPos[3]={0.47,0,-0.64}; float targetPos[3]={0.47,0,-0.64};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -25,10 +25,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 3.5;
float pitch = -136; float pitch = -28;
float yaw = 28; float yaw = -136;
float targetPos[3]={0.47,0,-0.64}; float targetPos[3]={0.47,0,-0.64};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -50,10 +50,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 3.5;
float pitch = -136; float pitch = -28;
float yaw = 28; float yaw = -136;
float targetPos[3]={0.47,0,-0.64}; float targetPos[3]={0.47,0,-0.64};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -87,10 +87,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 1.5; float dist = 1.5;
float pitch = -80; float pitch = -10;
float yaw = 10; float yaw = -80;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -313,8 +313,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 1.3; float dist = 1.3;
float pitch = 120; float pitch = -13;
float yaw = 13; float yaw = 120;
float targetPos[3]={-0.35,0.14,0.25}; float targetPos[3]={-0.35,0.14,0.25};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -30,10 +30,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={-1.34,1.4,3.44}; float targetPos[3]={-1.34,1.4,3.44};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -26,10 +26,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={-1.34,3.4,-0.44}; float targetPos[3]={-1.34,3.4,-0.44};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -27,10 +27,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -34,10 +34,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 1; float dist = 1;
float pitch = 50; float pitch = -35;
float yaw = 35; float yaw = 50;
float targetPos[3]={-3,2.8,-2.5}; float targetPos[3]={-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]);
} }

View File

@@ -40,10 +40,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -27,10 +27,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 270; float pitch = -21;
float yaw = 21; float yaw = 270;
float targetPos[3]={-1.34,3.4,-0.44}; float targetPos[3]={-1.34,3.4,-0.44};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -98,8 +98,8 @@ public:
virtual void resetCamera() BT_OVERRIDE virtual void resetCamera() BT_OVERRIDE
{ {
m_guiHelper->resetCamera( m_cameraDist, m_guiHelper->resetCamera( m_cameraDist,
m_cameraPitch,
m_cameraYaw, m_cameraYaw,
m_cameraPitch,
m_cameraTargetPos.x(), m_cameraTargetPos.x(),
m_cameraTargetPos.y(), m_cameraTargetPos.y(),
m_cameraTargetPos.z() m_cameraTargetPos.z()
@@ -115,8 +115,8 @@ MultiThreadedDemo::MultiThreadedDemo(struct GUIHelperInterface* helper)
m_groundBody = NULL; m_groundBody = NULL;
m_groundMovePhase = 0.0f; m_groundMovePhase = 0.0f;
m_cameraTargetPos = btVector3( 0.0f, 0.0f, 0.0f ); m_cameraTargetPos = btVector3( 0.0f, 0.0f, 0.0f );
m_cameraPitch = 90.0f; m_cameraPitch = -30.0f;
m_cameraYaw = 30.0f; m_cameraYaw = 90.0f;
m_cameraDist = 48.0f; m_cameraDist = 48.0f;
helper->setUpAxis( kUpAxis ); helper->setUpAxis( kUpAxis );
} }

View File

@@ -304,8 +304,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 10.5; float dist = 10.5;
float pitch = 136; float pitch = -32;
float yaw = 32; float yaw = 136;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -71,10 +71,10 @@ public:
dist = 130; dist = 130;
} }
float pitch = 62; float pitch = -33;
float yaw = 33; float yaw = 62;
float targetPos[4]={15.5,12.5,15.5,0}; float targetPos[4]={15.5,12.5,15.5,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -150,8 +150,8 @@ void GpuConvexScene::setupScene()
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraTargetPosition(camPos[0],camPos[1],camPos[2]); m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraTargetPosition(camPos[0],camPos[1],camPos[2]);
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraDistance(150); m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraDistance(150);
//m_instancingRenderer->setCameraYaw(85); //m_instancingRenderer->setCameraYaw(85);
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraYaw(30); m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraYaw(225);
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraPitch(225); m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraPitch(-30);
m_guiHelper->getRenderInterface()->updateCamera(1);//>updateCamera(); m_guiHelper->getRenderInterface()->updateCamera(1);//>updateCamera();

View File

@@ -86,10 +86,10 @@ m_window(0)
void GpuRigidBodyDemo::resetCamera() void GpuRigidBodyDemo::resetCamera()
{ {
float dist = 114; float dist = 114;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_data->m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_data->m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
GpuRigidBodyDemo::~GpuRigidBodyDemo() GpuRigidBodyDemo::~GpuRigidBodyDemo()

View File

@@ -205,6 +205,10 @@ int SimpleCamera::getCameraUpAxis() const
void SimpleCamera::update() void SimpleCamera::update()
{ {
b3Scalar yawRad = m_data->m_yaw * b3Scalar(0.01745329251994329547);// rads per deg
b3Scalar pitchRad = m_data->m_pitch * b3Scalar(0.01745329251994329547);// rads per deg
b3Scalar rollRad = 0.0;
b3Quaternion eyeRot;
int forwardAxis(-1); int forwardAxis(-1);
switch (m_data->m_cameraUpAxis) switch (m_data->m_cameraUpAxis)
@@ -213,11 +217,13 @@ void SimpleCamera::update()
forwardAxis = 2; forwardAxis = 2;
m_data->m_cameraUp = b3MakeVector3(0,1,0); m_data->m_cameraUp = b3MakeVector3(0,1,0);
//gLightPos = b3MakeVector3(-50.f,100,30); //gLightPos = b3MakeVector3(-50.f,100,30);
eyeRot.setEulerZYX(rollRad, yawRad, -pitchRad);
break; break;
case 2: case 2:
forwardAxis = 1; forwardAxis = 1;
m_data->m_cameraUp = b3MakeVector3(0,0,1); m_data->m_cameraUp = b3MakeVector3(0,0,1);
//gLightPos = b3MakeVector3(-50.f,30,100); //gLightPos = b3MakeVector3(-50.f,30,100);
eyeRot.setEulerZYX(yawRad, rollRad, pitchRad);
break; break;
default: default:
{ {
@@ -238,19 +244,7 @@ void SimpleCamera::update()
m_data->m_cameraForward.normalize(); m_data->m_cameraForward.normalize();
} }
eyePos = b3Matrix3x3(eyeRot)*eyePos;
// m_azi=m_azi+0.01;
b3Scalar rele = m_data->m_yaw * b3Scalar(0.01745329251994329547);// rads per deg
b3Scalar razi = m_data->m_pitch * b3Scalar(0.01745329251994329547);// rads per deg
b3Quaternion rot(m_data->m_cameraUp,razi);
b3Vector3 right = m_data->m_cameraUp.cross(m_data->m_cameraForward);
b3Quaternion roll(right,-rele);
eyePos = b3Matrix3x3(rot) * b3Matrix3x3(roll) * eyePos;
m_data->m_cameraPosition = eyePos; m_data->m_cameraPosition = eyePos;
m_data->m_cameraPosition+= m_data->m_cameraTargetPosition; m_data->m_cameraPosition+= m_data->m_cameraTargetPosition;

View File

@@ -96,10 +96,10 @@ class Planar2D : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 9; float dist = 9;
float pitch = 539; float pitch = -11;
float yaw = 11; float yaw = 539;
float targetPos[3]={8.6,10.5,-20.6}; float targetPos[3]={8.6,10.5,-20.6};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }

View File

@@ -55,10 +55,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 18; float dist = 18;
float pitch = 129; float pitch = -30;
float yaw = 30; float yaw = 129;
float targetPos[3]={-4.6,-4.7,-5.75}; float targetPos[3]={-4.6,-4.7,-5.75};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -143,8 +143,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.5; float dist = 3.5;
float pitch = 136; float pitch = -32;
float yaw = 32; float yaw = 136;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -121,8 +121,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 1.15; float dist = 1.15;
float pitch = 396; float pitch = -33.7;
float yaw = 33.7; float yaw = 396;
float targetPos[3]={-0.5,0.7,1.45}; float targetPos[3]={-0.5,0.7,1.45};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -128,8 +128,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 13; float dist = 13;
float pitch = 50; float pitch = -13;
float yaw = 13; float yaw = 50;
float targetPos[3]={-1,0,-0.3}; float targetPos[3]={-1,0,-0.3};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -137,10 +137,10 @@ struct TinyRendererSetup : public CommonExampleInterface
void resetCamera() void resetCamera()
{ {
float dist = 11; float dist = 11;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -47,10 +47,10 @@ struct RigidBodySoftContact : public CommonRigidBodyBase
void resetCamera() void resetCamera()
{ {
float dist = 3; float dist = 3;
float pitch = 52; float pitch = -35;
float yaw = 35; float yaw = 52;
float targetPos[3]={0,0.46,0}; float targetPos[3]={0,0.46,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -496,8 +496,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 1.5; float dist = 1.5;
float pitch = 18; float pitch = -10;
float yaw = 10; float yaw = 18;
float targetPos[3]={-0.2,0.8,0.3}; float targetPos[3]={-0.2,0.8,0.3};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -283,8 +283,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3; float dist = 3;
float pitch = 0; float pitch = -30;
float yaw = 30; float yaw = 0;
float targetPos[3]={-0.2,0.8,0.3}; float targetPos[3]={-0.2,0.8,0.3};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -188,8 +188,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3; float dist = 3;
float pitch = -75; float pitch = -30;
float yaw = 30; float yaw = -75;
float targetPos[3]={-0.2,0.8,0.3}; float targetPos[3]={-0.2,0.8,0.3};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -59,10 +59,10 @@ public:
void resetCamera() void resetCamera()
{ {
float dist = 35; float dist = 35;
float pitch = 0; float pitch = -14;
float yaw = 14; float yaw = 0;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -1930,6 +1930,86 @@ void b3RequestCameraImageSetShadow(b3SharedMemoryCommandHandle commandHandle, in
command->m_updateFlags |= REQUEST_PIXEL_ARGS_SET_SHADOW; command->m_updateFlags |= REQUEST_PIXEL_ARGS_SET_SHADOW;
} }
void b3ComputeYawPitchRollFromPosition(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], int upAxis, float* cameraDistance, float* cameraYaw, float* cameraPitch)
{
b3Vector3 camPos = b3MakeVector3(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
b3Vector3 camTargetPos = b3MakeVector3(cameraTargetPosition[0], cameraTargetPosition[1], cameraTargetPosition[2]);
b3Vector3 camUpVector = b3MakeVector3(cameraUp[0], cameraUp[1], cameraUp[2]);
camUpVector.normalize();
*cameraDistance = (camPos - camTargetPos).length();
b3Vector3 eyePos = camPos - camTargetPos;
b3Vector3 eyeInitPos = b3MakeVector3(0, 0, 0);
int forwardAxis = -1;
switch (upAxis)
{
case 1:
forwardAxis = 2;
break;
case 2:
forwardAxis = 1;
break;
default:
return;
};
eyeInitPos[forwardAxis] = -(*cameraDistance);
eyeInitPos.normalize();
eyePos.normalize();
b3Quaternion rot = b3ShortestArcQuat(eyeInitPos, eyePos);
btScalar yawRad;
btScalar pitchRad;
btScalar rollRad;
switch (upAxis)
{
case 1:
rot.getEulerZYX(rollRad, yawRad, pitchRad);
pitchRad = -pitchRad;
break;
case 2:
rot.getEulerZYX(yawRad, rollRad, pitchRad);
break;
default:
return;
};
*cameraYaw = yawRad/b3Scalar(0.01745329251994329547);
*cameraPitch = pitchRad/b3Scalar(0.01745329251994329547);
float cameraRoll = rollRad/b3Scalar(0.01745329251994329547);
printf("camera roll: %f\n", cameraRoll);
}
void b3ComputePositionFromViewMatrix(const float viewMatrix[16], float cameraPosition[3], float cameraTargetPosition[3], float cameraUp[3])
{
b3Matrix3x3 r(viewMatrix[0], viewMatrix[4], viewMatrix[8], viewMatrix[1], viewMatrix[5], viewMatrix[9], viewMatrix[2], viewMatrix[6], viewMatrix[10]);
b3Vector3 p = b3MakeVector3(viewMatrix[12], viewMatrix[13], viewMatrix[14]);
b3Transform t(r,p);
b3Transform tinv = t.inverse();
b3Matrix3x3 basis = tinv.getBasis();
b3Vector3 origin = tinv.getOrigin();
printf("basis: %f, %f, %f, %f, %f, %f, %f, %f, %f\n", basis[0][0], basis[0][1], basis[0][2], basis[1][0], basis[1][1], basis[1][2], basis[2][0], basis[2][1], basis[2][2]);
printf("origin: %f, %f, %f\n", origin[0], origin[1], origin[2]);
b3Vector3 s = b3MakeVector3(basis[0][0], basis[1][0], basis[2][0]);
b3Vector3 u = b3MakeVector3(basis[0][1], basis[1][1], basis[2][1]);
b3Vector3 f = b3MakeVector3(-basis[0][2], -basis[1][2], -basis[2][2]);
b3Vector3 eye = origin;
cameraPosition[0] = eye[0];
cameraPosition[1] = eye[1];
cameraPosition[2] = eye[2];
b3Vector3 center = f + eye;
cameraTargetPosition[0] = center[0];
cameraTargetPosition[1] = center[1];
cameraTargetPosition[2] = center[2];
cameraUp[0] = u[0];
cameraUp[1] = u[1];
cameraUp[2] = u[2];
}
void b3ComputeViewMatrixFromPositions(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], float viewMatrix[16]) void b3ComputeViewMatrixFromPositions(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], float viewMatrix[16])
{ {
b3Vector3 eye = b3MakeVector3(cameraPosition[0], cameraPosition[1], cameraPosition[2]); b3Vector3 eye = b3MakeVector3(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
@@ -1971,76 +2051,42 @@ void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetPosition[3], fl
b3Vector3 camTargetPos = b3MakeVector3(cameraTargetPosition[0], cameraTargetPosition[1], cameraTargetPosition[2]); b3Vector3 camTargetPos = b3MakeVector3(cameraTargetPosition[0], cameraTargetPosition[1], cameraTargetPosition[2]);
b3Vector3 eyePos = b3MakeVector3(0, 0, 0); b3Vector3 eyePos = b3MakeVector3(0, 0, 0);
int forwardAxis(-1);
{
switch (upAxis)
{
case 1:
{
forwardAxis = 0;
eyePos[forwardAxis] = -distance;
camForward = b3MakeVector3(eyePos[0], eyePos[1], eyePos[2]);
if (camForward.length2() < B3_EPSILON)
{
camForward.setValue(1.f, 0.f, 0.f);
}
else
{
camForward.normalize();
}
b3Scalar rollRad = roll * b3Scalar(0.01745329251994329547);
b3Quaternion rollRot(camForward, rollRad);
camUpVector = b3QuatRotate(rollRot, b3MakeVector3(0, 1, 0));
//gLightPos = b3MakeVector3(-50.f,100,30);
break;
}
case 2:
{
forwardAxis = 1;
eyePos[forwardAxis] = -distance;
camForward = b3MakeVector3(eyePos[0], eyePos[1], eyePos[2]);
if (camForward.length2() < B3_EPSILON)
{
camForward.setValue(1.f, 0.f, 0.f);
}
else
{
camForward.normalize();
}
b3Scalar rollRad = roll * b3Scalar(0.01745329251994329547);
b3Quaternion rollRot(camForward, rollRad);
camUpVector = b3QuatRotate(rollRot, b3MakeVector3(0, 0, 1));
//gLightPos = b3MakeVector3(-50.f,30,100);
break;
}
default:
{
//b3Assert(0);
return;
}
};
}
b3Scalar yawRad = yaw * b3Scalar(0.01745329251994329547);// rads per deg b3Scalar yawRad = yaw * b3Scalar(0.01745329251994329547);// rads per deg
b3Scalar pitchRad = pitch * b3Scalar(0.01745329251994329547);// rads per deg b3Scalar pitchRad = pitch * b3Scalar(0.01745329251994329547);// rads per deg
b3Scalar rollRad = 0.0;
b3Quaternion eyeRot;
b3Quaternion pitchRot(camUpVector, pitchRad); int forwardAxis(-1);
switch (upAxis)
{
case 1:
forwardAxis = 2;
camUpVector = b3MakeVector3(0,1,0);
eyeRot.setEulerZYX(rollRad, yawRad, -pitchRad);
break;
case 2:
forwardAxis = 1;
camUpVector = b3MakeVector3(0,0,1);
eyeRot.setEulerZYX(yawRad, rollRad, pitchRad);
break;
default:
return;
};
b3Vector3 right = camUpVector.cross(camForward); eyePos[forwardAxis] = -distance;
b3Quaternion yawRot(right, -yawRad);
camForward = b3MakeVector3(eyePos[0],eyePos[1],eyePos[2]);
if (camForward.length2() < B3_EPSILON)
{
camForward.setValue(1.f,0.f,0.f);
} else
{
camForward.normalize();
}
eyePos = b3Matrix3x3(eyeRot)*eyePos;
camUpVector = b3Matrix3x3(eyeRot)*camUpVector;
eyePos = b3Matrix3x3(pitchRot) * b3Matrix3x3(yawRot) * eyePos;
camPos = eyePos; camPos = eyePos;
camPos += camTargetPos; camPos += camTargetPos;

View File

@@ -161,6 +161,8 @@ void b3GetCameraImageData(b3PhysicsClientHandle physClient, struct b3CameraImage
///compute a view matrix, helper function for b3RequestCameraImageSetCameraMatrices ///compute a view matrix, helper function for b3RequestCameraImageSetCameraMatrices
void b3ComputeViewMatrixFromPositions(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], float viewMatrix[16]); void b3ComputeViewMatrixFromPositions(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], float viewMatrix[16]);
void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetPosition[3], float distance, float yaw, float pitch, float roll, int upAxis, float viewMatrix[16]); void b3ComputeViewMatrixFromYawPitchRoll(const float cameraTargetPosition[3], float distance, float yaw, float pitch, float roll, int upAxis, float viewMatrix[16]);
void b3ComputePositionFromViewMatrix(const float viewMatrix[16], float cameraPosition[3], float cameraTargetPosition[3], float cameraUp[3]);
void b3ComputeYawPitchRollFromPosition(const float cameraPosition[3], const float cameraTargetPosition[3], const float cameraUp[3], int upAxis, float* cameraDistance, float* cameraYaw, float* cameraPitch);
///compute a projection matrix, helper function for b3RequestCameraImageSetCameraMatrices ///compute a projection matrix, helper function for b3RequestCameraImageSetCameraMatrices
void b3ComputeProjectionMatrix(float left, float right, float bottom, float top, float nearVal, float farVal, float projectionMatrix[16]); void b3ComputeProjectionMatrix(float left, float right, float bottom, float top, float nearVal, float farVal, float projectionMatrix[16]);

View File

@@ -93,10 +93,10 @@ protected:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 3.45; float dist = 3.45;
float pitch = 287; float pitch = -16.2;
float yaw = 16.2; float yaw = 287;
float targetPos[3]={2.05,0.02,0.53};//-3,2.8,-2.5}; 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. ///request an image from a simulated camera, using a software renderer.
b3SharedMemoryCommandHandle commandHandle = b3InitRequestCameraImage(m_physicsClientHandle); 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); //b3RequestCameraImageSelectRenderer(commandHandle,ER_BULLET_HARDWARE_OPENGL);
float viewMatrix[16]; float viewMatrix[16];

View File

@@ -4517,8 +4517,8 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
if (clientCmd.m_updateFlags&COV_SET_CAMERA_VIEW_MATRIX) if (clientCmd.m_updateFlags&COV_SET_CAMERA_VIEW_MATRIX)
{ {
m_data->m_guiHelper->resetCamera( clientCmd.m_configureOpenGLVisualizerArguments.m_cameraDistance, m_data->m_guiHelper->resetCamera( clientCmd.m_configureOpenGLVisualizerArguments.m_cameraDistance,
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraPitch,
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraYaw, clientCmd.m_configureOpenGLVisualizerArguments.m_cameraYaw,
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraPitch,
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[0], clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[0],
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[1], clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[1],
clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[2]); clientCmd.m_configureOpenGLVisualizerArguments.m_cameraTargetPosition[2]);

View File

@@ -1016,9 +1016,9 @@ public:
{ {
m_childGuiHelper->setUpAxis(axis); m_childGuiHelper->setUpAxis(axis);
} }
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ) virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)
{ {
m_childGuiHelper->resetCamera(camDist,pitch,yaw,camPosX,camPosY,camPosZ); m_childGuiHelper->resetCamera(camDist,yaw,pitch,camPosX,camPosY,camPosZ);
} }
virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const virtual bool getCameraInfo(int* width, int* height, float viewMatrix[16], float projectionMatrix[16], float camUp[3], float camForward[3],float hor[3], float vert[3] ) const
@@ -1269,10 +1269,10 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 50; float pitch = -35;
float yaw = 35; float yaw = 50;
float targetPos[3]={0,0,0};//-3,2.8,-2.5}; float targetPos[3]={0,0,0};//-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]);
} }
virtual bool wantsTermination(); virtual bool wantsTermination();

View File

@@ -115,11 +115,11 @@ TinyRendererVisualShapeConverter::TinyRendererVisualShapeConverter()
m_data = new TinyRendererVisualShapeConverterInternalData(); m_data = new TinyRendererVisualShapeConverterInternalData();
float dist = 1.5; float dist = 1.5;
float pitch = -80; float pitch = -10;
float yaw = 10; float yaw = -80;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
m_data->m_camera.setCameraUpAxis(m_data->m_upAxis); m_data->m_camera.setCameraUpAxis(m_data->m_upAxis);
resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
@@ -678,7 +678,7 @@ void TinyRendererVisualShapeConverter::setUpAxis(int axis)
m_data->m_camera.setCameraUpAxis(axis); m_data->m_camera.setCameraUpAxis(axis);
m_data->m_camera.update(); m_data->m_camera.update();
} }
void TinyRendererVisualShapeConverter::resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ) void TinyRendererVisualShapeConverter::resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ)
{ {
m_data->m_camera.setCameraDistance(camDist); m_data->m_camera.setCameraDistance(camDist);
m_data->m_camera.setCameraPitch(pitch); m_data->m_camera.setCameraPitch(pitch);

View File

@@ -26,7 +26,7 @@ struct TinyRendererVisualShapeConverter : public LinkVisualShapesConverter
void setUpAxis(int axis); void setUpAxis(int axis);
void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ); void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ);
void clearBuffers(struct TGAColor& clearColor); void clearBuffers(struct TGAColor& clearColor);

View File

@@ -107,10 +107,10 @@ public:
{ {
//@todo depends on current_demo? //@todo depends on current_demo?
float dist = 45; float dist = 45;
float pitch = 27; float pitch = -31;
float yaw = 31; float yaw = 27;
float targetPos[3]={10-1,0}; float targetPos[3]={10-1,0};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
SoftDemo(struct GUIHelperInterface* helper) SoftDemo(struct GUIHelperInterface* helper)

View File

@@ -56,10 +56,10 @@ struct Dof6ConstraintTutorial : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 5; float dist = 5;
float pitch = 722; float pitch = -35;
float yaw = 35; float yaw = 722;
float targetPos[3]={4,2,-11}; float targetPos[3]={4,2,-11};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }
}; };

View File

@@ -614,8 +614,8 @@ public:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 10.5; float dist = 10.5;
float pitch = 136; float pitch = -32;
float yaw = 32; float yaw = 136;
float targetPos[3]={0,0,0}; float targetPos[3]={0,0,0};
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera()) if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
{ {

View File

@@ -121,10 +121,10 @@ class Hinge2Vehicle : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 8; float dist = 8;
float pitch = -45; float pitch = -32;
float yaw = 32; float yaw = -45;
float targetPos[3]={-0.33,-0.72,4.5}; float targetPos[3]={-0.33,-0.72,4.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]);
} }
/*static DemoApplication* Create() /*static DemoApplication* Create()

View File

@@ -108,10 +108,10 @@ class VoronoiFractureDemo : public CommonRigidBodyBase
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 18; float dist = 18;
float pitch = 129; float pitch = -30;
float yaw = 30; float yaw = 129;
float targetPos[3]={-1.5,4.7,-2}; float targetPos[3]={-1.5,4.7,-2};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,yaw,pitch,targetPos[0],targetPos[1],targetPos[2]);
} }