View Issue Details

IDProjectCategoryView StatusLast Update
0005601Multi Theft Auto : San AndreasScriptingpublic2010-11-09 11:08
ReportereAiAssigned ToKayl 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version 
Target Version1.1Fixed in Version1.1 
Summary0005601: processLineOfSight should return the normal of the face hit
Description

It's odd that pLoS doesn't return the normal of the face the ray hit, as I'm pretty sure we know what this is internally, so this should be easy to add.

TagsNo tags attached.

Relationships

child of 0003344 closed New Feature Requests Requested features tracker 

Activities

Kayl

2010-11-09 01:36

developer   ~~0012134

Attached a potential patch which adds:

  • normal
  • material
  • lighting intensity (of hit surface)
  • piece type (for ped body part and vehicle parts)

Here is the clientside code to test it:

function string.split(str, delim)
local startPos = 1
local endPos = string.find(str, delim, 1, true)
local result = {}
while endPos do
table.insert(result, string.sub(str, startPos, endPos-1))
startPos = endPos + 1
endPos = string.find(str, delim, startPos, true)
end
table.insert(result, string.sub(str, startPos))
return result
end

function _FDL(sx, sy, sz, ex, ey, ez, color)
local realColor = color or tocolor(255, 0, 0, 255)
local ssx, ssy = getScreenFromWorldPosition(sx, sy, sz)
local esx, esy = getScreenFromWorldPosition(ex, ey, ez)
if ssx and ssy and esx and esy then
dxDrawLine(ssx, ssy, esx, esy, realColor, 2)
end
end

addEventHandler("onClientRender", getRootElement(),
function()
local cx, cy, cz, tx, ty, tz = getCameraMatrix()

local hit, hx, hy, hz, hElement, nx, ny, nz, mat, light, piece = processLineOfSight ( cx, cy, cz, tx, ty, tz )
local text = ""
if not hit then
    text = "No hit"
else
    text = string.format("hit: %f %f %f\nelement: %s\nnormal: %f %f %f\nmaterial %s light %s piece %s", 
                    hx, hy, hz, 
                    tostring(hElement and isElement(hElement) and getElementType(hElement)),
                    nx, ny, nz,
                    tostring(mat), tostring(light),
                    tostring(piece), tostring(pb))
    _FDL(hx, hy, hz, hx+nx, hy+ny, hz+nz)
end

local width, height = guiGetScreenSize()
local nbLines = #(text:split("\n"))
dxDrawRectangle(0, 0, width, 10+nbLines*dxGetFontHeight(1.5,  "clear"), tocolor(0, 0, 0, 128))
dxDrawText(text, 0, 0, width, height, tocolor(255, 255, 255, 255), 1.5,  "clear", "center", "top")

end)

Issue History

Date Modified Username Field Change