Three rotate manipulators to play with;
G.rt = 0: one handle for each rotate axis G.rt = 2: traditional half-circle rotate handles G.rt = 3: mixed version
This commit is contained in:
@@ -325,6 +325,95 @@ static int calc_manipulator(ScrArea *sa)
|
|||||||
return totsel;
|
return totsel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ******************** DRAWING STUFFIES *********** */
|
||||||
|
|
||||||
|
/* radring = radius of donut rings
|
||||||
|
radhole = radius hole
|
||||||
|
start = starting segment (based on nrings)
|
||||||
|
end = end segment
|
||||||
|
nsides = amount of points in ring
|
||||||
|
nrigns = amount of rings
|
||||||
|
*/
|
||||||
|
static void partial_donut(float radring, float radhole, int start, int end, int nsides, int nrings)
|
||||||
|
{
|
||||||
|
float theta, phi, theta1;
|
||||||
|
float cos_theta, sin_theta;
|
||||||
|
float cos_theta1, sin_theta1;
|
||||||
|
float ring_delta, side_delta;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
ring_delta= 2.0*M_PI/(float)nrings;
|
||||||
|
side_delta= 2.0*M_PI/(float)nsides;
|
||||||
|
|
||||||
|
theta= M_PI+0.5*ring_delta;
|
||||||
|
cos_theta= cos(theta);
|
||||||
|
sin_theta= sin(theta);
|
||||||
|
|
||||||
|
for(i= nrings - 1; i >= 0; i--) {
|
||||||
|
theta1= theta + ring_delta;
|
||||||
|
cos_theta1= cos(theta1);
|
||||||
|
sin_theta1= sin(theta1);
|
||||||
|
|
||||||
|
if(i==start) { // cap
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glNormal3f(-sin_theta1, -cos_theta1, 0.0);
|
||||||
|
phi= 0.0;
|
||||||
|
for(j= nsides; j >= 0; j--) {
|
||||||
|
float cos_phi, sin_phi, dist;
|
||||||
|
|
||||||
|
phi += side_delta;
|
||||||
|
cos_phi= cos(phi);
|
||||||
|
sin_phi= sin(phi);
|
||||||
|
dist= radhole + radring * cos_phi;
|
||||||
|
|
||||||
|
glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
if(i>=start && i<=end) {
|
||||||
|
glBegin(GL_QUAD_STRIP);
|
||||||
|
phi= 0.0;
|
||||||
|
for(j= nsides; j >= 0; j--) {
|
||||||
|
float cos_phi, sin_phi, dist;
|
||||||
|
|
||||||
|
phi += side_delta;
|
||||||
|
cos_phi= cos(phi);
|
||||||
|
sin_phi= sin(phi);
|
||||||
|
dist= radhole + radring * cos_phi;
|
||||||
|
|
||||||
|
glNormal3f(cos_theta1 * cos_phi, -sin_theta1 * cos_phi, sin_phi);
|
||||||
|
glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi);
|
||||||
|
glNormal3f(cos_theta * cos_phi, -sin_theta * cos_phi, sin_phi);
|
||||||
|
glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i==end) { // cap
|
||||||
|
glBegin(GL_POLYGON);
|
||||||
|
glNormal3f(sin_theta, cos_theta, 0.0);
|
||||||
|
phi= 0.0;
|
||||||
|
for(j= nsides; j >= 0; j--) {
|
||||||
|
float cos_phi, sin_phi, dist;
|
||||||
|
|
||||||
|
phi -= side_delta;
|
||||||
|
cos_phi= cos(phi);
|
||||||
|
sin_phi= sin(phi);
|
||||||
|
dist= radhole + radring * cos_phi;
|
||||||
|
|
||||||
|
glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi);
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
theta= theta1;
|
||||||
|
cos_theta= cos_theta1;
|
||||||
|
sin_theta= sin_theta1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void manipulator_setcolor(char mode)
|
static void manipulator_setcolor(char mode)
|
||||||
{
|
{
|
||||||
float vec[4];
|
float vec[4];
|
||||||
@@ -370,11 +459,13 @@ static int Gval= 0xFFFF; // defines drawmodus while moving...
|
|||||||
|
|
||||||
static void draw_manipulator_rotate(float mat[][4])
|
static void draw_manipulator_rotate(float mat[][4])
|
||||||
{
|
{
|
||||||
GLUquadricObj *qobj = gluNewQuadric();
|
GLUquadricObj *qobj= gluNewQuadric();
|
||||||
double plane[4];
|
double plane[4];
|
||||||
float size, vec[3], unitmat[4][4];
|
float size, vec[3], unitmat[4][4];
|
||||||
float cusize= CYWID*0.75;
|
float cusize= CYWID*0.75;
|
||||||
int arcs= 0;
|
int arcs= (G.rt==2);
|
||||||
|
|
||||||
|
if(G.rt==3) cusize= CYWID*0.25;
|
||||||
|
|
||||||
/* when called while moving in mixed mode, do not draw when... */
|
/* when called while moving in mixed mode, do not draw when... */
|
||||||
if((Gval & MAN_ROT_C)==0) return;
|
if((Gval & MAN_ROT_C)==0) return;
|
||||||
@@ -397,7 +488,7 @@ static void draw_manipulator_rotate(float mat[][4])
|
|||||||
if(arcs) {
|
if(arcs) {
|
||||||
/* clipplane makes nice handles, calc here because of multmatrix but with translate! */
|
/* clipplane makes nice handles, calc here because of multmatrix but with translate! */
|
||||||
VECCOPY(plane, G.vd->viewinv[2]);
|
VECCOPY(plane, G.vd->viewinv[2]);
|
||||||
plane[3]= -0.001; // clip full circle
|
plane[3]= -0.1; // clip more
|
||||||
glClipPlane(GL_CLIP_PLANE0, plane);
|
glClipPlane(GL_CLIP_PLANE0, plane);
|
||||||
}
|
}
|
||||||
/* sets view screen aligned */
|
/* sets view screen aligned */
|
||||||
@@ -445,17 +536,17 @@ static void draw_manipulator_rotate(float mat[][4])
|
|||||||
if(!(G.f & G_PICKSEL)) {
|
if(!(G.f & G_PICKSEL)) {
|
||||||
/* axis */
|
/* axis */
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
if( (Gval & MAN_ROT_X) || (G.moving && (Gval & MAN_ROT_Y)) ) {
|
if( (Gval & MAN_ROT_X) || (G.moving && (Gval & MAN_ROT_Z)) ) {
|
||||||
manipulator_setcolor('x');
|
manipulator_setcolor('x');
|
||||||
glVertex3f(0.0, 0.0, 0.0);
|
glVertex3f(0.0, 0.0, 0.0);
|
||||||
glVertex3f(1.0, 0.0, 0.0);
|
glVertex3f(1.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
if( (Gval & MAN_ROT_Y) || (G.moving && (Gval & MAN_ROT_Z)) ) {
|
if( (Gval & MAN_ROT_Y) || (G.moving && (Gval & MAN_ROT_X)) ) {
|
||||||
manipulator_setcolor('y');
|
manipulator_setcolor('y');
|
||||||
glVertex3f(0.0, 0.0, 0.0);
|
glVertex3f(0.0, 0.0, 0.0);
|
||||||
glVertex3f(0.0, 1.0, 0.0);
|
glVertex3f(0.0, 1.0, 0.0);
|
||||||
}
|
}
|
||||||
if( (Gval & MAN_ROT_Z) || (G.moving && (Gval & MAN_ROT_X)) ) {
|
if( (Gval & MAN_ROT_Z) || (G.moving && (Gval & MAN_ROT_Y)) ) {
|
||||||
manipulator_setcolor('z');
|
manipulator_setcolor('z');
|
||||||
glVertex3f(0.0, 0.0, 0.0);
|
glVertex3f(0.0, 0.0, 0.0);
|
||||||
glVertex3f(0.0, 0.0, 1.0);
|
glVertex3f(0.0, 0.0, 1.0);
|
||||||
@@ -497,7 +588,7 @@ static void draw_manipulator_rotate(float mat[][4])
|
|||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arcs || G.moving) {
|
if(arcs==0 && G.moving) {
|
||||||
|
|
||||||
if(arcs) glEnable(GL_CLIP_PLANE0);
|
if(arcs) glEnable(GL_CLIP_PLANE0);
|
||||||
|
|
||||||
@@ -521,69 +612,109 @@ static void draw_manipulator_rotate(float mat[][4])
|
|||||||
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
||||||
manipulator_setcolor('y');
|
manipulator_setcolor('y');
|
||||||
drawcircball(unitmat[3], 1.0, unitmat);
|
drawcircball(unitmat[3], 1.0, unitmat);
|
||||||
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
glRotatef(90.0, 1.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arcs) glDisable(GL_CLIP_PLANE0);
|
if(arcs) glDisable(GL_CLIP_PLANE0);
|
||||||
}
|
}
|
||||||
if(arcs==0) {
|
// donut arcs
|
||||||
|
if(arcs) {
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_CLIP_PLANE0);
|
||||||
|
|
||||||
/* Z axis has Rotate X */
|
/* Z circle */
|
||||||
glTranslatef(0.0, 0.0, 1.0);
|
|
||||||
if(Gval & MAN_ROT_X) {
|
|
||||||
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
|
|
||||||
manipulator_setcolor('X');
|
|
||||||
glPushMatrix();
|
|
||||||
glRotatef(90.0, 1.0, 0.0, 0.0);
|
|
||||||
glTranslatef(0.0, 0.0, -0.5*CYLEN);
|
|
||||||
gluCylinder(qobj, cusize, cusize, CYLEN, 8, 2);
|
|
||||||
|
|
||||||
gluQuadricOrientation(qobj, GLU_INSIDE);
|
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
|
||||||
gluQuadricOrientation(qobj, GLU_OUTSIDE);
|
|
||||||
glTranslatef(0.0, 0.0, CYLEN);
|
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
/* X axis has Rotate Y */
|
|
||||||
glTranslatef(1.0, 0.0, -(1.0));
|
|
||||||
if(Gval & MAN_ROT_Y) {
|
|
||||||
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
|
|
||||||
manipulator_setcolor('Y');
|
|
||||||
glPushMatrix();
|
|
||||||
|
|
||||||
glTranslatef(0.0, 0.0, -0.5*CYLEN);
|
|
||||||
gluCylinder(qobj, cusize, cusize, CYLEN, 8, 2);
|
|
||||||
|
|
||||||
gluQuadricOrientation(qobj, GLU_INSIDE);
|
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
|
||||||
gluQuadricOrientation(qobj, GLU_OUTSIDE);
|
|
||||||
glTranslatef(0.0, 0.0, CYLEN);
|
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
|
||||||
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
/* Y axis has rotate Z */
|
|
||||||
glTranslatef(-(1.0), 1.0, 0.0);
|
|
||||||
if(Gval & MAN_ROT_Z) {
|
if(Gval & MAN_ROT_Z) {
|
||||||
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
|
||||||
manipulator_setcolor('Z');
|
manipulator_setcolor('Z');
|
||||||
glPushMatrix();
|
partial_donut(cusize/3.0, 1.0, 0, 48, 8, 48);
|
||||||
|
}
|
||||||
|
/* X circle */
|
||||||
|
if(Gval & MAN_ROT_X) {
|
||||||
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
|
||||||
glRotatef(90.0, 0.0, 1.0, 0.0);
|
glRotatef(90.0, 0.0, 1.0, 0.0);
|
||||||
glTranslatef(0.0, 0.0, -0.5*CYLEN);
|
manipulator_setcolor('X');
|
||||||
gluCylinder(qobj, cusize, cusize, CYLEN, 8, 2);
|
partial_donut(cusize/3.0, 1.0, 0, 48, 8, 48);
|
||||||
|
glRotatef(-90.0, 0.0, 1.0, 0.0);
|
||||||
|
}
|
||||||
|
/* Y circle */
|
||||||
|
if(Gval & MAN_ROT_Y) {
|
||||||
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
|
||||||
|
glRotatef(-90.0, 1.0, 0.0, 0.0);
|
||||||
|
manipulator_setcolor('Y');
|
||||||
|
partial_donut(cusize/3.0, 1.0, 0, 48, 8, 48);
|
||||||
|
glRotatef(90.0, 1.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_CLIP_PLANE0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(arcs==0) {
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
|
/* Z handle on X axis */
|
||||||
|
if(Gval & MAN_ROT_Z) {
|
||||||
|
glPushMatrix();
|
||||||
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
|
||||||
|
manipulator_setcolor('Z');
|
||||||
|
|
||||||
|
if(G.rt==3) {
|
||||||
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
|
|
||||||
|
/* Z handle on Y axis */
|
||||||
|
glRotatef(90.0, 0.0, 0.0, 1.0);
|
||||||
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
partial_donut(cusize, 1.0, 23, 25, 8, 48);
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Y handle on X axis */
|
||||||
|
if(Gval & MAN_ROT_Y) {
|
||||||
|
glPushMatrix();
|
||||||
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
|
||||||
|
manipulator_setcolor('Y');
|
||||||
|
|
||||||
gluQuadricOrientation(qobj, GLU_INSIDE);
|
if(G.rt==3) {
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
glRotatef(90.0, 1.0, 0.0, 0.0);
|
||||||
gluQuadricOrientation(qobj, GLU_OUTSIDE);
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
glTranslatef(0.0, 0.0, CYLEN);
|
|
||||||
gluDisk(qobj, 0.0, cusize, 8, 1);
|
/* Y handle on Z axis */
|
||||||
|
glRotatef(90.0, 0.0, 0.0, 1.0);
|
||||||
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glRotatef(90.0, 1.0, 0.0, 0.0);
|
||||||
|
glRotatef(90.0, 0.0, 0.0, 1.0);
|
||||||
|
partial_donut(cusize, 1.0, 23, 25, 8, 48);
|
||||||
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* X handle on Z axis */
|
||||||
|
if(Gval & MAN_ROT_X) {
|
||||||
|
glPushMatrix();
|
||||||
|
if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
|
||||||
|
manipulator_setcolor('X');
|
||||||
|
|
||||||
|
if(G.rt==3) {
|
||||||
|
glRotatef(-90.0, 0.0, 1.0, 0.0);
|
||||||
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
|
|
||||||
|
/* X handle on Y axis */
|
||||||
|
glRotatef(90.0, 0.0, 0.0, 1.0);
|
||||||
|
partial_donut(cusize, 1.0, 21, 27, 8, 48);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glRotatef(-90.0, 0.0, 1.0, 0.0);
|
||||||
|
glRotatef(90.0, 0.0, 0.0, 1.0);
|
||||||
|
partial_donut(cusize, 1.0, 23, 25, 8, 48);
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore */
|
/* restore */
|
||||||
|
|||||||
Reference in New Issue
Block a user