Page 1 of 1

How to I cast a ray from the camera to the sun node

Posted: Fri Jul 28, 2006 6:04 am
by Cezaro
Hello!

How to I cast a ray from the camera to the sun node and check it is actually visible and nothing stands between camera and that node???


thanks

Posted: Fri Jul 28, 2006 6:41 am
by vitek
Take the absolute positions of the camera and the sun and use them to create a ray from the camera to the sun. Then use the scene collision manager to find if there is any node whose bounding box is intersected with that line.

Classes and functions you will need to use...

ISceneNode::getAbsolutePosition()
ISceneCollisionManager::getSceneNodeFromRayBB()

That should be good enough to help you find your way.

Posted: Fri Jul 28, 2006 6:48 am
by Dances

Code: Select all

core::line3d<f32> line;
line.start = camera->getPosition();
line.end = sun->getPosition();

core::vector3df intersection;
core::triangle3df tri;

if (!smgr->getSceneCollisionManager()->getCollisionPoint(
		line, selector, intersection, tri))
//draw sun flare here