当前位置: 首页>>代码示例>>C++>>正文


C++ QMatrix4x4::setRow方法代码示例

本文整理汇总了C++中QMatrix4x4::setRow方法的典型用法代码示例。如果您正苦于以下问题:C++ QMatrix4x4::setRow方法的具体用法?C++ QMatrix4x4::setRow怎么用?C++ QMatrix4x4::setRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMatrix4x4的用法示例。


在下文中一共展示了QMatrix4x4::setRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: matrixByAxisCamera

void Camera::matrixByAxisCamera(QMatrix4x4& result, const QVector3D& pos,
                                                    const QVector3D& vRightNormalized,
                                                    const QVector3D& vUpNormalized) const
{
    QVector3D right = vRightNormalized;
    QVector3D up = vUpNormalized;
    QVector3D dir = QVector3D::crossProduct(up, right);

    result.setToIdentity();

    result.setRow(0, right);
    result.setRow(1, dir);
    result.setRow(2, up);

    result.translate( -pos );
}
开发者ID:0rps,项目名称:3dmanager,代码行数:16,代码来源:camera.cpp

示例2: surfaceNormal

QVector4D Cylinder::surfaceNormal(const QVector4D &p, const Ray &ray)
{
    QVector4D lp = m_worldToObject * p;
    QMatrix4x4 a = m_worldToObject.transposed();
    a.setRow(3, QVector4D(0.0, 0.0, 0.0, 1.0));


    if (m_hasCaps && fabs(fabs(lp.y()) - m_length * 0.5) < MathUtils::dEpsilon) {
        // Return cap normal
        QVector4D n;
        if (lp.y() < 0.0)
            n = QVector4D(0.0, -1.0, 0.0, 0.0);
        else
            n = QVector4D(0.0, 1.0, 0.0, 0.0);
        return (a * n).normalized();
    } else {
        // calculate cylinder normal
        QVector4D o = QVector4D(0.0, lp.y(), 0.0, 1.0);
        QVector4D n = lp - o;
        n = a * n;

        QVector4D rd = -ray.direction();
        if (QVector4D::dotProduct(n, rd) < 0)
            return -n.normalized();
        else
            return n.normalized();
    }
}
开发者ID:elpuri,项目名称:reijo,代码行数:28,代码来源:cylinder.cpp

示例3: surfaceNormal

QVector4D Cone::surfaceNormal(const QVector4D &p, const Ray &ray)
{
    QVector4D objectP = m_worldToObject * p;

    QVector4D n = fabs(objectP.y()) < MathUtils::dEpsilon ? QVector4D(0.0, -1.0, 0.0, 0.0) :  // We're on the base disc
                                                            QVector4D(objectP.x(), 1.0 - objectP.y(), objectP.z(), 0.0);
    QMatrix4x4 a = m_worldToObject.transposed();
    a.setRow(3, QVector4D(0.0, 0.0, 0.0, 1.0));
    n = a * n;
    return n.normalized();
}
开发者ID:elpuri,项目名称:reijo,代码行数:11,代码来源:cone.cpp

示例4:

/**
* Get polygon oriented bounding box
**/
void Polygon3D::getLoopOBB(Loop3D &pin, QVector3D &size, QMatrix4x4 &xformMat){
	float alpha = 0.0f;			
	float deltaAlpha = 0.05*3.14159265359f;
	float bestAlpha;

	Loop3D rotLoop;
	QMatrix4x4 rotMat;
	QVector3D minPt, maxPt;
	QVector3D origMidPt;
	QVector3D boxSz;
	QVector3D bestBoxSz;
	float curArea;
	float minArea = FLT_MAX;

	rotLoop = pin;
	Polygon3D::getLoopAABB(rotLoop, minPt, maxPt);
	origMidPt = 0.5f*(minPt + maxPt);

	//while(alpha < 0.5f*_PI){
	int cSz = pin.size();
	QVector3D difVec;
	for(int i=0; i<pin.size(); ++i){
		difVec = (pin.at((i+1)%cSz) - pin.at(i)).normalized();
		alpha = atan2(difVec.x(), difVec.y());
		rotMat.setToIdentity();				
		rotMat.rotate(57.2957795f*(alpha), 0.0f, 0.0f, 1.0f);//57.2957795 rad2degree				

		transformLoop(pin, rotLoop, rotMat);
		boxSz = Polygon3D::getLoopAABB(rotLoop, minPt, maxPt);
		curArea = boxSz.x() * boxSz.y();
		if(curArea < minArea){
			minArea = curArea;
			bestAlpha = alpha;
			bestBoxSz = boxSz;
		}
		//alpha += deltaAlpha;
	}

	xformMat.setToIdentity();											
	xformMat.rotate(57.2957795f*(bestAlpha), 0.0f, 0.0f, 1.0f);//57.2957795 rad2degree
	xformMat.setRow(3, QVector4D(origMidPt.x(), origMidPt.y(), origMidPt.z(), 1.0f));			
	size = bestBoxSz;
}//
开发者ID:gnishida,项目名称:CityDesigner,代码行数:46,代码来源:Polygon3D.cpp

示例5: parseMoveData

void PSMoveForm::parseMoveData(MoveData d)
{
	setButtons(d.buttons);
	ui->tempLcdNumber->display(d.temperature);
	if (d.battery <= 5) {
		for (int i = 0; i < 5; i++) {
			mBatteryCheckBoxes[i].setChecked(i < d.battery);
		}
		mBatteryLayout->setCurrentIndex(0);
	} else {
		mBatteryLayout->setCurrentIndex(1);
	}
	//emit setRumble(d.buttons.trigger);
	/*const QVector3D acc = d.accelerometer.normalized() * 128 + QVector3D(128, 128, 128);
	const QColor rgb(acc.x(), acc.y(), acc.z());
	static int w = 0;
	if (w++ == 10) {
		w = 0;
		emit setRgb(rgb);
	}*/

	//QVector3D normalisedAcc = d.accelerometer / 32768;
	//QVector3D normalisedMag = d.mag / 32768;
	//normalisedAcc.normalize();
	//normalisedMag = QVector3D::crossProduct(normalisedMag.normalized(), normalisedAcc).normalized();
	//QVector3D north = QVector3D::crossProduct(normalisedMag, normalisedAcc).normalized();

	bool movePressedB = d.buttons.buttonsPressed.contains(MoveButtons::Move);
	if (!mPrevMovePressed && movePressedB) {

		//mOne = normalisedAcc;
		//mTwo = normalisedMag;
		//mThree = north;

		qDebug() << "acc:" << d.accelerometer;
		qDebug() << "mag:" << d.mag;
		emit movePressed();
	}
	mPrevMovePressed = movePressedB;
	/*float one = std::acos(QVector3D::dotProduct(normalisedAcc, mOne));
	float two = std::acos(QVector3D::dotProduct(normalisedMag, mTwo));
	float three = std::acos(QVector3D::dotProduct(north, mThree));*/
	//qDebug() << QString::number(one, 'g', 4) << QString::number(two, 'g', 4) << QString::number(three, 'g', 4);
	/*ui->accXProgressBar->setValue(one * 180 / M_PI);
	ui->accYProgressBar->setValue(two * 180 / M_PI);
	ui->accZProgressBar->setValue(three * 180 / M_PI);*/

	if (ui->accGroupBox->isChecked()) {
		ui->accXProgressBar->setValue(d.accelerometer.x());
		ui->accYProgressBar->setValue(d.accelerometer.y());
		ui->accZProgressBar->setValue(d.accelerometer.z());
	}

	if (ui->gyroGroupBox->isChecked()) {
		ui->gyroXProgressBar->setValue(d.gyro.x());
		ui->gyroYProgressBar->setValue(d.gyro.y());
		ui->gyroZProgressBar->setValue(d.gyro.z());
	}

	if (ui->magGroupBox->isChecked()) {
		ui->magXProgressBar->setValue(d.mag.x());
		ui->magYProgressBar->setValue(d.mag.y());
		ui->magZProgressBar->setValue(d.mag.z());
	}

	bool triPressed = d.buttons.buttonsPressed.contains(MoveButtons::Triangle);
	if (triPressed && !mPrevTriPressed) {
		emit setTopRightCorner();
	}
	mPrevTriPressed = triPressed;

	bool squPressed = d.buttons.buttonsPressed.contains(MoveButtons::Square);
	if (squPressed && !mPrevSquPressed) {
		emit setBottomLeftCorner();
	}
	mPrevSquPressed = squPressed;
#if 0
	QVector3D acc = d.accelerometer;
	QVector3D mag = d.mag;
	acc.normalize();
	mag.normalize();
	QMatrix4x4 m;
	m.setRow(2, acc);
	QVector3D east = QVector3D::crossProduct(acc, -mag);
	m.setRow(0, east);
	QVector3D north = QVector3D::crossProduct(acc, -mag);
	m.setRow(1, north);
	//qDebug() << mag;

//    QVector3D gyro = d.gyro / 32768;
//    acc.setX(mAccFilters[0]->step(acc.x()));
//    acc.setY(mAccFilters[1]->step(acc.y()));
//    acc.setZ(mAccFilters[2]->step(acc.z()));

//    mag.setX(mMagFilters[0]->step(mag.x()));
//    mag.setY(mMagFilters[1]->step(mag.y()));
//    mag.setZ(mMagFilters[2]->step(mag.z()));

	QVector3D newY = acc;
	QVector3D newZ = mag;
//.........这里部分代码省略.........
开发者ID:janisozaur,项目名称:ve,代码行数:101,代码来源:PSMoveForm.cpp


注:本文中的QMatrix4x4::setRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。