#include "BBox.h"
#include "GL\glew.h"
-uint indexL1[4]{ 0, 1, 2, 3 },
-indexL2[4]{ 4, 5, 6, 7},
-indexS1[8]{0, 4, 1, 5, 2, 6, 3, 7};
BBox::BBox()
{
void BBox::drawModel() const
{
+ uint indexL1[4]{ 0, 1, 2, 3 },
+ indexL2[4]{ 4, 5, 6, 7},
+ indexS1[8]{0, 4, 1, 5, 2, 6, 3, 7};
+
//glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, 0);
glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL1);
glDrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_INT, indexL2);
import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex);
- updateBB(vertex);
+ updateBB(numvertices,vertex);
genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals);
import(_mesh, numvertices, numfaces, vertex, uvs, normals, index);
- updateBB(vertex);
+ updateBB(numvertices,vertex,modelMat);
genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals);
BBposition = (_min + _max) / 2.f;
}
-void Model::updateBB(const float* _vertices)
+void Model::updateBB(const uint _numvertices, const float* _vertices)
{
BBmin = vec3(_vertices[0], _vertices[1], _vertices[2]);
BBmax = BBmin;
- for (auto i = 3; i < numvertices * 3; ++i)
+ for (auto i = 3; i < _numvertices * 3; ++i)
{
if (_vertices[i] < BBmin[i % 3])
BBmin[i % 3] = _vertices[i];
BBposition = (BBmin + BBmax) / 2.f;
}
+void Model::updateBB(const uint _numvertices, const float* _vertices, const mat4& _modelMat)
+{
+ BBmin = (vec3)(_modelMat * vec4(_vertices[0], _vertices[1], _vertices[2],1.f));
+ BBmax = BBmin;
+ vec3 tmpVert;
+ for (auto j = 3; j < _numvertices * 3; j += 3)
+ {
+ tmpVert = (vec3)(_modelMat * vec4(_vertices[j], _vertices[j + 1], _vertices[j + 2], 1));
+ for (auto i = 0; i < 3; ++i)
+ {
+ if (tmpVert[i] < BBmin[i])
+ BBmin[i] = tmpVert[i];
+ if (tmpVert[i] > BBmax[i])
+ BBmax[i] = tmpVert[i];
+ }
+ }
+
+ BBsize = BBmax - BBmin;
+ BBposition = (BBmin + BBmax) / 2.f;
+}
+
void Model::getBBmm(vec3& _min, vec3& _max) const
{
std::unordered_map<uint, uint> shader_map;
void updateBB(const vec3& min, const vec3& max);
- void updateBB(const float* vertices);
+ void updateBB(const uint numvertices, const float* vertices);
+ void updateBB(const uint numvertices, const float* vertices, const mat4& modelMat);
void genBuffer(uint &buffer, uint size, void* value);
void bindBuffer(const uint &buffer, const uint index, const uint dim = 3);
@echo off
-C:\Programme\WinRar\rar a -r -x*.blend -x*.blend* -x*.pdb -x*.psb -x*.psd CGUE.zip textures models shader bin
+C:\Programme\WinRar\rar a -r -x*.blend -x*.blend* -x*.pdb -x*.psb -x*.psd CGUE.rar textures models shader bin
#pause
\ No newline at end of file