Jump to content
  • Advertisement
Sign in to follow this  
Peter Wenig

Correcting camera movement - with demonstrational video

This topic is 2078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);
}

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!