![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
|
|||||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
04-05-14, 04:30 PM
|
#1 |
|
Black Magic
![]() |
Today the SH4 forums gave me a great idea for a new patch: have the flags blow in the wind's direction
![]() I fired up OllyDebug and figured out where the object's matrix data is and where it's combined matrix data is (it's matrix data * parent's matrix data). After locating those two key bits of info I then had to figure out the kernel functions for reading angles from the matrix data and storing new angles to the matrix data. Luckily for me, the kernel just happened to have those two functions After a bit of playing around to figure out which value of the 3 angles returned was the yaw value (of the pitch, yaw, and roll returned) I was able to modify the yaw value returned for the flag. I modified the yaw value to have the flag yaw (rotate around it's Y axis) +45 degrees. I then called the kernel function to set the new angles in the matrix and it worked first try ![]() What I'm trying to derive currently is how to figure out how much the wind influences the flag's yaw. For instance, if the unit's speed is 8 knots @ 90 degrees, the wind's speed is 5 knots @ 315 degrees, how much should the flag yaw
|
|
|
04-05-14, 05:28 PM
|
#2 | |
|
Samurai Navy
![]() |
Quote:
[/URL] Using tangens you should be able to get the correct angle.
|
|
|
|
04-05-14, 06:29 PM
|
#3 |
|
Black Magic
![]() |
Actually I think the law of cosines applies here:
ship's heading (90) - winds heading (from 315 or 45 degrees) = 45 degrees square root of (8^2 + 5^2 + (2*8*5*COS(45))) = 12.065 12.065 is the length of the 3rd side of the triangle. flag's angle in relation to ship = COS-1((8^2 + 12.065^2 - 5^2) / (2*8*12.065)) = 17.04 degrees flag's angle = 17.04 + 90 = 107.04 degrees |
|
|
04-05-14, 09:34 PM
|
#4 |
|
Black Magic
![]() |
flags affected by wind patch coming along nicely
![]() |
|
|
04-06-14, 02:56 AM
|
#5 |
|
Captain
![]() Join Date: May 2011
Posts: 489
Downloads: 106
Uploads: 0
|
|
|
|
04-06-14, 05:50 AM
|
#6 | |
|
Samurai Navy
![]() |
Quote:
|
|
|
|
04-06-14, 07:49 AM
|
#7 | |
|
Black Magic
![]() |
Quote:
. If you can show me an eaiser/better/another way I'm all ears
|
|
|
|
04-06-14, 07:51 AM
|
#8 | |
|
Samurai Navy
![]() |
Quote:
|
|
|
|
04-06-14, 07:59 AM
|
#9 | |
|
Planesman
![]() Join Date: Jan 2010
Location: Italy
Posts: 195
Downloads: 333
Uploads: 0
|
Quote:
Salute Herr Kaleun!
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
