GetCameraMatrix: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 5: Line 5:
Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).
Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).


==Syntax==
==Procedural==
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float cameraX, float cameraY, float cameraZ, float targetX, float targetY, float targetZ, float roll, float fov = getCameraMatrix ( player thePlayer )
float float float float float float float float getCameraMatrix (player thePlayer)
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===  
===Required Arguments===
*'''thePlayer:''' The player whose camera matrix is to be returned.
*'''thePlayer:''' The player whose camera matrix is to be returned.
</section>
</section>
Line 17: Line 17:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float cameraX, float cameraY, float cameraZ, float targetX, float targetY, float targetZ, float roll, float fov = getCameraMatrix ( )
float float float float float float float float getCameraMatrix ()
</syntaxhighlight>
</syntaxhighlight>
</section>
This function returns 8 [[float|floats]] if the argument is valid (when applicable); the first three indicate the position of the camera, the next three indicate the position of the point it's facing, and the last two are the roll and field of view. Returns ''false'' if the argument is invalid.


===Required Arguments===  
===Example===
''None.''
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
local x, y, z, lx, ly, lz = getCameraMatrix ()
x, lx = x + 1, lx + 1
 
setCameraMatrix (x, y, z, lx, ly, lz)
</syntaxhighlight>
</section>
</section>


===Returns===
Returns eight ''float'' numbers if the argument(s) are valid; the first three indicate the position of the camera, the next three indicate the position of the point it's facing, and the last two are the roll and FOV (field of view). Returns ''false'' if the arguments are invalid.


==Example==
==Object-oriented==
'''Example 1:''' This clientside example moves camera +1 unit on X axis.
<section name="Server" class="server" show="true">
The server-side object-oriented alternative is not implemented yet.
</section>
 
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local x, y, z, lx, ly, lz = getCameraMatrix() -- Get the current location and lookat of camera
Matrix Camera.getMatrix ()
x, lx = x + 1, lx + 1 -- What will be the new x and x lookat values
setCameraMatrix(x,y,z,lx,ly,lz) -- Set camera to new position
</syntaxhighlight>
</syntaxhighlight>
</section>
This function returns a matrix with the position of the camera (first three elements), the position of the point it's facing (next three elements) and the roll and field of view (last two elements) if the function is successful. Returns an empty matrix otherwise.
===Example===
This page lacks an example.


==See Also==
==See Also==
{{Camera functions}}
{{Camera functions}}

Revision as of 20:47, 10 December 2013

This function gets the position of the camera and the position of the point it is facing.

Note: The server-side version of this function returns the last camera matrix that was set by the server, and thus does not necessarily indicate the current matrix of the camera (since it may have been changed client-side).

Procedural

Click to collapse [-]
Server
float float float float float float float float getCameraMatrix (player thePlayer)

Required Arguments

  • thePlayer: The player whose camera matrix is to be returned.
Click to collapse [-]
Client
float float float float float float float float getCameraMatrix ()

This function returns 8 floats if the argument is valid (when applicable); the first three indicate the position of the camera, the next three indicate the position of the point it's facing, and the last two are the roll and field of view. Returns false if the argument is invalid.

Example

Click to collapse [-]
Client
local x, y, z, lx, ly, lz = getCameraMatrix ()
x, lx = x + 1, lx + 1

setCameraMatrix (x, y, z, lx, ly, lz)


Object-oriented

Click to collapse [-]
Server

The server-side object-oriented alternative is not implemented yet.

Click to collapse [-]
Client
Matrix Camera.getMatrix ()

This function returns a matrix with the position of the camera (first three elements), the position of the point it's facing (next three elements) and the roll and field of view (last two elements) if the function is successful. Returns an empty matrix otherwise.

Example

This page lacks an example.

See Also