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


C++ Matrix4f::Invert方法代码示例

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


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

示例1: display

static void display()
{
    const Vector3f eyePosition(0, 0, 13);
    const Vector3f eyeCenter(0,0,0);
    const Vector3f eyeUp(0,1,0);
    const Vector3f lightPosition(5 * sin(lightAngle), 1.5, 5 * cos(lightAngle));
    Camera camera(eyePosition, eyeCenter, eyeUp);
    transform.SetCamera(camera);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    cgGLBindProgram(programVertex);
    Log("binding vertex program");

    cgGLEnableProfile(profileVertex);
    Log("enabling vertex profile");

    cgGLBindProgram(programFragment);
    Log("binding fragment program");

    cgGLEnableProfile(profileFragment);
    Log("enabling fragment profile");

    setBrassMaterial();
    transform.SetTranslate(2, 0, 0);
    transform.SetArbitraryRotation(20, 1, 1, 1);
    Matrix4f modelMatrix;
    transform.GetModelMatrix(modelMatrix);
    Matrix4f invModelMatrix = modelMatrix.Invert();
    Vector4f objSpaceEyePosition = invModelMatrix.Mul(eyePosition);
    Vector4f objSpaceLightPosition = invModelMatrix.Mul(lightPosition);
    Matrix4f modelViewProjMatix;
    transform.GetMVPMatrix(modelViewProjMatix);
    CgSetParam(paramVertexmodelViewProj, modelViewProjMatix);

    //CgSetParam(paramFragmentEyePosition, objSpaceEyePosition);
    CgSetParam(paramFragmentLightPosition, objSpaceLightPosition);

    CgSetParam(paramVertexLightPosition, objSpaceLightPosition);
    CgSetParam(paramVertexEyePosition, objSpaceEyePosition);

    cgUpdateProgramParameters(programVertex);
    cgUpdateProgramParameters(programFragment);
    glutSolidSphere(2.0, 10, 10);

    cgGLDisableProfile(profileVertex);
    Log("disabling vertex profile");

    cgGLDisableProfile(profileFragment);
    Log("disabling fragment profile");
    glutSwapBuffers();
}
开发者ID:softwarekid,项目名称:crayon,代码行数:50,代码来源:renderFramework.cpp

示例2: GetWNormalizedMouseFarPosition

///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
Vector3 InputSystem::GetWNormalizedMouseFarPosition( OpenGLRenderer* renderer )
{
    if (!renderer)
        return Vector3::ZERO;

    Vector2 mousePos = GetMousePosition();
    Vector2 halfDisplaySize( renderer->GetDisplayWidth() * 0.5f, renderer->GetDisplayHeight() * 0.5f );
    Vector2 offset = mousePos - halfDisplaySize;
    Vector2 ndcCoords( RangeMap( offset.x, -halfDisplaySize.x, halfDisplaySize.x, -1.0f, 1.0f ), RangeMap( offset.y, -halfDisplaySize.y, halfDisplaySize.y, -1.0f, 1.0f ) );

    Matrix4f perspectiveToWorld = MatrixMultiply( renderer->GetViewMatrix(), renderer->GetPerspectiveMatrix() );
    perspectiveToWorld.Invert();

    Vector4f farWorldPosVec = perspectiveToWorld.TransformVector( Vector4f( ndcCoords.x, ndcCoords.y, 1.0f, 1.0f ) );

    Vector3 farWorldPos( farWorldPosVec.x / farWorldPosVec.w, farWorldPosVec.y / farWorldPosVec.w, farWorldPosVec.z / farWorldPosVec.w );

    return farWorldPos;
}
开发者ID:tbgeorge,项目名称:putty_engine,代码行数:22,代码来源:InputSystem.cpp

示例3: _Draw

void AttenateLighting::_Draw(const Vector4f& rotation, const Vector3f& translate, const Vector3f& eyePos, const Vector3f& lightPosition, const Material& m, RenderObject obj)
{
    _SetMaterial(m);
    _transform.SetArbitraryRotation(rotation[1], rotation[2], rotation[3], rotation[4]);
    _transform.SetTranslate(translate.x, translate.y, translate.z);
    Matrix4f modelMatrix;
    _transform.GetModelMatrix(modelMatrix);
    //TODO can I use rvalue-reference here?
    Matrix4f invModelMatrix = modelMatrix.Invert();

    Vector3f objSpaceEyePosition = _MatVecMulReduced(invModelMatrix, eyePos);
    _fragParams->SetEyePosition(objSpaceEyePosition);
    Vector3f objSpaceLightPosition = _MatVecMulReduced(invModelMatrix, lightPosition);
    _fragParams->SetLightPos(objSpaceLightPosition);
    Matrix4f modelViewProjMatix;
    _transform.GetMVPMatrix(modelViewProjMatix);
    _vertParams->SetMVPMatrix(modelViewProjMatix);
    // deferred params are updated, aka, perform a draw call
    _vertShader->UpdateParams();
    _fragShader->UpdateParams();
    _RenderMesh(obj);
}
开发者ID:softwarekid,项目名称:crayon,代码行数:22,代码来源:AttenuateLighting.cpp

示例4: Draw

void SceneDrawCall::Draw(const Camera& camera, const Vector4f& rotation, const Vector3f& translate, const Vector3f& eyePos, const Vector3f& lightPosition, const Material& m, std::function<void()> draw)
{
    _SetMaterial(m);
    _transform.SetCamera(camera);
    _transform.SetArbitraryRotation(rotation[1], rotation[2], rotation[3], rotation[4]);
    _transform.SetTranslate(translate.x, translate.y, translate.z);
    Matrix4f modelMatrix;
    _transform.GetModelMatrix(modelMatrix);
    //TODO can I use rvalue-reference here?
    Matrix4f invModelMatrix = modelMatrix.Invert();

    Vector3f objSpaceEyePosition = _MatVecMulReduced(invModelMatrix, eyePos);
    _vertParam->SetEyePosition(objSpaceEyePosition);
    Vector3f objSpaceLightPosition = _MatVecMulReduced(invModelMatrix, lightPosition);
    _vertParam->SetLightPos(objSpaceLightPosition);
    Matrix4f modelViewProjMatix;
    _transform.GetMVPMatrix(modelViewProjMatix);
    _vertParam->SetMVPMatrix(modelViewProjMatix);
    // deferred params are updated, aka, perform a draw call
    _vertShader->UpdateParams();
    _fragShader->UpdateParams();
    draw();
}
开发者ID:softwarekid,项目名称:crayon,代码行数:23,代码来源:SceneDrawCall.cpp


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