worked on 3D model stuff

minor changes
This commit is contained in:
2018-02-12 16:57:08 +01:00
parent 2a923dfabc
commit 42a3a47317
3 changed files with 164 additions and 12 deletions

View File

@@ -9,13 +9,26 @@ namespace Ray3D {
class Cube : public Mesh {
public:
private:
/** ctor */
Cube() {
unitCube(true);
//unitCube(true);
}
public:
// Cube (const Point3 p1, const Point3 p2, const Point3 p3, const Point3 p4, const float h) {
//// const Point3 ph(0,0,h);
//// addQuad(p1+ph, p2+ph, p3+ph, p4+ph); // top
//// addQuad(p4, p3, p2, p1); // bottom
//// addQuad(p3+ph, p2+ph, p2, p3); // right
//// addQuad(p1+ph, p4+ph, p4, p1); // left
//// addQuad(p2+ph, p1+ph, p1, p2); // front
//// addQuad(p4+ph, p3+ph, p3, p4); // back
// addQuad();
// }
/** ctor with position, size and rotation */
Cube(const Point3 pos, const Point3 size, const Point3 rot_deg, const bool topAndBottom = true) {
unitCube(topAndBottom);
@@ -37,6 +50,30 @@ namespace Ray3D {
return res;
}
static Cube unit() {
return Cube();
}
/** cube from 8 vertices (upper 4, lower 4) */
static Cube fromVertices(const Point3 pt1, const Point3 pt2, const Point3 pt3, const Point3 pt4, const Point3 pb1, const Point3 pb2, const Point3 pb3, const Point3 pb4) {
Cube cube;
cube.addQuad(pt1, pt2, pt3, pt4); // top
cube.addQuad(pb4, pb3, pb2, pb1); // bottom
cube.addQuad(pt3, pt2, pb2, pb3); // right
cube.addQuad(pt1, pt4, pb4, pb1); // left
cube.addQuad(pt2, pt1, pb1, pb2); // front
cube.addQuad(pt4, pt3, pb3, pb4); // back
return cube;
}
/** cube from 8 vertices (upper 4, lower 4) */
static Cube fromBottomAndHeight(const Point3 pb1, const Point3 pb2, const Point3 pb3, const Point3 pb4, const float h) {
const Point3 ph(0,0,h);
return Cube::fromVertices(pb1+ph, pb2+ph, pb3+ph, pb4+ph, pb1, pb2, pb3, pb4);
}
private:
/** build unit-cube faces */