This is kind of a weird request, but I hope it's possible.
What I'm requesting is a command that can give you the 'clipped' version of the bounding box of an object at a certain height for a given LOD.
Let's say I want to place an object next to the trunk of a tree. But since trees typically have large bounding boxes (due to the branches, which are irrelevant in this case), I'd have to 'refine' the BB by checking multiple line intersects to determine the actual bounds of the Geometry LOD at a certain height.
But there's always some error associated with this method (you'd have to do this at discrete steps, which means you could miss a surface between the gaps)
Since the game can "see" all the LODs, it would be much more convenient if there was a command that clipped the LOD at a certain height.
Something like this (it is created with the workaround method described above):
Which is the clipped version of the geometry LOD:
obj clipLOD [LOD, z1, z2]
LOD: String. Name of the LOD (e.g. "Geometry")
z1: Number. Z value where the clipping starts from in model coordinates.
z2: Number. Z value where the clipping ends at in model coordinates.
Return value: Array. Clipped LOD in format [[x1,y1,z1],[x2,y2,z2]] (similar to boundingBox format)
For the above example, this would be:
_z1 = (boundingBoxReal tree)#0#2; //the very bottom of the bounding box _z2 = (tree worldToModel (ASLtoAGL getPosASL tree))#2 + 0.5; //0.5 meter above the land contact, in model coordinates (assuming the object is perfectly upright, i.e vectorUp isEqualTo [0,0,1]) tree clipLOD ["Geometry", _z1, _z2]
Other examples where such command comes in handy:
- Path generation.
- Detecting cover positions next to an object, such as a tree.
- Creating alternative version of findEmptyPosition (sometimes it puts the object into another object's BB, causing explosions)
If we could also choose the "up" vector during clipping, it would be even better (X, Y or Z in model coordinates).
Because sometimes, objects might be on their sides. (e.g vectorUp = [1,0,0])
obj clipLOD [LOD, z1, z2, upDir]
upDir (optional): Number. 0: X direction; 1: Y direction; 2: Z direction (Default, 2)