acemod / ACE3

Open-source realism mod for Arma 3
https://ace3.acemod.org
Other
1.01k stars 736 forks source link

Missing nametags for cargo units #538

Closed bux closed 8 years ago

bux commented 9 years ago

Testing Session 2015 04 12

2015-04-12_00014

In case this isn't by design.

commy2 commented 9 years ago

Wouldn't work. all getPos / modelToWorld etc. commands return the position of the vehicle. All nametags would be at the same place in the center of the vehicle.

CorruptedHeart commented 9 years ago

I know one mod that manages to show names for people in vehicles. ZAM Show Names

jaynus commented 9 years ago

It looks like it uses the boundingBox of the model instead of position or selection offsets, which may be a visual render location instead of world position, which is why they dont work in vehicles.

This could actually prove useful in other places as well.

adampiskorski commented 9 years ago

In my mod it does show names in vehicles, and it works perfectly for stationary vehicles, but when you start moving then the positions get offset.

nicolasbadano commented 9 years ago

In my mod it does show names in vehicles, and it works perfectly for stationary vehicles, but when you start moving then the positions get offset.

That should be fixable. You probably need to apply this corection:

_correctedPos = _pos vectorAdd ((getPosASLVisual _vehicle) vectorDiff (getPosASL _vehicle));

we've done similar things for other stuff

adampiskorski commented 9 years ago

Thanks for the tip! Also, to be clear the mod CorruptedHeart linked to is mine.

jaynus commented 9 years ago

Can you clarify how its being done? Are you using visual model rendering positions bounding boxes or some other factor for it?

adampiskorski commented 9 years ago

It's been a while since I rewrote it, so I'll have to jog my memory, but my code is quite nicely commented (for me at least so that I can easily remember what I was doing) and it's nicely explained here: https://bitbucket.org/zulualpha/zam-shownames/src/fa3e5a18fd9f4cac45cd0fe121cfac29cf34941b/Addons/zam_shownames/functions/fn_showNames_OnEachFrame.sqf?at=default

That is the function that runs the most frequently (on each frame). Other calculations that are done less frequently are done in a normal spawned loop here: https://bitbucket.org/zulualpha/zam-shownames/src/fa3e5a18fd9f4cac45cd0fe121cfac29cf34941b/Addons/zam_shownames/functions/fn_showNames_pressLoop.sqf?at=default

I am meaning to rewrite part of my mod to use Arma 3 modules and actually remove some features, as there are a bit too many and might clog up the code in the future.

nicolasbadano commented 9 years ago

fn_showNames_OnEachFrame.sqf just uses modelToWorldVisual; @commy2 said it didn't work inside vehicles; he's either wrong or some other function is used for those cases

adampiskorski commented 9 years ago

Ill have to look into it, but if my mod doesn't show nametags in vehicles above the passengers heads, then this is the first I am hearing of it.

jaynus commented 9 years ago

modelToWorld and modelToWorldVisual may return completely different coordinate sets and not be documented. I'll test now.

nicolasbadano commented 9 years ago

BTW, @adampiskorski sorry but the correction I posted above won't work in your code, as you already use modelToWorldVisual. IDK why they would lag then.

adampiskorski commented 9 years ago

I suspect because the position is only updated per frame and not per tick, so in a moving vehicle that won't be good enough.

nicolasbadano commented 9 years ago

@adampiskorski, checking a bit more: To get fully consistent 3d positions with rendering you need to use modelToWorldVisual on an Draw3D mission event, not on a onEachFrame event. Graphical transformations are applied in the engine between the two, so if you draw on onEachFrame the draw positions lag a frame. We had to fix that too. e.g.:

https://github.com/acemod/ACE3/blob/master/addons/interact_menu/XEH_clientInit.sqf#L7

adampiskorski commented 9 years ago

Thanks!

Also @jaynus I just tested it on my side and modelToWorldVisual and modelToWorld returned the same result to me, at least by casually putting them into the debug console when both in and out of the vehicle.

Just to make sure we are all in the same page, is this behavior what you guys are looking for? https://www.dropbox.com/s/ol9mdabcqr2e9o7/arma3%202015-04-16%2019-16-15-60.jpg?dl=0

On a side note about that image, I just noticed that the passengers on the firing position at the back of the truck won't have their names show up as for some reason those seats now fail LOS calculations, probably since the Heli DLC

nicolasbadano commented 9 years ago

Ok, I think modelToWorldVisual should work. The only thing we need to do is iterate through units in vehicles; maybe only for units in your own vehicle or turned out units on nearby vehicles.

jaynus commented 9 years ago

Lets assign it and get it done; if it was just an incorrect assumption for modelToWorldVisual then lets do it. It should be a tiny change to the ace_nametags module to use it.

adampiskorski commented 9 years ago

Awesome to see you guys at work and thanks for the tips!

nicolasbadano commented 9 years ago

I think it's safe to push this to 3.1, as it's really low priority