本文整理汇总了C++中QVector3D::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector3D::x方法的具体用法?C++ QVector3D::x怎么用?C++ QVector3D::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector3D
的用法示例。
在下文中一共展示了QVector3D::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateSegmentContour
void SegmentGL::CalculateSegmentContour(QVector<GLfloat> *positions, float lat_first, float lon_first, float lat_last, float lon_last)
{
QVector3D pos;
double sinlatdiff = sin((lat_first-lat_last)/2);
double sinlondiff = sin((lon_first-lon_last)/2);
double sinpsi = sqrt(sinlatdiff * sinlatdiff + cos(lat_first)*cos(lat_last)*sinlondiff * sinlondiff);
double delta = 2*asin(sinpsi);
int nDelta = 10;
double deltax = delta / (nDelta - 1);
double lonpos, latpos, dlon, tc;
tc = fmod(atan2(sin(lon_first-lon_last)*cos(lat_last), cos(lat_first)*sin(lat_last)-sin(lat_first)*cos(lat_last)*cos(lon_first-lon_last)) , 2 * PI);
for (int pix = 0 ; pix < nDelta; pix++)
{
latpos = asin(sin(lat_first)*cos(deltax * pix)+cos(lat_first)*sin(deltax * pix)*cos(tc));
dlon=atan2(sin(tc)*sin(deltax * pix)*cos(lat_first),cos(deltax * pix)-sin(lat_first)*sin(latpos));
lonpos=fmod( lon_first-dlon + PI,2*PI )-PI;
LonLat2PointRad(latpos, lonpos, &pos, 1.001f);
positions->append(pos.x());
positions->append(pos.y());
positions->append(pos.z());
}
}
示例2: getHeightAboveGround
inline bool Terrain::getHeightAboveGround( const QVector3D & position, float & heightAboveGround ) const
{
bool ret = getHeight( QPointF(position.x(),position.z()), heightAboveGround );
if( ret )
heightAboveGround = position.y() - heightAboveGround;
return ret;
}
示例3: RenderScene
void RayTracer::RenderScene(Scene * scene, Camera * camera, QImage * buffer)
{
buffer->fill(QColor(Qt::white).rgb());
double fov = camera->GetFOV();
double fov_2 = fov / 2.0;
double largestDim = std::max(camera->getXRes(), camera->getYRes());
double cameraPlaneDist = 0.5 * largestDim * tan((90 - fov_2) * DEGREE_TO_RAD);
// Assumes camera location is negative
// TODO: Fix this assumption
QVector3D cameraPlaneLocation = QVector3D(0, 0, camera->GetZPos() + cameraPlaneDist);
int y_2 = camera->getYRes() / 2;
int x_2 = camera->getXRes() / 2;
QVector3D cp = QVector3D(0, 0, camera->GetZPos());
for (int y = -y_2; y < y_2; ++y)
{
for (int x = - x_2; x < x_2; ++x)
{
// Compute the vector from the eye
QVector3D rayDirection = QVector3D(x, y, cameraPlaneLocation.z());
QVector3D color = TraceRay(scene, cp, rayDirection, 0);
buffer->setPixel(x + x_2, y + y_2, qRgb(color.x() * 255, color.y()* 255, color.z() * 255));
}
}
}
示例4: isSphereInFrustum
bool FrustumTest::isSphereInFrustum( QVector3D center, float radius ) const
{
for( int p = 0; p < 6; p++ )
if( mFrustum[p].x() * center.x() + mFrustum[p].y() * center.y() + mFrustum[p].z() * center.z() + mFrustum[p].w() <= -radius )
return false;
return true;
}
示例5: toMap
inline QPoint Terrain::toMap( const QPointF & point ) const
{
return QPoint(
floorf( (point.x()-mOffset.x()) * mToMapFactor.width() ),
floorf( (point.y()-mOffset.z()) * mToMapFactor.height() )
);
}
示例6: mouseDragged
void EulerBall::mouseDragged(const QVector3D ¤tPoint)
{
QVector3D delta = currentPoint - v_down;
phi_now = phi_down - 2.0 * atan(delta.x() / 2.0);
theta_now = theta_down - 2.0 * atan(delta.y() / 2.0);
}
示例7: createFrame
void GLGameModel::createFrame()
{
glNewList(frameDisplayListID, GL_COMPILE);
for(int i = 0; i < glModelFaces.size(); ++i)
{
GLModelFace face = glModelFaces.at(i);
// draw the model
glBegin(GL_POLYGON);
for(int n = 0; n < face.vertexIds.size(); ++n)
{
int x = face.vertexIds.at(n);
if(x < 0 || x >= vertices.size()) continue;
QVector3D v = vertices.at(x);
glVertex3f(v.x(), v.y(), v.z());
}
glEnd();
}
glEndList();
}
示例8: _generateMeshVertices
void SimpleRoadGraph::_generateMeshVertices(ucore::TextureManager* textureManager) {
ucore::RenderableQuadList* renderable = new ucore::RenderableQuadList(textureManager->get("data/textures/street.jpg"));
roadGraphEdgeIter ei, eend;
for (boost::tie(ei, eend) = boost::edges(myRoadGraph); ei != eend; ++ei) {
SimpleRoadGraphEdge* edge = &myRoadGraph[*ei];
QVector3D pt1 = myRoadGraph[boost::source(*ei, myRoadGraph)].getPt();
QVector3D pt2 = myRoadGraph[boost::target(*ei, myRoadGraph)].getPt();
QVector3D vec = pt2 - pt1;
vec = QVector3D(-vec.y(), vec.x(), 0.0f);
vec.normalize();
QVector3D p0 = pt1 + vec * edge->getWidth() / 2.0f + QVector3D(0, 0, heightAboveGround);
QVector3D p1 = pt1 - vec * edge->getWidth() / 2.0f + QVector3D(0, 0, heightAboveGround);
QVector3D p2 = pt2 - vec * edge->getWidth() / 2.0f + QVector3D(0, 0, heightAboveGround);
QVector3D p3 = pt2 + vec * edge->getWidth() / 2.0f + QVector3D(0, 0, heightAboveGround);
QVector3D normal = ucore::Util::calculateNormal(p0, p1, p2);
//renderable2->addQuad(p0, p1, p2, p3, normal, color);
renderable->addQuad(p0, p1, p2, p3, normal, 0, 1, 0, 1);
}
renderables.push_back(renderable);
}
示例9: 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);
}
}
示例10: Rotation
Maillage Maillage::Rotation(const double matrice[3][3])
{
QVector<QVector3D> geom2;
QVector3D temp;
for (int i = 0; i < geom.size(); ++i)
{
temp = geom.at(i);
temp.setX(temp.x() * matrice[0][0] + temp.y() * matrice[0][1] + temp.z() * matrice[0][2]);
temp.setY(temp.x() * matrice[2][0] + temp.y() * matrice[2][1] + temp.z() * matrice[2][2]);
temp.setZ(temp.x() * matrice[1][0] + temp.y() * matrice[1][1] + temp.z() * matrice[1][2]);
geom2.append(temp);
}
Maillage * sphere = new Maillage(geom2, topo, normales);
return *sphere;
}
示例11: QGLWidget
GLWidget::GLWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
resize(800,800);
QString filename = qApp->arguments().value(1,"");
qDebug() << "arglength: " << qApp->arguments().length();
if (filename == "artificial" || qApp->arguments().length() == 1) {
qDebug() << "creating new artificial data";
cons = new ArtificialConnections();
} else if (arg("nodes")!=""){
qDebug() << arg("nodes");
cons = new Connections(arg("nodes"), arg("cons"));
} else {
qDebug() << filename;
cons = new Connections(filename);
}
view = new GLfloat[16];
stuffAlpha = 0.99;
QVector3D size = cons->max-cons->min;
float largest = qMax(size.x(),size.y());
scale = (1/largest)*0.95;
bg = 1;
p1 = true;
p2 = true;
if (qApp->arguments().indexOf(QRegExp("-writefib"))!=-1) cons->writeBinaryVTK(filename+".fib");
if (qApp->arguments().indexOf(QRegExp("-screenshot"))!=-1) screenshot(filename+".png");
if (qApp->arguments().indexOf(QRegExp("-csv"))!=-1) cons->writeCSVs();
setFocus();
}
示例12: QRectF
QRectF Disk2dROI_QVecQVec3D::boundaryBox()
{
QVector3D c = d_center->getValue();
float r = d_radius->getValue();
return QRectF(c.x()-r,c.y()-r,2*r,2*r);
}
示例13: LoadModelGL
void ModelRenderer::LoadModelGL() {
Scene::Ptr scene = GetScene();
// Clear out any previously loaded model.
ClearModel();
// Load the model as a scene graph resource.
Scene::Ptr model = AssetImporter::ImportFile(GetResources(), model_fname_);
if (!model) {
return;
}
// Create a node in the main scene graph.
node_ = scene->MakeGroup(GetBaseNode());
// Instantiate the model as a child of the newly created node.
scene->MakeGroupFromScene(node_, model);
// Scale and translate the model so that it fits inside a unit cube
// centered at the origin.
const AxisAlignedBox& box = model->Root()->WorldBoundingBox();
const QVector3D span = box.Max() - box.Min();
const float max_span = std::max(std::max(span.x(), span.y()), span.z());
const double scale_factor = 1.0 / max_span;
node_->SetScale(QVector3D(scale_factor, scale_factor, scale_factor));
node_->SetTranslation(-0.5 * scale_factor * (box.Max() + box.Min()));
GetViewport()->ScheduleRedraw();
}
示例14: drawBall
void Quiddiards::drawBall(const Ball& ball){
glPushMatrix();
glTranslatef(ball.getX(), ball.getY(), ball.getZ());
//transpose the matrix because qt uses row-major matrix while opengl use column major matrix
glMultMatrixf(ball.getRotation().transposed().constData());
switch (ball.getType()){
case Ball::QUAFFLE:
bindTexture("quaffle.jpg");
break;
case Ball::BLUDGER:
bindTexture("bludger.jpg");
break;
case Ball::CUEBALL:
bindTexture("cueball.jpg");
break;
case Ball::SNITCH:
bindTexture("snitch.jpg");
break;
default:
QVector3D color = ball.getColor();
glColor3f(color.x(), color.y(), color.z());
break;
}
gluSphere(quad, ball.getR(), 16, 16);
releaseTexture();
glPopMatrix();
}
示例15: calculIntervalle
void Util_Move_Object_Class::calculIntervalle(QVector3D positionSource, QVector3D positionFinale, int time, Function::Type easingType){
if (easingType == 0){
for (int i = 0; i < time/16; i++){ // number of position to calcul
intervalleTranslate.append(QVector3D((positionFinale.x() - positionSource.x())/time*16, (positionFinale.y()-positionSource.y())/time*16, (positionFinale.z()- positionSource.z())/time*16));
}
}
else if(easingType == 1){
}
else if(easingType == 2){
}
else if(easingType == 3){
}
}