EntityVisible

Blitz3D Forums/Blitz3D Programming/EntityVisible

Shambler(Posted 2003) [#1]
I seem to be having problems with EntityVisible where it is acting just like EntityInView.

I load one of my levels meshes and set it to being an occluder...

m\mesh=LoadMesh("./Media/dungy.b3d")
EntityPickMode m\mesh,2,True
;cam is the camera, e\pivot is a cube created with createcube...
;This returns true even if the mesh above is blocking the line of sight between the camera and entity O.o
If EntityVisible (cam,e\pivot)=True 
etc.
etc.



It does return false just like EntityInView does i.e. if the entity is outside of the camera's frustum.

Im sure it was working once, what have I overlooked ? Do I have to make the entity pickable too or something?


Shambler(Posted 2003) [#2]
After much tweaking I found out what was going on.

I assumed that if I made an occluder Blitz would automatically hide entities which are occluded and not draw them...wrong ^^

Now I do this for each of my particle emitters...


Function Update_Emitters(cam)
For e.emitter=Each emitter
HideEntity e\vis
If EntityInView(e\vis,cam)=True
If EntityVisible(cam,e\vis)=True
ShowEntity e\vis
UpdateParticles.
etc..
etc...




Ross C(Posted 2003) [#3]
That's a handy piece of code. Mind if i nick it? :D


Shambler(Posted 2003) [#4]
Hehe sure.

On further thinking about it I can see that Blitz hides entities automatically if they are outside the frustum but not if they are behind an obscurer.

Actually on second thoughts the EntityInView test is not needed since an entity outside the frustum gets hidden anyway.

I make a cube or sphere emitter that defines the area where the particles will be, then each particle is parented to the emitter so that hiding/showing the emitter does the same for all the particles...and also the particles don't get updated either if the emitter is not in view.

Another thing I think I am seeing is that for EntityVisible Blitz is ignoring any radius/box and only using the positions of the entity/camera for the occlusion test.

May have to do some more work on this, possibly doing some linepicks instead.


Rob(Posted 2003) [#5]
Thats correct. EntityVisible works soly on the pivot point of the entity. EntityInView uses bounding box. I would like entityvisible to use bounding box too frankly.

I don't know why mark hasn't already done so, but I suppose you can roll your own.


Shambler(Posted 2003) [#6]
I can see that a roll your own solution is going to be a cludge and there are several ways of doing it.

I'm going to start by simply parenting a pivot either side of the camera and linepicking to the entity from them.

This should be sufficient for the kind of geometry I have in the level at the moment but I may have to expand the test at a later date.