Hello,
I'm working on an application where I build very big maps consisting of many square tiles each. Thus, I need to determine which tiles are currently visible by the camera, so that I don't load unnecessary textures. I don't want to construct an entity and a scenenode for a tile that is invisible, hence I can't check the current visibility by using usual methods (like node->isInScene()). The question is: given the middle point as vector and the length of each tile (a rectangle), how can I determine if it's visible by the current camera?
Thank you!
Is rectangle in scene?
-
- Gnoblar
- Posts: 11
- Joined: Mon Nov 25, 2013 7:07 pm
- Location: Colombia
- puso1990
- Gnoblar
- Posts: 24
- Joined: Mon Feb 27, 2012 8:41 pm
- Location: Slovenia
- x 3
Re: Is rectangle in scene?
hmm I never tried this but I think that this can be done with Ogre::Frustum. Camera is actualy a child of Frustum class and so it has:
...method which I think might help you. You can get your SceneNode AABB with _getWorldAABB() I think.
Hope this helps someway
Code: Select all
bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0)
Hope this helps someway
-
- Gnoblar
- Posts: 11
- Joined: Mon Nov 25, 2013 7:07 pm
- Location: Colombia
Re: Is rectangle in scene?
Thank you!
Yes I was trying to do something like that. The problem that I have is that I don't have a scenenode, because the object doesn't exist yet. I want to create the entity and the scene node after I have determined if the object is visible. The ideal thing would be to create an AABB of the object, an then use isVisible(). But I don't know how to construct such a bounding box with the information I have.
Yes I was trying to do something like that. The problem that I have is that I don't have a scenenode, because the object doesn't exist yet. I want to create the entity and the scene node after I have determined if the object is visible. The ideal thing would be to create an AABB of the object, an then use isVisible(). But I don't know how to construct such a bounding box with the information I have.
- puso1990
- Gnoblar
- Posts: 24
- Joined: Mon Feb 27, 2012 8:41 pm
- Location: Slovenia
- x 3
Re: Is rectangle in scene?
As I said I haven't tried this myself but I think you could create new AxisAlignedBox set it's Minimum and Maximum corners (probably in world space, not sure) and test it against the frustum.
Or you can simply use frustums:
to simply check if a Vertex (in world space) is in Cameras frustum. Repeat this 4 times for each of the corners of the tile and I think should work
Or you can simply use frustums:
Code: Select all
bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0)
-
- Gnoblar
- Posts: 11
- Joined: Mon Nov 25, 2013 7:07 pm
- Location: Colombia
Re: Is rectangle in scene?
Thank you! It seems to be working!