本文整理汇总了C++中QVector4D::setZ方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector4D::setZ方法的具体用法?C++ QVector4D::setZ怎么用?C++ QVector4D::setZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector4D
的用法示例。
在下文中一共展示了QVector4D::setZ方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: retrieveColor
inline void AssimpScene::retrieveColor(
const aiMaterial * mtl
, const char * pKey
, const unsigned int type
, const unsigned int index
, QVector4D & color
, const float r
, const float g
, const float b
, const float a)
{
aiColor4D acolor;
if (AI_SUCCESS == aiGetMaterialColor(mtl, pKey, type, index, &acolor))
{
color.setX(acolor.r);
color.setY(acolor.g);
color.setZ(acolor.b);
color.setW(acolor.a);
}
else
{
color.setX(r);
color.setY(g);
color.setZ(b);
color.setW(a);
}
}
示例2: getValue
void PropertyGroup::getValue(QVector4D & v)
{
v.setX(properties.at(0)->getValue());
v.setY(properties.at(1)->getValue());
v.setZ(properties.at(2)->getValue());
v.setW(properties.at(3)->getValue());
}
示例3: _fromScreenToWorld
void GLWidget::_fromScreenToWorld(QVector3D *answer, const QVector4D &screenCoordinates, bool forcedHeight, double height)
{
QVector4D worldCoordinates;
if(projection == PERSPECTIVE)
{
TwoDimArray a(finalMatrixInverse.data());
QVector4D screenCoordPersp;
screenCoordinatesPerspective(&screenCoordPersp, a, height, screenCoordinates);
if(!forcedHeight && screenCoordPersp.z() < 0)
{
height = int(camera[projection].position().z()) + 2 * (camera[projection].position().z() > 0) - 1;
screenCoordinatesPerspective(&screenCoordPersp, a, height, screenCoordinates);
}
worldCoordinates = finalMatrixInverse * screenCoordPersp;
worldCoordinates.setZ(height);
}
else worldCoordinates = finalMatrixInverse * screenCoordinates;
*answer = QVector3D(worldCoordinates);
}
示例4: setData
bool PropertyMatrixModel::setData(const QModelIndex &index, const QVariant &data, int role)
{
if (!index.isValid())
return false;
if (role != Qt::EditRole)
return false;
bool ok = false;
float floatData = data.toFloat(&ok);
if (!ok)
return false;
switch (m_matrix.type()) {
case QVariant::Vector2D: {
QVector2D value = m_matrix.value<QVector2D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Vector3D: {
QVector3D value = m_matrix.value<QVector3D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
case 2: value.setZ(floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Vector4D: {
QVector4D value = m_matrix.value<QVector4D>();
switch (index.row()) {
case 0: value.setX(floatData); break;
case 1: value.setY(floatData); break;
case 2: value.setZ(floatData); break;
case 3: value.setW(floatData); break;
}
m_matrix = value;
break;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
case QVariant::Quaternion: {
float pitch, yaw, roll;
const QQuaternion value = m_matrix.value<QQuaternion>();
value.getEulerAngles(&pitch, &yaw, &roll);
switch (index.row()) {
case 0: pitch = floatData; break;
case 1: yaw = floatData; break;
case 2: roll = floatData; break;
}
m_matrix = QQuaternion::fromEulerAngles(pitch, yaw, roll);
break;
}
#endif
case QVariant::Matrix: {
QMatrix value = m_matrix.value<QMatrix>();
switch (index.row() << 4 | index.column()) {
case 0x00: value.setMatrix(floatData, value.m12(), value.m21(), value.m22(), value.dx(), value.dy()); break;
case 0x01: value.setMatrix(value.m11(), floatData, value.m21(), value.m22(), value.dx(), value.dy()); break;
case 0x10: value.setMatrix(value.m11(), value.m12(), floatData, value.m22(), value.dx(), value.dy()); break;
case 0x11: value.setMatrix(value.m11(), value.m12(), value.m21(), floatData, value.dx(), value.dy()); break;
case 0x20: value.setMatrix(value.m11(), value.m12(), value.m21(), value.m22(), floatData, value.dy()); break;
case 0x21: value.setMatrix(value.m11(), value.m12(), value.m21(), value.m22(), value.dx(), floatData); break;
}
m_matrix = value;
break;
}
case QVariant::Transform: {
QTransform value = m_matrix.value<QTransform>();
switch (index.row() << 4 | index.column()) {
case 0x00: value.setMatrix(floatData, value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x01: value.setMatrix(value.m11(), floatData, value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x02: value.setMatrix(value.m11(), value.m12(), floatData, value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x10: value.setMatrix(value.m11(), value.m12(), value.m13(), floatData, value.m22(), value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x11: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), floatData, value.m23(), value.m31(), value.m32(), value.m33()); break;
case 0x12: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), floatData, value.m31(), value.m32(), value.m33()); break;
case 0x20: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), floatData, value.m32(), value.m33()); break;
case 0x21: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), floatData, value.m33()); break;
case 0x22: value.setMatrix(value.m11(), value.m12(), value.m13(), value.m21(), value.m22(), value.m23(), value.m31(), value.m32(), floatData); break;
}
m_matrix = value;
//.........这里部分代码省略.........
示例5: leftMouseDown
void CombinedNavRenderer::leftMouseDown( int x, int y )
{
float xf = static_cast<float>( x );
float yf = static_cast<float>( m_height - y );
QVector4D test;
test.setX( ( 2 * xf ) / m_width - 1 );
test.setY( ( 2 * yf ) / m_height - 1 );
test.setZ( 1 );
test.setW( 1 );
int xout;
int yout;
QVector4D out = m_mvpMatrix.inverted() * test;
QModelIndex mi;
if ( m_ratio > 1.5 )
{
xout = out.x() / m_dx;
if ( ( (float)out.x() / m_dx ) < m_nx )
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = out.y() / m_dy;
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
else if ( ( (float)out.x() / m_dx ) < m_nx * 2 )
{
xout = xout - m_nx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = out.y() / m_dz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
else
{
xout = xout - ( 2 * m_nx );
xout = qMax( 0, qMin( m_ny - xout - 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = out.y() / m_dz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
}
else if ( m_ratio < 0.66 )
{
yout = out.y() / m_dz;
if ( ( (float)out.y() / m_dz ) < m_nz )
{
xout = out.x() / m_dy;
xout = qMax( 0, qMin( m_ny - xout - 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
else if ( ( (float)out.y() / m_dz ) < m_nz * 2 )
{
xout = out.x() / m_dx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - m_nz;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
else
{
xout = out.x() / m_dx;
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - ( 2 * m_nz );
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
}
else
{
xout = out.x() / m_dx;
yout = out.y() / m_dy;
if ( ( (float)out.x() / m_dx ) < m_nx )
{
if ( ( (float)out.y() / m_dy ) < m_nz )
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = qMax( 0, qMin( yout, static_cast<int>( m_ny - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_CORONAL, 0 );
}
else
{
xout = qMax( 0, qMin( xout, static_cast<int>( m_nx - 1.0 ) ) );
yout = yout - m_ny;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::SAGITTAL_AXIAL, 0 );
}
}
else
{
xout = xout - m_nx;
xout = qMax( 0, qMin( m_ny - xout- 1, static_cast<int>( m_ny - 1.0 ) ) );
yout = yout - m_ny;
yout = qMax( 0, qMin( yout, static_cast<int>( m_nz - 1.0 ) ) );
mi = model()->index( (int)Fn::Global::CORONAL_AXIAL, 0 );
}
}
QPoint p( xout, yout );
//.........这里部分代码省略.........
示例6: importObject
static MeshPtr importObject(QDataStream &stream)
{
using namespace Ogre;
QVector4D bbMin, bbMax;
stream >> bbMin >> bbMax;
float distance, distanceSquared; // Here's a bug for you: writes "double"'s instead of floats
stream >> distanceSquared >> distance;
MeshPtr ogreMesh = MeshManager::getSingleton().createManual("conversion",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
int vertexCount, indexCount;
stream >> vertexCount >> indexCount;
VertexData *vertexData = new VertexData();
ogreMesh->sharedVertexData = vertexData;
LogManager::getSingleton().logMessage("Reading geometry...");
VertexDeclaration* decl = vertexData->vertexDeclaration;
VertexBufferBinding* bind = vertexData->vertexBufferBinding;
unsigned short bufferId = 0;
// Information for calculating bounds
Vector3 min = Vector3::ZERO, max = Vector3::UNIT_SCALE, pos = Vector3::ZERO;
Real maxSquaredRadius = -1;
bool firstVertex = true;
/*
Create a vertex definition for our buffer
*/
size_t offset = 0;
const VertexElement &positionElement = decl->addElement(bufferId, offset, VET_FLOAT3, VES_POSITION);
offset += VertexElement::getTypeSize(VET_FLOAT3);
const VertexElement &normalElement = decl->addElement(bufferId, offset, VET_FLOAT3, VES_NORMAL);
offset += VertexElement::getTypeSize(VET_FLOAT3);
// calculate how many vertexes there actually are
vertexData->vertexCount = vertexCount;
// Now create the vertex buffer
HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().
createVertexBuffer(offset, vertexData->vertexCount,
HardwareBuffer::HBU_STATIC_WRITE_ONLY, false);
// Bind it
bind->setBinding(bufferId, vbuf);
// Lock it
unsigned char *pVert = static_cast<unsigned char*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
unsigned char *pVertStart = pVert;
QVector<float> positions;
positions.reserve(vertexCount * 3);
// Iterate over all children (vertexbuffer entries)
for (int i = 0; i < vertexCount; ++i) {
float *pFloat;
QVector4D vertex;
stream >> vertex;
vertex.setZ(vertex.z() * -1);
/* Copy over the position */
positionElement.baseVertexPointerToElement(pVert, &pFloat);
*(pFloat++) = (float)vertex.x();
*(pFloat++) = (float)vertex.y();
*(pFloat++) = (float)vertex.z();
positions.append(vertex.x());
positions.append(vertex.y());
positions.append(vertex.z());
/* While we're at it, calculate the bounding sphere */
pos.x = vertex.x();
pos.y = vertex.y();
pos.z = vertex.z();
if (firstVertex) {
min = max = pos;
maxSquaredRadius = pos.squaredLength();
firstVertex = false;
} else {
min.makeFloor(pos);
max.makeCeil(pos);
maxSquaredRadius = qMax(pos.squaredLength(), maxSquaredRadius);
}
pVert += vbuf->getVertexSize();
}
// Set bounds
const AxisAlignedBox& currBox = ogreMesh->getBounds();
Real currRadius = ogreMesh->getBoundingSphereRadius();
if (currBox.isNull())
{
//do not pad the bounding box
//.........这里部分代码省略.........