Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Go Back  Xtreme Visual Basic Talk > > > > Rotation around maintained arbitrary axis.


Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2012, 12:55 PM
Zerocyde Zerocyde is offline
Freshman
 
Join Date: May 2007
Posts: 32
Default Rotation around maintained arbitrary axis.


I've been racking my brain for days now and can't find the answer. I'm using C++ and DirectX but I figure that this is more of a math problem that can relate to all languages trying to work in 3D.

Basically, to rotate a flying vehicle (spaceship, airplane, whatever) I am using this system that I found for FPS camera control:

Code:
	up=D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	look=D3DXVECTOR3(0.0f, 0.0f, 1.0f);
	right=D3DXVECTOR3(1.0f, 0.0f, 0.0f);

	D3DXMATRIX yawMatrix;
	D3DXMatrixRotationAxis(&yawMatrix, &up, yaw);
	D3DXVec3TransformCoord(&look, &look, &yawMatrix);
	D3DXVec3TransformCoord(&right, &right, &yawMatrix);

	D3DXMATRIX pitchMatrix;
	D3DXMatrixRotationAxis(&pitchMatrix, &right, pitch);
	D3DXVec3TransformCoord(&look, &look, &pitchMatrix);
	D3DXVec3TransformCoord(&up, &up, &pitchMatrix);

	D3DXMATRIX rollMatrix;
	D3DXMatrixRotationAxis(&rollMatrix, &look, roll);
	D3DXVec3TransformCoord(&right, &right, &rollMatrix);
	D3DXVec3TransformCoord(&up, &up, &rollMatrix);

	rotMatrix = yawMatrix*pitchMatrix*rollMatrix;
And you rotate by adjusting the yaw, pitch, and roll float values. The problem is that this code only seems to rotate around the default axis. For instance, if I make my little ship pitch down (lower the nose to fly downwards) and then wish to "roll" left or right, I want to rotate the ship around the look axis of the ship itself, but with this method it will only rotate around (0, 0, 1).

Basically, what methods can I use to maintain a look, right, and up axis that stay aligned with the object in question and never revert to default so that I can rotate around them at will?

EDIT: Actually, to be more precise, this method will rotate properly around the look axis I want, but only because it does roll last after the look axis is already fully finished by the yaw and pitch rotations. Pitch rotates around a half formed right axis, and yaw rotates around the default (0, 1, 0) up axis.

Last edited by Zerocyde; 05-16-2012 at 01:03 PM.
Reply With Quote
  #2  
Old 05-16-2012, 02:26 PM
passel's Avatar
passelRotation around maintained arbitrary axis. passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,021
Default

I was going to move this to the legacy VB DirectX forum, assuming that forum had more activity than the Managed DirectX forum, and the question is more of a DirectX question than a specific language question.
But the fact is that neither DirectX forum has had a lot of activity the last couple of years, so I don't know it would matter which was chosen.
I guess I'll still try the legacy forum, but you may have to search for a more active DirectX related forum to get a quick answer.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis. Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
 
Rotation around maintained arbitrary axis.
Rotation around maintained arbitrary axis.
 
-->