Scene::Scene(unsigned int x, unsigned int y, unsigned int width, unsigned int height, float fovy, float zNear, float zFar, vec3 pos, SceneObject* _lookat) :
viewPort(new ViewPort(x, y, width, height, fovy, zNear, zFar)),
- projection(perspective(fovy, (float)width / height, zNear, zFar)),
- view(translate(pos)),
SceneObjects(new list<SceneObject*>),
ShaderSet(new set<Shader*>),
newObjects(true),
Scene::Scene(Scene* _Scene, unsigned int x, unsigned int y, unsigned int width, unsigned int height, float fovy, float zNear, float zFar, vec3 pos, SceneObject* _lookat) :
viewPort(new ViewPort(x, y, width, height, fovy, zNear, zFar)),
- projection(perspective(fovy, (float)width / height, zNear, zFar)),
- view(translate(pos)),
SceneObjects(_Scene->SceneObjects),
ShaderSet((_Scene->ShaderSet)),
newObjects(false),
if (lookat != NULL){
pos = lookat->getPosition();
- view = view*translate(-pos);
}
int move_x = Events::getMoveX();
}
- if (lookat != NULL)
- view = view*translate(lookat->getPosition());
-
}
void Scene::draw() const
for (auto i = ShaderSet->cbegin(); i != ShaderSet->cend(); ++i)
{
viewPort->bindView(*i,lookat->getPosition()+vec3(0.0f,1.0f,0.0f));
- //(*i)->useShader();
- //glUniformMatrix4fv((*i)->getUniformLocation("projection"), 1, false, value_ptr(projection));
- //glUniformMatrix4fv((*i)->getUniformLocation("view"), 1, false, value_ptr(view));
}
SceneObjects->remove(_del);
}
-const vec3 Scene::getViewerPos() const
-{
- return vec3(projection * vec4(0.0f));
-}
list<SceneObject*>* Scene::getSceneObjects()
{
return SceneObjects;
}
-//void Scene::setProjection(mat4 _projection)
-//{
-// projection = _projection;
-//}
-
-void Scene::setProjection(float fovy, float aspect, float zNear, float zFar)
-{
- projection = perspective(fovy, aspect, zNear, zFar);
-}
-
-/*
-void Scene::updateProjection(mat4 _projection)
-{
- projection = _projection * projection;
-}*/
-
-//void Scene::setViewPort(unsigned int x, unsigned int y, unsigned int width, unsigned int height)
-//{
-// viewPort = new ViewPort(x, y, width, height);
-//}
void Scene::setLookAt(SceneObject* _lookat)
{
void addObject(SceneObject*);
void deleteObject(SceneObject*);
- const vec3 getViewerPos() const;
-
SceneList* getSceneObjects();
-// void setViewPort(unsigned int, unsigned int, unsigned int, unsigned int);
-
-// void setProjection(mat4 _projection);
- void setProjection(float fovy, float aspect, float zNear, float zFar);
- //void updateProjection(mat4);
-
void setLookAt(SceneObject* _lookat);
protected:
ViewPort* viewPort;
- mat4 projection;
- mat4 view;
SceneObject* lookat;
projection(perspective(fovy, (float)width / height, zNear, zFar)),
view_angle_x(0),
view_angle_y(0),
- view_dist(2)
+ view_dist(2),
+ view(0.f)
{
rotateView(0.f, 0.f);
}
if (angle_y || angle_x){
- view_angle_x += angle_x;
- view_angle_y += angle_y;
+ view_angle_x -= angle_x;
+ view_angle_y -= angle_y;
//Y-Limits
if (view_angle_y > VIEW_TOP_LIM)
if (view_angle_y < VIEW_BOT_LIM)
view_angle_y = VIEW_BOT_LIM;
+ //keine Ahnung warum hier noch durch 50 geteilt werden muss, sonst ists aber irgend wie falsch
view = translate(vec3(0.f, 0.f, -view_dist))*rotate(view_angle_y / 50, vec3(1.f, 0.f, 0.f))*rotate(view_angle_x / 50, vec3(0.f, 1.f, 0.f));
}