コード例 #1
0
ファイル: Camera.cpp プロジェクト: anandhotwani/NGL
//----------------------------------------------------------------------------------------------------------------------
void Camera::writeRib( RibExport &_rib ) const noexcept
{
	if(_rib.isOpen()!=0)
	{
		Real *M=(Real *)&m_viewMatrix.m_m;
		_rib.writeTabs();
		_rib.getStream() <<"# Camera transform from GraphicsLib Camera\n"  ;
		_rib.getStream() <<"# now we need to flip the Z axis\n";
		_rib.getStream() <<"Scale 1 1 -1 \n";

		_rib.getStream() <<"ConcatTransform [ ";
		for (int i=0; i<16; i++)
		{
			_rib.getStream() <<M[i]<<" ";
		}
		_rib.getStream() <<"]\n";
		_rib.getStream() <<"# now we Set the clipping \n";
		_rib.getStream() <<"Clipping "<<m_zNear<<" "<<m_zFar<<"\n";
		_rib.getStream() <<"Projection \"perspective\" \"fov\" ["<<m_fov<<"]\n";
		_rib.getStream() <<"#End of Camera from GraphicsLib\n";
	}
}
コード例 #2
0
ファイル: AbstractMesh.cpp プロジェクト: Benkyi/NGL
//----------------------------------------------------------------------------------------------------------------------
void AbstractMesh::writeToRibSubdiv(RibExport& _ribFile )const noexcept
{
    // Declare the variables
    std::list< int > lVertLink;
    std::list< int >::iterator vertLinkItr;
    std::vector< float > vVerts;
    std::vector< float >::iterator vertsItr;

    // Check if the rib exists
    if( _ribFile.isOpen() != 0 )
    {
        _ribFile.comment( "OBJ AbstractMeshect" );
        // Start printing the SubdivisionPolygons tag to the rib
        _ribFile.getStream() << "SubdivisionMesh \"catmull-clark\" [ ";

        // Loop through all the Polygons
        for (unsigned long  int I=0; I<m_nVerts; ++I)
        {
            // Print the count of vertices for the current polygon to the rib
            _ribFile.getStream() << m_face[I].m_numVerts << " ";
            // Start building the vertids and parameterlist
            for (unsigned long int i = 0; i < m_face[I].m_numVerts; ++i)
            {
                // Set the verts vector size and testing variables
                int iVecSize = vVerts.size();
                bool bTest = false;
                int counter = 0;
                // Loop through the expanding vector checking whether
                // the current vertice exists
                for (int j = 0; j < iVecSize; j = j + 3)
                {
                    // If the vertice if found in the vector, set the test
                    // flag and exit the loop. Else keep going.
                    if( ( FCompare(m_verts[i].m_x ,vVerts[j]) ) &&
                            ( FCompare(m_verts[i].m_y,vVerts[j + 1]) ) &&
                            ( FCompare(m_verts[i].m_y,vVerts[j + 2]) )
                      )
                    {
                        bTest = true;
                        break;
                    }
                    else
                    {
                        counter++;
                    }
                } //end for

                // Add the vertice to the vector if it is not found
                if( bTest == false )
                {
                    vVerts.push_back( m_verts[m_face[I].m_vert[i]].m_x );
                    vVerts.push_back( m_verts[m_face[I].m_vert[i]].m_y );
                    vVerts.push_back( m_verts[m_face[I].m_vert[i]].m_z );
                    lVertLink.push_back( counter );
                }
                else
                {
                    lVertLink.push_back( counter );
                }

            }// end outer for

        }// end if

        _ribFile.getStream() << "] [ ";

        // Print the vertids to the rib
        std::list< int >::iterator vertLinkEnd=lVertLink.end();
        for (vertLinkItr = lVertLink.begin(); vertLinkItr != vertLinkEnd; ++vertLinkItr)
        {
            _ribFile.getStream() << *vertLinkItr << " ";
        }

        _ribFile.getStream() << "] [\"interpolateboundary\"] [0 0] [] [] \"P\" [ ";
        // Print the parameterlist to the rib
        std::vector< float >::iterator vVertEnd=vVerts.end();
        for (vertsItr = vVerts.begin(); vertsItr != vVertEnd; ++vertsItr)
        {
            _ribFile.getStream() << *vertsItr << " ";
        }

        // Print new lines to the rib
        _ribFile.getStream() << "]\n\n";
    }

}