// Shader* shaderSky = new Shader("skybox_VS.hlsl", "skybox_FS.hlsl");
// load LVL
- current_world->addObject(new SceneObject(shader1, scale(3.f * vec3(1.f, .3f, 1.f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png"));
+ SceneObject* tmp_world = new SceneObject(shader1, scale(3.f * vec3(1.f, .3f, 1.f)), vec4(4.0f, 1.0f, 1.0f, 2.0f), "level_test.dae", "model_levelTest_2D.png");
+ tmp_world->ignore = true;
+ current_world->addObject(tmp_world);
current_world->addObject(new SceneObject(shader1, translate(vec3(-3.f, 1.f, 0.f)), vec4(1.0f, 1.0f, 1.0f, 3.0f), new BBox(), ""));
return true;
}
+
+void IMesh::isColliding(int& _overlap, int& _inside, const Model* _model, const mat4& _modelMatThis, const mat4& _modelMatOther) const
+{
+ Model::isColliding(_overlap, _inside, _model, _modelMatThis*modelMat, _modelMatOther);
+}
\ No newline at end of file
//void bindShader(Shader* shader);
+ /* calls Colliding to check if self collides with model*/
+ virtual void isColliding(int& overlap, int& inside, const Model* model, const mat4& modelMatThis, const mat4& modelMatOther) const;
+
+
protected:
mat4 modelMat;
getBBsp(sizeA, posA);
_model->getBBsp(sizeB, posB);
- posA = (vec3)(_modelMatThis*vec4(posA, 1.f));
+ posA = (vec3)(_modelMatThis*vec4(posA, 1.f)); //transpose sollte eigentlich reichen
posB = (vec3)(_modelMatOther*vec4(posB, 1.f));
- sizeA = (mat3)_modelMatThis * sizeA;
- sizeB = (mat3)_modelMatOther * sizeB;
+ sizeA = rotateSize(sizeA, _modelMatThis);
+ sizeB = rotateSize(sizeB, _modelMatOther);
vec3 pDist, sDist;
vec3 overlap, inside;
_inside = (int)sign(glm::min(glm::min(inside.x, inside.y), inside.z));
}
+vec3 Model::rotateSize(const vec3& _size, const mat4& _modelMat)
+{
+ vec3 Size = vec3(0.f);
+ vec4 tmp;
+ for (auto i = 0; i < 3; ++i)
+ {
+ tmp = vec4(0.f);
+ tmp[i] = _size[i];
+ Size += abs((vec3)(_modelMat* tmp));
+ }
+ return Size;
+}
+
Model* Model::BoundingBox = nullptr;
Shader* Model::BBoxShader = nullptr;
static Shader* BBoxShader;
static bool exBBox;
+ static vec3 rotateSize(const vec3& size, const mat4& modelMat);
+
vec3 BBmin, BBmax;
private:
collision_ignore(false),
texture(nullptr),
ySpeed(0),
-yStatic(true)
+yStatic(true),
+ignore(false)
{
//Message::info("Error from befor?");
//Graphix::getGlError();
collision_ignore(false),
texture(nullptr),
ySpeed(0),
-yStatic(true)
+yStatic(true),
+ignore(false)
{
//Message::info("Error from befor?");
//Graphix::getGlError();
model->isColliding(isOverlaping,isInside,_other->model,modelMat,_other->modelMat);
/* overlapping 1 yes, 0 touch, -1 no*/
/* inside 1 yes, 0 touch, -1 no*/
- //if (isOverlaping >= 0)
- // Message::info("Kollision");
+ if ((texture != nullptr && texture->operator std::string() == "model_player_2D.png") || _other->texture != nullptr && (_other->texture->operator std::string() == "model_player_2D.png"))
+ {
+ if (isOverlaping >= 0 && (!ignore && !_other->ignore))
+ Message::info("Kollision");
+ }
}
bool SceneObject::floorBound() const
bool yStatic;
float ySpeed;
+ bool ignore;
+
protected:
+
+
mat4 modelMat;
vec4 material;
Shader* shader;