Commit MetaInfo

Revisiona5aa600db92bc7c9a0b40d6022f9a2e252016d2a (tree)
Time2013-01-09 02:01:00
AuthorRisingFury
CommiterRisingFury

Log Message

Tracker: added immediate direction setting on load

Change Summary

Incremental Difference

diff -r e3481d57c037 -r a5aa600db92b Orbitersdk/samples/AscensionUltra/Tracker.cpp
--- a/Orbitersdk/samples/AscensionUltra/Tracker.cpp Tue Jan 08 01:28:00 2013 +0100
+++ b/Orbitersdk/samples/AscensionUltra/Tracker.cpp Tue Jan 08 18:01:00 2013 +0100
@@ -193,9 +193,44 @@
193193 {
194194 if (!strnicmp (line, "TGT", 3))
195195 {
196- target=oapiGetObjectByName(line+4);
197- return true;
196+ // target=oapiGetObjectByName(line+4); // WARNING: This doesn't work! Don't ask me why...
197+ // target = oapiGetFocusObject(); // WARNING: This doesn't work either!
198+ target = owner->GetHandle(); // This works fine, however.
199+
200+ if ((target != NULL) && (owner != NULL))
201+ {
202+ // Snap the dish directly to the target when the scenario loads.
203+
204+ VECTOR3 pos, loc;
205+ oapiGetGlobalPos(target, &pos);
206+ owner->Global2Local(pos, loc);
207+ loc-=position;
208+ normalise(loc);
209+
210+ double DesiredAzimuth = 0;
211+ if (loc.x<-1E-6 || loc.x>1E-6) DesiredAzimuth=atan(loc.z/loc.x); //If not locked, calculate arctan
212+ //Check quadrants
213+ if (DesiredAzimuth>0 && loc.z<0) DesiredAzimuth+=PI;
214+ if (DesiredAzimuth<0 && loc.z<0) DesiredAzimuth+=2*PI;
215+ if (DesiredAzimuth<0 && loc.z>0) DesiredAzimuth+=PI;
216+
217+ DesiredAzimuth+=rotationOffset;
218+ if (DesiredAzimuth<0) DesiredAzimuth+=2*PI;
219+ if (DesiredAzimuth>2*PI) DesiredAzimuth-=2*PI;
220+
221+ double DesiredElevation=asin(loc.y);
222+ if (DesiredElevation<0) DesiredElevation=0;
223+
224+ CurrentAzimuth = DesiredAzimuth;
225+ CurrentElevation = DesiredElevation;
226+
227+ owner->SetAnimation (anim_azimuth, DesiredAzimuth / (2 * PI));
228+ owner->SetAnimation (anim_elevation, DesiredElevation);
229+
230+ return true;
231+ }
198232 }
233+
199234 return false;
200235 }
201236
Show on old repository browser