Update:
I took the animation code from VicMar's Shoreham terminal building clock, and I modified it so that it referred to the whole model of my boat, instead of just two small pieces of his, as in the hands of the clock. I also figured out how to change the two animations so that one affected the roll axis and one affected the pitch axis. On the very first try, even, the changes I made worked exactly as I expected!...
- Code: Select all
<?xml version="1.0"?>
<PropertyList>
<path>balt-co-police-boat.ac</path>
<animation>
<type>rotate</type>
<property>/sim/time/utc/day-seconds</property>
<factor>0.1</factor>
<axis>
<x>0</x>
<y>1</y>
<z>0</z>
</axis>
</animation>
<animation>
<type>rotate</type>
<property>/sim/time/utc/day-seconds</property>
<factor>0.008333</factor>
<axis>
<x>1</x>
<y>0</y>
<z>0</z>
</axis>
</animation>
</PropertyList>
Of course, the result of this is that the boat flips over on its side once per hour, and on its nose once per day... LOL!
(I know I only did it as a test, but I must admit, it was quite comical to see it in warp speed...)
Now, the problem is figuring out how to change the straight linear scaling accomplished by the <factor> tags, and replace it with the sine wave formula. I know the math I need to do, and I could probably script it (clumsily) in NASAL; I just don't know how to express it in XML. Even if it has to be done with Nasal, I don't know how to embed that code in this .xml file and how to "pass the variable" from the animation tag to the Nasal script and back to the resulting rotation.
Anyway, the formula will do the following:
(1) take that day-seconds value and divide by three, and then lop off the integer portion so we're left with the digits beyond the decimal point. (The result will cycle from 0 to 1 every three seconds.)
(2) scale that up by a factor of 360, so that it cycles from 0 to 360 every three seconds.
(3) take the sin of that value, the result of which will oscillate from 0 to 1, back to 0 and then to -1, and then back to 0, every three seconds.
(4) scale the result of that by 10 and put the result on the y-axis (roll) rotation.
Then the same formula will take the day-seconds PLUS ONE (for that offset) and then do the exact same thing, except in step four it will scale the result by 5 and use the x-axis (pitch) rotation.
Of course I just realized that for an even more realistic effect, instead of using 10 and 5 as the pitch variations, I could throw in a scaling factor based on the current wind speed as well. So maybe if whoever posts a reply can include that step...??
So can anyone help me with how to do that in XML?