Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

How to quickly determine if object is visible ?

How to quickly determine if object is visible ?

Anonymous
Not applicable
1,041 Views
1 Reply
Message 1 of 2

How to quickly determine if object is visible ?

Anonymous
Not applicable
Hello all, time since last post.
How to quickly determine if object is visible trough camera over time say animation range from frame 5 to 160.. Problem is I produced A LOT of objects and not everyone is visible from various cameras.. so i'm trying to reduce their count based on camera visibility and leave only that are visible in any of frame from one particular camera. Then setup scene again for other camera.
I read something about ID and frame buffer but seems useless cause there is too much objects. Object is represented as cube volume and test should be based on visibility of this volume in camera view.
I was thinking of some array containing only a visible objects based on some visibility or camera volume selection but i don't know how to perform this test exactly so some example or link would be great..
Any help is welcome.. Some guru here? 🙂

ps: i like if script could be quick but i'll be happy if i get objects sorted out in reasonable time, speed is not condition...

& i have phyton instaled also if this is some help..

Than you all

image: boxes on which should be performed test.. on display is only aprox. 15% of total objects... not counting other geometry.. it is huge scene 😛

0 Likes
1,042 Views
1 Reply
Reply (1)
Message 2 of 2

gplourde
Participant
Participant
Don't know if its fast enough but try this,


fn cameraCull pos =
(
p = pos * viewport.getTM()

start = (mapScreenToView (p.z) )
end = (mapScreenToView p.z )
norm = (start - end)
s = (point2 ((renderWidth/(abs norm.x))*(p.x-start.x)) (-((renderHeight/(abs norm.y))*(p.y-start.y))))

if s.x > 0 and s.y > 0 and s.x < renderWidth and s.y < renderHeight then
return true
else
return false
)
fn isVisible obj =
(
if (cameraCull obj.min) or (cameraCull obj.max) or (cameraCull obj.center) then
return true
else
return false
)

for o in $* do
(
if (isVisible o == true) then
setRenderable o true
else
setRenderable o false
)



This basicly check if the min max and center of an object is inside the renderable part of the viewport. Project them to the viewport and check the render height and width.
0 Likes