I must be very tired because the solution completely eludes me The Spring.GetProjectilesInRectangle ( number xmin, number zmin, number xmax, number zmax ...) function takes a rectangle as input. How do I determine the rectangle of the map in view? I tried with TraceScreenRay, but I cant make it work properly for rotated cameras. Any suggestions/previous implementations greatly appreciated.
Hmm, well Spring.TraceScreenRay works for me, are you passing a "true" parameter to only use ground? You may need to use max/min width/height if it goes off the screen.
Also, it doesn't work with water - it will hit the seabed instead of the waves, but according to jk you can use camera to recalculate that (I haven't done it yet so can't supply code):
Quote:
[02:12] <[LCC]jK> you can recalc waterpos from tracescreenray [02:13] <[LCC]jK> with Spring.GetCameraDirection() [02:14] <[LCC]jK> it won't be 100% exact cause tracescreenray use a perscreenpixel direction, but it will give sane results
think it may be a problem if you're using corners, try this instead.
Code:
at, b=Spring.TraceScreenRay(sx / 2,0,true,false,false) --bottom if at=='ground' then y2=math.min(y2, b[3]) end at, t=Spring.TraceScreenRay(sx / 2,sy-1,true,false,false) -- top if at=='ground' then y1=math.max(y1, t[3]) end at, l=Spring.TraceScreenRay(0,sy / 2,true,false,false) -- left if at=='ground' then x1=math.max(x1, l[1]) end at, t=Spring.TraceScreenRay(sx-1,sy / 2,true,false,false) --right if at=='ground' then x2=math.min(x2, t[1]) end
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum