• I Spy with My Little Eye...
    2 replies, posted
Want to know how to get the position of an entity inside of a... render.RenderView( { origin = orig, angles = Angle( -90, 0, 0 ), x = x, y = y, w = w, h = h } ) 'Nuff said. Also, just clarifying, the angle supplied should be looking "downwards" (relative to a zero angle) because the pitch is at -90, downwards a right angle, correct? Orig is also at a fixed point in the map, high above ground.
Found this after a quick google search.
You will always be remembered as my hero. For reference, here's the answer after put through the garbage filter <Imagine a whirling machine that resembles a gold panning thing but for forum posts> function camToScreen( cPos, cAng, cFov, scrW, scrH, vDir ) local vDir = cPos - vDir local d = 4 * scrH / ( 6 * math.tan( 0.5 * cFov ) ) local fdp = cAng:Forward():Dot( vDir ) if ( fdp == 0 ) then return 0, 0, false, false end local vProj = ( d / fdp ) * vDir local x = 0.5 * scrW + cAng:Right():Dot( vProj ) local y = 0.5 * scrH - cAng:Up():Dot( vProj ) return x, y, ( 0 < x && x < scrW && 0 < y && y < scrH ) && fdp < 0, fdp > 0 end
Sorry, you need to Log In to post a reply to this thread.