J'utilise une connexion WinSock pour obtenir les informations de l'accéléromètre et l'iPhone et dans une application Direct3D. J'ai modifié le code d'exemple d'Apple GLGravity pour faire bouger mon hélicoptère par rapport à la gravité, mais j'ai besoin de "boucher" le mouvement pour que l'hélicoptère ne puisse pas voler à l'envers! J'ai essayé de limiter la sortie de l'accéléromètre comme siDirect3D & iPhone Accelerometer Matrix
if (y < -0.38f) {
y = -0.38f;
}
Sauf que cela ne semble pas fonctionner !? La seule chose que je peux penser est que j'ai besoin de modifier la matrice personnalisée, mais je n'arrive pas à comprendre ce que j'ai besoin de changer. La matrice est le code ci-dessous.
_x = acceleration.x;
_y = acceleration.y;
_z = acceleration.z;
float length;
D3DXMATRIX matrix, t;
memset(matrix, '\0', sizeof(matrix));
D3DXMatrixIdentity(&matrix);
// Make sure acceleration value is big enough.
length = sqrtf(_x * _x + _y * _y + _z * _z);
if (length >= 0.1f && kInFlight == TRUE) { // We have a acceleration value good enough to work with.
matrix._44 = 1.0f; //
// First matrix column is a gravity vector.
matrix._11 = _x/length;
matrix._12 = _y/length;
matrix._13 = _z/length;
// Second matrix is arbitrary vector in the plane perpendicular to the gravity vector {Gx, Gy, Gz}.
// defined by the equation Gx * x + Gy * y + Gz * z = 0 in which we set x = 0 and y = 1.
matrix._21 = 0.0f;
matrix._22 = 1.0f;
matrix._23 = -_y/_z;
length = sqrtf(matrix._21 * matrix._21 + matrix._22 * matrix._22 + matrix._23 * matrix._23);
matrix._21 /= length;
matrix._22 /= length;
matrix._23 /= length;
// Set third matrix column as a cross product of the first two.
matrix._31 = matrix._12 * matrix._23 - matrix._13 * matrix._22;
matrix._32 = matrix._21 * matrix._13 - matrix._23 * matrix._11;
matrix._33 = matrix._11 * matrix._22 - matrix._12 * matrix._21;
}
Si quelqu'un peut l'aider serait très apprécié!
quel comportement avez-vous maintenant? – bayda
directx sur l'iphone? – hhafez
non, je pense qu'il a utilisé iphone comme dispositif de contrôle – bayda