Match inbetween faces.
parent
167a97e66a
commit
21e46e5e16
25
src/bmesh.c
25
src/bmesh.c
|
@ -807,6 +807,30 @@ int bmeshStitch(bmesh *bm) {
|
|||
return bmeshStichFrom(bm, 0, bmeshGetRootBall(bm));
|
||||
}
|
||||
|
||||
static void rollQuadVertexs(quad *q) {
|
||||
int i;
|
||||
quad oldQuad = *q;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
q->pt[i] = oldQuad.pt[(i + 1) % 4];
|
||||
}
|
||||
}
|
||||
|
||||
static void matchTwoFaces(quad *q1, quad *q2) {
|
||||
int i;
|
||||
float minDistance = 9999;
|
||||
int matchTo = 0;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
float distance = vec3Distance(&q1->pt[0], &q2->pt[i]);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
matchTo = i;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < matchTo; ++i) {
|
||||
rollQuadVertexs(q2);
|
||||
}
|
||||
}
|
||||
|
||||
void calculateBallQuad(bmeshBall *ball, quad *q) {
|
||||
vec3 z, y;
|
||||
vec3Scale(&ball->localYaxis, ball->radius, &y);
|
||||
|
@ -825,6 +849,7 @@ static void drawWallsBetweenQuads(vec3 *origin, quad *q1, quad *q2) {
|
|||
int i;
|
||||
vec3 normal;
|
||||
vec3 o2v;
|
||||
matchTwoFaces(q1, q2);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
quad wall = {{q1->pt[i], q2->pt[i],
|
||||
q2->pt[(i + 1) % 4], q1->pt[(i + 1) % 4]}};
|
||||
|
|
|
@ -38,6 +38,7 @@ void drawTriangle(triangle *poly) {
|
|||
void drawQuad(quad *poly) {
|
||||
vec3 normal;
|
||||
int i;
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
glBegin(GL_QUADS);
|
||||
vec3Normal(&poly->pt[0], &poly->pt[1], &poly->pt[2], &normal);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
|
@ -45,6 +46,13 @@ void drawQuad(quad *poly) {
|
|||
glVertex3f(poly->pt[i].x, poly->pt[i].y, poly->pt[i].z);
|
||||
}
|
||||
glEnd();
|
||||
glColor3f(0.0, 0.0, 0.0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
glVertex3f(poly->pt[i].x, poly->pt[i].y, poly->pt[i].z);
|
||||
}
|
||||
glVertex3f(poly->pt[0].x, poly->pt[0].y, poly->pt[0].z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
int drawCylinder(vec3 *topOrigin, vec3 *bottomOrigin, float radius, int slices,
|
||||
|
|
|
@ -42,7 +42,7 @@ static int drawBmeshBall(bmesh *bm, bmeshBall *ball) {
|
|||
static void drawBmeshBallRecursively(bmesh *bm, bmeshBall *ball) {
|
||||
bmeshBallIterator iterator;
|
||||
bmeshBall *child;
|
||||
//drawBmeshBall(bm, ball);
|
||||
drawBmeshBall(bm, ball);
|
||||
for (child = bmeshGetBallFirstChild(bm, ball, &iterator);
|
||||
child;
|
||||
child = bmeshGetBallNextChild(bm, ball, &iterator)) {
|
||||
|
@ -281,7 +281,7 @@ void Render::paintGL() {
|
|||
|
||||
for (index = 0; index < bmeshGetBoneNum(bm); ++index) {
|
||||
bmeshBone *bone = bmeshGetBone(bm, index);
|
||||
//drawBmeshBone(bm, bone);
|
||||
drawBmeshBone(bm, bone);
|
||||
}
|
||||
/*
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5);
|
||||
|
|
Loading…
Reference in New Issue