There might not be a good way to do this, but very often I want to exclude selected objects that are not actually visible for me in my current view. I know about the flag “isHiddenInVpt”, but that doesn’t work if the objects are not visible because they’re behind another object (attached image):
There objects aren’t really hidden, but they are “hidden” to me because they’re behind another object. Is there any way of determining if an object is actually not visible to me because it’s behind another object?
Wow, the creativity of you and a few others in here never seizes to amaze me, that’s a really clever idea. You don’t happen to know if something like this has been posted in here before? Or maybe something similar that I could use as reference when trying to write this script myself?
there certainly were scripts posted that separately solve parts of the task, but it is likely that you will faster code it yourself than find something with forum search broken
You’ll have to make sure to disable safe frames, stats, make viewport background flat-colored etc… in order this workaround to actually work.
Oh, awesome! I’m curious, are you using the pixel method, or have you been able to figure out another method? The reason I ask is that I did some tinkering with the pixel method, and it kinda works, but it wasn’t completely accurate. I guess I would have to increase the resolution to increase the accuracy, but that would mean I would have to render the current view.
this is quite fun and could be used as a basis for the “cull”
fn is_ccw p a b = ( (a.x - p.x) * (b.y - p.y) - (a.y - p.y) * (b.x - p.x) <= 0.0; )
fn comp_points p1 p2 =
if p1.x == p2.x and p1.y == p2.y
else if p1.x < p2.x or (p1.x == p2.x and p1.y < p2.y)
fn convex_hull pnts =
local n = pnts.count, k = 1;
res = #();
if n <= 3 then
res = pnts;
res.count = n * 2;
qsort pnts comp_points;
for i = 1 to n do
while k >= 3 and is_ccw res[k - 2] res[k - 1] pnts[i] do k -= 1;
res[k] = pnts[i];
k += 1;
local t = k + 1;
for i = n to 2 by -1 do
while k >= t and is_ccw res[k - 2] res[k - 1] pnts[i - 1] do k -= 1;
res[k] = pnts[i - 1];
k += 1;
res.count = k-2;
fn GetScreenVerts obj =
msh = snapshotasmesh obj;
pnts = for v = 1 to msh.numverts collect gw.wTransPoint (getvert msh v);
fn draw_screen_bounds =
for obj in geometry do
outline = convex_hull (GetScreenVerts obj);
poly = for p in outline collect [p.x, p.y, 0];
gw.wpolyline poly true;
there seems to be a bug with a standard sphere object (though geoshere seems fine )
yeah it kinda of sorted it’s self out here too… got a feeling it may be duplicate point issue or something. Interesting as it is I don’t think convex hulls are the way forward but I do think there is a good screen space 2d solution to be had though it may need the sdk to be realized. Though if sdk is an option then ray tracing isn’t the bottle neck any more
May I ask what it is for?
I want to hear all the arguments for this… and probably each of them I can question, or can suggest another, possibly simpler solution.
I can understand Klvnk doing this purely for fun… but what’s the practical use of it?
I remember back in the early days of the gaming industry we did this to exclude objects from rendering that weren’t in the camera… but we didn’t have GPU render and Z-buffer at that time. Well, why now?
Of course I often receive CAD models from customers, and when they want me to create animations/presentations for their products they rarely need to showcase anything “inside” of the model (the hidden parts). So lets say I receive a CAD model of some kind of machine which consists of several million polys, these models often have a lot of small and really dense/heavy geometry that’s inside of the model (which I don’t need). Removing these objects is often necessary for me to be able to work with the models without lag.
On many models it’s pretty easy to just manually select the “shell” of the model, then invert and delete. However, more often than not this process can be a bit more work than I’d like. If I could save some minutes for each model (in some cases more than minutes) it would definitely help, so it’s just an attempt to improve my workflow
Another use-case would be a pure general (maybe just a personal) workflow improvement, which would be to link the script to a hotkey that de-selects anything not visible in the current view. When working in and out of isolation mode it would just serve as a practical option.
Just to be clear though, I do practice workarounds. I could roughly split the model into different display layers and animate part for part. But still, it’s not optimal as I have to be careful to consider parent/child relationships etc. I’ve been able to do this without a script such as I’m asking for for years, but I’ve started to realize that I have to start addressing possible workflow improvements.
However, there might definitely be some tricks you could think of that could help, so I’m very open to hear what you think could be an alternative to a script similar to what miauu is working on?
Oh, and on another (random) note; How do you quote posts? I feel like a toddler when using this forum some times, I’m not able to search, and I don’t even know how to quote a post properly