kleinere aenderungen
This commit is contained in:
parent
cf11ce691a
commit
9a8fbaf759
|
@ -11,6 +11,11 @@ Sphere::Sphere() {
|
|||
radius = 1.0f;
|
||||
}
|
||||
|
||||
void Sphere::set(Punkt3D _pos, float _radius) {
|
||||
pos = _pos;
|
||||
radius = _radius;
|
||||
}
|
||||
|
||||
bool Sphere::collision(const Sphere &s) const {
|
||||
return ((pos-s.pos)*(pos-s.pos))<((radius+s.radius)*(radius+s.radius));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ class Sphere {
|
|||
Sphere(Punkt3D _pos, float radius);
|
||||
Sphere();
|
||||
|
||||
void set(Punkt3D _pos, float _radius);
|
||||
|
||||
bool collision(const Sphere &s) const;
|
||||
bool collision(const Ray &r) const;
|
||||
bool collision(const Box & b) const;
|
||||
|
|
|
@ -206,9 +206,10 @@ bool LoadOBJ::load(Model *m) {
|
|||
v.clear();
|
||||
}
|
||||
|
||||
// Calculate bounding box
|
||||
// Calculate bounding box and rad for sphere
|
||||
float minx=m->meshdata[0].x, maxx=m->meshdata[0].x, miny=m->meshdata[0].y, maxy=m->meshdata[0].y, minz=m->meshdata[0].z, maxz=m->meshdata[0].z;
|
||||
for(unsigned int i=0; i<m->meshdataanz; i++) {
|
||||
m->boundingrad = std::max(m->boundingrad, abs(m->meshdata[i]));
|
||||
minx = std::min(minx, m->meshdata[i].x);
|
||||
maxx = std::max(maxx, m->meshdata[i].x);
|
||||
miny = std::min(miny, m->meshdata[i].y);
|
||||
|
|
|
@ -108,6 +108,8 @@ Model::Model() {
|
|||
normdataanz = 0;
|
||||
loaded = false;
|
||||
|
||||
boundingrad = 0.0f;
|
||||
|
||||
backupmat.diffuse.set(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Model {
|
|||
void render();
|
||||
|
||||
Quader getBoundingBox() { return boundingbox; }
|
||||
float getBoundingRadius() { return boundingrad; }
|
||||
float getBoundingRad() { return boundingrad; }
|
||||
|
||||
const Punkt3D* getMeshData(unsigned int *meshanz);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue