本文整理汇总了C++中QMatrix4x4::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QMatrix4x4::data方法的具体用法?C++ QMatrix4x4::data怎么用?C++ QMatrix4x4::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMatrix4x4
的用法示例。
在下文中一共展示了QMatrix4x4::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attrib_buffers
void Viewer::attrib_buffers(QGLViewer* viewer)
{
QMatrix4x4 mvpMatrix;
QMatrix4x4 mvMatrix;
double mat[16];
viewer->camera()->getModelViewProjectionMatrix(mat);
for(int i=0; i < 16; i++)
{
mvpMatrix.data()[i] = (float)mat[i];
}
viewer->camera()->getModelViewMatrix(mat);
for(int i=0; i < 16; i++)
{
mvMatrix.data()[i] = (float)mat[i];
}
// define material
QVector4D ambient(0.25f, 0.20725f, 0.20725f, 0.922f);
QVector4D diffuse( 1.0f,
0.829f,
0.829f,
0.922f );
QVector4D specular( 0.6f,
0.6f,
0.6f,
1.0f );
QVector4D position(0.0f,0.0f,1.0f,1.0f );
GLfloat shininess = 11.264f;
rendering_program.bind();
mvpLocation = rendering_program.uniformLocation("mvp_matrix");
mvLocation = rendering_program.uniformLocation("mv_matrix");
colorLocation = rendering_program.uniformLocation("color");
lightLocation[0] = rendering_program.uniformLocation("light_pos");
lightLocation[1] = rendering_program.uniformLocation("light_diff");
lightLocation[2] = rendering_program.uniformLocation("light_spec");
lightLocation[3] = rendering_program.uniformLocation("light_amb");
lightLocation[4] = rendering_program.uniformLocation("spec_power");
rendering_program.setUniformValue(lightLocation[0], position);
rendering_program.setUniformValue(lightLocation[1], diffuse);
rendering_program.setUniformValue(lightLocation[2], specular);
rendering_program.setUniformValue(lightLocation[3], ambient);
rendering_program.setUniformValue(lightLocation[4], shininess);
rendering_program.setUniformValue(mvpLocation, mvpMatrix);
rendering_program.setUniformValue(mvLocation, mvMatrix);
rendering_program.release();
rendering_program_points.bind();
mvpLocation_points = rendering_program_points.uniformLocation("mvp_matrix");
colorLocation_points = rendering_program_points.uniformLocation("color");
rendering_program_points.setUniformValue(mvpLocation_points, mvpMatrix);
rendering_program_points.release();
}
示例2: attrib_buffers
void Scene_implicit_function_item::attrib_buffers(Viewer* viewer) const
{
QMatrix4x4 mvpMatrix;
QMatrix4x4 fMatrix;
double mat[16];
viewer->camera()->getModelViewProjectionMatrix(mat);
for(int i=0; i < 16; i++)
{
mvpMatrix.data()[i] = (float)mat[i];
}
frame_->getMatrix(mat);
for(int i=0; i < 16; i++)
{
fMatrix.data()[i] = (float)mat[i];
}
rendering_program.bind();
colorLocation[0] = rendering_program.uniformLocation("color");
mvpLocation[0] = rendering_program.uniformLocation("mvp_matrix");
rendering_program.setUniformValue(mvpLocation[0], mvpMatrix);;
rendering_program.release();
tex_rendering_program.bind();
colorLocation[1] = tex_rendering_program.uniformLocation("color");
f_Location = tex_rendering_program.uniformLocation("f_matrix");
mvpLocation[1] = tex_rendering_program.uniformLocation("mvp_matrix");
tex_rendering_program.setUniformValue(mvpLocation[1], mvpMatrix);;
tex_rendering_program.setUniformValue(f_Location, fMatrix);;
tex_rendering_program.release();
}
示例3: qglClearColor
void Dragon2Widget::paintGL()
{
qglClearColor(Qt::white);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// use the OpenGL shader program for painting
glUseProgram(_program);
// set model matrix
glUniformMatrix4fv(_modelMatrixLocation, 1, GL_FALSE, _modelMatrix.data());
// set view matrix
QMatrix4x4 viewMatrix;
viewMatrix.setToIdentity();
viewMatrix.lookAt(QVector3D(0, 0, -1000), QVector3D(0, 0, 0), QVector3D(0, -1, 0));
glUniformMatrix4fv(_viewMatrixLocation, 1, GL_FALSE, viewMatrix.data());
// set projection matrix
QMatrix4x4 projectionMatrix;
projectionMatrix.setToIdentity();
projectionMatrix.perspective(30, (float)width()/height(), 0.01f, 1e5f);
glUniformMatrix4fv(_projectionMatrixLocation, 1, GL_FALSE, projectionMatrix.data());
// bind ArrayBuffer to _vertBuffer
glBindBuffer(GL_ARRAY_BUFFER, _vertBuffer);
// enable vertex attribute "position" (bound to 0 already)
glEnableVertexAttribArray(0);
// set the data of vertex attribute "position" using current ArrayBuffer
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(_vertices.first()), 0);
// enable vertex attribute "normal" (bound to 1 already)
glEnableVertexAttribArray(1);
// set the data of vertex attribute "normal" using current ArrayBuffer
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(_vertices.first()), (void*)(3 * sizeof(float)));
// bind ElementArrayBuffer to _triangleIndicesBuffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _triangleIndicesBuffer);
// draw mesh using the indices stored in ElementArrayBuffer
glDrawElements(GL_TRIANGLES, _triangleIndices.size(), GL_UNSIGNED_INT, 0);
// disable vertex attributes
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
// unbind buffers
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
// restore states
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
}
示例4: attrib_buffers
void Viewer::attrib_buffers(CGAL::QGLViewer* viewer)
{
QMatrix4x4 mvpMatrix;
QMatrix4x4 mvMatrix;
double mat[16];
viewer->camera()->getModelViewProjectionMatrix(mat);
for(int i=0; i < 16; i++)
{
mvpMatrix.data()[i] = (float)mat[i];
}
viewer->camera()->getModelViewMatrix(mat);
for(int i=0; i < 16; i++)
{
mvMatrix.data()[i] = (float)mat[i];
}
// define material
QVector4D diffuse( 0.9f,
0.9f,
0.9f,
0.9f );
QVector4D specular( 0.0f,
0.0f,
0.0f,
1.0f );
QVector4D position((bb.xmax()-bb.xmin())/2, (bb.ymax()-bb.ymin())/2,bb.zmax(), 0.0 );
GLfloat shininess = 1.0f;
rendering_program.bind();
mvpLocation[0] = rendering_program.uniformLocation("mvp_matrix");
mvLocation = rendering_program.uniformLocation("mv_matrix");
lightLocation[0] = rendering_program.uniformLocation("light_pos");
lightLocation[1] = rendering_program.uniformLocation("light_diff");
lightLocation[2] = rendering_program.uniformLocation("light_spec");
lightLocation[3] = rendering_program.uniformLocation("light_amb");
lightLocation[4] = rendering_program.uniformLocation("spec_power");
rendering_program.setUniformValue(lightLocation[0], position);
rendering_program.setUniformValue(lightLocation[1], diffuse);
rendering_program.setUniformValue(lightLocation[2], specular);
rendering_program.setUniformValue(lightLocation[3], ambient);
rendering_program.setUniformValue(lightLocation[4], shininess);
rendering_program.setUniformValue(mvpLocation[0], mvpMatrix);
rendering_program.setUniformValue(mvLocation, mvMatrix);
rendering_program.release();
rendering_program_p_l.bind();
mvpLocation[1] = rendering_program_p_l.uniformLocation("mvp_matrix");
colorLocation = rendering_program_p_l.uniformLocation("color");
rendering_program.setUniformValue(mvpLocation[1], mvpMatrix);
rendering_program_p_l.release();
}
示例5: apply
void PipeLine::apply(ShaderProgram *shader)
{
initializeOpenGLFunctions();
QMatrix4x4 MVP = m_projection*m_view*m_model;
QMatrix4x4 MV = m_view * m_model;
shader->setUniformMat4v("g_MVP_matrix", MVP.data());
shader->setUniformMat4v("g_MV_matrix", MV.data());
shader->setUniformMat4v("g_model_matrix", m_model.data());
shader->setUniformMat4v("g_projection_matrix",m_projection.data());
shader->setUniform3Float("g_eye_position",m_eyePosition.x(),m_eyePosition.y(), m_eyePosition.z());
shader->setUniform3Float ("g_eye_dir",m_eyeDirection.x (),m_eyeDirection.y (),m_eyeDirection.z ());
}
示例6:
void CAnm2D::convMat(double *ret, const QMatrix4x4 &mat)
{
const qreal *p = mat.data() ;
for ( int i = 0 ; i < 16 ; i ++ ) {
ret[i] = p[i] ;
}
}
示例7: pointLightPass
void Scene::pointLightPass(RenderTarget *target)
{
if(!this->pointLights.empty ())
{
for(int i =0;i<pointLights.size ();i++)
{
ShaderProgram * shader = ShaderPool::getInstance ()->get("point_light_pass");
shader->use ();
PointLight * light = this->pointLights[i];
light->apply (shader,0);
m_quad->setShaderProgram (shader);
QMatrix4x4 m;
m.setToIdentity ();
auto camera = target->camera ();
shader->setUniformMat4v ("g_MVP_matrix",m.data ());
shader->setUniform2Float ("g_screen_size",1024,768);
shader->setUniformInteger ("g_color_map",0);
shader->setUniformInteger ("g_position_map",1);
shader->setUniformInteger ("g_normal_map",2);
shader->setUniform3Float ("g_eye_position",
camera->pos ().x(),
camera->pos ().y(),
camera->pos ().z());
m_quad->draw (true);
}
}
}
示例8: rotToFloatArray
void Render::rotToFloatArray(float conv[16]) {
QMatrix4x4 mat = rotToMatrix();
qreal *from = mat.data();
for (int i = 0; i < 16; i++) {
conv[i] = from[i];
}
}
示例9: directionLightPass
void Scene::directionLightPass(RenderTarget *target)
{
ShaderProgram * shader =ShaderPool::getInstance ()->get("dir_light_pass");
shader->use ();
int texture_offset = 5;
for(int i = 0 ;i<4;i++)
{
directionLight.getCSM_FBO (i)->BindForReading(GL_TEXTURE0+i+texture_offset);
char GLSL_shadowMap_name [30];
sprintf(GLSL_shadowMap_name,"g_shadow_map[%d]",i);
directionLight.getCSM_FBO (i)->applyShadowMapTexture (shader,i+texture_offset,GLSL_shadowMap_name);
}
QMatrix4x4 m;
m.setToIdentity ();
m_quad->setShaderProgram (shader);
shader->setUniformMat4v ("g_MVP_matrix",m.data ());
shader->setUniform2Float ("g_screen_size",1024,768);
shader->setUniformInteger ("g_color_map",0);
shader->setUniformInteger ("g_position_map",1);
shader->setUniformInteger ("g_normal_map",2);
shader->setUniformInteger ("g_depth_map",4);//for depth
auto camera = target->camera ();
if(camera)
{
shader->setUniform3Float ("g_eye_position",
camera->pos ().x(),
camera->pos ().y(),
camera->pos ().z());
}
QMatrix4x4 lightView;
lightView.setToIdentity();
QVector3D lightDir = directionLight.getDirection ();
QVector3D pos = QVector3D(0,0,0);
lightView.lookAt(pos,lightDir,QVector3D(0,1,0));
for(int i =0 ;i <4 ;i++)
{
if(!camera) break;
auto split_frustum_aabb = camera->getSplitFrustumAABB (i);
split_frustum_aabb.transForm (target->camera()->getModelTrans ());
split_frustum_aabb.transForm (lightView);
auto matrix = getCropMatrix (split_frustum_aabb);
QMatrix4x4 light_vp;
light_vp = matrix * lightView ;
char GLSL_light_VP_name [30];
sprintf(GLSL_light_VP_name,"g_light_vp_matrix[%d]",i);
shader->setUniformMat4v (GLSL_light_VP_name,light_vp.data ());
}
this->directionLight.apply(shader);
this->ambientLight.apply(shader);
m_quad->draw (true);
}
示例10: setUniform
//points position
void PagShaderProgram::setUniform(std::string name, QMatrix4x4 value)
{
GLint location = glGetUniformLocation(program, name.c_str());
if (location >= 0) {
glUniformMatrix4fv(location, 1, GL_FALSE, value.data());
} else {
qDebug() << "No es posible encontrar localización para: " << name.c_str();
}
}
示例11:
QMatrix4x4 Qgs3DUtils::stringToMatrix4x4( const QString &str )
{
QMatrix4x4 m;
float *d = m.data();
QStringList elems = str.split( ' ' );
for ( int i = 0; i < 16; ++i )
d[i] = elems[i].toFloat();
return m;
}
示例12: paintGL
void DragonWidget::paintGL()
{
makeCurrent();
qglClearColor(Qt::white);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_SMOOTH);
// set model-view matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
QMatrix4x4 viewMatrix;
viewMatrix.lookAt(QVector3D(0, 0, -1000), QVector3D(0, 0, 0), QVector3D(0, -1, 0));
glMultMatrixf(viewMatrix.data());
glMultMatrixf(_modelMatrix.data()); // now model-view matrix = lookAt(...) * _modelMatrix
// set projection matrix
// (projection matrix is often set in resizeGL(width, height) functions,
// since it only relies on the size of the window in most cases)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
QMatrix4x4 projectionMatrix;
projectionMatrix.perspective(30.0f, (float)width() / height(), 0.01f, 1e5f);
glMultMatrixf(projectionMatrix.data());
// draw mesh
glBegin(GL_TRIANGLES);
for(int vid : _triangleIndices)
{
glColor3fv(&(_vertices[vid].normal[0]));
glVertex3fv(&(_vertices[vid].position[0]));
}
glEnd();
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
}
示例13: glGetFloatv
QMatrix4x4 Object3D::glGetMatrix(GLenum fetchType)
{
QMatrix4x4 ret;
GLfloat mat[16];
glGetFloatv(fetchType, mat);
//float *m = ret.data();
qreal *m = ret.data();
for (int index = 0; index < 16; ++index)
m[index] = mat[index];
return ret;
}
示例14: initializeTexGeometry
void MusikQuadRender::initializeTexGeometry()
{
ShapeData shape = ShapeGenerator::makeQuadTex();
tVertex.create();
tVertex.bind();
tVertex.setUsagePattern(QOpenGLBuffer::StaticDraw);
tVertex.allocate(shape.vertices,shape.numVertices*sizeof(Vertex));
tObject.create();
tObject.bind();
programm->enableAttributeArray(vposAttr);
programm->enableAttributeArray(vcolAttr);
programm->setAttributeBuffer(vposAttr,GL_FLOAT,Vertex::positionOffset(),Vertex::PositionTupleSize,Vertex::stride());
programm->setAttributeBuffer(vcolAttr,GL_FLOAT,Vertex::colorOffset(),Vertex::ColorTupleSize,Vertex::stride());
tIndex.create();
tIndex.bind();
tIndex.setUsagePattern(QOpenGLBuffer::StaticDraw);
tIndex.allocate(shape.indices,shape.indexBufferSize());
numIndx = shape.numIndices;
tVertex.release();
tObject.release();
tTransform.create();
tTransform.bind();
tTransform.setUsagePattern(QOpenGLBuffer::StaticDraw);
tTransform.allocate(quadTransforms,sizeof(QMatrix4x4)*numQuads);
tObject.bind();
programm->setAttributeBuffer(vmatrixAttr,GL_FLOAT,sizeof(QVector4D)*0,4,sizeof(QMatrix4x4));
QMatrix4x4 mat;
programm->setAttributeValue(vmatrixAttr,mat.data(),4,4);
tObject.release();
tTransform.release();
shape.cleanup();
}
示例15: getTransformMatrix
QMatrix4x4 AndroidSurfaceTexture::getTransformMatrix()
{
QMatrix4x4 matrix;
if (!m_surfaceTexture.isValid())
return matrix;
QJNIEnvironmentPrivate env;
jfloatArray array = env->NewFloatArray(16);
m_surfaceTexture.callMethod<void>("getTransformMatrix", "([F)V", array);
env->GetFloatArrayRegion(array, 0, 16, matrix.data());
env->DeleteLocalRef(array);
return matrix;
}