worked on 3d models within map

adjusted grid factory
adjusted nav mesh factory
minoor changes/fixes
new helper classes
refactoring
This commit is contained in:
2018-04-03 14:55:59 +02:00
parent f3b6155157
commit 1c2081d406
25 changed files with 620 additions and 93 deletions

View File

@@ -18,6 +18,16 @@ namespace Ray3D {
public:
enum Part {
CUBE_TOP = 1,
CUBE_BOTTOM = 2,
CUBE_LEFT = 4,
CUBE_RIGHT = 8,
CUBE_FRONT = 16,
CUBE_BACK = 32,
};
// 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
@@ -30,8 +40,8 @@ namespace Ray3D {
// }
/** ctor with position, size and rotation */
Cube(const Point3 pos, const Point3 size, const Point3 rot_deg, const bool topAndBottom = true) {
unitCube(topAndBottom);
Cube(const Point3 pos, const Point3 size, const Point3 rot_deg, const Part parts = (Part)63) {
unitCube(parts);
transform(pos, size, rot_deg);
}
@@ -50,8 +60,10 @@ namespace Ray3D {
return res;
}
static Cube unit() {
return Cube();
static Cube unit(const Part parts = (Part) 63) {
Cube cube;
cube.unitCube(parts);
return cube;
}
/** cube from 8 vertices (upper 4, lower 4) */
@@ -77,72 +89,73 @@ namespace Ray3D {
private:
/** build unit-cube faces */
void unitCube(const bool topAndBottom) {
void unitCube(const Part parts) {
const float s = 1.0f;
// left?
addQuad(
Point3(+s, -s, -s),
Point3(+s, -s, +s),
Point3(-s, -s, +s),
Point3(-s, -s, -s)
);
if (parts & CUBE_LEFT) {
addQuad(
Point3(+s, -s, -s),
Point3(+s, -s, +s),
Point3(-s, -s, +s),
Point3(-s, -s, -s)
);
}
// right?
addQuad(
Point3(-s, +s, -s),
Point3(-s, +s, +s),
Point3(+s, +s, +s),
Point3(+s, +s, -s)
);
if (parts & CUBE_RIGHT) {
addQuad(
Point3(-s, +s, -s),
Point3(-s, +s, +s),
Point3(+s, +s, +s),
Point3(+s, +s, -s)
);
}
// small side
if (1 == 1) {
// front
// front
if (parts & CUBE_FRONT) {
addQuad(
Point3(-s, -s, -s),
Point3(-s, -s, +s),
Point3(-s, +s, +s),
Point3(-s, +s, -s)
);
}
// read
// back
if (parts & CUBE_BACK) {
addQuad(
Point3(+s, +s, -s),
Point3(+s, +s, +s),
Point3(+s, -s, +s),
Point3(+s, -s, -s)
);
}
if (topAndBottom) {
// top
// top
if (parts & CUBE_TOP) {
addQuad(
Point3(+s, +s, +s),
Point3(-s, +s, +s),
Point3(-s, -s, +s),
Point3(+s, -s, +s)
);
}
// bottom
// bottom
if (parts & CUBE_BOTTOM) {
addQuad(
Point3(+s, -s, -s),
Point3(-s, -s, -s),
Point3(-s, +s, -s),
Point3(+s, +s, -s)
);
}
}