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

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Cezaro
Posts: 18
Joined: Fri Jul 07, 2006 2:31 pm
Location: Korytow Poland

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

Post 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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post 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
Post Reply