Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: 1 [2]
  Print  
Author Topic: Rotation Problem (Quaternion's)  (Read 16574 times)
War
Community Member
*
Posts: 147


« Reply #20 on: August 10, 2004, 04:25:10 PM »

@SalatalikTursusu et al

Sorry for the delay but I had other pressing matters to attend to first -- life go figure.

Anyhow rather than attempt to give you a drawn-out explanation I decided that we’d be better served with an actual sample.  The good news is I’ve updated the TV3D - Object Oriented Design sample to demonstrate how to do what you’re attempting, the bad news is that you’ll have to sift through it and pull out what’s relevant to your project.

With that being said – what I’ve done is adjusted the TV3D - Object Oriented Design to allow you to rotate and move a model based on keyboard input (don’t worry the original movement and rotation routines are still present and functioning, this is simply an alternative).

The keys are:

A – Move forward
Z – Move backwards

+ – Accelerate movement
- – Decelerate movement

I – Pitch up
M – Pitch Down
J – Yaw Left
K – Yaw Right
Insert – Roll Left
Page Up – Roll right

You can easily adjust these by updating the GameActions class and changing the key assignments.

As with the original sample, all rotation is handled in the Starship base class.  Review the Instance_FrameStart and Instance_KeyDown methods paying attention to the Interactive movement, Acceleration and Deceleration regions.

One last thing, I’ve created a source only download for those you that have already downloaded the sample its about 180k and can be found here

-War
Logged
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #21 on: August 12, 2004, 09:04:07 AM »

thank you so much War!
i implemented your solution ...

but i see that sometimes model becomes bigger after continuous rotations ... i mean something like ScaleMesh ... any idea ? this also exist in your sample ...  :?

after applying rotation matrix, can i extract direction vector directly from new rotation matrix ? something like this;
Code:
direction.x = RotationMatrix.M12;
direction.y = RotationMatrix.M22;
direction.z = RotationMatrix.M32;


i need direction vector for firing rockects and shells/projectile/ermm ... i am going to use simple models for rockects but what about shells ? Particle Engine ?

tnx!
Logged
War
Community Member
*
Posts: 147


« Reply #22 on: August 12, 2004, 10:08:55 AM »

You're welcome.  

Hmmm I haven't seen any deformation on this end, thought I have seen the effect and know what you are referring to.  Do you have a clear-cut sequence to reproduce or even a general one?  I can look into it to see what's going on once I have a place to start.

As for your question -- yes that is correct you can extract it that way.  You might want to note the Axiom.Matlib.Quaternion.ToAxes method which essentially does the same thing but for all three.

When you are talking about shells are you referring to something small like a shotgun or something large like a mass driver cannon?

-War
Logged
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #23 on: August 12, 2004, 02:36:15 PM »

i cant define clear sequence but i can give this as an example;

continuous local z axis rotations (roll) -> a,
continuous local x axis rotations (pitch) -> b

a b a b ... causes deformation on mesh ... also if you continue applying this sequence mesh deformation continues  :?

and about shells, i am talking about small shotgun like shells , i will use simple models for my rockets  :wink:
Logged
War
Community Member
*
Posts: 147


« Reply #24 on: August 12, 2004, 09:49:25 PM »

OK -- I've been able to reproduce that so I'll take a look to see what's causing it and let you know.

For a shotgun ... I'm not sure I’d show anything beyond a muzzle flash and impact pattern (decals), as it would be a bit of diminishing return IMHO.

-War
Logged
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #25 on: August 13, 2004, 05:26:56 AM »

I really think that War deserves a bottle of whisky for the C# math code he gave out in an earlier post.

Well organised, easy to read, theory into code in one place! I'll be able to verify and update a number of my own APL math routines. Thank you!




PS. To calculate a dot-product (inner product) in APL, i write:

result = vector1 +.* vector2
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
War
Community Member
*
Posts: 147


« Reply #26 on: August 13, 2004, 07:38:13 AM »

Thanks for the compliment Waterman.  I'm assuming you mean the post that deals with

Quote
Q37. How do I convert a rotation matrix to Euler angles?


If so I really can't take credit for that (other than posting it) since it is part of the
The Matrix and Quaternions FAQ which was created in the late 90's, it's a great reference for anything involving  Matrix or Quaternion.

Another good math reference is Martin Baker's Euclideanspace

-War
Logged
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #27 on: August 13, 2004, 08:06:39 AM »

Count 7 posts back from this and you see your own link behind the word "here" ;-)
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #28 on: August 13, 2004, 08:50:13 AM »

Quote from: "Waterman"
I really think that War deserves a bottle of whisky for the C# math code he gave out in an earlier post.

Well organised, easy to read, theory into code in one place! I'll be able to verify and update a number of my own APL math routines. Thank you!


true!  Smiley
Logged
War
Community Member
*
Posts: 147


« Reply #29 on: August 13, 2004, 09:08:00 AM »

Oh that C# code!  Well with the exception of the Axiom.Mathlib credit would go to both Phether and I.  I'm glad you found the sample helpful.  We'll be updating it periodically as time permits.

-War
Logged
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #30 on: August 13, 2004, 01:35:59 PM »

war, did you find any solution for deformation problem ?  :wink:
Logged
War
Community Member
*
Posts: 147


« Reply #31 on: August 13, 2004, 04:18:09 PM »

No not yet, I'm still trying to pinpoint the cause -- implementation, conversion or math library.  My gut is it's my implementation but based on what I know and see I'm beginning to suspect something else (conversion or math lib).  I have a few tests I want to run to see if I can narrow the possibilities.

I have made a few interesting discoveries during my testing so far.

1.  The bounding box properties don't seem to grow with the model.  Visually they do of course but numerically TV shows them as being the original size.
2.  It seems the math library has a few new features I didn't know about at the time, for instance there is an operator overload for -, which makes the negate method redundant.

In short I don't have an ETA but it's on the top of my priority list because either my understanding of the quaternions is flawed or the underlying math implementation is.  In either case I need this worked out because we're reaching a point within our project where this is going to bite us.

Anyhow, I'll keep you apprised :-)

-War
Logged
War
Community Member
*
Posts: 147


« Reply #32 on: August 13, 2004, 10:51:30 PM »

A quick update -- I've confirmed the source of the problem to be my implementation (go figure) it would seem that I might be trying stuff 10 lbs into a 5 lb bag.  :oops:

I'm going to have to rethink the implementation and update the sample.  Again ETA unknown but I'm working on it.  :wink:

-War
Logged
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #33 on: August 15, 2004, 02:15:56 AM »

i couldnt find the problem ... i only implemented the quaternion operations for rotation which is defined in (StarShip)Instance_FrameStart->Interactive rotation region ... problem may be in the matrix conversions ...
Logged
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #34 on: August 15, 2004, 09:03:33 AM »

Forgot to normalize something somewhere?

Btw, i wonder if the algo for reflection in the C# code lacks a negation of the result... or perhaps it's just how you use it.
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
War
Community Member
*
Posts: 147


« Reply #35 on: August 15, 2004, 11:20:14 AM »

@SalatalikTursusu et al --

All right, it was without a doubt my implementation -- a combination of mixing conventions and trying to do too much within the interactive rotation code.

So, I had to take a step back and reorganize things a little bit, tweak some things and in general remove all the *HACKS* I had put in place.  It’s my own fault and I know better but that’s what you get when you are in a rush to get things done and don't take the time to think things through.

Anyhow -- I've updated the code base and things look much better than they did but I would ask for some assistant in testing it.  You can find the code only update here

Some items that have changed include:

Action Mappings

Interactive Mode

A – Move forward
Z – Move backwards

+ – Accelerate movement
- – Decelerate movement

I – Pitch up
M – Pitch Down
J – Yaw Left
K – Yaw Right
U – Roll Left
O – Roll right

Strategy Mode

W - issue move orders (M key was conflicting with the above)

2.  Rotation methods where moved into the GameObject base class.

3.  New GameObject members include:

Public Properties

Depth - Represents the depth of the model's bounding box.
Height -Represents the height of the model's bounding box.
Orientation - Model Orientation Quaternion.
OrientationMode - Represents the orientation mode of the model.
Width - Represents the width of the model's bounding box.

Public Methods

ConvertOrientation - Overloaded.  Converts the model's _Orientation field to a D3DMatrix. *OR* Converts the specified Quaternion to a D3DMatrix.
GetOrientation - Returns a Quaternion representation of the models D3D Matrix.
GetSize -Extracts the values for Height, Width and Depth from the bounding box information.
Rotate - Overloaded.  Used to orient the GameObject using the supplied axis and angle.  *OR* Used to orient the GameObject to the supplied vector.
SetRotation - Sets the model rotation based on the supplied Quaternion.

Public Events

OrientationChanged - Occurs when the models orientation has changed.
OrientationModeChanged - Occurs when the models orientation mode has changed.
Note: PositionChange event event handler was renamed to GameObjectMovementEventHandler

Protected Fields

_Orientation -  Quaternion which represents the objects current orientation.  
_RotationDestination - Quaternion which represents the target orientation.  
_RotationOrigin - Quaternion which represents the objects origin orientation.  

Protected Methods

OnOrientationChanged - Raises the OrientationChanged event.  
OnOrientationModeChanged - Raises the OrientationModeChanged event.

------

Other important notes:

The interactive rotation code has been removed from the Starship.Instance_FrameStart event handler entirely.  The interactive rotation is handled via the Starship.Instance_KeyDown event handler Interactive movement check region of code.  Which essentially evaluates the keyboard input and applies the rotation (via GameObject.Rotate method) to the model's orientation immediately based on the appropriate action mapping.

As always I’ll be happy to field any question regarding the implementation.


-War
Logged
SalatalikTursusu
Community Member
*
Posts: 20


« Reply #36 on: August 15, 2004, 01:13:45 PM »

thank you war, i tested the sample and i couldnt find an error/such with rotations ...

i will implement in my test application, if i find another problem or can't implement, i will post a reply here ...

thank you so much! (errm still waiting suggestions for shotgun style shell handling)
Logged
War
Community Member
*
Posts: 147


« Reply #37 on: August 15, 2004, 02:22:07 PM »

Great!  Let me know if you run into any problems.

As for the shotgun shell handling ... as I stated in an earlier post I don't think I would display the pellets themselves just compute the trajectory of the burst and painting decals (and apply damage) to whatever was hit.

I don't have much to offer beyond that since my project deals with ship based weaponry, which are handled differently.  I can say this, the ballistic based weapons (missiles, torpedoes, mass-driver) have both a model and particle effects applied to them, while energy based weapons are particle effects only.

-War
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks