irrklang help

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

irrklang help

Post by spike314 »

can someone please tell me wat im doing wrong?

I created a Listener and attacted to my camera and created a 3d sound and add to my mesh but the sounds are not playing right for example when the mesh is in front of the camera the sound is behind it.

I have added a update so the listener is always with the camera aswell.

Code: Select all

	ISoundSource* ss=sound->getSoundSource  (    );
	engine->play3D(ss,node->getPosition(), loop,false);

engine->setListenerPosition(parent->getPosition(),parent->getRotation(),parent->getPosition());
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I haven't used irrKlang, but I would think that you will want to use absolute positions and rotations. There is a chance Niko got the Z coordinate backwards, but I wouldn't expect that would be true.

Travis
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

Thanks but how do i do that?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Instead of using getPosition() you would call getAbsolutePosition().

I think the problem is much more obvious than I had originally thought. The parameters passed to setListenerPosition() are the absolute position, look direction, velocity and up vector. You are passing the relative position, relative rotation and relative position. That will not get you what you want.

I think you want to write

Code: Select all

   // get the up vector
   core::vector3df upwards(0.f, 1.f, 0.f);
   camera->getAbsoluteTransformation().rotateVect(upwards);

   // and forward vector
   core::vector3df forwards(0.f, 0.f, 1.f);
   camera->getAbsoluteTransformation().rotateVect(forwards);

   // do doppler
   const f32 elapsed = (timeMs - PreviousTime) / 1000.f;
   PreviousTime = timeMs;

   // do position/velocity
   const core::vector3df position = getAbsolutePosition();
   const core::vector3df velocity = (position - PreviousPosition) / elapsed;
   PreviousPosition = position;

   // feed position, velocity and orientation information to sound engine
   SoundEngine->setListenerPosition(position, forwards, velocity, upwards);
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You might have a look at the scene nodes I posted here. They automatically position and orient the sound and the listener so that you don't have to do it yourself.

Travis
spike314
Posts: 27
Joined: Sun Nov 19, 2006 11:51 am
Location: Shropshire (UK)
Contact:

Post by spike314 »

thank you
Post Reply