本文整理汇总了C++中QVector3D::z方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector3D::z方法的具体用法?C++ QVector3D::z怎么用?C++ QVector3D::z使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector3D
的用法示例。
在下文中一共展示了QVector3D::z方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glhProjectf
QVector2D SegmentGL::glhProjectf(QVector3D obj, float *modelview, float *projection, int width, int height)
{
//Transformation vectors
float fTempo[8];
//Modelview transform
fTempo[0]=modelview[0]*obj.x()+modelview[4]*obj.y()+modelview[8]*obj.z()+modelview[12]; //w is always 1
fTempo[1]=modelview[1]*obj.x()+modelview[5]*obj.y()+modelview[9]*obj.z()+modelview[13];
fTempo[2]=modelview[2]*obj.x()+modelview[6]*obj.y()+modelview[10]*obj.z()+modelview[14];
fTempo[3]=modelview[3]*obj.x()+modelview[7]*obj.y()+modelview[11]*obj.z()+modelview[15];
//Projection transform, the final row of projection matrix is always [0 0 -1 0]
//so we optimize for that.
fTempo[4]=projection[0]*fTempo[0]+projection[4]*fTempo[1]+projection[8]*fTempo[2]+projection[12]*fTempo[3];
fTempo[5]=projection[1]*fTempo[0]+projection[5]*fTempo[1]+projection[9]*fTempo[2]+projection[13]*fTempo[3];
fTempo[6]=projection[2]*fTempo[0]+projection[6]*fTempo[1]+projection[10]*fTempo[2]+projection[14]*fTempo[3];
fTempo[7]=-fTempo[2];
//The result normalizes between -1 and 1
// if(fTempo[7]==0.0) //The w value
// return 0;
fTempo[7]=1.0/fTempo[7];
//Perspective division
fTempo[4]*=fTempo[7];
fTempo[5]*=fTempo[7];
fTempo[6]*=fTempo[7];
//Window coordinates
//Map x, y to range 0-1
QVector2D win((fTempo[4]*0.5+0.5)*width, (fTempo[5]*0.5+0.5)*height);
//This is only correct when glDepthRange(0.0, 1.0)
//windowCoordinate[2]=(1.0+fTempo[6])*0.5; //Between 0 and 1
return win;
}
示例2:
// allow QVector3D's to be stored in a QMap
inline bool operator<(const QVector3D &a, const QVector3D &b)
{
if (qFskCompare(a.x(), b.x()))
{
if (qFskCompare(a.y(), b.y()))
{
if (qFskCompare(a.z(), b.z()))
{
return false; // equal so not less-than
}
else
{
return a.z() < b.z();
}
}
else
{
return a.y() < b.y();
}
}
else
{
return a.x() < b.x();
}
}
示例3: Intersection
bool SelectionQuery::Intersection(const AxisAlignedBox& box,
const QVector3D& ray_start, const QVector3D& ray_dir, double* result) {
const QVector3D& bmin = box.Min();
const QVector3D& bmax = box.Max();
const double inv_x = 1 / ray_dir.x();
const double inv_y = 1 / ray_dir.y();
const double inv_z = 1 / ray_dir.z();
const double tx1 = (bmin.x() - ray_start.x()) * inv_x;
const double tx2 = (bmax.x() - ray_start.x()) * inv_x;
double tmin = std::min(tx1, tx2);
double tmax = std::max(tx1, tx2);
const double ty1 = (bmin.y() - ray_start.y()) * inv_y;
const double ty2 = (bmax.y() - ray_start.y()) * inv_y;
tmin = std::max(tmin, std::min(ty1, ty2));
tmax = std::min(tmax, std::max(ty1, ty2));
const double tz1 = (bmin.z() - ray_start.z()) * inv_z;
const double tz2 = (bmax.z() - ray_start.z()) * inv_z;
tmin = std::max(tmin, std::min(tz1, tz2));
tmax = std::min(tmax, std::max(tz1, tz2));
if (tmax >= tmin && tmax > 0) {
*result = std::max(0.0, std::min(tmin, tmax));
return true;
}
return false;
}
示例4: setThresholds
void RtSourceDataWorker::setThresholds(const QVector3D& vecThresholds)
{
m_lHemiVisualizationInfo[0].dThresholdX = vecThresholds.x();
m_lHemiVisualizationInfo[0].dThresholdZ = vecThresholds.z();
m_lHemiVisualizationInfo[1].dThresholdX = vecThresholds.x();
m_lHemiVisualizationInfo[1].dThresholdZ = vecThresholds.z();
}
示例5: center
QVector<QVector3D> SurfaceItem::vertices() const
{
QSize size = surface()->size();
qreal w = (m_height * size.width()) / size.height();
qreal h = m_height;
QVector3D pos = m_pos + m_normal * m_depthOffset;
QVector2D center(pos.x(), pos.z());
QVector3D perp = QVector3D::crossProduct(QVector3D(0, 1, 0), m_normal);
QVector2D delta = w * QVector2D(perp.x(), perp.z()).normalized() / 2;
qreal scale = qMin(1.0, m_time.elapsed() * 0.002);
qreal top = m_pos.y() + h * 0.5 * scale;
qreal bottom = m_pos.y() - h * 0.5 * scale;
QVector2D left = center - delta * scale;
QVector2D right = center + delta * scale;
QVector3D va(left.x(), top, left.y());
QVector3D vb(right.x(), top, right.y());
QVector3D vc(right.x(), bottom, right.y());
QVector3D vd(left.x(), bottom, left.y());
QVector<QVector3D> result;
result << va << vb << vc << vd;
return result;
}
示例6: calcAngleSum
float Ray::calcAngleSum(QVector3D q, QVector<QVector4D> p)
{
float m1,m2;
float anglesum=0,costheta;
QVector3D p1,p2;
float twoPi = M_PI * 2;
int n = p.size();
for (int i=0;i<n;++i) {
p1.setX(p[i].x() - q.x());
p1.setY(p[i].y() - q.y());
p1.setZ(p[i].z() - q.z());
p2.setX(p[(i+1)%n].x() - q.x());
p2.setY(p[(i+1)%n].y() - q.y());
p2.setZ(p[(i+1)%n].z() - q.z());
m1 = p1.length();
m2 = p2.length();
if (m1*m2 <= 0.00001)
return 0; /* We are on a node, consider this inside */
else
costheta = (p1.x()*p2.x() + p1.y()*p2.y() + p1.z()*p2.z()) / (m1*m2);
anglesum += acos(costheta);
}
return qAbs(anglesum - twoPi);
}
示例7: Ecriture
void Maillage::Ecriture(std::string nom)
{
std::ofstream fichier(nom, std::ios::out | std::ios::trunc);
if(fichier)
{
fichier << "o " << nom << std::endl;
fichier << std::endl;
QVector3D temp;
for (int i = 0; i < geom.size(); ++i)
{
temp = geom.at(i);
fichier << "v " << temp.x() << " " << temp.y() << " " << temp.z() << std::endl;
}
fichier << std::endl;
for (int i = 0; i < normales.size(); ++i)
{
temp = normales.at(i);
fichier << "vn " << temp.x() << " " << temp.y() << " " << temp.z() << std::endl;
}
fichier << std::endl;
for (int i = 0; i < topo.size(); i+=3)
{
fichier << "f " << topo.at(i)+1 << " " << topo.at(i+1)+1 << " " << topo.at(i+2)+1 << std::endl;
}
fichier.close(); // on referme le fichier
}
else
{
std::cerr << "Erreur à l'ouverture !" << std::endl;
}
}
示例8: renderScanline
void WhittedRenderer::renderScanline(int y)
{
float* buffer = m_buffer + y * m_renderedWidth * 3;
float aspect = (float) m_renderedWidth / m_renderedHeight;
float xStep = 1.0 / (m_renderedWidth - 1);
float yStep = 1.0 / (m_renderedHeight - 1);
if (m_antiAliasing == None) {
for (int x=0; x < m_renderedWidth; x++) {
QVector3D shaded;
Ray primaryRay;
m_activeCamera->generateRay(primaryRay, x * xStep, y * yStep, aspect);
shaded = trace(primaryRay, 0, m_shapes, m_lights);
*buffer++ = shaded.x(); *buffer++ = shaded.y(); *buffer++ = shaded.z();
}
} else if (m_antiAliasing == JitteredSamples) {
float sampleScaler = 1.0 / m_samplesPerPixel;
for (int x=0; x < m_renderedWidth; x++) {
QVector3D shaded;
for (int i=0; i < m_samplesPerPixel; i++) {
Ray primaryRay;
float xJitter = i == 0 ? 0.0 : (MathUtils::randomf() * xStep);
float yJitter = i == 0 ? 0.0 : (MathUtils::randomf() * yStep);
float xSample = x * xStep + xJitter;
float ySample = y * yStep + yJitter;
m_activeCamera->generateRay(primaryRay, xSample, ySample, aspect);
shaded += trace(primaryRay, 0, m_shapes, m_lights) * sampleScaler;
}
*buffer++ = shaded.x(); *buffer++ = shaded.y(); *buffer++ = shaded.z();
}
}
}
示例9: RotateVector
void RotateVector(QVector3D &vec, double angledeg, QVector3D axis)//choose 1 axis of rotation at a time..
{
double prevx;
double prevy;
double prevz;
double cosval = qCos( angledeg * TO_RAD );
double sinval = qSin( angledeg * TO_RAD );
if(axis.x())
{
prevx = vec.x();
prevy = vec.y();
prevz = vec.z();
vec.setY( prevy * cosval - prevz * sinval);
vec.setZ( prevy * sinval + prevz * cosval);
}
if(axis.y())
{
prevx = vec.x();
prevy = vec.y();
prevz = vec.z();
vec.setZ( prevz * cosval - prevx * sinval);
vec.setX( prevz * sinval + prevx * cosval);
}
if(axis.z())
{
prevx = vec.x();
prevy = vec.y();
prevz = vec.z();
vec.setX( prevx * cosval - prevy * sinval);
vec.setY( prevx * sinval + prevy * cosval);
}
}
示例10: extend
const bool AxisAlignedBoundingBox::extend(const QVector3D & vertex)
{
const QVector3D llf(m_llf);
const QVector3D urb(m_urb);
if(vertex.x() < m_llf.x())
m_llf.setX(vertex.x());
if(vertex.x() > m_urb.x())
m_urb.setX(vertex.x());
if(vertex.y() < m_llf.y())
m_llf.setY(vertex.y());
if(vertex.y() > m_urb.y())
m_urb.setY(vertex.y());
if(vertex.z() < m_llf.z())
m_llf.setZ(vertex.z());
if(vertex.z() > m_urb.z())
m_urb.setZ(vertex.z());
const bool extended(urb != m_urb && llf != m_llf);
if(extended)
{
m_center = m_llf + (m_urb - m_llf) * .5f;
m_radius = (m_urb - m_llf).length() * .5f;
}
return extended;
}
示例11: setRotate
void Camera::setRotate(const QVector3D &_vec)
{
QVector3D diffRotate = m_rotate - _vec;
if(m_isFreeMode)
{
QQuaternion quaRight = QQuaternion::fromAxisAndAngle(m_right, -diffRotate.x() );
QQuaternion quaUp = QQuaternion::fromAxisAndAngle(m_up, -diffRotate.z() );
m_right = quaUp.rotatedVector(m_right);
m_up = quaRight.rotatedVector(m_up);
} else {
QQuaternion quaRight = QQuaternion::fromAxisAndAngle(m_right, diffRotate.x());
QQuaternion quaUp = QQuaternion::fromAxisAndAngle(m_up, diffRotate.z());
QQuaternion qua = quaUp*quaRight;
QVector3D rightRadiusVector = relativeRotate(m_right + m_cameraPos, qua, m_targetCamera);
QVector3D upRadiusVector = relativeRotate(m_up + m_cameraPos, qua, m_targetCamera);
m_cameraPos = relativeRotate(m_cameraPos, qua, m_targetCamera);
m_right = (rightRadiusVector - m_cameraPos).normalized();
m_up = (upRadiusVector - m_cameraPos).normalized();
}
matrixByAxisCamera(m_cameraMatrix, m_cameraPos, m_right, m_up);
m_rotate = _vec;
}
示例12: calculateBounds
void Connections::calculateBounds() {
for (int i = 0; i < edges.size(); i++) {
Edge *aedge = edges.at(i);
QVector3D afn = aedge->fn;
QVector3D atn = aedge->tn;
if (i==0){
max = QVector3D(afn.x(),afn.y(),afn.z());
min = QVector3D(afn.x(),afn.y(),afn.z());
} else {
max.setX(qMax(afn.x(),max.x()));
max.setY(qMax(afn.y(),max.y()));
max.setZ(qMax(afn.z(),max.z()));
min.setX(qMin(afn.x(),min.x()));
min.setY(qMin(afn.y(),min.y()));
min.setZ(qMin(afn.z(),min.z()));
max.setX(qMax(atn.x(),max.x()));
max.setY(qMax(atn.y(),max.y()));
max.setZ(qMax(atn.z(),max.z()));
min.setX(qMin(atn.x(),min.x()));
min.setY(qMin(atn.y(),min.y()));
min.setZ(qMin(atn.z(),min.z()));
}
}
piv = -(min+max)/2;
}
示例13: toMapF
inline QPointF Terrain::toMapF( const QVector3D & point ) const
{
return QPointF(
(point.x()-(float)mOffset.x()) * mToMapFactor.width(),
(point.z()-(float)mOffset.z()) * mToMapFactor.height()
);
}
示例14: init
Triangle::Triangle(QVector3D &p, QVector3D &q, QVector3D &r) {
_vertices[0]<<p.x(), p.y(), p.z();
_vertices[1]<<q.x(), q.y(), q.z();
_vertices[2]<<r.x(), r.y(), p.z();
init();
}
示例15: boundingRect
void SSTask::drawMeshes3D( const QSizeF& mapSize ) const
{
QRectF boundingRect(QPointF( -mapSize.width()/2.0, -mapSize.height()/2.0), mapSize);
glBegin(GL_TRIANGLES);
mutex.lockForRead();
for(int i = 0; i < m_meshes_cache.size(); i++){
Triangle3D t = m_meshes_cache.at(i);
if(!boundingRect.contains(t.v1.toPointF())
|| !boundingRect.contains(t.v2.toPointF())
|| !boundingRect.contains(t.v3.toPointF()))
continue;
QVector3D normal = QVector3D::crossProduct(t.v2 - t.v1, t.v3 - t.v1);
if(normal.z() < 0){
t = Triangle3D(t.v3, t.v2, t.v1);
normal.setZ( - normal.z());
}
glNormal3d(normal.x(), normal.y(), normal.z());
glVertex3d(t.v1.x(), t.v1.y(), t.v1.z());
glVertex3d(t.v2.x(), t.v2.y(), t.v2.z());
glVertex3d(t.v3.x(), t.v3.y(), t.v3.z());
}
mutex.unlock();
glEnd();
}