本文整理汇总了C++中eigen::Matrix4f::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4f::data方法的具体用法?C++ Matrix4f::data怎么用?C++ Matrix4f::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix4f
的用法示例。
在下文中一共展示了Matrix4f::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintGL
/// @overload QGLWidget
void paintGL(){
vao.bind();
program.bind();
{
///--- Update modelview
#ifdef WITH_QGLVIEWER
/// use the trackball to specify the matrices
setup_modelview(camera(), program);
#else
///--- simple unit cube orthographic view
static Eigen::Matrix4f M = Eigen::Matrix4f::Identity();
static Eigen::Matrix4f P = Eigen::ortho(-1.0f, +1.0f, -1.0f, +1.0f, -1.0f, +1.0f);
static Eigen::Matrix4f V = Eigen::Matrix4f::Identity();
static Eigen::Matrix4f MV = V*M;
static Eigen::Matrix4f MVP = P*MV;
GLint MVP_id = glGetUniformLocation(program.programId(), "MVP");
glUniformMatrix4fv(MVP_id, 1, GL_FALSE, MVP.data());
GLint MV_id = glGetUniformLocation(program.programId(), "MV");
glUniformMatrix4fv(MV_id, 1, GL_FALSE, MV.data());
#endif
///--- clear & draw
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, triangles.size(), GL_UNSIGNED_INT, 0);
}
vao.release();
program.release();
}
示例2: render
void Cube::render(const Eigen::Matrix4f& mvMatrix, const Eigen::Matrix4f& prMatrix, const Eigen::Matrix3f& nmMatrix) {
m_prog.use();
m_prog.setUniformMat4("mvM", mvMatrix.data());
m_prog.setUniformMat4("prM", prMatrix.data());
m_prog.setUniformMat3("nmM", nmMatrix.data());
m_geom.bind();
glDrawElements(GL_TRIANGLE_STRIP, 14, GL_UNSIGNED_INT, (char*)NULL);
m_geom.release();
}
示例3: setMVPMatrix
void TextureWarpShader::setMVPMatrix(const Eigen::Matrix4f &mvp)
{
//Transpose to opengl column-major format
glUseProgram(mProgram.getId());
glUniformMatrix4fv(mUniformMVPMatrix, 1, false, mvp.data());
glUseProgram(mProgram_Alpha.getId());
glUniformMatrix4fv(mUniformMVPMatrix_Alpha, 1, false, mvp.data());
glUseProgram(mProgram_Color.getId());
glUniformMatrix4fv(mUniformMVPMatrix_Color, 1, false, mvp.data());
}
示例4: updateCoM
void stabilityWindow::updateCoM()
{
if (!comVisu || comVisu->getNumChildren() == 0)
{
return;
}
// Draw CoM
Eigen::Matrix4f globalPoseCoM;
globalPoseCoM.setIdentity();
if (currentRobotNodeSet)
{
globalPoseCoM.block(0, 3, 3, 1) = currentRobotNodeSet->getCoM();
}
else if (robot)
{
globalPoseCoM.block(0, 3, 3, 1) = robot->getCoMGlobal();
}
SoMatrixTransform* m = dynamic_cast<SoMatrixTransform*>(comVisu->getChild(0));
if (m)
{
SbMatrix ma(reinterpret_cast<SbMat*>(globalPoseCoM.data()));
// mm -> m
ma[3][0] *= 0.001f;
ma[3][1] *= 0.001f;
ma[3][2] *= 0.001f;
m->matrix.setValue(ma);
}
// Draw CoM projection
if (currentRobotNodeSet && comProjectionVisu && comProjectionVisu->getNumChildren() > 0)
{
globalPoseCoM(2, 3) = 0;
m = dynamic_cast<SoMatrixTransform*>(comProjectionVisu->getChild(0));
if (m)
{
SbMatrix ma(reinterpret_cast<SbMat*>(globalPoseCoM.data()));
// mm -> m
ma[3][0] *= 0.001f;
ma[3][1] *= 0.001f;
ma[3][2] *= 0.001f;
m->matrix.setValue(ma);
}
}
}
示例5:
void nsgl::sendUniMat4(Program &prog, const std::string & uniName,
const Eigen::Matrix4f & mat4) {
if (prog.getUniform(uniName).isValid()) {
glUniformMatrix4fv(prog.getUniform(uniName).location, 1, GL_FALSE,
mat4.data());
}
}
示例6: comTargetMovedX
void stabilityWindow::comTargetMovedX(int value)
{
if(!currentRobotNodeSet)
return;
Eigen::Matrix4f T;
T.setIdentity();
m_CoMTarget(0) = value;
T.block(0, 3, 2, 1) = m_CoMTarget;
if(comTargetVisu && comTargetVisu->getNumChildren() > 0)
{
SoMatrixTransform *m = dynamic_cast<SoMatrixTransform *>(comTargetVisu->getChild(0));
if(m)
{
SbMatrix ma(reinterpret_cast<SbMat*>(T.data()));
// mm -> m
ma[3][0] *= 0.001f;
ma[3][1] *= 0.001f;
ma[3][2] *= 0.001f;
m->matrix.setValue(ma);
}
}
performCoMIK();
}
示例7: view
void view() {
// 透視変換を操作するお!と宣言
glMatrixMode(GL_PROJECTION);
// 正規行列を読み込む
glLoadIdentity();
glViewport(0, 0, Width, Height);
// 透視変換行列を作成して適用
// glFrustum(GLdouble left, GLdouble right,
// GLdouble bottom, GLdouble top,
// GLdouble near, GLdouble far);
// 左端の座標、右端の座標
// 下端の座標、上端の座標
// 最前面までの距離、最前面までの距離(距離はどちらも0より大きい値)
/*glFrustum( -1, 1,
1, -1,
0.5, 20.0);*/
// Eigenの行列をOpenGLに渡す
float aspect = Width / float(Height);
Eigen::Matrix4f m = perspectiveView(36, aspect, 0.5, 50);
glMultMatrixf(m.data());
// モデリング行列を操作するお!と宣言
glMatrixMode(GL_MODELVIEW);
// 正規行列を読み込む
glLoadIdentity();
}
示例8: set_uniform
// had to separate declaration from implementation due to compilation errors on linux
void ObjectRenderer::set_uniform(const char* name, const Eigen::Matrix4f& value){
assert(program.isLinked());
program.bind();
GLuint id = glGetUniformLocation(program.programId(),name);
if(id==-1)
printf("!!!WARNING: shader '%d' does not contain uniform variable '%s'\n", program.programId(), name);
glUniformMatrix4fv(id, 1, GL_FALSE, value.data());
program.release();
}
示例9: reductionSystemCPU
HRESULT DX11BuildLinearSystem::applyBL( ID3D11DeviceContext* context, ID3D11ShaderResourceView* inputSRV, ID3D11ShaderResourceView* correspondenceSRV, ID3D11ShaderResourceView* correspondenceNormalsSRV, D3DXVECTOR3& mean, float meanStDev, Eigen::Matrix4f& deltaTransform, unsigned int imageWidth, unsigned int imageHeight, unsigned int level, Matrix6x7f& res, LinearSystemConfidence& conf )
{
HRESULT hr = S_OK;
unsigned int dimX = (unsigned int)ceil(((float)imageWidth*imageHeight)/(GlobalCameraTrackingState::getInstance().s_localWindowSize[level]*m_blockSizeBL));
Eigen::Matrix4f deltaTransformT = deltaTransform.transpose();
// Initialize Constant Buffer
D3D11_MAPPED_SUBRESOURCE mappedResource;
V_RETURN(context->Map(m_constantBufferBL, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource))
CBufferBL *cbuffer = (CBufferBL*)mappedResource.pData;
cbuffer->imageWidth = (int)imageWidth;
cbuffer->imageHeigth = (int)imageHeight;
memcpy(cbuffer->deltaTransform, deltaTransformT.data(), 16*sizeof(float));
cbuffer->imageHeigth = (int)imageHeight;
memcpy(cbuffer->mean, (float*)mean, 3*sizeof(float));
cbuffer->meanStDevInv = 1.0f/meanStDev;
context->Unmap(m_constantBufferBL, 0);
// Setup Pipeline
context->CSSetShaderResources(0, 1, &inputSRV);
context->CSSetShaderResources(1, 1, &correspondenceSRV);
context->CSSetShaderResources(2, 1, &correspondenceNormalsSRV);
context->CSSetUnorderedAccessViews(0, 1, &m_pOutputFloatUAV, 0);
context->CSSetConstantBuffers(0, 1, &m_constantBufferBL);
context->CSSetShader(m_pComputeShaderBL[level], 0, 0);
// Start Compute Shader
context->Dispatch(dimX, 1, 1);
assert(dimX <= D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION);
// De-Initialize Pipeline
ID3D11ShaderResourceView* nullSAV[1] = { NULL };
ID3D11UnorderedAccessView* nullUAV[1] = { NULL };
ID3D11Buffer* nullCB[1] = { NULL };
context->CSSetShaderResources(0, 1, nullSAV);
context->CSSetShaderResources(1, 1, nullSAV);
context->CSSetShaderResources(2, 1, nullSAV);
context->CSSetUnorderedAccessViews(0, 1, nullUAV, 0);
context->CSSetConstantBuffers(0, 1, nullCB);
context->CSSetShader(0, 0, 0);
// Copy to CPU
context->CopyResource(m_pOutputFloatCPU, m_pOutputFloat);
V_RETURN(context->Map(m_pOutputFloatCPU, 0, D3D11_MAP_READ, 0, &mappedResource));
res = reductionSystemCPU((float*)mappedResource.pData, dimX, conf);
context->Unmap(m_pOutputFloatCPU, 0);
return hr;
}
示例10: setUniformValue
bool ShaderProgram::setUniformValue(const std::string& name,
const Eigen::Matrix4f& matrix)
{
GLint location = static_cast<GLint>(findUniform(name));
if (location == -1) {
m_error = "Could not set uniform " + name + ". No such uniform.";
return false;
}
glUniformMatrix4fv(location, 1, GL_FALSE,
static_cast<const GLfloat*>(matrix.data()));
return true;
}
示例11: perspView
void MainCamera::perspView() {
float f = float(1. / std::tan(toRadians(fovy_) * 0.5));
float g = -((far_ + near_) / (far_ - near_));
float h = -((2 * far_ * near_) / (far_ - near_));
float i = f / aspect_;
Eigen::Matrix4f m;
m << i, 0.0f, 0.0f, 0.0f,
0.0f, f, 0.0f, 0.0f,
0.0f, 0.0f, g, h,
0.0f, 0.0f, -1, 0.0f;
glMultMatrixf(m.data());
}
示例12: display_form
void display_form(int form, Eigen::Matrix4f marker_matrix, float falling){
glMatrixMode(GL_MODELVIEW);
glColor4f(1.0, 0.0, 0.0, 1.0);
//transform to marker
glLoadTransposeMatrixf(marker_matrix.data());
glTranslatef(0.0, 0.0, falling);
//move to marker position
if(form == 0){
glutSolidSphere(0.02, 10, 100);
} else {
drawCube(0.04);
}
}
示例13: display_fallthrough
void display_fallthrough(Eigen::Matrix4f marker_matrix){
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glColor4f(0.0, 0.0, 0.0, 1.0);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
//transform to marker
glLoadTransposeMatrixf(marker_matrix.data());
glTranslatef(0.0, 0.0, 0.06);
drawCube(0.08);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
示例14: sizeof
Eigen::Matrix4f
orthoMatrix(
GLfloat left, GLfloat right,
GLfloat top, GLfloat bottom,
GLfloat nearz, GLfloat farz
) {
GLfloat const tx = -((right + left) / (right - left));
GLfloat const ty = -((top + bottom) / (top - bottom));
GLfloat const tz = -((farz + nearz) / (farz - nearz));
GLfloat const matrix[] = {
2.0f / (right - left), 0.0f, 0.0f, tx,
0.0f, 2.0f / (top - bottom), 0.0f, ty,
0.0f, 0.0f, -2.0f / (farz - nearz), tz,
0.0f, 0.0f, 0.0f, 1.0f,
};
Eigen::Matrix4f result;
::memcpy(result.data(), matrix, sizeof(matrix));
result.matrix().transposeInPlace();
return result;
}
示例15: lookToTarget
void MainCamera::lookToTarget() {
Vec3f z = getForward() / getForward().length();
Vec3f b = up_.cross(z);
Vec3f x = b / b.length();
Vec3f y = z.cross(x);
Eigen::Matrix4f R;
R << x.x, x.y, x.z, 0.0f,
y.x, y.y, y.z, 0.0f,
z.x, z.y, z.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f;
Eigen::Matrix4f T;
T << 1.0f, 0.0f, 0.0f, -pos_.x,
0.0f, 1.0f, 0.0f, -pos_.y,
0.0f, 0.0f, 1.0f, -pos_.z,
0.0f, 0.0f, 0.0f, 1.0f;
Eigen::Matrix4f m = R * T;
glMultMatrixf(m.data());
}