/// <summary>
/// Renders the color and face streams
/// </summary>
/// <param name="nTime">timestamp of frame</param>
/// <param name="pBuffer">pointer to frame data</param>
/// <param name="nWidth">width (in pixels) of input image data</param>
/// <param name="nHeight">height (in pixels) of input image data</param>
void CFaceBasics::DrawStreams(INT64 nTime, RGBQUAD* pBuffer, int nWidth, int nHeight)
{
    if (m_hWnd)
    {
        HRESULT hr;
        hr = m_pDrawDataStreams->BeginDrawing();

        if (SUCCEEDED(hr))
        {
            // Make sure we've received valid color data
            if (pBuffer && (nWidth == cColorWidth) && (nHeight == cColorHeight))
            {
                // Draw the data with Direct2D
                hr = m_pDrawDataStreams->DrawBackground(reinterpret_cast<BYTE*>(pBuffer), cColorWidth * cColorHeight * sizeof(RGBQUAD));        
            }
            else
            {
                // Recieved invalid data, stop drawing
                hr = E_INVALIDARG;
            }

            if (SUCCEEDED(hr))
            {
                // begin processing the face frames
                ProcessFaces();				
            }

            m_pDrawDataStreams->EndDrawing();
        }

        if (!m_nStartTime)
        {
            m_nStartTime = nTime;
        }

        double fps = 0.0;

        LARGE_INTEGER qpcNow = {0};
        if (m_fFreq)
        {
            if (QueryPerformanceCounter(&qpcNow))
            {
                if (m_nLastCounter)
                {
                    m_nFramesSinceUpdate++;
                    fps = m_fFreq * m_nFramesSinceUpdate / double(qpcNow.QuadPart - m_nLastCounter);
                }
            }
        }

        WCHAR szStatusMessage[64];
        StringCchPrintf(szStatusMessage, _countof(szStatusMessage), L" FPS = %0.2f    Time = %I64d", fps, (nTime - m_nStartTime));

        if (SetStatusMessage(szStatusMessage, 1000, false))
        {
            m_nLastCounter = qpcNow.QuadPart;
            m_nFramesSinceUpdate = 0;
        }
    }    
}
Exemple #2
0
/*
@@@@@@@@@@@@@@@@@@@@@
R_BeginRegistration

Specifies the model that will be used as the world
@@@@@@@@@@@@@@@@@@@@@
*/
void R_BeginRegistration(const char *model)
{
    char        fullname[MAX_QPATH];
    bsp_t       *bsp;
    qerror_t    ret;
    int         i;

    registration_sequence++;
    r_oldviewcluster = -1;      // force markleafs

    D_FlushCaches();

    Q_concat(fullname, sizeof(fullname), "maps/", model, ".bsp", NULL);
    ret = BSP_Load(fullname, &bsp);
    if (!bsp) {
        Com_Error(ERR_DROP, "%s: couldn't load %s: %s",
                  __func__, fullname, Q_ErrorString(ret));
    }

    if (bsp == r_worldmodel) {
        for (i = 0; i < bsp->numtexinfo; i++) {
            bsp->texinfo[i].image->registration_sequence = registration_sequence;
        }
        bsp->refcount--;
        return;
    }

    BSP_Free(r_worldmodel);
    r_worldmodel = bsp;

    ProcessTexinfo(bsp);
    ProcessFaces(bsp);

    // TODO
    R_NewMap();
}
Exemple #3
0
        /**
         * Gmsh file contains a list of nodes and their coordinates, along with
         * a list of elements and those nodes which define them. We read in and
         * store the list of nodes in #m_node and store the list of elements in
         * #m_element. Each new element is supplied with a list of entries from
         * #m_node which defines the element. Finally some mesh statistics are
         * printed.
         *
         * @param   pFilename           Filename of Gmsh file to read.
         */
        void InputVtk::Process()
        {
            if (m_mesh->m_verbose)
            {
                cout << "InputVtk: Start reading file..." << endl;
            }

            vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New();
            vtkMeshReader->SetFileName(m_config["infile"].as<string>().c_str());
            vtkMeshReader->Update();
            vtkPolyData *vtkMesh = vtkMeshReader->GetOutput();

            vtkPoints *vtkPoints = vtkMesh->GetPoints();

            const int numCellTypes = 3;
            vtkCellArray* vtkCells[numCellTypes];
            LibUtilities::ShapeType vtkCellTypes[numCellTypes];
            int vtkNumPoints[numCellTypes];
            vtkCells[0] = vtkMesh->GetPolys();
            vtkCells[1] = vtkMesh->GetStrips();
            vtkCells[2] = vtkMesh->GetLines();
            vtkCellTypes[0] = LibUtilities::eTriangle;
            vtkCellTypes[1] = LibUtilities::eTriangle;
            vtkCellTypes[2] = LibUtilities::eSegment;
            vtkNumPoints[0] = 3;
            vtkNumPoints[1] = 3;
            vtkNumPoints[2] = 2;

            vtkIdType npts;
            vtkIdType *pts = 0;
            double p[3];

            for (int i = 0; i < vtkPoints->GetNumberOfPoints(); ++i)
            {
                vtkPoints->GetPoint(i, p);

                if ((p[0] * p[0]) > 0.000001 && m_mesh->m_spaceDim < 1)
                {
                    m_mesh->m_spaceDim = 1;
                }
                if ((p[1] * p[1]) > 0.000001 && m_mesh->m_spaceDim < 2)
                {
                    m_mesh->m_spaceDim = 2;
                }
                if ((p[2] * p[2]) > 0.000001 && m_mesh->m_spaceDim < 3)
                {
                    m_mesh->m_spaceDim = 3;
                }

                m_mesh->m_node.push_back(boost::shared_ptr<Node>(new Node(i, p[0], p[1], p[2])));
            }

            for (int c = 0; c < numCellTypes; ++c)
            {
                vtkCells[c]->InitTraversal();
                for (int i = 0; vtkCells[c]->GetNextCell(npts, pts); ++i)
                {
                    for (int j = 0; j < npts - vtkNumPoints[c] + 1; ++j)
                    {
                        // Create element tags
                        vector<int> tags;
                        tags.push_back(0); // composite
                        tags.push_back(vtkCellTypes[c]); // element type

                        // Read element node list
                        vector<NodeSharedPtr> nodeList;
                        for (int k = j; k < j + vtkNumPoints[c]; ++k)
                        {
                            nodeList.push_back(m_mesh->m_node[pts[k]]);
                        }

                        // Create element
                        ElmtConfig conf(vtkCellTypes[c],1,false,false);
                        ElementSharedPtr E = GetElementFactory().
                            CreateInstance(vtkCellTypes[c],
                                            conf,nodeList,tags);

                        // Determine mesh expansion dimension
                        if (E->GetDim() > m_mesh->m_expDim) {
                            m_mesh->m_expDim = E->GetDim();
                        }
                        m_mesh->m_element[E->GetDim()].push_back(E);
                    }
                }
            }

            ProcessVertices();
            ProcessEdges();
            ProcessFaces();
            ProcessElements();
            ProcessComposites();
        }