Game Development Community

AlxSource3f

by Sam Redfern · in Torque Game Engine · 07/08/2005 (4:16 am) · 2 replies

I don't know if anyone else has noticed, but there's some very obvious bugs in the alxSource3f console function in audioFunctions.cc (I'm using TGE 1.3). There's no way it can work as it stands.

Here's a fixed version, might be of use to anyone who wants to move a 3D sound source around after it has started playing:


ConsoleFunction(alxSource3f, void, 3, 6, "(handle, ALenum, x, y, z)\n\n"
"@note You can replace the last three parameters with a string, "
"\"x y z\"")
{
ALenum e = getEnum(argv[2], (Source|Set|Float3));
if(e == AL_INVALID)
{
Con::errorf(ConsoleLogEntry::General, "cAudio_alxSource3f: invalid enum name '%s'", argv[2]);
return;
}

if(argc != 3 && argc != 6)
{
Con::errorf(ConsoleLogEntry::General, "cAudio_alxSource3f: wrong number of args");
return;
}

Point3F pos;
if(argc == 3)
dSscanf(argv[3], "%f %f %f", &pos.x, &pos.y, &pos.z);
else
{
pos.x = dAtof(argv[3]);
pos.y = dAtof(argv[4]);
pos.z = dAtof(argv[5]);
}

alxSource3f(dAtoi(argv[1]), e, pos.x, pos.y, pos.z);
}

#1
08/02/2005 (11:02 pm)
I believe you will also need to change the line:

if(argc != 3 && argc != 6)

to read

if(argc != 4 && argc != 6)

and the line

if(argc == 3)

to read

if(argc == 4)

to get the string version of this function to work.
#2
08/03/2005 (4:31 pm)
This is incidentally fixed in 1.4 trunk. (Don't think it made it out for RC1 tho.)