Correcting camera movement - with demonstrational video

Started by
0 comments, last by Semeii 10 years, 5 months ago

I have a sphere as FBX and a shader that enables me to have a texture inside of the sphere. Also inside of the sphere I have a camera. The goal is to have a simple panoramic viewer that is being driven by a headtracker.

The texture is being shown but the camera is reacting in a weird way:

When rotating the headtracker, the image is all over the place, jittery and not at all correlated to the actual movements. The headtracker input itself is correct, though.

See this video for further clarification. Each time I keep the tracker steady at first and then I move it. In the second half, the first three numbers are evaluated. The other three values are gyro.

I presume the problem to be in the following code, something about the Vectors(Vector3.whatever) could be off:


protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.CornflowerBlue);

foreach (ModelMesh mesh in skyDome.Meshes)
{
foreach (BasicEffect ef in mesh.Effects)
{
float aspectRatio = (float)graphics.GraphicsDevice.PresentationParameters.BackBufferWidth / (float)graphics.GraphicsDevice.PresentationParameters.BackBufferHeight;

Vector3 camPosition = Vector3.Transform(Vector3.Up, Quaternion.CreateFromYawPitchRoll(drehung, neigung, rollen));
ef.View = Matrix.CreateLookAt(Vector3.Zero, camPosition,Vector3.Forward);
ef.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspectRatio, 0.1f, 10000.0f);
ef.TextureEnabled = true; //Textur zulassen
ef.Texture = panoramaTextur; //Textur auf Model darstellen
}
mesh.Draw();
}
base.Draw(gameTime);
}
Advertisement

something about the Vectors(Vector3.whatever)

That's not a good way to show your dedication to your own problem.

Vector3 camPosition = Vector3.Transform(Vector3.Up, Quaternion.CreateFromYawPitchRoll(drehung, neigung, rollen));

ef.View = Matrix.CreateLookAt(Vector3.Zero, camPosition,Vector3.Forward);

Neither of those seem to make any sense. Look up XNA's documentation for Matrix.CreateLookAt and spend some time studying what you are trying to accomplish there. Some transformation, matrix FAQ will be needed for you to complete this. There is plenty of DirectX tutorials going around about view matrices and basic matrix transformation, what it does, what do you accomplish with it and why.

This topic is closed to new replies.

Advertisement