MinGfx Toolkit  1.0
A minimal library for writing cross-platform (Windows, OSX, linux) graphics programs.
aabb.h
Go to the documentation of this file.
1 /*
2  This file is part of the MinGfx Project.
3 
4  Copyright (c) 2017,2018 Regents of the University of Minnesota.
5  All Rights Reserved.
6 
7  Original Author(s) of this File:
8  David Schroeder, 2010-ish, University of Minnesota
9 
10  Author(s) of Significant Updates/Modifications to the File:
11  Dan Keefe, 2018, University of Minnesota
12  ...
13  */
14 
15 #ifndef SRC_AABB_H_
16 #define SRC_AABB_H_
17 
18 #include "point3.h"
19 #include "vector3.h"
20 
21 namespace mingfx {
22 
23 // forward declaration
24 class Mesh;
25 
31 class AABB {
32 public:
34  AABB();
35 
37  AABB(const Point3 &a);
38 
40  AABB(const Point3 &a, const Point3 &b, const Point3 &c);
41 
44  AABB(const Vector3 &extents);
45 
48  AABB(const Point3 &center, const Vector3 &extents);
49 
51  AABB(const Mesh &mesh);
52 
54  AABB(const Mesh &mesh, unsigned int tri_id);
55 
56  virtual ~AABB();
57 
60 
63  float Volume() const;
64 
66  Point3 min() const;
67 
69  Point3 max() const;
70 
74  void set_user_data(int data);
75 
79  int user_data();
80 
81 private:
82 
83  Point3 min_, max_;
84 
85  int user_data_;
86 
87  friend AABB operator+(const AABB &A, const AABB &B);
88 };
89 
90 // Returns an AABB that contains both A and B completely (kind of like a union)
91 AABB operator+(const AABB &A, const AABB &B);
92 
93 
94 } // end namespace
95 
96 #endif
A 3D axis-aligned bounding box defined by two corners (min and max).
Definition: aabb.h:31
AABB(const Vector3 &extents)
Box centered at the origin with width, height, and depth specified by the vector.
float Volume() const
Returns the volume of the box or -1.0 when empty and 0.0 if the box contains just a single point.
AABB(const Mesh &mesh, unsigned int tri_id)
Box that contains just triangle number "tri_id" from the specified mesh.
int user_data()
You can set this to whatever you want in order to use it as a handle into your own program....
Point3 min() const
Returns the coordinates for the minimum corner of the box.
Vector3 Dimensions() const
Returns the dimensions of the box in x, y, and z as a 3D vector.
AABB(const Point3 &a)
Box that contains a single point.
friend AABB operator+(const AABB &A, const AABB &B)
AABB(const Point3 &center, const Vector3 &extents)
Box centered at the center with width, height, and depth specified by the vector.
AABB(const Mesh &mesh)
Box that contains a whole mesh.
AABB(const Point3 &a, const Point3 &b, const Point3 &c)
Box that contains a triangle defined by 3 points.
Point3 max() const
Returns the coordinates for the maximum corner of the box.
void set_user_data(int data)
You can set this to whatever you want in order to use it as a handle into your own program....
virtual ~AABB()
AABB()
Creates an empty box.
A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.
Definition: mesh.h:127
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
Definition: point3.h:52
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Definition: vector3.h:62
Namespace for the MinGfx Toolkit.
Definition: aabb.h:21
AABB operator+(const AABB &A, const AABB &B)