本文整理汇总了C++中QVector3D::setY方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector3D::setY方法的具体用法?C++ QVector3D::setY怎么用?C++ QVector3D::setY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector3D
的用法示例。
在下文中一共展示了QVector3D::setY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2:
/**
* @brief: Get polygon axis aligned bounding box
* @return: The dimensions of the AABB
**/
QVector3D Polygon3D::getLoopAABB(Loop3D &pin, QVector3D &minCorner, QVector3D &maxCorner)
{
maxCorner = QVector3D(-FLT_MAX, -FLT_MAX, -FLT_MAX);
minCorner = QVector3D( FLT_MAX, FLT_MAX, FLT_MAX);
QVector3D curPt;
for(int i=0; i<pin.size(); ++i){
curPt = pin.at(i);
if( curPt.x() > maxCorner.x() ){
maxCorner.setX(curPt.x());
}
if( curPt.y() > maxCorner.y() ){
maxCorner.setY(curPt.y());
}
if( curPt.z() > maxCorner.z() ){
maxCorner.setZ(curPt.z());
}
//------------
if( curPt.x() < minCorner.x() ){
minCorner.setX(curPt.x());
}
if( curPt.y() < minCorner.y() ){
minCorner.setY(curPt.y());
}
if( curPt.z() < minCorner.z() ){
minCorner.setZ(curPt.z());
}
}
return QVector3D(maxCorner - minCorner);
}//
示例3: aktivatePlaymode
void myCam::aktivatePlaymode(QVector3D kugelWhite, int abstand)
{
this->activePlaymode = true;
this->distanz = abstand;
this->kugelWhite = kugelWhite;
QVector3D position;
position.setX(kugelWhite.x());
position.setY(kugelWhite.y());
position.setZ(kugelWhite.z());
if(position.x()==0 && position.y()==0 && position.z() == 0)
{
position.setZ(-1);
}
position.normalize();
position.setX(position.x()*abstand + kugelWhite.x());
position.setY(8);
position.setZ(position.z()*abstand + kugelWhite.z());
//this->viewMatrix.setToIdentity();
//this->viewMatrix.lookAt(position,kugelWhite,QVector3D(0,1,0));
this->queueAnimation(position,kugelWhite,100);
position = position-kugelWhite;
if(position.x()>0 && position.z()>0)
{
this->angleY = atan(position.z()/position.x())*180/3.1415926-90;
}
else if(position.x()<0 && position.z()>0)
{
this->angleY = atan(-position.x()/position.z())*180/3.1415926;
}
else if(position.x()<0 && position.z()<0)
{
this->angleY = atan(position.z()/position.x())*180/3.1415926+90;
}
else if(position.x()>0 && position.z()<0)
{
this->angleY = atan(position.x()/-position.z())*180/3.1415926+180;
}
else if(position.x() == 0)
{
if(position.z()>0)
this->angleY = 0;
else
this->angleY = 180;
}
else if(position.z() == 0)
{
if(position.x()>0)
this->angleY = 270;
else
this->angleY = 90;
}
this->angleX = 15;
this->camRotate(0,0);
this->freeCameramode = false;
}
示例4: onSurfaceTranslationYChanged
void FsSurfaceTreeItem::onSurfaceTranslationYChanged(float fTransY)
{
QVector3D position = m_pRenderable3DEntity->position();
position.setY(fTransY);
m_pRenderable3DEntity->setPosition(position);
m_pRenderable3DEntityNormals->setPosition(position);
}
示例5: update
void BulletComponent::update(float delta)
{
EnemyComponent *enemy = target->getComponent<EnemyComponent>();
if(enemy != nullptr) {
destination = target->getPosition();
}
QVector3D dir = -(this->getEntity()->getPosition() - destination);
if(dir.length() < 10) {
if(enemy != nullptr) {
enemy->takeDamage(damage);
QVector3D v = getEntity()->getPosition();
v.setX(v.x() / 768);
v.setY(v.y() / 624);
v.setZ(0);
FMODManager::getInstance()->setCurrentEvent("event:/hit");
FMODManager::getInstance()->setEventInstancePosition(v);
FMODManager::getInstance()->setEventInstanceVolume(0.4);
FMODManager::getInstance()->setParameterValue("pitch", 0.3 + (qrand() % 200) * 0.001);
FMODManager::getInstance()->startEventInstance();
}
this->getEntity()->release();
} else {
dir.normalize();
this->getEntity()->setPosition(this->getEntity()->getPosition() + dir * speed * delta);
}
}
示例6: BoundingVolume
void Qt3DGeometryTab::computeBoundingVolume(const Qt3DGeometryAttributeData &vertexAttr,
const QByteArray &bufferData)
{
m_boundingVolume = BoundingVolume();
QVector3D v;
for (unsigned int i = 0; i < vertexAttr.count; ++i) {
const char *c = bufferData.constData() + vertexAttr.byteOffset + i * vertexAttr.byteStride;
switch (vertexAttr.vertexBaseType) {
case Qt3DRender::QAttribute::Float:
{
// cppcheck-suppress invalidPointerCast
auto f = reinterpret_cast<const float *>(c);
v.setX(*f);
++f;
v.setY(*f);
++f;
v.setZ(*f);
break;
}
default:
qWarning() << "Vertex type" << vertexAttr.vertexBaseType << "not implemented yet";
return;
}
m_boundingVolume.addPoint(v);
}
}
示例7: SetMember
void Transform::SetMember(QVector3D& member,const QVariant& data)
{
QList<QVariant> dataList(data.toList());
member.setX( dataList[0].toFloat() );
member.setY( dataList[1].toFloat() );
member.setZ( dataList[2].toFloat() );
}
示例8: cp
DisplayWindow *FourierDCT::invert(ComplexArray *ca, QString title, QImage::Format format, QWidget *p)
{
int w = ca->shape()[1];
int h = ca->shape()[2];
perform(ca, true);
ColorParser cp(format);
QImage result(w, h, format);
result.fill(Qt::black);
if (format == QImage::Format_Indexed8) {
QVector<QRgb> colors;
colors.reserve(256);
for (int i = 0; i < 256; i++) {
colors << qRgb(i, i, i);
}
result.setColorTable(colors);
}
for (unsigned int i = 1; i < ca->shape()[0]; i += 2) {
qreal min = 0;
qreal max = 0;
for (unsigned int j = 0; j < ca->shape()[1]; j++) {
for (unsigned int k = 0; k < ca->shape()[2]; k++) {
Complex c = (*ca)[i][j][k];
qreal real = c.real();
if (real > max) {
max = real;
} else if (real < min) {
min = real;
}
}
}
for (unsigned int j = 0; j < ca->shape()[1]; j++) {
for (unsigned int k = 0; k < ca->shape()[2]; k++) {
Complex c = (*ca)[i][j][k];
qreal p = (c.real() - min) / (max - min) * 255.0;
{
QVector3D oldPixel = cp.pixel(k, j, result);
QVector3D newPixel;
switch (i / 2) {
case 0:
newPixel.setX(p);
break;
case 1:
newPixel.setY(p);
break;
case 2:
newPixel.setZ(p);
break;
default:
break;
}
cp.setPixel(k, j, result, cp.merge(oldPixel, newPixel));
}
}
}
}
result = result.rgbSwapped();
PhotoWindow *pw = new PhotoWindow(result, title + ", IFDCT", p);
return pw;
}
示例9: result
DisplayWindow *ContrastFilter::apply(QString windowBaseName)
{
QImage result(mImg.size(), mFormat);
if (mFormat == QImage::Format_Indexed8 || mFormat == QImage::Format_Mono) {
result.setColorTable(mImg.colorTable());
}
ColorParser cp(mFormat);
float c = std::tan((float)mValue / 100.0f);
qDebug() << "contrast:" << c;
QVector<int> lut;
lut.reserve(256);
for (int i = 0; i < 256; i++) {
lut << qBound(0, (int)(c * (i - 127) + 127), 255);
}
for (int x = 0; x < mImg.width(); x++) {
for (int y = 0; y < mImg.height(); y++) {
QVector3D colorVec = cp.pixel(x, y, mImg);
colorVec.setX(lut.at((int)colorVec.x()));
colorVec.setY(lut.at((int)colorVec.y()));
colorVec.setZ(lut.at((int)colorVec.z()));
cp.setPixel(x, y, result, colorVec);
}
}
// parent's parent should be MainWindow
return new PhotoWindow(result, windowBaseName + ", " + name(), q_check_ptr(qobject_cast<QWidget *>(parent()->parent())));
}
示例10: calculatePorosity
void Particles::calculatePorosity()
{
int N = particles.size()/100;
if (N==0)
return;
int cnt = 1;
calculateBoundingBox();
float l = (boundsMax - boundsMin).length()/135.0;
qDebug() << "l = " << l;
for (int i=0;i<N;i++) {
QVector3D p;
p.setX(Util::floatRandom(boundsMin.x(), boundsMax.x()));
p.setY(Util::floatRandom(boundsMin.y(), boundsMax.y()));
p.setZ(Util::floatRandom(boundsMin.z(), boundsMax.z()));
for (int j=0;j<particles.size();j++) {
if ((particles[j]->getPos() - p).lengthSquared()<l*l) {
cnt++;
j=particles.size();
break;
}
}
if (rand()%100>=99)
qDebug() << cnt / (float)i;
}
m_calculatedPorosity = (float)cnt/(float)N;
// qDebug() << m_calculatedPorosity << " " << N << " / " << cnt;
}
示例11: qCalculateNormal
static bool qCalculateNormal(int i, int j, int k, QGeometryData &p, QVector3D *vec = 0)
{
QVector3D norm;
QVector3D *n = &norm;
if (vec)
n = vec;
bool nullTriangle = false;
*n = QVector3D::crossProduct(p.vertexAt(j) - p.vertexAt(i),
p.vertexAt(k) - p.vertexAt(j));
if (qFskIsNull(n->x()))
n->setX(0.0f);
if (qFskIsNull(n->y()))
n->setY(0.0f);
if (qFskIsNull(n->z()))
n->setZ(0.0f);
if (n->isNull())
{
nullTriangle = true;
}
else
{
setNormals(i, j, k, p, *n);
}
return nullTriangle;
}
示例12: initTrees
/**
* @brief GameWindow::initTrees, Lorsque le fichier binaire est vide, initialise les arbres des différentes saisons pour la fenêtre.
*/
void GameWindow::initTrees()
{
tree = new GameObject**[FileManager::NB_TERRAIN];
tree[Saison::PRINTEMPS] = new GameObject*[NB_ARBRES];
tree[Saison::ETE] = new GameObject*[NB_ARBRES];
tree[Saison::AUTOMNE] = new GameObject*[NB_ARBRES];
tree[Saison::HIVER] = new GameObject*[NB_ARBRES];
for(unsigned int j = 0 ; j < FileManager::NB_TERRAIN ; j++){
for(unsigned int i = 0 ; i < NB_ARBRES ; i++){
QVector3D pos;
int rand_x, rand_y, id;
rand_x = rand() % nb_vertex_width;
rand_y = rand() % nb_vertex_height;
id = rand_y * nb_vertex_width + rand_x;
pos.setX(p[id].x); pos.setY(p[id].y); pos.setZ(p[id].z);
if(j == Saison::PRINTEMPS){
tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/island_tree.ply");
}else if(j == Saison::ETE){
tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/summertree.ply");
}else if(j == Saison::AUTOMNE){
tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/autumntree.ply");
}else if(j == Saison::HIVER){
tree[j][i] = new GameObject(pos, QVector3D(0.f,0.f,0.f), QVector3D(0.1f,0.1f,0.1f), ":/wintertree.ply");
}
}
}
}
示例13: QGLWidget
HeightmapWidget::HeightmapWidget(QWidget *parent) :
QGLWidget(parent)
{
// Load heightmap
QImage img = QImage(":/heightmap.png");
vertices_by_x = img.width();
vertices_by_z = img.height();
quads_by_x = vertices_by_x - 1;
quads_by_z = vertices_by_z - 1;
QVector3D vertice;
for(int z = 0; z < vertices_by_z; ++z)
{
for(int x = 0; x < vertices_by_x; ++x)
{
QRgb color = img.pixel(x, z);
vertice.setX((MAP_SIZE * x / vertices_by_x) - MAP_SIZE / 2);
vertice.setY(2.0 * qGray(color) / 255);
vertice.setZ((MAP_SIZE * z / vertices_by_z) - MAP_SIZE / 2);
m_vertices.push_back(vertice);
}
}
// Timer settings
connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL()));
timer.start(20);
frame_count = 0;
last_count = 0;
last_time = QTime::currentTime();
}
示例14: centreNode
void nodeDock::centreNode( AEntity *ent ) // places the node in the centre of the view
{
nodeEntity *node( ent->castTo<nodeEntity*>() );
if( node )
{
connect( node, SIGNAL(requestNetworkRedraw()), mScene, SLOT(update()), Qt::UniqueConnection );
if( qFuzzyCompare( node->property("nodeEntity/pos")->toVector3D(), QVector3D( 0, 0, 0 ) ) )
{
// set pos to centre of screen
QPointF pos;
pos.setX(mView->rect().width()/2);
pos.setY(mView->rect().height()/2);
// get transformation matrix and invert it (viewMatrix moves the scene, so invert to move to view)
QTransform viewMatrix = mView->getTransform();
viewMatrix = viewMatrix.inverted();
// map point to matrix
pos = viewMatrix.map(pos);
// set position
QVector3D vectPos;
vectPos.setX(pos.x());
vectPos.setY(pos.y());
node->property("nodeEntity/pos") = vectPos;
}
//Rebuild gui from here, rather than direct signal so only rebuild on NODE added, not just any entity
rebuildGui();
}
}
示例15:
QVector3D& cube::createVectorByPoint(PointDDD& a,PointDDD& b)
{
QVector3D *tmp = new QVector3D();
tmp->setX(b.getX() - a.getX());
tmp->setY(b.getY() - a.getY());
tmp->setZ(b.getZ() - a.getZ());
return *tmp;
}