SetCameraMatrix: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(23 intermediate revisions by 16 users not shown)
Line 2: Line 2:
{{Server client function}}
{{Server 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 (or 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.}}


'''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">
<section name="Server" class="server" show="true">
Line 9: Line 9:
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )
bool setCameraMatrix ( player thePlayer, float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[player]]:setCameraMatrix|cameraMatrix|getCameraMatrix}}
===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player whose camera is to be changed.
*'''thePlayer:''' The player whose camera is to be changed.
Line 15: Line 15:
*'''positionY:''' The y coordinate of the camera's position.
*'''positionY:''' The y coordinate of the camera's position.
*'''positionZ:''' The z coordinate of the camera's position.
*'''positionZ:''' The z coordinate of the camera's position.
*'''{{New feature/item|3.0141|1.4.1|7005|Instead of six coordinates, or two vectors, a Matrix can be supplied.}}'''


===Optional Arguments===  
===Optional Arguments===  
Line 20: Line 21:
*'''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.
*'''roll:''' The camera roll angle, 0 to 360. A value of 0 means the camera sits straight, higher values will tilt it more and more to the left. 180 means the camera is upside down.
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.
*'''fov:''' the field of view angle, 0.01 to 180. The higher this value is, the more you will be able to see what is to your sides.
</section>
</section>


<section name="Client" class="client" show="true">
<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, float roll, float fov ] )
bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )
</syntaxhighlight>
</syntaxhighlight>
{{OOP|This is under the static class '''Camera'''|Camera.setMatrix|matrix|getCameraMatrix}}


===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player whose camera is to be changed.
*'''positionX:''' The x coordinate of the camera's position.
*'''positionX:''' The x coordinate of the camera's position.
*'''positionY:''' The y coordinate of the camera's position.
*'''positionY:''' The y coordinate of the camera's position.
*'''positionZ:''' The z coordinate of the camera's position.
*'''positionZ:''' The z coordinate of the camera's position.
*'''{{New feature/item|3.0141|1.4.1|7005|Instead of six coordinates, or two vectors, a Matrix can be supplied.}}'''


===Optional Arguments===  
===Optional Arguments===  
Line 39: Line 41:
*'''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.
*'''roll:''' The camera roll angle, 0 to 360. A value of 0 means the camera sits straight, higher values will tilt it more and more to the left. 180 means the camera is upside down.
*'''roll:''' The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.
*'''fov:''' the field of view angle, 0 to 180. The higher this value is, the more you will be able to see what is to your sides.
*'''fov:''' the field of view angle, 0.01 to 180. The higher this value is, the more you will be able to see what is to your sides.
</section>
</section>


Line 47: Line 49:


==Example==
==Example==
This code fixates the camera onto the Vinewood sign in Las Venturas for any player that joins the server:
This code fixates the camera onto the Vinewood sign in Los Santos for any player that joins the server:
<section class="server" name="Server script" show="true">
<section class="server" name="Server script" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 56: Line 58:
     setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
     setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
end
end
addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin)</syntaxhighlight>
addEventHandler("onPlayerJoin", root, setCameraOnPlayerJoin)</syntaxhighlight>
</section>
</section>


==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}
[[hu:setCameraMatrix]]
[[RO:setCameraMatrix]]

Latest revision as of 08:29, 10 October 2020

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").

[[{{{image}}}|link=|]] 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, float roll = 0, float fov = 70 ] )

OOP Syntax Help! I don't understand this!

Method: player:setCameraMatrix(...)
Variable: .cameraMatrix
Counterpart: getCameraMatrix


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.
  • Instead of six coordinates, or two vectors, a Matrix can be supplied.

Optional Arguments

  • 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.
  • roll: The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.
  • fov: the field of view angle, 0.01 to 180. The higher this value is, the more you will be able to see what is to your sides.
Click to collapse [-]
Client
bool setCameraMatrix ( float positionX, float positionY, float positionZ [, float lookAtX, float lookAtY, float lookAtZ, float roll = 0, float fov = 70 ] )

OOP Syntax Help! I don't understand this!

Note: This is under the static class Camera
Method: Camera.setMatrix(...)
Variable: .matrix
Counterpart: getCameraMatrix


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.
  • Instead of six coordinates, or two vectors, a Matrix can be supplied.

Optional Arguments

  • 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.
  • roll: The camera roll angle, -180 to 180. A value of 0 means the camera sits straight, positive values will turn it counter-clockwise and negative values will turn it clockwise. -180 or 180 means the camera is upside down.
  • fov: the field of view angle, 0.01 to 180. The higher this value is, the more you will be able to see what is to your sides.

Returns

Returns true if the arguments are valid, false otherwise.

Example

This code fixates the camera onto the Vinewood sign in Los Santos 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", root, setCameraOnPlayerJoin)

See Also