Answered
0
0

Hello,
I’m still having a hard time understanding the FMod coordinate system in relation to the OpenGL coordinate system.

I have some sound emitting object with these OpenGL coordinates (x,y,z), stored in FMOD_VECTOR objectpos:

20910.4, -21.1514, -21543.7

I have a camera i.ex. with these OpenGL coordinates (x,y,z), stored in FMOD_VECTOR camerapos:

20911.5, -20.7203, -21543.1

Now I wanted to find out how the sound changes if I move my camera.
So I tried to set the channel 3D position to the one of the sound emitting object:

result = channel1->set3DAttributes(&objectpos, &vel, 0);
ERRCHECK(result);

Next I made a loop which keeps reading the camera position and calls the update() on FMod. Inside this loop I set the 3DListenerAttributes:

result = systemi->set3DListenerAttributes(0, &camerapos, &vel,
&listenerforward, &up); ERRCHECK(result);

The problem is I dont hear the sound. I assume this is because the coordinates are “out of scope” of FMOD. So far I didn’t find any information on the “scope” of the coordinate system of FMod besides that it is normalized some way. Does it expect values from 0.0 to 1.0? How would I get such normalized values?

I have no clue how to “translate” my OpenGL values to something FMod can handle?

(Just as a sidenote, if I manually set the positions to something “nice”, like -100.0f, 0.0f, 0.0f, I can hear the sound. So the problem is not that my FMod system in general is not working right and not the problem.)

Any help is very appreciated. Thank you!
Chris

  • You must to post comments
Great Answer
0
0

Tx for testing!
It is strange that you are able to use the positions.

I initialize like that:

result = systemi->set3DSettings(1.0, DISTANCEFACTOR, 1.0f);

result = systemi->createSound(“wave.mp3”, FMOD_3D, 0, &sound1);

result = sound1->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 50000.0f * DISTANCEFACTOR);

result = sound1->setMode(FMOD_INIT_3D_RIGHTHANDED);

Then:

result = channel1->set3DAttributes(&objectpos, &vel);

And in loop:

result = systemi->set3DListenerAttributes(0, &camerapos, &vel,&listenerforward, &up);

My objectpos was: -14260.4, -167.72, 46030 (x,y,z)
And my camerapos: -14119.4, -138.978, 46099.5 (x,y,z)
vel was (0,0,0), forward (0,0,1) and up (0,1,0)

And I didnt hear anything :(

Do you see something wrong or strange? For bad luck there is only one 3D example shipping with FMod and well, besides that it is using position x,y,z alot smaller (100, 0, 0 and such) it seems way similar? Using these smaller values from sample I can also hear the sound, as mentioned, but not with the objectpos and camerapos above …

  • Cameron Baron

    The first thing that stands out is the:
    result = sound1->setMode(FMOD_INIT_3D_RIGHTHANDED);

    The right handed flag needs to be used in the System::init() call not on the sound.
    This doesn’t give you an error because it is just using a hexadecimal value, which is what the function is expecting. (https://www.fmod.org/docs/content/generated/FMOD_MODE.html)

  • You must to post comments
0
0

Tx for reply!

So far I knew that and this is not the problem.

The problem is that the values (coordinates) seem to be out of scope of what FMOD is expecting. It is working with values like 100,0,0 but not with values like 20910.4, -21.1514, -21543.7.

But the latter are the coordinates I get from OpenGL.

So my question was how to get these values in scope for FMOD?

Greetings

  • Cameron Baron

    In terms of FMOD’s cooridinate system using normalized values, that is specifically for the orientation vectors (eg. forward & up), set3DListenerAttributes won’t work otherwise.

    I am able to use the position values you mention with no issue.

    Have you had a look at the examples included with the API download?
    There may be something in there that stands out.

  • You must to post comments
0
0

Alright, now I can hear sound :)
Not sure if it was what you pointed to, but after changing this and the order of the playSound and the set3DAttributes its now working fine!

Thanks alot!

  • You must to post comments
0
0

OpenGL uses the right handed coordinate system while FMOD uses Left handed by default.

You can change this by specifying the FMOD_INIT_3D_RIGHTHANDED flag in either System::init or System::setAdvancedSettings.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.