Example #1
0
void CRenderSystem::GetPickRay(Vec3D& vRayPos, Vec3D& vRayDir,int x, int y)
{
	Matrix mProj;
	getProjectionMatrix(mProj);
	CRect<int> rc;
	getViewport(rc);
	Matrix mView;
	getViewMatrix(mView);
	::GetPickRay(vRayPos,vRayDir,x,y,mView,mProj,rc.getRECT());
}
Example #2
0
void CUIEditBox::OnFrameRender(const Matrix& mTransform, double fTime, float fElapsedTime)
{
    if(m_bVisible == false)
        return;

    CUIControl::updateUIMatrix(mTransform, fTime, fElapsedTime);


    int nSelStartX = 0, nCaretX = 0;  // Left and right X cordinates of the selection region

    {
        PlaceCaret(m_nCaret);  // Call PlaceCaret now that we have the font info (node),
        // so that scrolling can be handled.
    }

    RECT rc;
    rc.left =0;
    rc.right = m_rcRelativeBox.getWidth();
    rc.top =0;
    rc.bottom = m_rcRelativeBox.getHeight();
    m_Style.draw(rc, m_Buffer.GetBuffer() + m_nFirstVisible, GetState(), fElapsedTime);

    // Compute the X coordinates of the first visible character.
    //
    int nXFirst;
    m_Buffer.CPtoX(m_nFirstVisible, FALSE, nXFirst);

    //
    // Compute the X coordinates of the selection rectangle
    //
    m_Buffer.CPtoX(m_nCaret, FALSE, nCaretX);
    if(m_nCaret != m_nSelStart)
        m_Buffer.CPtoX(m_nSelStart, FALSE, nSelStartX);
    else
        nSelStartX = nCaretX;

    //
    // Render the selection rectangle
    //
    CRect<int> rcSelection;  // Make this available for rendering selected text
    if(m_nCaret != m_nSelStart)
    {
        int nSelLeftX = nCaretX, nSelRightX = nSelStartX;
        // Swap if left is bigger than right
        if(nSelLeftX > nSelRightX)
        {
            int nTemp = nSelLeftX;
            nSelLeftX = nSelRightX;
            nSelRightX = nTemp;
        }

        rcSelection.set(nSelLeftX, m_rcText.top, nSelRightX, m_rcText.bottom);
        rcSelection.offset(m_rcText.left - nXFirst, 0);
        rcSelection.IntersectRect(m_rcText, rcSelection);

        int nFirstToRender = __max(m_nFirstVisible, __min(m_nSelStart, m_nCaret));
        int nNumChatToRender = __max(m_nSelStart, m_nCaret) - nFirstToRender;
        //m_Styles[0].m_mapFont = m_SelTextColor;
        ///m_Style.Blend(CONTROL_STATE_FOCUS, fElapsedTime, 1);
        std::wstring wstrSelection = m_Buffer.GetBuffer() + nFirstToRender;
        wstrSelection = wstrSelection.substr(0,nNumChatToRender);
        m_StyleSelection.draw(rcSelection.getRECT(), wstrSelection.c_str(), GetState(), fElapsedTime);
    }

    //
    // Blink the caret
    //
    if(GetTickCount()*0.001f - m_dfLastBlink >= m_dfBlink)
    {
        m_bCaretOn = !m_bCaretOn;
        m_dfLastBlink = GetTickCount()*0.001f;
    }

    //
    // Render the caret if this control has the focus
    //
    if(IsFocus() && m_bCaretOn && !s_bHideCaret)
    {
        // Start the rectangle with insert mode caret
        CRect<int> rcCaret(m_rcText.left - nXFirst + nCaretX - 1, m_rcText.top,
                           m_rcText.left - nXFirst + nCaretX + 1, m_rcText.bottom);

        // If we are in overwrite mode, adjust the caret rectangle
        // to fill the entire character.
        if(!m_bInsertMode)
        {
            // Obtain the right edge X coord of the current character
            int nRightEdgeX;
            m_Buffer.CPtoX(m_nCaret, TRUE, nRightEdgeX);
            rcCaret.right = m_rcText.left - nXFirst + nRightEdgeX;
        }
        m_StyleSelection.draw(rcCaret.getRECT(), L"", GetState(), fElapsedTime);
    }
}