ProcessLineAgainstMesh: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Add "See Also")
(Remove obsolete Requirements section)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
{{Client function}}
{{Client function}}
__NOTOC__
{{New feature/item|3.0161|1.6.0|22219|Does a raycast against an element's renderable mesh model directly}}
Does a raycast against an element's renderable mesh model [not the collision model!].
Does a raycast against an element's renderable mesh model [not the collision model!].
The same functionality is already present in [[processLineOfSight]], but the latter is a little buggy due to the fact that the collision model is always simplified, and not exactly the same as the mesh, which leads to situations where no hit is detected, even though the visible mesh is hittable [or vice versa].
The same functionality is already present in [[processLineOfSight]], but the latter is a little buggy due to the fact that the collision model is always simplified, and not exactly the same as the mesh, which leads to situations where no hit is detected, even though the visible mesh is hittable [or vice versa].
Line 6: Line 7:


==Syntax==  
==Syntax==  
Single line for convenience.
<syntaxhighlight lang="lua">
bool, float, float, string, string, float, float, float processLineAgainstMesh(element toTest, float startX, float startY, float startZ, float endX, float endY, float endZ)
</syntaxhighlight>
Return values labelled for ease of reference.
Return values labelled for ease of reference.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">

Latest revision as of 17:34, 7 November 2024

ADDED/UPDATED IN VERSION 1.6.0 r22219:
Does a raycast against an element's renderable mesh model directly

Does a raycast against an element's renderable mesh model [not the collision model!]. The same functionality is already present in processLineOfSight, but the latter is a little buggy due to the fact that the collision model is always simplified, and not exactly the same as the mesh, which leads to situations where no hit is detected, even though the visible mesh is hittable [or vice versa]. Also, when one is interested in a specific element the overhead is a lot smaller [as we can skip all the collision detection done by the before-mentioned function].

Syntax

Single line for convenience.

bool, float, float, string, string, float, float, float processLineAgainstMesh(element toTest, float startX, float startY, float startZ, float endX, float endY, float endZ)

Return values labelled for ease of reference.

bool               -- hit 
float float        -- texU, texV
string             -- textureName
string             -- frameName
float float float  -- worldX, worldY, worldZ
                  processLineAgainstMesh(element toTest, 
                                         float startX, float startY, float startZ, 
                                         float endX, float endY, float endZ)

Required Arguments

  • toProcess: The element to process the line against
  • startX, startY, startZ: The start [origin] of the line
  • endX, endY, endZ: The end of the line

Returns

  • hit: true if there is a collision with the given element's mesh, false otherwise [in which case all other values are nil]
  • texU, texV: the U, V coordinates on the hit geometry's texture
  • textureName: name of the hit geometry's texture
  • frameName: hit frame's name
  • worldX, worldY, worldZ: collision position in world space

See Also