#include "GLM.h"
+typedef unsigned int uint;
+
float VektorAbs(const vec3& vek)
{
return sqrt(vek.x*vek.x + vek.y*vek.y + vek.z*vek.z);
updMax[j] = inpMax[j];
}
}
+
+void scaleVec3(vec3& _vec, const vec3& _scale)
+{
+ for (uint i = 0; i < 3; ++i)
+ _vec[i] *= _scale[i];
+}
+
void updateVec3MinMax(vec3& updMin, vec3& updMax, const vec3& inpMin, const vec3& inpMax);
+void scaleVec3(vec3& _vec, const vec3& _scale);
+
float vertex[] { -.5f, -.5f, -.5f, .5f, -.5f, -.5f, .5f, .5f, -.5f, -.5f, .5f, -.5f, -.5f, -.5f, .5f, .5f, -.5f, .5f, .5f, .5f, .5f, -.5f, .5f, .5f };
- updateBB(vec3(-.5f), vec3(.5f));
+ setBB(vec3(-.5f), vec3(.5f));
//import("skybox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0);
// Vergleiche Unterbaum
//#define COMPARE_MTREE
//draw BBox of MTREE deep LVL -1 means all lvl's
-#define BBOX_MTREE 7
+#define BBOX_MTREE 10
// Vergleiche auch Triangles
#define COMPARE_FACE
import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex);
#ifdef COMPARE_MTREE
- root = buildMeshTree(modelMat, numvertices, numfaces, vertex, normals, index);
+ root = buildMeshTree(mat4(1.f), numvertices, numfaces, vertex, normals, index);
vec3 min, max;
root->getBBmm(min, max);
- updateBB(min, max);
+ setBB(min, max);
#else
- updateBB(numvertices, vertex);
+ setBB(numvertices, vertex);
#endif
genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
import(_mesh, numvertices, numfaces, vertex, uvs, normals, index);
#ifdef COMPARE_MTREE
- root = buildMeshTree(modelMat, numvertices, numfaces, vertex, normals, index);
+ root = buildMeshTree(_transformation, numvertices, numfaces, vertex, normals, index);
vec3 min, max;
root->getBBmm(min, max);
- updateBB(min, max);
+ setBB(min, max);
#else
- updateBB(numvertices, vertex,modelMat);
+ setBB(numvertices, vertex, _transformation);
#endif
genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
//
//}
+Overlap IMesh::checkColNode2O(const Node* _node, const vec3& _scale, const mat4& _mOSMat, const Model* _model, const mat4& _modelMat) const
+{
+ vec3 pos;
+ vec3 size;
+ _node->getBBcs(pos, size);
+
+ scaleVec3(pos, _scale);
+ scaleVec3(size, _scale);
+
+ Overlap stepNode = _model->checkColO2SBox(_modelMat, pos, size,_mOSMat);
+
+ //Falls _node nicht overlap
+ if (!stepNode)
+ return stepNode;
+
+ //check sub _nodes
+ if (_node->getElement() == nullptr)
+ {
+ Overlap left = checkColNode2O(_node->getLNode(), _scale, _mOSMat, _model, _modelMat);
+ Overlap right = checkColNode2O(_node->getUNode(), _scale, _mOSMat, _model, _modelMat);
+ Overlap stepSub;
+ if (left)
+ stepSub.update(left);
+ if (right)
+ stepSub.update(right);
+
+ return stepSub;
+ }
+ else
+ {
+ //TODO ELEMENT CHECK
+ return stepNode;
+ }
+
+}
+
+Overlap IMesh::checkColO2NodeBox(const Node* _node, const vec3& _scale, const mat4& _mOSMat, const vec3& _pos, const vec3& _size, const mat4& _modelMat) const
+{
+ //vec3 pos;
+ //vec3 size;
+ //_node->getBBcs(pos, size);
+
+ //scaleVec3(pos, _scale);
+ //scaleVec3(size, _scale);
+
+ //Overlap stepNode = checkColO2SBox(_modelMat, pos, size, _mOSMat);
+
+ ////Falls _node nicht overlap
+ //if (!stepNode)
+ // return stepNode;
+
+ ////check sub _nodes
+ //if (_node->getElement() == nullptr)
+ //{
+ // Overlap left = checkColNode2O(_node->getLNode(), _scale, _mOSMat, _model, _modelMat);
+ // Overlap right = checkColNode2O(_node->getUNode(), _scale, _mOSMat, _model, _modelMat);
+ // Overlap stepSub;
+ // if (left)
+ // stepSub.update(left);
+ // if (right)
+ // stepSub.update(right);
+
+ // return stepSub;
+ //}
+ //else
+ //{
+ // //TODO ELEMENT CHECK
+ // return stepNode;
+ //}
+ return Overlap();
+}
+
Overlap IMesh::checkColS2O(const mat4& _mMat, const Model* _model, const mat4& _modelMat) const
{
- //Outer BBox
+ //Outer BBoxes
+#ifdef COMPARE_MTREE
+ vec3 scale = getScale(_mMat);
+ Overlap firstBB = checkColNode2O(root, scale, removeScale(_mMat), _model, _modelMat);
+#else
Overlap firstBB = Model::checkColS2O(_mMat, _model, _modelMat);
+#endif
+
//if (!firstBB)
return firstBB;
Overlap IMesh::checkColO2SBox(const mat4& _mMat, const vec3& _pos, const vec3& _size, const mat4& _modelMat) const
{
//Outer Mesh
+//#ifdef COMPARE_MTREE
+// vec3 scale = getScale(_mMat);
+// Overlap firstBB = checkColO2NodeBox(root, scale, removeScale(_mMat), _pos, _size, _modelMat);
+//#else
Overlap firstBB = Model::checkColO2SBox(_mMat, _pos, _size, _modelMat);
+//#endif
+
//if (!firstBB)
return firstBB;
return "IMesh";
}
-void getPSfromNodeList(vec3& center, vec3& size, const list<Node*>& TriList)
+void getCSfromNodeList(vec3& _center, vec3& _size, const list<Node*>& _TriList)
{
vec3 BBmin, BBmax;
- TriList.front()->getBBmm(BBmin, BBmax);
- for (auto k = TriList.cbegin(); k != TriList.cend(); ++k)
+ _TriList.front()->getBBmm(BBmin, BBmax);
+ for (auto k = _TriList.cbegin(); k != _TriList.cend(); ++k)
{
(*k)->getUBBmm(BBmin, BBmax);
}
- size = (BBmax - BBmin) / 2.f;
- center = (BBmin + BBmax) / 2.f;
+ _size = (BBmax - BBmin) / 2.f;
+ _center = (BBmin + BBmax) / 2.f;
+}
+
+void getMMfromNodeList(vec3& _min, vec3& _max, const list<Node*>& _TriList)
+{
+ _TriList.front()->getBBmm(_min, _max);
+ for (auto k = _TriList.cbegin(); k != _TriList.cend(); ++k)
+ {
+ (*k)->getUBBmm(_min, _max);
+ }
}
-Node* IMesh::buildMeshTree(const list<Node*>& _triList, vec3 center, vec3 size)
+Node* IMesh::buildMeshTree(const list<Node*>& _triList, vec3 _min, vec3 _max)
{
//catch if list is empty
if (_triList.size() == 0)
return _triList.front();
//catch if list has only two elements => 2 LEAFS
if (_triList.size() == 2)
- return new Node(center, size, _triList.front(), _triList.back());
+ return new Node(_min, _max, _triList.front(), _triList.back());
if (_triList.size() == 3)
{
- vec3 nC, nS;
+ vec3 nMi, nMa;
list<Node*> tmpList = _triList;
Node* tmpNode = tmpList.front();
tmpList.pop_front();
- getPSfromNodeList(nC, nS, tmpList);
+ getMMfromNodeList(nMi, nMa, tmpList);
- return new Node(center, size, tmpNode, buildMeshTree(tmpList, nC, nS));
+ return new Node(_min, _max, tmpNode, buildMeshTree(tmpList, nMi, nMa));
}
-
+ vec3 size = (_min - _max) / 2.f;
+ vec3 center = (_min + _max) / 2.f;
//find longest dist
vec3 sort = sortVec3(size);
dim = bestDim;
- return new Node(center, size, buildMeshTree(lower[dim], (lMin[dim] + lMax[dim]) / 2.f, (lMax[dim] - lMin[dim]) / 2.f),
- buildMeshTree(upper[dim], (uMin[dim] + uMax[dim]) / 2.f, (uMax[dim] - uMin[dim]) / 2.f));
+ return new Node(_min, _max, buildMeshTree(lower[dim], lMin[dim], lMax[dim]),
+ buildMeshTree(upper[dim], uMin[dim], uMax[dim]));
}
Node* IMesh::buildMeshTree(const mat4& modelMat, const uint& numvertices, const uint& numfaces, const float* vertex, const float* normals, const uint* index)
tmp_normal *= -1;
node_list.push_back(new Node(new Triangle(tmp_vert, tmp_normal)));
}
- vec3 center, size;
- getPSfromNodeList(center, size, node_list);
+ vec3 min, max;
+ getMMfromNodeList(min, max, node_list);
- return buildMeshTree(node_list, center, size);
+ return buildMeshTree(node_list, min, max);
}
//{
//}
-Node::Node(const vec3& _center, const vec3& _size, Node* _lower, Node* _upper)
- : element(nullptr), lNode(_lower), uNode(_upper), splitDim(-1), center(_center), size(_size)
+Node::Node(const vec3& _min, const vec3& _max, Node* _lower, Node* _upper)
+ : element(nullptr), lNode(_lower), uNode(_upper), splitDim(-1), center((_min + _max) / 2.f), size((_max - _min) / 2.f), min(_min), max(_max)
{
}
Overlap checkColO2SBox(const mat4& mMat, const vec3& pos, const vec3& size, const mat4& modelMat) const override;
Overlap checkColO2STriangle(const mat4& mMat, const vec3& pos, const mat3& directions) const override;
+ Overlap checkColNode2O(const Node* node, const vec3& scale, const mat4& mOSMat, const Model* model, const mat4& modelMat) const;
+ Overlap checkColO2NodeBox(const Node* node, const vec3& scale, const mat4& mOSMat, const vec3& pos, const vec3& size, const mat4& modelMat) const;
+
operator std::string() const override;
static Node* buildMeshTree(const mat4& modelMat, const uint& numvertices, const uint& numfaces, const float* vertex, const float* normals, const uint* index);
- static Node* buildMeshTree(const std::list<IMesh::Node*>& triList, vec3 center, vec3 size);
+ static Node* buildMeshTree(const std::list<IMesh::Node*>& triList, vec3 min, vec3 max);
class Node
{
public:
Node(Triangle* tri);
//Node(Triangle* tri, const vec3& center, const vec3& size, const vec3& min, const vec3& max);
- Node::Node(const vec3& center, const vec3& size, Node* lower, Node* upper);
+ Node::Node(const vec3& min, const vec3& max, Node* lower, Node* upper);
~Node();
/* sets center & size */
const aiNode* root = scene->mRootNode;
- aiMatrix4x4* aimat;
- mat4 tmpModelMat;
- vec3 BBmin, BBmax, tmpMin, tmpMax;
+
if (scene->HasMeshes())// && scene->mNumMeshes > mindex)
{
- aimat = &(root->mChildren[0]->mTransformation);
+ IMesh* tmpIMesh;
+ aiMatrix4x4* aimat;
+ mat4 tmpModelMat;
+ //vec3 BBmin, BBmax, tmpMin, tmpMax;
+
+ //aimat = &(root->mChildren[0]->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);
+ //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);
- IMesh* tmpIMesh = new IMesh(scene->mMeshes[0], tmpModelMat);
- models.push_back(tmpIMesh);
- tmpIMesh->getBBmm(BBmin, BBmax);
+ //tmpIMesh = new IMesh(scene->mMeshes[0], tmpModelMat);
+ //models.push_back(tmpIMesh);
+ //tmpIMesh->getBBmm(BBmin, BBmax);
- for (uint i = 1; i < scene->mNumMeshes; i++)
+ for (uint i = 0; i < scene->mNumMeshes; i++)
{
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);
- for (auto j = 0; j < 3; ++j)
- {
- if (tmpMin[j] < BBmin[j])
- BBmin[j] = tmpMin[j];
- if (tmpMax[j] > BBmax[j])
- BBmax[j] = tmpMax[j];
- }
+ updateBB(tmpIMesh->getBBox());
+ //tmpIMesh->getBBmm(tmpMin, tmpMax);
+ //for (auto j = 0; j < 3; ++j)
+ //{
+ // if (tmpMin[j] < BBmin[j])
+ // BBmin[j] = tmpMin[j];
+ // if (tmpMax[j] > BBmax[j])
+ // BBmax[j] = tmpMax[j];
+ //}
}
- updateBB(BBmin, BBmax);
+
+ //setBB(BBmin, BBmax);
}
else
{
void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const
{
+ Model::drawBBox(_modelMat, vec4(0.f,.9f,.9f,1.f));
if (models.size() == 1)
models.front()->drawBBox(_modelMat, _color);
else
#include "../../Events.h"
+typedef Model::Triangle Triangle;
+typedef Model::Box Box;
+
Model::Model() :
numfaces(0),
numvertices(0),
void Model::drawBBox(const mat4& _modelMat, const vec4& _color) const
{
- vec3 BBsiz, BBpos;
- getBBsp(BBsiz, BBpos);
Graphix::getGlError();
Graphix::shader_BBox->useShader();
int tmp = Graphix::shader_BBox->getUniformLocation("uFragmentColor");
if (tmp >= 0)
glUniform4fv(tmp, 1, value_ptr(_color));
Graphix::getGlError();
- getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(BBpos)*glm::scale(BBsiz*2.f));
+ getBBoxModel()->drawModel(Graphix::shader_BBox, NULL, _modelMat*translate(box.center())*glm::scale(box.size()*2.f));
}
-void Model::updateBB(const vec3& _min, const vec3& _max)
+void Model::setBB(const vec3& _min, const vec3& _max)
{
- BBmin = _min;
- BBmax = _max;
- BBsize = (BBmax - BBmin) / 2.f;
- BBposition = (BBmin + BBmax) / 2.f;
+ box = Box((_min + _max) * .5f, (_max - _min) * .5f);
}
-void Model::updateBB(const uint _numvertices, const float* _vertices)
+void Model::setBB(const uint _numvertices, const float* _vertices)
{
- BBmin = vec3(_vertices[0], _vertices[1], _vertices[2]);
- BBmax = BBmin;
+ vec3 BBmin = vec3(_vertices[0], _vertices[1], _vertices[2]);
+ vec3 BBmax = BBmin;
for (uint i = 3; i < _numvertices * 3; ++i)
{
if (_vertices[i] < BBmin[i % 3])
BBmax[i % 3] = _vertices[i];
}
- BBsize = (BBmax - BBmin) / 2.f;
- BBposition = (BBmin + BBmax) / 2.f;
+ box = Box((BBmin + BBmax) * .5f, (BBmax - BBmin) * .5f);
}
-void Model::updateBB(const uint _numvertices, const float* _vertices, const mat4& _modelMat)
+void Model::setBB(const uint _numvertices, const float* _vertices, const mat4& _modelMat)
{
- BBmin = (vec3)(_modelMat * vec4(_vertices[0], _vertices[1], _vertices[2], 1.f));
- BBmax = BBmin;
+ vec3 BBmin = (vec3)(_modelMat * vec4(_vertices[0], _vertices[1], _vertices[2], 1.f));
+ vec3 BBmax = BBmin;
vec3 tmpVert;
for (uint j = 3; j < _numvertices * 3; j += 3)
{
}
}
- BBsize = (BBmax - BBmin) / 2.f;
- BBposition = (BBmin + BBmax) / 2.f;
+ box = Box((BBmin + BBmax) * .5f, (BBmax - BBmin) * .5f);
}
-
-void Model::getBBmm(vec3& _min, vec3& _max) const
+void Model::updateBB(const Box& _box)
{
- _min = BBmin;
- _max = BBmax;
+ box = Box::merge(box, _box);
}
-void Model::getBBsp(vec3& _size, vec3& _position) const
+//void Model::getBBmm(vec3& _min, vec3& _max) const
+//{
+// _min = BBmin;
+// _max = BBmax;
+//}
+
+void Model::getBBcs(vec3& _center, vec3& _size) const
{
- _size = BBsize;
- _position = BBposition;
+ _size = box.size();
+ _center = box.center();
}
+Box Model::getBBox() const
+{
+ return box;
+}
void Model::genBuffer(uint &buffer, uint size, void* value)
{
Overlap Model::checkColS2O(const mat4& _mMat, const Model* _model, const mat4& _modelMat) const
{
vec3 scale = getScale(_mMat);
- vec3 pos = BBposition;
+ vec3 pos = box.center();
+ vec3 size = box.size();
+
scaleVec3(pos, scale);
- vec3 size = BBsize;
scaleVec3(size, scale);
Overlap stepBB = _model->checkColO2SBox(_modelMat, pos, size, removeScale(_mMat));
Overlap Model::checkColO2SBox(const mat4& _mMat, const vec3& _posB, const vec3& _sizeB, const mat4& _modelMatB) const
{
vec3 scale = getScale(_mMat);
- vec3 posA = BBposition;
+ vec3 posA = box.center();
+ vec3 sizeA = box.size();
+
scaleVec3(posA, scale);
- vec3 sizeA = BBsize;
scaleVec3(sizeA, scale);
mat4 mMat = removeScale(_mMat);
Overlap Model::checkColO2STriangle(const mat4& _mMat, const vec3& _posB, const mat3& _directionsB) const
{
- vec3 posA = BBposition;
- vec3 sizeA = BBsize;
+ vec3 posA = box.center();
+ vec3 sizeA = box.size();
vec3 scale = getScale(_mMat);
scaleVec3(posA, scale);
return ret;
}
-void Model::scaleVec3(vec3& _vec, const vec3& _scale)
-{
- for (uint i = 0; i < 3; ++i)
- _vec[i] *= _scale[i];
-}
-
-
Model* Model::getBBoxModel()
{
if (BoundingBox == nullptr)
{
vec3 posA, sizeA;
- getBBsp(sizeA, posA);
+ getBBcs(posA, sizeA);
//vec3 posAR = (vec3)(modelAR*vec4(posA, 1.f));
//vec3 posBR = (vec3)(modelBR*vec4(posB, 1.f));
std::unordered_map<string, Model*> Model::IMetaModel;
std::unordered_map<string, uint> Model::IMetaModel_count;
-Model::Triangle::Triangle(const mat3& _vertex, const vec3& _normal) : vertex(_vertex), normal(normalize(_normal))
+// CLASS TRIANGLE
+
+Triangle::Triangle(const mat3& _vertex, const vec3& _normal) : vertex(_vertex), normal(normalize(_normal))
{
}
-Model::Triangle::~Triangle()
+Triangle::~Triangle()
{
}
-void Model::Triangle::getBBcs(vec3& center, vec3& size) const
+void Triangle::getBBcs(vec3& center, vec3& size) const
{
vec3 BBmin = vertex[0];
vec3 BBmax = BBmin;
center = (BBmin + BBmax) / 2.f;
}
-void Model::Triangle::getBBmm(vec3& min, vec3& max) const
+void Triangle::getBBmm(vec3& min, vec3& max) const
{
min = vertex[0];
max = min;
getUBBmm(min, max);
}
-void Model::Triangle::getUBBmm(vec3& min, vec3& max) const
+void Triangle::getUBBmm(vec3& min, vec3& max) const
{
for (uint i = 0; i < 3; ++i)
{
}
}
-vec3 Model::Triangle::getMean() const
+vec3 Triangle::getMean() const
{
return (vertex[0] + vertex[1] + vertex[2]) / 3.f;
+}
+
+//CLASS BOX
+
+Box::Box() : cen(0.f), siz(0.f)
+{}
+
+Box::Box(const vec3& _center, const vec3& _size) : cen(_center), siz(_size)
+{
+}
+
+Box::Box(const Box& _box) : cen(_box.cen), siz(_box.siz)
+{
+}
+
+Box::~Box()
+{
+}
+
+void Box::getBBcs(vec3& _center, vec3& _size) const
+{
+ _center = cen;
+ _size = siz;
+}
+
+vec3 Box::center() const
+{
+ return cen;
+}
+
+vec3 Box::size() const
+{
+ return siz;
+}
+
+Box Box::merge(const Box& _boxA, const Box& _boxB)
+{
+ vec3 diff = _boxB.cen - _boxA.cen;
+ vec3 size;
+ vec3 center;
+ for (int i = 0; i<3; ++i)
+ {
+ if (abs(_boxA.siz[i] - _boxB.siz[i]) - abs(diff[i]) >= 0)
+ {
+ if (_boxA.siz[i] > _boxB.siz[i])
+ {
+ size[i] = _boxA.siz[i];
+ center[i] = _boxA.cen[i];
+ }
+ else
+ {
+ size[i] = _boxB.siz[i];
+ center[i] = _boxB.cen[i];
+ }
+ }
+ else
+ {
+ size[i] = (_boxA.siz[i] + _boxB.siz[i] + abs(diff[i])) * .5f;
+ center[i] = _boxA.cen[i] - sign(diff[i]) * _boxA.siz[i] - size[i];
+ }
+
+ }
+ return Box(center,size);
}
\ No newline at end of file
class Model
{
public:
+ class Triangle;
+ class Box;
/* Binds Model to the Model*/
virtual void bindShader(Shader* shader);
virtual void drawBBox(const mat4& modelMat, const vec4& color = vec4(0.9f, 0.f, 0.f, 1.f)) const;
/* Get min&max from BBox */
- virtual void getBBmm(vec3& min, vec3& max) const;
+// virtual void getBBmm(vec3& min, vec3& max) const;
/* Get size&position from BBox */
- virtual void getBBsp(vec3& size, vec3& pos) const;
+ virtual void getBBcs(vec3& center, vec3& size) const;
+
+ Box getBBox() const;
/* calls Colliding to check if self collides with model*/
static Overlap isColliding(const Model* modelThis, const Model* modelOther, const mat4& modelMatThis, const mat4& modelMatOther);
{
public:
Triangle(const mat3& vertex, const vec3& normal);
+ Triangle(const Triangle& tri) = default;
~Triangle();
/* sets center & size */
};
+ class Box
+ {
+ public:
+ Box();
+ Box(const Box& box);
+ Box(const vec3& center, const vec3& size);
+ ~Box();
+
+ //Box& operator=(const Box& box) const;
+
+ void getBBcs(vec3& center, vec3& size) const;
+
+ static Box merge(const Box& boxA, const Box& boxB);
+ vec3 center() const;
+ vec3 size() const;
+ protected:
+ vec3 cen;
+ vec3 siz;
+ };
+
// Mesh Speichern?
static bool import(const std::string& modelpath, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, uint mindex = 0);
static bool import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index);
std::unordered_map<uint, uint> shader_map;
- void updateBB(const vec3& min, const vec3& max);
- void updateBB(const uint numvertices, const float* vertices);
- void updateBB(const uint numvertices, const float* vertices, const mat4& modelMat);
+ void setBB(const vec3& min, const vec3& max);
+ void setBB(const uint numvertices, const float* vertices);
+ void setBB(const uint numvertices, const float* vertices, const mat4& modelMat);
+
+ void updateBB(const Box& box);
void genBuffer(uint &buffer, uint size, void* value);
void bindBuffer(const uint &buffer, const uint index, const uint dim = 3);
static void checkCollideByAxis(float& overlap, float& inside, uint dim, const float* posA, const float* posB, const float* sizeA, const float* sizeB);
- static void scaleVec3(vec3& vec, const vec3& scale);
static vec3 rotateSize(const vec3& size, const mat4& modelMat);
static float directSize(const vec3& size, const vec3& direction);
private:
- vec3 BBmin, BBmax;
- vec3 BBsize, BBposition;
+// vec3 BBmin, BBmax;
+// vec3 BBsize, BBposition;
+
+ Box box;
};
\ No newline at end of file
SkyBox::SkyBox()
{
- numvertices = 4;
- numfaces = 2;
float *vertex = nullptr, *normals = nullptr, *uvs = nullptr;
uint *index = nullptr;
- //float vertex[] { -1.f, - 1.f, 0.f, 1.f, - 1.f, 0.f, - 1.f, 1.f, 0.f, 1.f, 1.f, 0.f };
- //uint index[] { 1,3,2,0,1,2};
-
import("SkyBox.dae", numvertices, numfaces, vertex, uvs, normals, index, 0);
genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);