How the camera works

From Second Life Wiki
Revision as of 16:52, 3 November 2006 by James Linden (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The viewer is authoritative about camera position. The server uses the client's reported camera position to decide which objects to transmit to the client.

Second Life uses a different coordinate frame than OpenGL. Our frame is Z-at, X-up, Y-right.

The viewer camera is implemented in newview/llviewercamera.cpp based on llmath/llcamera.cpp.

The camera position and look-at vector is transmitted by send_agent_update() in llviewermessage.cpp. This function is called once per frame and can transmit packets up to 20 times per second. Note that it does not transmit unless the agent or camera position or rotation have changed.

Camera movement can be accomplished with the keyboard (alt-AWSD) or mouse (Alt-drag). Movement commands call into LLAgent::cameraOrbitAround() and similar functions. This accumulates motion and rotation through the frame.

The camera has several "modes", including third person, first person ("mouselook"), appearance editing, etc. These are managed in LLAgent, not LLViewerCamera.