本文整理汇总了C++中QOpenGLFunctions_2_1::glTranslatef方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glTranslatef方法的具体用法?C++ QOpenGLFunctions_2_1::glTranslatef怎么用?C++ QOpenGLFunctions_2_1::glTranslatef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glTranslatef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawUnitArrow
void DrawUnitArrow(int ID, const CCVector3& start, const CCVector3& direction, PointCoordinateType scale, const ccColor::Rgb& col, CC_DRAW_CONTEXT& context)
{
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
return;
if (ID > 0)
{
glFunc->glLoadName(ID);
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, start.x, start.y, start.z);
ccGL::Scale(glFunc, scale, scale, scale);
//we compute scalar prod between the two vectors
CCVector3 Z(0.0,0.0,1.0);
PointCoordinateType ps = Z.dot(direction);
if (ps < 1)
{
CCVector3 axis(1,0,0);
PointCoordinateType angle_deg = static_cast<PointCoordinateType>(180.0);
if (ps > -1)
{
//we deduce angle from scalar prod
angle_deg = acos(ps) * static_cast<PointCoordinateType>(CC_RAD_TO_DEG);
//we compute rotation axis with scalar prod
axis = Z.cross(direction);
}
ccGL::Rotate(glFunc,angle_deg, axis.x, axis.y, axis.z);
}
if (!c_arrowShaft)
c_arrowShaft = QSharedPointer<ccCylinder>(new ccCylinder(0.15f,0.6f,0,"ArrowShaft",12));
if (!c_arrowHead)
c_arrowHead = QSharedPointer<ccCone>(new ccCone(0.3f,0,0.4f,0,0,0,"ArrowHead",24));
glFunc->glTranslatef(0,0,0.3f);
c_arrowShaft->setTempColor(col);
c_arrowShaft->draw(context);
glFunc->glTranslatef(0,0,0.3f+0.2f);
c_arrowHead->setTempColor(col);
c_arrowHead->draw(context);
glFunc->glPopMatrix();
}
示例2: DrawUnitTorus
static void DrawUnitTorus(int ID, const CCVector3& center, const CCVector3& direction, PointCoordinateType scale, const ccColor::Rgb& col, CC_DRAW_CONTEXT& context)
{
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
return;
if (ID > 0)
glFunc->glLoadName(ID);
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, center.x, center.y, center.z);
ccGL::Scale(glFunc, scale, scale, scale);
//we compute scalar prod between the two vectors
CCVector3 Z(0,0,1);
PointCoordinateType ps = Z.dot(direction);
if (ps < 1)
{
CCVector3 axis(1,0,0);
PointCoordinateType angle_deg = 180;
if (ps > -1)
{
//we deduce angle from scalar prod
angle_deg = acos(ps) * static_cast<PointCoordinateType>(CC_RAD_TO_DEG);
//we compute rotation axis with scalar prod
axis = Z.cross(direction);
}
ccGL::Rotate(glFunc, angle_deg, axis.x, axis.y, axis.z);
}
if (!c_torus)
c_torus = QSharedPointer<ccTorus>(new ccTorus(0.2f, 0.4f, 2.0*M_PI, false, 0, 0, "Torus", 12));
glFunc->glTranslatef(0,0,0.3f);
c_torus->setTempColor(col);
c_torus->draw(context);
glFunc->glPopMatrix();
}
示例3: tab
//.........这里部分代码省略.........
//automatically elide the title
//title = titleFontMetrics.elidedText(title,Qt::ElideRight,m_closeButtonROI[0]-2*margin);
}
int halfW = (context.glW >> 1);
int halfH = (context.glH >> 1);
//draw label rectangle
int xStart = static_cast<int>(context.glW * m_screenPos[0]);
int yStart = static_cast<int>(context.glH * (1.0f - m_screenPos[1]));
m_lastScreenPos[0] = xStart;
m_lastScreenPos[1] = yStart - m_labelROI.height();
//colors
bool highlighted = (!pushName && isSelected());
//default background color
unsigned char alpha = static_cast<unsigned char>((context.labelOpacity/100.0) * 255);
ccColor::Rgbaub defaultBkgColor(context.labelDefaultBkgCol,alpha);
//default border color (mustn't be totally transparent!)
ccColor::Rgbaub defaultBorderColor(ccColor::red);
if (!highlighted)
{
//apply only half of the transparency
unsigned char halfAlpha = static_cast<unsigned char>((50.0 + context.labelOpacity/200.0) * 255);
defaultBorderColor = ccColor::Rgbaub(context.labelDefaultBkgCol,halfAlpha);
}
glFunc->glPushAttrib(GL_COLOR_BUFFER_BIT);
glFunc->glEnable(GL_BLEND);
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glTranslatef(static_cast<GLfloat>(-halfW + xStart), static_cast<GLfloat>(-halfH + yStart), 0);
if (!pushName)
{
//compute arrow base position relatively to the label rectangle (for 0 to 8)
int arrowBaseConfig = 0;
int iArrowDestX = static_cast<int>(arrowDestX)-xStart;
int iArrowDestY = static_cast<int>(arrowDestY)-yStart;
{
if (iArrowDestX < m_labelROI.left()) //left
arrowBaseConfig += 0;
else if (iArrowDestX > m_labelROI.right()) //Right
arrowBaseConfig += 2;
else //Middle
arrowBaseConfig += 1;
if (iArrowDestY > -m_labelROI.top()) //Top
arrowBaseConfig += 0;
else if (iArrowDestY < -m_labelROI.bottom()) //Bottom
arrowBaseConfig += 6;
else //Middle
arrowBaseConfig += 3;
}
//we make the arrow base start from the nearest corner
if (arrowBaseConfig != 4) //4 = label above point!
{
glFunc->glColor4ubv(defaultBorderColor.rgba);
glFunc->glBegin(GL_TRIANGLE_FAN);
glFunc->glVertex2d(arrowDestX - xStart, arrowDestY - yStart);
switch(arrowBaseConfig)
{
case 0: //top-left corner
示例4: drawMeOnly
void ccSample::drawMeOnly(CC_DRAW_CONTEXT& context)
{
if (MACRO_Draw3D(context)) {
if (!this->getSample())
return;
QOpenGLFunctions_2_1* glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
bool pushName = MACRO_DrawEntityNames(context);
if (pushName) {
// not particularily fast
if (MACRO_DrawFastNamesOnly(context))
return;
glFunc->glPushName(getUniqueIDForDisplay());
}
if (!c_unitPointMarker) {
c_unitPointMarker = QSharedPointer<ccSphere>(new ccSphere(m_radius_, 0, "PointMarker", 12));
c_unitPointMarker->showColors(true);
c_unitPointMarker->setVisible(true);
c_unitPointMarker->setEnabled(true);
}
// build-up point maker own 'context'
CC_DRAW_CONTEXT markerContext = context;
markerContext.drawingFlags
&= (~CC_DRAW_ENTITY_NAMES); // we must remove the 'push name flag' so
// that the sphere doesn't push its own!
markerContext.display = nullptr;
if (isSelected() && !pushName) {
c_unitPointMarker->setTempColor(ccColor::red);
c_unitPointMarker->setRadius(2 * m_radius_);
}
else {
c_unitPointMarker->setTempColor(ccColor::magenta);
c_unitPointMarker->setRadius(m_radius_);
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
float x, y, z;
Eigen::Vector3f p = this->getSample()->getPosition();
// const CCVector3* P = m_points[i].cloud->getPoint(m_points[i].index);
// ccGL::Translate();
glFunc->glTranslatef(p(0), p(1), p(2));
glFunc->glScalef(context.labelMarkerSize, context.labelMarkerSize,
context.labelMarkerSize);
m_current_scaling_ = context.labelMarkerSize;
c_unitPointMarker->draw(markerContext);
glFunc->glPopMatrix();
drawStratPos(context);
if (pushName)
glFunc->glPopName();
}
}