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


C++ Texture::GetImage方法代码示例

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


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

示例1: Draw

//----------------------------------------------------------------------------
void DxRenderer::Draw (const ProjectedTexture& rkPTexture)
{
    float fNear, fFar, fLeft, fRight, fTop, fBottom;
    D3DXMATRIX kMatrixViewCamera;
    D3DXMATRIX kMatrixInverseViewCamera;
    D3DXMATRIX kMatrixViewProjector;
    D3DXMATRIX kMatrixProjectionProjector;
    D3DXMATRIX kMatTmp1, kMatTmp2;
    D3DXMATRIX kMatrixTextureProjector;

    // If multitexturing is not supported, then we cannot render a
    // projected texture onto the objects.  But render the objects anyway.
    if ( !m_bCapMultitexture )
    {
        Renderer::Draw(rkPTexture.GetObjects());
        return;
    }


    // Reserve an available texture unit, but use one on at the end of the
    // sequence to allow room for the model if it needs to use any
    // texture units prior to the ProjectedTexture texture.  If one is
    // not available, then we cannot render a projected texture onto
    // the objects.  But render the objects anyway.
    int iUnit = RequestTextureUnit();
    if ( iUnit < 0 )
    {
        Renderer::Draw(rkPTexture.GetObjects());
        return;
    }


    // Fill the texture state object and bind it.
    Texture* pkTexture = rkPTexture.GetTexture();
    TextureState* pkTS = rkPTexture.GetTextureState();
    pkTS->Set(iUnit,pkTexture);
    SetTextureState(pkTS);
    pkTS->Remove(iUnit);


    // Setup the inverse for the current camera viewing transform. - 
    // Texture coordinates will be obtained from camera space position,
    // but that camera viewing transform needs to be undone to get
    // back to world coordinates.
    ms_hResult = m_pqDevice->GetTransform(D3DTS_VIEW,&kMatrixViewCamera); 
    WML_DX_ERROR_CHECK(GetTransform);
    D3DXMatrixInverse(&kMatrixInverseViewCamera,NULL,&kMatrixViewCamera);
    

    // Setup viewing transform for the projector.
    // Setup a lookat matrix using the projected texture camera
    // viewpoint and view direction.
    const Vector3f& rkCameraLoc = rkPTexture.GetCamera()->GetLocation();
    const Vector3f& rkCameraDir = rkPTexture.GetCamera()->GetDirection();
    const Vector3f& rkCameraUp = rkPTexture.GetCamera()->GetUp();
    const Vector3f& rkCameraLookAt = rkCameraLoc + rkCameraDir;
    D3DXVECTOR3 kProjectorEye(rkCameraLoc.X(),rkCameraLoc.Y(),
        rkCameraLoc.Z());
    D3DXVECTOR3 kProjectorUp(rkCameraUp.X(),rkCameraUp.Y(),rkCameraUp.Z());
    D3DXVECTOR3 kProjectorLookAt(rkCameraLookAt.X(),rkCameraLookAt.Y(),
        rkCameraLookAt.Z());
    D3DXMatrixLookAtRH(&kMatrixViewProjector,&kProjectorEye,&kProjectorLookAt,
        &kProjectorUp);


    // Setup the projection transform for the projector - ProjectionProjector.
    // Setup a right-handed off-center perspective projection matrix using
    // the projected texture camera frustrum.
    rkPTexture.GetCamera()->GetFrustum(fNear,fFar,fLeft,fRight,fTop,fBottom);
    D3DXMatrixPerspectiveOffCenterRH(&kMatrixProjectionProjector,fLeft,fRight,
        fBottom,fTop,fNear,fFar);


    // Bias and scale the texture so that it covers the near plane.
    // Note that integral screen coordinates represent pixel centers
    // whereas integral texture coordinates represent texel boundaries.
    // We also need to know the dimensions of the texture being projected.
    Image* pkTextureImage = pkTexture->GetImage();
    float fOffsetX = 0.5f + (0.5f / pkTextureImage->GetWidth());
    float fOffsetY = 0.5f + (0.5f / pkTextureImage->GetHeight());
    D3DXMATRIX kMatrixScaleBiasTexture(
        0.5f,0.0f,0.0f,0.0f,
        0.0f,0.5f,0.0f,0.0f,
        0.0f,0.0f,1.0f,0.0f,
        fOffsetX,fOffsetY,0.0f,1.0f);


    // Create the projected texture transform by combining the
    // following transformations in the given order (left to right):
    //  . kMatrixInverseViewCamera
    //  . kMatrixViewProjector
    //  . kMatrixProjectionProjector
    //  . kMatrixScaleBiasTexture
    D3DXMatrixMultiply(&kMatrixTextureProjector,
        D3DXMatrixMultiply(&kMatTmp1,&kMatrixInverseViewCamera,
            &kMatrixViewProjector),
        D3DXMatrixMultiply(&kMatTmp2,&kMatrixProjectionProjector,
            &kMatrixScaleBiasTexture));
    ms_hResult = m_pqDevice->SetTransform(
//.........这里部分代码省略.........
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:101,代码来源:WmlDxProjectedTexture.cpp


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