# DirectX camera issue

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

## Recommended Posts

Okay you linear algebra masters, I need some help. I have a camera that needs to be attached to a certain point within a model that will rotate on all axes. The details: Our model rotates using three floats representing the angle of rotation on each axis in radians. It has a position vector that represents its location in the world. Our camera needs to attach to a spot in the model, offset from the model's position. The model can and will rotate on all axes. We rotate the camera around the model's position so that it maintains its proper position inside the model. The problem: The horizon needs to be level. We need to get the camera to roll back so that the Y-axis is straight up, but without losing the position we found once we rotated with the model. Once we have rolled the camera into the right position, we need to rotate the camera again at that position. So far we just get the camera moving back as if we rolled it around a point, rather than in place. We have tried multiple variations of calculations, but we continue to miss some detail that is ruining our position once we try to level the camera. Anyone have suggestions?

##### Share on other sites
New camera problem!

This time I'm working with a first-person camera for a character in the program. It moves and looks based on using input, along with being attached to a model moving in the world.

I have a position vector and rotation matrix based on user input, then I have the position and rotation of the model the character is on. Currently I have everything rotation and moving correctly except for one issue. With the model rotates, the character does the proper world rotation to stay in its place on the model. However, its local rotation on the X (looking up and down)becomes screwed. At a 90 degree world rotation, a local X rotation acts like a local Z-rotation.

I've found that I can create the same problem by doing the local X rotation before the local Y rotation and turning 90 degrees.

Currently, the matrix math is like this:
mFinal = localRot * userPos * modelRot * modelPos

Any suggestions on fixes?

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013162
×