SetCameraMatrix: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Client function}} This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the cam...)
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the camera faces (the point it "looks at").
This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the camera faces (or the point it "looks at").
 
Note: Calling this function takes the camera's focus away from the player and sets the camera in a fixed position and rotation. The camera's focus can be brought back to the player using the [[setCameraTarget]] function.
==Syntax==
==Syntax==
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ, float lookAtX, float lookAtY, float lookAtZ )
</syntaxhighlight>
===Required Arguments===
*'''thePlayer:''' The player whose camera is to be changed.
*'''positionX:''' The x coordinate of the camera's position.
*'''positionY:''' The y coordinate of the camera's position.
*'''positionZ:''' The z coordinate of the camera's position.
*'''lookAtX:''' The x coordinate of the point the camera faces.
*'''lookAtY:''' The y coordinate of the point the camera faces.
*'''lookAtZ:''' The z coordinate of the point the camera faces.
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setCameraMatrix ( float positionX, float positionY, float positionZ, float lookAtX, float lookAtY, float lookAtZ )
bool setCameraMatrix ( float positionX, float positionY, float positionZ, float lookAtX, float lookAtY, float lookAtZ )
Line 14: Line 32:
*'''lookAtY:''' The y coordinate of the point the camera faces.
*'''lookAtY:''' The y coordinate of the point the camera faces.
*'''lookAtZ:''' The z coordinate of the point the camera faces.
*'''lookAtZ:''' The z coordinate of the point the camera faces.
</section>


===Returns===
===Returns===
Line 19: Line 38:


==Example==
==Example==
Pending..
This code fixates the camera onto a nice view of the Vinewood sign, for any player that joins the server:
<section class="server" name="Server script" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
moo?</syntaxhighlight>
function setCameraOnPlayerJoin()
    -- slowly fade the camera in to make the screen visible
    fadeCamera(source, true, 5)
    -- set the player's camera to a fixed position, looking at a fixed point
    setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
end
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin)</syntaxhighlight>
</section>





Revision as of 05:21, 16 March 2008

This function sets the camera's position and direction. The first three arguments are the point at which the camera lies, the last three are the point the camera faces (or the point it "looks at").

Note: Calling this function takes the camera's focus away from the player and sets the camera in a fixed position and rotation. The camera's focus can be brought back to the player using the setCameraTarget function.

Syntax

Click to collapse [-]
Server
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ, float lookAtX, float lookAtY, float lookAtZ )

Required Arguments

  • thePlayer: The player whose camera is to be changed.
  • positionX: The x coordinate of the camera's position.
  • positionY: The y coordinate of the camera's position.
  • positionZ: The z coordinate of the camera's position.
  • lookAtX: The x coordinate of the point the camera faces.
  • lookAtY: The y coordinate of the point the camera faces.
  • lookAtZ: The z coordinate of the point the camera faces.
Click to collapse [-]
Client
bool setCameraMatrix ( float positionX, float positionY, float positionZ, float lookAtX, float lookAtY, float lookAtZ )

Required Arguments

  • positionX: The x coordinate of the camera's position.
  • positionY: The y coordinate of the camera's position.
  • positionZ: The z coordinate of the camera's position.
  • lookAtX: The x coordinate of the point the camera faces.
  • lookAtY: The y coordinate of the point the camera faces.
  • lookAtZ: The z coordinate of the point the camera faces.

Returns

Returns true if the arguments are valid, false otherwise.

Example

This code fixates the camera onto a nice view of the Vinewood sign, for any player that joins the server:

Click to collapse [-]
Server script
function setCameraOnPlayerJoin()
     -- slowly fade the camera in to make the screen visible
     fadeCamera(source, true, 5)
     -- set the player's camera to a fixed position, looking at a fixed point
     setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
end
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin)


See Also