Koordinatenbezugssysteme im Viewer

From Second Life Wiki
Revision as of 06:40, 20 July 2010 by Phillie Rhode (talk | contribs) (Translation in progress)
Jump to navigation Jump to search

Koordinaten Bezugssysteme

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 Code, der 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 Bibliotheken (LLCamera und LLPrimitive im speziellen) verwenden die Konventionen auch NICHT. Seien Sie besonders vorsichtig, wenn Sie Werte direkt aus diesen heraus verwenden.

Global

Absolutes globales Koordinatenbezugssystem, im F64 Format angegeben. Das ist vom U32 Format der x und y Koordinaten der Angaben der Region plus dem Offset der Region abgeleitet. Es ist genau genug, um ~109 Regionen mit der gleichen Genauigkeit übereinander auszurichten, wie es mit lokalen Regionenkoordinaten möglich wäre.

Region

Der Ausgangspunkt ist der Ursprung der Region, die das Objekt "besitzt".

Agent

Derzeit ist der Bezugspunkt der Ursprung der Region, in der sich der Agent momentan befindet. DAS BEDEUTET NICHT UNBEDINGT, dass das auch in ZUkunft so sein wird. This should be used only for code involving rendering (pipeline, visibility/frustum calculations)

Local

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

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.

Attachments

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.

Naming conventions

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.

For example:

mPositionGlobal, pos_global
mPositionRegion, pos_region
mPositionAgent, pos_agent

Conversion functions

In 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<source>() - 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.