Changed Entity to 3d axis and added a fpstimer that calculates the fps
This commit is contained in:
parent
ec551064c4
commit
28c3cd0529
11 changed files with 222 additions and 72 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package ei.engine.sound;
|
||||
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.scene.Entity;
|
||||
|
||||
/**
|
||||
|
|
@ -13,6 +14,7 @@ public class Sound extends Entity{
|
|||
private int buffer;
|
||||
private int sourceId;
|
||||
private int id;
|
||||
private Vector3f velocity;
|
||||
|
||||
/**
|
||||
* Create a new sound
|
||||
|
|
@ -24,6 +26,7 @@ public class Sound extends Entity{
|
|||
super(name);
|
||||
id = soundId;
|
||||
soundId++;
|
||||
velocity = new Vector3f();
|
||||
this.buffer = SoundLoader.getInstnace().loadSound(ref);
|
||||
}
|
||||
|
||||
|
|
@ -75,10 +78,14 @@ public class Sound extends Entity{
|
|||
public void update() {
|
||||
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
|
||||
SoundManager.getInstnace().setSoundLocation(
|
||||
this, getLocation().getX(),getLocation().getY(),0);
|
||||
this, getLocation().getX(),getLocation().getY(),getLocation().getZ());
|
||||
|
||||
}
|
||||
|
||||
public Vector3f getVelocity(){
|
||||
return velocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* unimplamented method
|
||||
*
|
||||
|
|
|
|||
|
|
@ -98,6 +98,16 @@ public class SoundManager {
|
|||
AL10.alSourcef(sources.get(sourceId).source, AL10.AL_GAIN, 1.0f);
|
||||
AL10.alSourcei(sources.get(sourceId).source, AL10.AL_LOOPING, (loop ? AL10.AL_TRUE : AL10.AL_FALSE) );
|
||||
|
||||
|
||||
AL10.alSource3f(sources.get(sourceId).source, AL10.AL_POSITION,
|
||||
sound.getLocation().getX(),
|
||||
sound.getLocation().getY(),
|
||||
sound.getLocation().getZ());
|
||||
AL10.alSource3f(sources.get(sourceId).source, AL10.AL_VELOCITY,
|
||||
sound.getVelocity().getX(),
|
||||
sound.getVelocity().getY(),
|
||||
sound.getVelocity().getZ());
|
||||
|
||||
AL10.alSourcePlay(sources.get(sourceId).source);
|
||||
sources.get(sourceId).soundId = sound.getSoundId();
|
||||
return sourceId;
|
||||
|
|
@ -179,6 +189,39 @@ public class SoundManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the location of the listener
|
||||
*
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param z The z coordinate
|
||||
*/
|
||||
public void setListenerLocation(float x, float y, float z){
|
||||
AL10.alListener3f(AL10.AL_POSITION, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the velocity of the listener
|
||||
*
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param z The z coordinate
|
||||
*/
|
||||
public void setListenerVelocity(float x, float y, float z){
|
||||
AL10.alListener3f(AL10.AL_VELOCITY, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the orientation of the listener
|
||||
*
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param z The z coordinate
|
||||
*/
|
||||
public void setListenerOrientation(float x, float y, float z){
|
||||
AL10.alListener3f(AL10.AL_ORIENTATION, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1) Identify the error code.
|
||||
* 2) Return the error as a string.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue