本文整理汇总了C++中QVector4D::w方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector4D::w方法的具体用法?C++ QVector4D::w怎么用?C++ QVector4D::w使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector4D
的用法示例。
在下文中一共展示了QVector4D::w方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static inline QVector4D qt_sRGB_to_linear_RGB(const QVector4D &color)
{
return QVector4D(qt_sRGB_to_linear_RGB(color.x()),
qt_sRGB_to_linear_RGB(color.y()),
qt_sRGB_to_linear_RGB(color.z()),
color.w());
}
示例2: if
QVector<float> UniformItem::getGlData() const
{
QVector<float> glData;
if (type == UniformType::SPHERICAL_3D) {
QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], 0.0);
glData.push_back(cartesian.x());
glData.push_back(cartesian.y());
glData.push_back(cartesian.z());
} else if (type == UniformType::SPHERICAL_4D) {
QVector4D cartesian = CoordinateConversions::sphericalToCartesian(data[0], data[1], data[2], data[3]);
glData.push_back(cartesian.x());
glData.push_back(cartesian.y());
glData.push_back(cartesian.z());
glData.push_back(cartesian.w());
} else if (type == UniformType::COLOR) {
glData.push_back(data[0] / 255.0f);
glData.push_back(data[1] / 255.0f);
glData.push_back(data[2] / 255.0f);
} else if (type == UniformType::COLOR_ALPHA) {
glData.push_back(data[0] / 255.0f);
glData.push_back(data[1] / 255.0f);
glData.push_back(data[2] / 255.0f);
glData.push_back(data[3] / 255.0f);
} else {
glData = data;
}
return glData;
}
示例3: vectorX
colour4::colour4( QVector4D in ) : vectorX( 4 )
{
r() = in.x();
g() = in.y();
b() = in.z();
a() = in.w();
}
示例4:
QDebug operator<<(QDebug dbg, const QVector4D &vector)
{
dbg.nospace() << "QVector4D("
<< vector.x() << ", " << vector.y() << ", "
<< vector.z() << ", " << vector.w() << ')';
return dbg.space();
}
示例5:
void rpnoc::Cell::setBackGroundColor( QVector4D iColor )
{
mBackgroundColor = iColor;
GLfloat color[4] = { iColor.x(), iColor.y(), iColor.z(), iColor.w() };
Vertex< 4 > oVertex[4] = { color, color, color, color };
mPanel->setColor( oVertex );
}
示例6: tmp
static QVector3D unproject( QVector3D v, const QMatrix4x4 &modelView, const QMatrix4x4 &projection, QRect viewport )
{
// Reimplementation of QVector3D::unproject() - see qtbase/src/gui/math3d/qvector3d.cpp
// The only difference is that the original implementation uses tolerance 1e-5
// (see qFuzzyIsNull()) as a protection against division by zero. For us it is however
// common to get lower values (e.g. as low as 1e-8 when zoomed out to the whole Earth with web mercator).
QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
QVector4D tmp( v, 1.0f );
tmp.setX( ( tmp.x() - float( viewport.x() ) ) / float( viewport.width() ) );
tmp.setY( ( tmp.y() - float( viewport.y() ) ) / float( viewport.height() ) );
tmp = tmp * 2.0f - QVector4D( 1.0f, 1.0f, 1.0f, 1.0f );
QVector4D obj = inverse * tmp;
if ( qgsDoubleNear( obj.w(), 0, 1e-10 ) )
obj.setW( 1.0f );
obj /= obj.w();
return obj.toVector3D();
}
示例7: unproject
QVector4D GLScene::unproject(const QVector3D & screen){
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
const qreal xNorm = (2.0f * ((screen.x() - viewport[0]) / (viewport[2] - viewport[0]))) - 1.0f;
const qreal yNorm = 1.0f - (2.0f * ((screen.y() - viewport[1]) / (viewport[3] - viewport[1])));
QMatrix4x4 pvMatrixInv = camera().projViewProduct().inverted();
QVector4D worldPoint = pvMatrixInv * QVector4D(xNorm, yNorm, screen.z(), 1);
if (worldPoint.w() == 0){
return QVector4D(0,0,0,0);
}
worldPoint.setW(1 / worldPoint.w());
worldPoint.setX(worldPoint.x() * worldPoint.w());
worldPoint.setY(worldPoint.y() * worldPoint.w());
return worldPoint;
}
示例8: toString
Ogre::String toString(const QVector4D &v)
{
Ogre::String s="<QVector4D ";
s+="w="+Ogre::StringConverter::toString((float)v.w())+", ";
s+="x="+Ogre::StringConverter::toString((float)v.x())+", ";
s+="y="+Ogre::StringConverter::toString((float)v.y())+", ";
s+="z="+Ogre::StringConverter::toString((float)v.z());
s+=">";
return s;
}
示例9: qAbs
bool QQuickVector4DValueType::fuzzyEquals(const QVector4D &vec, qreal epsilon) const
{
qreal absEps = qAbs(epsilon);
if (qAbs(v.x() - vec.x()) > absEps)
return false;
if (qAbs(v.y() - vec.y()) > absEps)
return false;
if (qAbs(v.z() - vec.z()) > absEps)
return false;
if (qAbs(v.w() - vec.w()) > absEps)
return false;
return true;
}
示例10: rotateSelected
void GLWidget::rotateSelected(float x, float y, float z, float angle)
{
obj.rotateSelected(x, y, z, angle);
QQuaternion rotate = QQuaternion::fromAxisAndAngle(x, y, z, angle);
QVector4D qrotate = rotate.toVector4D();
Matrix3d mat3 = Quaterniond(qrotate.w(),qrotate.x(), qrotate.y(), qrotate.z()).toRotationMatrix();
Matrix4d mat4 = Matrix4d::Identity();
mat4.block(0,0,3,3) = mat3;
pd.InterTransform(obj.getSelectVertexIds(),rotate);
qDebug() << "update!!";
update();
}
示例11: on_configurationTreeView_doubleClicked
void MainWindow::on_configurationTreeView_doubleClicked(const QModelIndex &index)
{
QModelIndex &intermediateIndex = const_cast<QModelIndex &>(index);
currentIndex = &intermediateIndex;
if (treeModel->isFileNameItem(index)) {
QString fileName = QFileDialog::getOpenFileName(this);
if (!fileName.isEmpty()) {
treeModel->setData(index, QVariant::fromValue(fileName));
on_configurationTreeView_clicked(index);
}
} else if (treeModel->isPositionItem(index)) {
QVector4D value = qvariant_cast<QVector4D>(treeModel->getItemData(index));
QVector4D spherical = CoordinateConversions::cartesianToSpherical(value);
SphericalDialog *editor = new SphericalDialog(this);
editor->setValues(spherical.x(), spherical.y(), spherical.z(), spherical.w());
editor->setModal(true);
editor->show();
connect(editor, SIGNAL(valueChanged(double,int,int,double)), this, SLOT(currentPositionChanged(double,int,int,double)));
} else if (treeModel->isUniformConfigurationItem(index)) {
示例12: outcode
/**
* copied from https://searchcode.com/codesearch/view/35195518/
* qt3d /src/threed/painting/qglpainter.cpp
* no changes in the code
*/
static inline uint outcode( QVector4D v )
{
// For a discussion of outcodes see pg 388 Dunn & Parberry.
// For why you can't just test if the point is in a bounding box
// consider the case where a view frustum with view-size 1.5 x 1.5
// is tested against a 2x2 box which encloses the near-plane, while
// all the points in the box are outside the frustum.
// TODO: optimise this with assembler - according to D&P this can
// be done in one line of assembler on some platforms
uint code = 0;
if ( v.x() < -v.w() ) code |= 0x01;
if ( v.x() > v.w() ) code |= 0x02;
if ( v.y() < -v.w() ) code |= 0x04;
if ( v.y() > v.w() ) code |= 0x08;
if ( v.z() < -v.w() ) code |= 0x10;
if ( v.z() > v.w() ) code |= 0x20;
return code;
}
示例13: getMatrizRotacion
QMatrix4x4 iPolacion::getMatrizRotacion(QVector4D q){
QMatrix4x4 m = QMatrix4x4((1-(2*((q.y()*q.y())+(q.z()*q.z())))),
((2*q.x()*q.y())-(2*q.w()*q.z())),
((2*q.w()*q.y())+(2*q.x()*q.z())),
0
,
((2*q.x()*q.y())+(2*q.w()*q.z())),
(1-(2*((q.x()*q.x())+(q.z()*q.z())))),
((-2*q.w()*q.x())+(2*q.y()*q.z())),
0
,
((-2*q.w()*q.y())+(2*q.x()*q.z())),
((2*q.w()*q.x())+(2*q.y()*q.z())),
(1-(2*((q.x()*q.x())+(q.y()*q.y())))),
0
,
0,0,0,1);
return m;
}
示例14: glLineWidth
void
ClipPlanes::drawViewportBorders(QGLViewer *viewer)
{
int ow = viewer->width();
int oh = viewer->height();
float aspectRatio = viewer->aspectRatio();
viewer->startScreenCoordinatesSystem();
for (int i=0; i<m_clips.count(); i++)
{
QVector4D vp = m_clips[i]->viewport();
// render only when textured plane and viewport active
if (m_clips[i]->tfset() >= 0 &&
m_clips[i]->tfset() < Global::lutSize() &&
vp.x() >= 0.0)
{
int vx, vy, vh, vw;
vx = vp.x()*ow;
vy = oh-vp.y()*oh;
vw = vp.z()*ow;
vh = vp.w()*oh;
vx+=1; vy+=1;
vw-=2; vh-=2;
glLineWidth(2);
if (m_clips[i]->viewportGrabbed())
{
glLineWidth(3);
glColor3f(0.0, 1.0, 0.3);
}
else
{
Vec clipColor = m_clips[i]->color();
glColor3dv(clipColor);
}
glBegin(GL_LINE_STRIP);
glVertex2i(vx, vy);
glVertex2i(vx, vy-vh);
glVertex2i(vx+vw, vy-vh);
glVertex2i(vx+vw, vy);
glVertex2i(vx, vy);
glEnd();
if (m_clips[i]->viewportGrabbed())
{
glLineWidth(2);
glColor3f(0.8, 0.8, 0.8);
}
else
{
glLineWidth(1);
glColor3f(0.2, 0.2, 0.2);
}
glBegin(GL_LINE_STRIP);
glVertex2i(vx, vy);
glVertex2i(vx, vy-vh);
glVertex2i(vx+vw, vy-vh);
glVertex2i(vx+vw, vy);
glVertex2i(vx, vy);
glEnd();
}
}
viewer->stopScreenCoordinatesSystem();
}
示例15: convert
Ogre::Quaternion convert(const QVector4D &v)
{
return Ogre::Quaternion(v.w(),v.x(),v.y(),v.z());
}