Quote:Original post by D3DXVEC5Then you did something wrong.
nope, it totally disable rotation
If you still need help with the problem, post the code again along with any revisions you've made.
Quote:Original post by D3DXVEC5Then you did something wrong.
nope, it totally disable rotation
const float PI = 3.14159265358979323846f; // Pi#define DEGTORAD(x) ( ((x) * PI) / 180.0 )#define RADTODEG(x) ( ((x) * 180.0) / PI )void FromEuler(NxQuat *q,float x,float y,float z){ double ex, ey, ez; // temp half euler angles double cr, cp, cy, sr, sp, sy, cpcy, spsy; // temp vars in roll,pitch yaw ex = DEGTORAD(x) / 2.0; // convert to rads and half them ey = DEGTORAD(y) / 2.0; ez = DEGTORAD(z) / 2.0; cr = cos(ex); cp = cos(ey); cy = cos(ez); sr = sin(ex); sp = sin(ey); sy = sin(ez); cpcy = cp * cy; spsy = sp * sy; q->w = float(cr * cpcy + sr * spsy); q->x = float(sr * cpcy - cr * spsy); q->y = float(cr * sp * cy + sr * cp * sy); q->z = float(cr * cp * sy - sr * sp * cy); q->normalize();}void NxQuatToD3DXQ(NxQuat *q,D3DXQUATERNION *q_r){ q_r->w=q->w; q_r->x=q->x; q_r->y=q->y; q_r->z=q->z;}NxVec3 QMultiplyVEC(NxQuat q,NxVec3 v){ NxVec3 vn(v); vn.normalize(); NxQuat vq, rq,cq; vq.x = vn.x; vq.y = vn.y; vq.z = vn.z; vq.w = 0.0f; q.conjugate(); rq = vq * q; rq = q * rq; return (NxVec3(rq.x, rq.y, rq.z));}class TestCam{ D3DXMATRIX CamProj; D3DXMATRIX CamView; NxVec3 CamPos; NxQuat CamRot;public: TestCam() { D3DXMatrixIdentity(&CamProj); D3DXMatrixIdentity(&CamView); CamPos=NxVec3(0,0,0); CamRot.id(); } void Turn(float Pitch,float Yaw,float Roll) { NxQuat temp; temp.id(); FromEuler(&temp,Pitch,Yaw,Roll); CamRot = CamRot*temp; } void Move(float dx,float dy,float dz) { NxQuat resq; resq.id(); NxVec3 resv=QMultiplyVEC(CamRot,NxVec3(dx,dy,dz)); CamPos += resv * 0.1f; } void BuildView() { D3DXQUATERNION p; D3DXMATRIX trans; NxQuatToD3DXQ(&CamRot,&p); D3DXMatrixRotationQuaternion(&CamView,&p); D3DXMatrixTranslation(&trans,-CamPos.x,-CamPos.y,-CamPos.z); CamView=CamView*trans; device->SetTransform(D3DTS_VIEW,&CamView); } void BuildProjection() { D3DXMatrixPerspectiveFovLH( &CamProj, D3DXToRadian( 70 ), (float)(d3dpp.BackBufferWidth / d3dpp.BackBufferHeight), 1,1000 ); device->SetTransform(D3DTS_PROJECTION, &CamProj); }};