//============================================================================== void CVDisk::m_CalcScrnVertices() { int iVtx; double dAngleStep, dAngle0; double dX, dY; float * p_fVtxX, * p_fVtxY; dAngleStep = TWO_PI/m_nVertices; dAngle0 = m_dAngle * DEGS_TO_RADS; // circle is always of radius 1 // disk radius is represented by scale p_fVtxX = m_afScrnVtxX; p_fVtxY = m_afScrnVtxY; for( iVtx = 0; iVtx < m_nVertices; iVtx++) { dX = cos(dAngleStep * iVtx + dAngle0) * m_dScale + m_dX; dY = sin(dAngleStep * iVtx + dAngle0) * m_dScale + m_dY; g_TransformCoordinatesF( dX, dY, p_fVtxX, p_fVtxY ); p_fVtxX++; p_fVtxY++; } }
void CVComplexShape::Draw() { // logToFile((f, "CVComplexShape Draw\n")); if(!m_IsVisible) return; double *vertices = exact ? scrVertices : m_getVertices(); if (arrays[aiIndices] != 0 && GetLength(arrays[aiIndices], 1) == 0 || vertices == 0 || GetLength(vertices, 1) == 0) return; glPushMatrix(); if(exact){ glMatrixMode (GL_MODELVIEW); glLoadIdentity(); glTranslated(0.0, 0.0, m_dZ); } else { // Only get exact calibration location of center // and approximate the rest of the points /* float x = XPosToScreen((float)X,(float)Y); float y = YPosToScreen((float)X,(float)Y); m_nClipped = VISWIN_IS_CLIPPED(x,y); */ float pix[2]; g_TransformCoordinatesF( m_dX, m_dY, pix, pix+1 ); m_nClipped = IS_OFF_WINDOW(pix[0],pix[1]); g_TransformGradientD(JAC,m_dX,m_dY); /* DPosToDScreen(JAC,x,y); */ // Rot 4x4, allocated by column, as in matlab // Jac, though, is only the 2x2 Jacobian ROT[0]=m_dScale*JAC[0][0]; ROT[1]=m_dScale*JAC[1][0]; ROT[4]=m_dScale*JAC[0][1]; ROT[5]=m_dScale*JAC[1][1]; ROT[12]=pix[0]; ROT[13]=pix[1]; ROT[14]=m_dZ; glMatrixMode (GL_MODELVIEW); // glLoadIdentity(); // glTranslatef((float)x,(float)y,Z); // 3: Translate // glScalef((float)scx,(float)scy,1); // 2: Scale glLoadMatrixd(ROT); // 2: Translate and Scale glRotatef((float)m_dAngle,0,0,1); // 1: Rotate About Z axis } glColor4d(m_fRGB[0],m_fRGB[1],m_fRGB[2],m_fAlpha); if (drawMode >= odmLines && drawMode <= odmLineLoop) { if (lineStipple != 0) { glLineStipple(lineStippleFactor, lineStipple); glEnable(GL_LINE_STIPPLE); } if (lineWidth != 1.0) glLineWidth((float)lineWidth); } if (drawMode == odmPoints && pointSize != 1.0) glPointSize((float)pointSize); if (drawMode >= odmTriangles && drawMode <= odmPolygon) { if (arrays[aiPolygonStipple] != 0) { glEnable(GL_POLYGON_STIPPLE); glPolygonStipple((unsigned char *)arrays[aiPolygonStipple]); } } if (vertices != 0) glEnableClientState(GL_VERTEX_ARRAY); if (arrays[aiColors ] != 0) glEnableClientState(GL_COLOR_ARRAY); if (arrays[aiEdgeFlags] != 0) glEnableClientState(GL_EDGE_FLAG_ARRAY); if (arrays[aiIndices] != 0) { if (vertices != 0) glVertexPointer(GetLength(vertices, 0), GL_DOUBLE, 0, vertices); if (arrays[aiColors] != 0) glColorPointer (GetLength(arrays[aiColors], 0), GL_DOUBLE, 0, arrays[aiColors]); // if (arrays[aiEdgeFlags] != 0) // glEdgeFlagPointer(0, arrays[aiEdgeFlags]); if (GetDim(arrays[aiIndices]) == 1 || GetLength(arrays[aiIndices], 0) == 1) glDrawElements(glDrawModeMap[drawMode], GetLength(arrays[aiIndices]), GL_UNSIGNED_INT, arrays[aiIndices]); else { int len0 = GetLength(arrays[aiIndices], 0); int len1 = GetLength(arrays[aiIndices], 1); for (int i=0; i < len1; ++i) glDrawElements(glDrawModeMap[drawMode], len0, GL_UNSIGNED_INT, ((unsigned int *)arrays[aiIndices]) + len0 * i); } } else if (vertices != 0) { int len2 = GetDim(vertices) <= 2 ? 1 : GetLength(vertices, 2); for (int i=0; i < len2; ++i) { if (vertices != 0) glVertexPointer(GetLength(vertices, 0), GL_DOUBLE, 0, vertices + GetLength(vertices, 0) * GetLength(vertices, 1) * i); if (arrays[aiColors] != 0) glColorPointer (GetLength(arrays[aiColors], 0), GL_DOUBLE, 0, arrays[aiColors] + GetLength(arrays[aiColors], 0) * GetLength(arrays[aiColors], 1) * i); // if (arrays[aiEdgeFlags] != 0) // glEdgeFlagPointer(0, arrays[aiEdgeFlags]); glDrawArrays(glDrawModeMap[drawMode], 0, GetLength(vertices, 1)); } } if (vertices != 0) glDisableClientState(GL_VERTEX_ARRAY); if (arrays[aiColors ] != 0) glDisableClientState(GL_COLOR_ARRAY); if (arrays[aiEdgeFlags] != 0) glDisableClientState(GL_EDGE_FLAG_ARRAY); if (drawMode >= odmTriangles && drawMode <= odmPolygon) { if (arrays[aiPolygonStipple] != 0) glDisable(GL_POLYGON_STIPPLE); } if (drawMode >= odmLines && drawMode <= odmLineLoop) { if (lineStipple != 0) glDisable(GL_LINE_STIPPLE); if (lineWidth != 1.0) glLineWidth(1.0); } if (drawMode == odmPoints && pointSize != 1.0) glPointSize(1.0); glPopMatrix(); }