Koordinatenbezugssysteme im Viewer
Es gibt derzeit vier verschiedene Bezugssysteme, die im Viewer verwendet werden. Beachten Sie bitte, dass es einige Fälle gibt, in denen der Programmcode im Viewer diesen Konventionen NICHT folgt: Der Coder im Rendering verwendet "World" und "W" für den Agent und Teile des Character/Verbinden Codes haben kein Bezugssystem festgelegt, aber das wird im Agent definiert. Auch allgemeine Bibliothken (LLCamera und LLPrimitive im speziellen) verwenden do NOT use this convention. Be particularly careful when pulling values directly out of these.
Absolute global coordinate frame, expressed using F64's. This is derived from the U32 x and y coords of the handles of regions, plus the region offset. Precise enough for ~109 regions on an edge with same precision as region-local coordinates.
Origin is the origin of the region which "owns" the object.
Currently, the origin is the origin of the agent's current region. THIS DOES NOT necessarily have to be the case in the future. This should be used only for code involving rendering (pipeline, visibility/frustum calculations)
Currently a catch-all for coordinate frames which are not one of the ones above. Generally object-relative positioning.
The local frame is used in two ways in LSL:
- Child prims (not root prims) are positioned local to the root prim; their global position and angle effected by both the root prims rotation and position.
- Objects that are attached are positioned local to the attach point; their global position and angle are affected by the position and rotation of the avatar and the playing animations.
ALL variables/class members dealing with values in one of these coordinate frames should be post-fixed appended with the coordinate frame that it's being used in. PLEASE do this - it greatly reduces errors.
mPositionGlobal, pos_global mPositionRegion, pos_region mPositionAgent, pos_agent
Conversion functionsIn LLAgent and LLViewerRegion there are conversion functions for converting from one coordinate frame to the other. They have syntax of the form getPos<target>From
() - i.e. getPosAgentFromGlobal() converts from the global coordinate frame to the agent coordinate frame. = Type conversion = In order to support the high-precision global coordinates, there is a new class LLVector3d, standing for LLVector3, double precision. It's somewhat inconsistent, but the only other alternative was renaming ALL of the math classes to use the GL style last-letter type convention, which I wasn't up to doing. ALL math being done in global coordinates should be done using LLVector3ds. Currently, all functions which return global coordinates do so in LLVector3ds. The ONLY current exception to this is audio, which I am converting to regular LLVector3s before handing them off to the audio engine - I guess this will be the case until we convert the audio engine to use agent coords. The LLVector3d class DELIBERATELY does not have ANY form of automatic type-conversion between it and the LLVector3 class. Since conversion back and forth isn't cheap (and potentially loses precision), you have to explicitly do a setVec() on the other class to convert back and forth.