IMesh* tmpIMesh = new IMesh(scene->mMeshes[0], tmpModelMat);
models.push_back(tmpIMesh);
tmpIMesh->getBBmm(BBmin, BBmax);
-
+
for (uint i = 1; i < scene->mNumMeshes; i++)
{
- //delete tmpIMesh;
aimat = &(root->mChildren[i]->mTransformation);
tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4);
-
tmpIMesh = new IMesh(scene->mMeshes[i], tmpModelMat);
models.push_back(tmpIMesh);
tmpIMesh->getBBmm(tmpMin, tmpMax);
BBmax[j] = tmpMax[j];
}
}
- //delete tmpIMesh;
updateBB(BBmin, BBmax);
}
else
Message::error("The file " + _modelpath + " doesn't contain any nodes.");
return;
}
-
}
IMetaMesh::~IMetaMesh()
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)),
+viewPort(x, y, width, height, fovy, zNear, zFar),
lookat(_lookat),
-move_delta(0),
-SkyBox(new Sky())
+move_delta(0)
{
-
}
- if (viewPort != nullptr)
- delete viewPort;
+ //if (viewPort != nullptr)
+ // delete viewPort;
+ //if (SkyBox != nullptr)
+ // delete SkyBox;
}
//int reset = Events::getAction2();
// XYAchse um den Player
- viewPort->rotateView(0.002f*Events::getViewX(), 0.001f*Events::getViewY());
+ viewPort.rotateView(0.002f*Events::getViewX(), 0.001f*Events::getViewY());
//Jump
if (Events::getJump() && lookat->floorBound())
// MOVE Player
if (move_x)
- lookat->move(SPEED_MOVE_NORMAL *move_x * deltaT * viewPort->rotateDirection(vec3(-1.f, 0.f, 0.f)));
+ lookat->move(SPEED_MOVE_NORMAL *move_x * deltaT * viewPort.rotateDirection(vec3(-1.f, 0.f, 0.f)));
if (move_y){
if (move_y > 0){
move_delta += deltaT;
if (move_delta > TIME_TILL_MAX_MOVE)
move_delta = TIME_TILL_MAX_MOVE;
- lookat->move(SPEED_MOVE_NORMAL * (MOVE_FASTER * move_delta / TIME_TILL_MAX_MOVE + 1) *move_y * deltaT * viewPort->rotateDirection(vec3(0.f, 0.f, -1.f)));
+ lookat->move(SPEED_MOVE_NORMAL * (MOVE_FASTER * move_delta / TIME_TILL_MAX_MOVE + 1) *move_y * deltaT * viewPort.rotateDirection(vec3(0.f, 0.f, -1.f)));
}
else
- lookat->move(SPEED_MOVE_NORMAL *move_y * deltaT * viewPort->rotateDirection(vec3(0.f, 0.f, -1.f)));
+ lookat->move(SPEED_MOVE_NORMAL *move_y * deltaT * viewPort.rotateDirection(vec3(0.f, 0.f, -1.f)));
}
else
{
//Rotate Play in move direction
if (move_x || move_y)
- lookat->turnTo(viewPort->rotateDirection(vec3(0.f, 0.f, -1.f)), 3 * deltaT / TIME_TILL_DIRECTION_ROTATE);
+ lookat->turnTo(viewPort.rotateDirection(vec3(0.f, 0.f, -1.f)), 3 * deltaT / TIME_TILL_DIRECTION_ROTATE);
//// Zoom auf Player
void Scene::draw() const
{
- viewPort->useViewPort();
+ viewPort.useViewPort();
//Skybox
- viewPort->bindView(SkyBox->getShader(), lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
+ viewPort.bindView(SkyBox.getShader(), lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
//BBox
- viewPort->bindView(Graphix::shader_BBox, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
+ viewPort.bindView(Graphix::shader_BBox, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
for (auto i = ShaderSet.cbegin(); i != ShaderSet.cend(); ++i)
{
- viewPort->bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
-
- //don't know if this is really the right place to set the lighting
- //add ambient light
- //GLfloat ambientcolor[] = { 0.5f, 0.5f, 0.5f, 1.0f };
- //glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientcolor);
-
- //add positioned light
- //GLfloat lightcolor0[] = { 1.5f, 1.5f, 1.5f, 1.0f };
- //GLfloat lightposition0[] = { 1.0f, 1.0f, 1.0f, 1.0f };
- //glLightfv(GL_LIGHT0, GL_DIFFUSE, lightcolor0);
- //glLightfv(GL_LIGHT0, GL_POSITION, lightposition0);
+ viewPort.bindView(*i, lookat->getPosition() + vec3(0.0f, 1.0f, 0.0f));
}
- SkyBox->draw();
+ SkyBox.draw();
for (auto i = SceneObjects.cbegin(); i != SceneObjects.cend(); ++i)
{
#define YFALL_SPEED 9.8f
SceneObject::SceneObject(Shader* _shader, const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath, unsigned int _model_index) :
-model(new IMetaMesh(_modelpath)),
+model(nullptr),
modelMat(_modelMat),
material(_material),
shader(_shader),
//Message::info("Creating modelMat");
//Graphix::getGlError();
//modelID = _shader->getUniformLocation("modelMat");
+ if (_modelpath != "")
+ model = new IMetaMesh(_modelpath);
+
if (texturepath != "")
texture = new Texture(texturepath);
//Message::info("Creating SkyBox Shader");
if (collision_ignore || _other->collision_ignore)
return;
+ vec3 posA, sizeA, posB, sizeB;
+
+ model->getBBsp(sizeA, posA);
+ _other->model->getBBsp(sizeB, posB);
+
+ vec3 pDist, sDist;
+ vec3 overlap, inside;
+ int isOverlaping, isInside;
+
+ sizeA /= 2;
+ sizeB /= 2;
+
+ pDist = posB - posA;
+ pDist *= sign(pDist);
+
+ sDist = sizeB - sizeA;
+ sDist *= sign(sDist);
+
+ overlap =(sizeA + sizeB) - pDist;
+ inside = sDist - pDist;
+
+
+ /* overlapping 1 yes, 0 touch, -1 no*/
+ isOverlaping = sign(glm::min(glm::min(overlap.x, overlap.y), overlap.z));
+ /* inside 1 yes, 0 touch, -1 no*/
+ isInside = sign(glm::min(glm::min(inside.x, inside.y), inside.z));
+
+
+
}
bool SceneObject::floorBound() const
}
-Shader* SceneObject::getShader()
+Shader* SceneObject::getShader() const
{
return shader;
}