added camera and removed old sound dident work whit the sound system. There is one problem whit the sound system its to quiet
This commit is contained in:
parent
28c3cd0529
commit
448fca2fdf
19 changed files with 833 additions and 36 deletions
79
src/ei/engine/renderer/Camera.java
Normal file
79
src/ei/engine/renderer/Camera.java
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
package ei.engine.renderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import ei.engine.LWJGLGameWindow;
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.sound.SoundManager;
|
||||
|
||||
|
||||
/**
|
||||
* The Camera calss hadels the viewport of the user
|
||||
* and the sound listener location
|
||||
* @author Ziver
|
||||
*
|
||||
*/
|
||||
public class Camera{
|
||||
//coordinat
|
||||
private Vector3f location;
|
||||
//Sound
|
||||
private Vector3f velocity;
|
||||
|
||||
/**
|
||||
* Creates a camera
|
||||
*
|
||||
*/
|
||||
public Camera(){
|
||||
location = new Vector3f();
|
||||
velocity = new Vector3f();
|
||||
|
||||
SoundManager.getInstnace().setListenerLocation(
|
||||
location.getX() + (LWJGLGameWindow.getWidth()/2),
|
||||
location.getY() + (LWJGLGameWindow.getHeight()/2),
|
||||
location.getZ());
|
||||
SoundManager.getInstnace().setListenerVelocity(
|
||||
velocity.getX(),
|
||||
velocity.getY(),
|
||||
velocity.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the camera
|
||||
*
|
||||
*/
|
||||
public void update(){
|
||||
SoundManager.getInstnace().setListenerLocation(
|
||||
location.getX() + (LWJGLGameWindow.getWidth()/2),
|
||||
location.getY() + (LWJGLGameWindow.getHeight()/2),
|
||||
location.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the camera
|
||||
*
|
||||
* @return The location of the camera
|
||||
*/
|
||||
public Vector3f getLocation(){
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the world in opengl
|
||||
* should be used before rendering.
|
||||
*/
|
||||
public void setWorldTranslationGL(){
|
||||
// translate to the right location and prepare to draw
|
||||
GL11.glTranslatef(-location.getX(), -location.getY(), -location.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the location of the camera
|
||||
*
|
||||
* @param v The location of the camera
|
||||
*/
|
||||
public void setLocation(Vector3f v){
|
||||
location = v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue