I am hoping someone can help me out with this.
I am trying to do this weird thing where, I am "projecting" a sound like a flashlight.
If I were holding a flashlight, whereever the "light" would hit a wall, there would be point where a sound emanates instead.
Now I am sure if I needed to project the sound from the center of the screen like a typical FPS, I wouldn't have a problem, but I need the sound to be projected from a point off center. Say screen coordinates 50, 50.
When I do that, the sound I hear seems to emanate from the correct spot against walls, as long as I am pointing AWAY from the origin [0,0,0].
But as I move away from the origin [using Irrlicht's FPS Camera] and turn to face it, the sound starts emanating from the opposite speaker it should be coming out of the screen.
I think this may be a vector/matrix4 translation/orienation problem, but I am a little weak on 3D math.
Does anyone have any suggestion on how I would correct this problem?
Below is the pertinent code.
Code: Select all
//This set irrKlang's ear's to match the camera.
engine->setListenerPosition( camera->getPosition(), camera->getTarget(), vector3df(0,0,0), camera->getUpVector() );
//The following is straight from the Collision tutorial, expect I am using getRayFromScreenCoordinates(), since the sound's projection from me is off center.
_line = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates( position2d<s32>( 50, 50 ), 0);
if (smgr->getSceneCollisionManager()->getCollisionPoint( line, selector, intersection, tri))
{
bill->setPosition(intersection);
}
//Now it seems that reasonably the intersection of the billboard, would be that of the sound. But like I said the sound only emanates from the correct location if I am pointing away from the Origin.
_IRRsound->setPosition( intersection );
Thanks in advance..
Staque