0
0

Hello,

I have been attempting to practice sound occlusion using the provided tutorials and examples, but have been unable to reproduce sound occlusion in my own code. Despite looking at the API, examples, and multitudes of printf function outputs, I’m quite stumped and am hoping someone can help me figure out what I’m missing. Everything appears to be working fine, expect for the occlusion. The sounds are loaded and played, the polygons are added to a geometry object, printf functions show each FMOD_VECTOR for every polygon and the listener in the correct positions, the sounds are audible and update appropriately, but there is still no occlusion.

This is a visual of what the code is supposed to be reproducing:
[img:2aza7vsz]http://web.engr.oregonstate.edu/~clinew/FMOD_occlusion/occlusion023.jpg[/img:2aza7vsz]
The view is as if one is looking down on a 2D game such as one of the old Zeldas.

This is a summary of what the code actually does*:

  1. Initialize FMOD system using recommended startup sequence
  2. Set the system’s geometry settings
    [code:2aza7vsz]result = system->setGeometrySettings(1000.0f);[/code:2aza7vsz]
  3. Set the system’s 3D settings
    [code:2aza7vsz]result = system->set3DSettings( dopplerscale, distancefactor, rolloffscale );[/code:2aza7vsz]
  4. Create a geometry object
    [code:2aza7vsz]result = system->createGeometry(6, 24, &rightWall_geometry);[/code:2aza7vsz]
  5. Set the geometry object as active
    [code:2aza7vsz]result = rightWall_geometry->setActive(true);[/code:2aza7vsz]
  6. Set position, rotation, and up vectors of the geometry object
    [code:2aza7vsz]//Set the object location
    temp[0] = init_FMOD_VECTOR( 0.0f, 0.0f, 0.0f );
    result = rightWall_geometry->setPosition( &temp[0] );
    FMOD_errorCheck(result);
    //Set forward and up vectors
    temp[0] = init_FMOD_VECTOR( 0.0f, 1.0f, 0.0f );
    temp[1] = init_FMOD_VECTOR( 0.0f, 0.0f, -1.0f );
    result = rightWall_geometry->setRotation( &temp[0], &temp[1] );
    FMOD_errorCheck(result);[/code:2aza7vsz]
  7. Add 6 polygons to the geometry object
    [code:2aza7vsz]result = rightWall_geometry->addPolygon( 0.5f, 0.5f, 1, 4, temp, NULL );[/code:2aza7vsz]*6 (after re-initializing FMOD_VECTOR temp[4], of course)
  8. Set the system’s 3D Listener Attributes
    [code:2aza7vsz]result = system->set3DListenerAttributes(0, &player.getLocation(), NULL, &player.getForward(), &player.getUp());[/code:2aza7vsz]
  9. Create two 3D sounds in the system using FMOD_SOFTWARE | FMOD_3D
    [code:2aza7vsz]result = system->createSound("sounds/sound1.wav", FMOD_SOFTWARE | FMOD_3D, NULL, &sound1);
    result = system->createSound("sounds/sound2.wav", FMOD_SOFTWARE | FMOD_3D, NULL, &sound2);[/code:2aza7vsz]
  10. Play the two sounds
    [code:2aza7vsz]//In Siren class:
    result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &this->channel);
    FMOD_errorCheck(result);
    result = this->channel->set3DAttributes(&this->position,&this->velocity);
    FMOD_errorCheck(result);[/code:2aza7vsz]
  11. Go into an infinite loop that updates the sound positions and calls system->update()
    [code:2aza7vsz]//In Siren class
    result = this->channel->set3DAttributes(&this->position,&this->velocity);
    //In main
    result = system->update();[/code:2aza7vsz][size=85:2aza7vsz]*The FMOD_errorCheck function is called after every FMOD call[/size:2aza7vsz]

Full source code for the project and an executable of the latest build (from Microsoft Visual Studio 10.0 on Windows Vista) can be found here: http://web.engr.oregonstate.edu/~clinew/FMOD_occlusion/

This is a summary of the class list:
[i:2aza7vsz]Siren[/i:2aza7vsz]: An object containing an FMOD::Channel* that plays a sound.
[i:2aza7vsz]Player[/i:2aza7vsz]: Contains position, velocity, forward, and up vectors to update listener with
[i:2aza7vsz]Wall[/i:2aza7vsz] (OUTDATED): Supposed to contain polygon information. Outdated due to a misinterpretation of what a FMOD::Geometry* object is. Currently not in use.
[i:2aza7vsz]projectLibrary[/i:2aza7vsz]: Contains helpful functions such as init_FMOD_VECTOR, FMOD_errorCheck, and a static FMOD_RESULT variable used throughout the program.

I apologize if this is a lot of information, but I am currently quite unsure where to start from. If you have any questions I am happy to answer them.

Thank you for your time,

Wade

  • You must to post comments
0
0

That is correct, order is important. The direction of the winding determines the polygon’s normal direction.

  • You must to post comments
0
0

I just got crazy over just the same thing. It’s not documented as far as I know, but the order in which you construct your vector array seems important. So this won’t work:

3 4
1 2

but this does:

2 3
1 4

So the points have to be in clockwise order. Perhaps counter-clockwise will also work, but I think you have to take care to "draw" a polygon, not a Z-shape.

  • You must to post comments
0
0

Hi peter and icuurd12b42,

Sorry about the delayed response; been busy moving and getting re-adjusted.
[quote="peter":1ieijglh]The standard left-handed coordinate system is as follows:
+x is right
+y is up
+z is forward.

In the image you posted, the player is moving along the X-Z plane. Regardless, it doesn’t matter what coordinate system you use, so long as you’re consistent it should still work.[/quote:1ieijglh]
[quote="icuurd12b42":1ieijglh]A lot of us convert x,y topdown 2d games to 3d…. Leaving the z for up/down.[/quote:1ieijglh]
Yes, using the X-Y plane for 2D movement and the Z vector for up/down is my intention. This has been used consistently throughout the program.

[quote="icuurd12b42":1ieijglh]I suggest you set your camera to point straight down on the "walking" plane like for a 2d game setup and use the mouse to move your sound arround. It is possible you have an axis inverted, start with z=0 in your case since z is your up/down vector and mouve the sound on the x,y axis with the mouse.[/quote:1ieijglh]
I am afraid I do not [i:1ieijglh]yet[/i:1ieijglh] know how to do graphics or user input, but was planning on learning OpenGL in the near future (ideally, after FMOD occlusion, though this may not be the case).
[quote="icuurd12b42":1ieijglh]It is also possible you’ve set your occlusion object, it’s vectices, in a way the facets face the wrong direction.[/quote:1ieijglh]
This is probably what is happening. The most suspect is the geometry object.

Should the geometry object be using the same rotation vectors as the listener? The geometry and listener’s current forward and up vectors are both:

[b:1ieijglh]Forward:[/b:1ieijglh] ( 0.0f, 1.0f, 0.0f )
[b:1ieijglh]Up:[/b:1ieijglh] ( 0.0f, 0.0f, -1.0f )

Perhaps the problem is that the rotation is displacing the polygons from their intended location…

Also, though it may not be good practice, is it okay to set the geometry’s location to ( 0.0f, 0.0f, 0.0f ) and then place the polygons with respect to the origin?

Complete vertex and vector output is below (sorry if it is lengthy, but I’ve gone over this code for about 5-10 hours have not found anything incorrect):

[img:1ieijglh]http://web.engr.oregonstate.edu/~clinew/FMOD_occlusion/output.bmp[/img:1ieijglh]

Again, thank you for your time and help so far.

Sincerely,
Wade

  • You must to post comments
0
0

A lot of us convert x,y topdown 2d games to 3d…. Leaving the z for up/down.

I suggest you set your camera to point straight down on the "walking" plane like for a 2d game setup and use the mouse to move your sound arround. It is possible you have an axis inverted, start with z=0 in your case since z is your up/down vector and mouve the sound on the x,y axis with the mouse. It is also possible you’ve set your occlusion object, it’s vectices, in a way the facets face the wrong direction.

  • You must to post comments
0
0

The standard left-handed coordinate system is as follows:
+x is right
+y is up
+z is forward.

In the image you posted, the player is moving along the X-Z plane. Regardless, it doesn’t matter what coordinate system you use, so long as you’re consistent it should still work. This kind of hard coded vector stuff can be a real brain bender.

  • You must to post comments
0
0

Hi peter,

[quote:2pch2r89]it seems you are using a very unsual cooridinate system:[/quote:2pch2r89]
My understanding of a Left-handed 3D coordinate system, or 3D coordinate systems in general, may not be correct, and thus the vector logic incorrect. The idea is to have the listener facing in a position such as in [url=http://img404.imageshack.us/img404/2599/screenshot002nk0.png:2pch2r89]this screen shot[/url:2pch2r89], where the in-game character would be facing north on the computer screen, and the user looking down upon the character.

I’ll do some research on 3D coordinate systems, experiment with the project a bit more, and post the results, hopefully before or early next week.

Thank you for the recommendations,

Wade

  • You must to post comments
0
0

Hi clinew,

it seems you are using a very unsual cooridinate system:
[quote:3i5f8trr] //forward
temp[2] = init_FMOD_VECTOR( 0.0f, 1.0f, 0.0f );
//up
temp[3] = init_FMOD_VECTOR( 0.0f, 0.0f, -1.0f );
[/quote:3i5f8trr]
So ‘forward’ is positive Y and ‘up’ is negative Z ?

I’d reccomend moving the sound around and try to find a location that does cause occlusion. Then try to work backward and determine why it is occluded in that locaiton there and not at the expected location.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.