Added position audio.

This commit is contained in:
rude
2009-08-04 21:13:32 +02:00
parent 73b37f626d
commit cc9a142a98
14 changed files with 340 additions and 1 deletions
+38
View File
@@ -156,6 +156,44 @@ namespace audio
**/
virtual float getVolume() const = 0;
/**
* Gets the position of the listener.
* @param v A float array of size 3 containing (x,y,z) in that order.
**/
virtual void getPosition(float * v) const = 0;
/**
* Sets the position of the listener.
* @param v A float array of size 3 containing [x,y,z] in that order.
**/
virtual void setPosition(float * v) = 0;
/**
* Gets the orientation of the listener.
* @param v A float array of size 6 containing [x,y,z] for the forward
* vector, followed by [x,y,z] for the up vector.
**/
virtual void getOrientation(float * v) const = 0;
/**
* Sets the orientation of the listener.
* @param v A float array of size 6 containing [x,y,z] for the forward
* vector, followed by [x,y,z] for the up vector.
**/
virtual void setOrientation(float * v) = 0;
/**
* Gets the velocity of the listener.
* @param v A float array of size 3 containing [x,y,z] in that order.
**/
virtual void getVelocity(float * v) const = 0;
/**
* Sets the velocity of the listener.
* @param v A float array of size 3 containing [x,y,z] in that order.
**/
virtual void setVelocity(float * v) = 0;
}; // Audio
} // audio
+8
View File
@@ -53,6 +53,14 @@ namespace audio
virtual void setVolume(float volume) = 0;
virtual float getVolume() const = 0;
// all float * v must be of size 3
virtual void setPosition(float * v) = 0;
virtual void getPosition(float * v) const = 0;
virtual void setVelocity(float * v) = 0;
virtual void getVelocity(float * v) const = 0;
virtual void setDirection(float * v) = 0;
virtual void getDirection(float * v) const = 0;
void setLooping(bool looping);
bool isLooping() const;
+24
View File
@@ -122,6 +122,30 @@ namespace null
return volume;
}
void Audio::getPosition(float * v) const
{
}
void Audio::setPosition(float * v)
{
}
void Audio::getOrientation(float * v) const
{
}
void Audio::setOrientation(float * v)
{
}
void Audio::getVelocity(float * v) const
{
}
void Audio::setVelocity(float * v)
{
}
} // null
} // audio
} // love
+7
View File
@@ -67,6 +67,13 @@ namespace null
void setVolume(float volume);
float getVolume() const;
void getPosition(float * v) const;
void setPosition(float * v);
void getOrientation(float * v) const;
void setOrientation(float * v);
void getVelocity(float * v) const;
void setVelocity(float * v);
}; // Audio
} // null
+24
View File
@@ -89,6 +89,30 @@ namespace null
return volume;
}
void Source::setPosition(float * v)
{
}
void Source::getPosition(float * v) const
{
}
void Source::setVelocity(float * v)
{
}
void Source::getVelocity(float * v) const
{
}
void Source::setDirection(float * v)
{
}
void Source::getDirection(float * v) const
{
}
} // null
} // audio
} // love
+7
View File
@@ -57,6 +57,13 @@ namespace null
void setVolume(float volume);
float getVolume() const;
void setPosition(float * v);
void getPosition(float * v) const;
void setVelocity(float * v);
void getVelocity(float * v) const;
void setDirection(float * v);
void getDirection(float * v) const;
}; // Source
} // null
+30
View File
@@ -175,6 +175,36 @@ namespace openal
return volume;
}
void Audio::getPosition(float * v) const
{
alGetListenerfv(AL_POSITION, v);
}
void Audio::setPosition(float * v)
{
alListenerfv(AL_POSITION, v);
}
void Audio::getOrientation(float * v) const
{
alGetListenerfv(AL_ORIENTATION, v);
}
void Audio::setOrientation(float * v)
{
alListenerfv(AL_ORIENTATION, v);
}
void Audio::getVelocity(float * v) const
{
alGetListenerfv(AL_VELOCITY, v);
}
void Audio::setVelocity(float * v)
{
alListenerfv(AL_VELOCITY, v);
}
} // openal
} // audio
} // love
+7
View File
@@ -96,6 +96,13 @@ namespace openal
void setVolume(float volume);
float getVolume() const;
void getPosition(float * v) const;
void setPosition(float * v);
void getOrientation(float * v) const;
void setOrientation(float * v);
void getVelocity(float * v) const;
void setVelocity(float * v);
}; // Audio
} // openal
+36
View File
@@ -163,6 +163,42 @@ namespace openal
return volume;
}
void Source::setPosition(float * v)
{
if(source)
alSourcefv(source, AL_POSITION, v);
}
void Source::getPosition(float * v) const
{
if(source)
alGetSourcefv(source, AL_POSITION, v);
}
void Source::setVelocity(float * v)
{
if(source)
alSourcefv(source, AL_VELOCITY, v);
}
void Source::getVelocity(float * v) const
{
if(source)
alGetSourcefv(source, AL_VELOCITY, v);
}
void Source::setDirection(float * v)
{
if(source)
alSourcefv(source, AL_DIRECTION, v);
}
void Source::getDirection(float * v) const
{
if(source)
alGetSourcefv(source, AL_DIRECTION, v);
}
} // openal
} // audio
} // love
+7
View File
@@ -67,6 +67,13 @@ namespace openal
void setVolume(float volume);
float getVolume() const;
void setPosition(float * v);
void getPosition(float * v) const;
void setVelocity(float * v);
void getVelocity(float * v) const;
void setDirection(float * v);
void getDirection(float * v) const;
}; // Source
} // openal
+74
View File
@@ -140,6 +140,72 @@ namespace audio
return 1;
}
int _wrap_setPosition(lua_State * L)
{
float v[3];
v[0] = (float)luaL_checknumber(L, 1);
v[1] = (float)luaL_checknumber(L, 2);
v[2] = (float)luaL_checknumber(L, 3);
instance->setPosition(v);
return 0;
}
int _wrap_getPosition(lua_State * L)
{
float v[3];
instance->getPosition(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 3;
}
int _wrap_setOrientation(lua_State * L)
{
float v[6];
v[0] = (float)luaL_checknumber(L, 1);
v[1] = (float)luaL_checknumber(L, 2);
v[2] = (float)luaL_checknumber(L, 3);
v[3] = (float)luaL_checknumber(L, 4);
v[4] = (float)luaL_checknumber(L, 5);
v[5] = (float)luaL_checknumber(L, 6);
instance->setOrientation(v);
return 0;
}
int _wrap_getOrientation(lua_State * L)
{
float v[6];
instance->getOrientation(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
lua_pushnumber(L, v[3]);
lua_pushnumber(L, v[4]);
lua_pushnumber(L, v[5]);
return 6;
}
int _wrap_setVelocity(lua_State * L)
{
float v[3];
v[0] = (float)luaL_checknumber(L, 1);
v[1] = (float)luaL_checknumber(L, 2);
v[2] = (float)luaL_checknumber(L, 3);
instance->setVelocity(v);
return 0;
}
int _wrap_getVelocity(lua_State * L)
{
float v[3];
instance->getVelocity(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 3;
}
// List of functions to wrap.
static const luaL_Reg wrap_Audio_functions[] = {
{ "getNumSources", _wrap_getNumSources },
@@ -153,6 +219,14 @@ namespace audio
{ "rewind", _wrap_rewind },
{ "setVolume", _wrap_setVolume },
{ "getVolume", _wrap_getVolume },
{ "setPosition", _wrap_setPosition },
{ "getPosition", _wrap_getPosition },
{ "setOrientation", _wrap_setOrientation },
{ "getOrientation", _wrap_getOrientation },
{ "setVelocity", _wrap_setVelocity },
{ "getVelocity", _wrap_getVelocity },
{ 0, 0 }
};
+6
View File
@@ -42,6 +42,12 @@ namespace audio
int _wrap_rewind(lua_State * L);
int _wrap_setVolume(lua_State * L);
int _wrap_getVolume(lua_State * L);
int _wrap_setPosition(lua_State * L);
int _wrap_getPosition(lua_State * L);
int _wrap_setOrientation(lua_State * L);
int _wrap_getOrientation(lua_State * L);
int _wrap_setVelocity(lua_State * L);
int _wrap_getVelocity(lua_State * L);
int wrap_Audio_open(lua_State * L);
} // audio
+66 -1
View File
@@ -59,6 +59,72 @@ namespace audio
return 1;
}
int _wrap_Source_setPosition(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
v[0] = (float)luaL_checknumber(L, 2);
v[1] = (float)luaL_checknumber(L, 3);
v[2] = (float)luaL_checknumber(L, 4);
t->setPosition(v);
return 0;
}
int _wrap_Source_getPosition(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
t->getPosition(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 3;
}
int _wrap_Source_setVelocity(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
v[0] = (float)luaL_checknumber(L, 2);
v[1] = (float)luaL_checknumber(L, 3);
v[2] = (float)luaL_checknumber(L, 4);
t->setVelocity(v);
return 0;
}
int _wrap_Source_getVelocity(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
t->getVelocity(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 3;
}
int _wrap_Source_setDirection(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
v[0] = (float)luaL_checknumber(L, 2);
v[1] = (float)luaL_checknumber(L, 3);
v[2] = (float)luaL_checknumber(L, 4);
t->setDirection(v);
return 0;
}
int _wrap_Source_getDirection(lua_State * L)
{
Source * t = luax_checksource(L, 1);
float v[3];
t->getDirection(v);
lua_pushnumber(L, v[0]);
lua_pushnumber(L, v[1]);
lua_pushnumber(L, v[2]);
return 3;
}
int _wrap_Source_setLooping(lua_State * L)
{
Source * t = luax_checksource(L, 1);
@@ -73,7 +139,6 @@ namespace audio
return 1;
}
static const luaL_Reg wrap_Source_functions[] = {
{ "setPitch", _wrap_Source_setPitch },
{ "getPitch", _wrap_Source_getPitch },
+6
View File
@@ -33,6 +33,12 @@ namespace audio
int _wrap_Source_getPitch(lua_State * L);
int _wrap_Source_setVolume(lua_State * L);
int _wrap_Source_getVolume(lua_State * L);
int _wrap_Source_setPosition(lua_State * L);
int _wrap_Source_getPosition(lua_State * L);
int _wrap_Source_setVelocity(lua_State * L);
int _wrap_Source_getVelocity(lua_State * L);
int _wrap_Source_setDirection(lua_State * L);
int _wrap_Source_getDirection(lua_State * L);
int _wrap_Source_setLooping(lua_State * L);
int _wrap_Source_isLooping(lua_State * L);
int wrap_Source_open(lua_State * L);