コード例 #1
0
	void XMLPrinter::CloseElement(bool compactMode)
	{
		--_depth;
		const char* name = _stack.Pop();

		if (_elementJustOpened)
		{
			Print("/>");
		}
		else
		{
			if (_textDepth < 0 && !compactMode)
			{
				Print("\n");
				PrintSpace(_depth);
			}
			Print("</%s>", name);
		}

		if (_textDepth == _depth)
		{
			_textDepth = -1;
		}
		if (_depth == 0 && !compactMode)
		{
			Print("\n");
		}
		_elementJustOpened = false;
	}
コード例 #2
0
ファイル: gmodelexp.cpp プロジェクト: chenbk85/3dlearn
void GmodelExp::ExportMesh(void)
{
	PrintSpace(); fprintf(m_pFile, "Begin Mesh\n");
	PrintSpace(); fprintf(m_pFile, "{\n");
	PushSpace();

	PrintSpace(); fprintf(m_pFile, "meshes %d\n", m_iNumNodes);

	for ( int i=0; i<m_iNumNodes; i++ )
	{
		INode *node = m_NodeTable[i];
		ExportNodeMesh(node, i);
	}

	PopSpace();
	PrintSpace(); fprintf(m_pFile, "}\n");
	PrintSpace(); fprintf(m_pFile, "End Mesh\n");
}
コード例 #3
0
ファイル: 019_NumbersPyramid.c プロジェクト: f2008700/BITS
void PrintLine(int n, int limit)
{
	int i;
	PrintSpace(limit - n);
	
	for(i = 1; i < n; i++)printf("%3d", i);
	for(i = n; i > 0; i--)printf("%3d", i);
	printf("\n\n");
}
コード例 #4
0
ファイル: bvt24.cpp プロジェクト: Palantir555/ecos-mars-zx3
static void PrintHeap (const vector<int>& v)
{
    size_t maxWidth, nLayers;
    HeapSize (v.size(), maxWidth, nLayers);
    vector<int>::const_iterator src (v.begin());
    cout << ios::width(3);
    maxWidth *= 3;
    for (uoff_t i = 0; i < nLayers; ++ i) {
	const size_t w = 1 << i;
	const size_t spacing = max (0, int(maxWidth / w) - 3);
	PrintSpace (spacing / 2);
	for (uoff_t j = 0; j < w && src != v.end(); ++ j) {
	    cout << *src++;
	    if (j < w - 1 && src != v.end() - 1)
		PrintSpace (spacing);
	}
	cout << endl;
    }
}
コード例 #5
0
ファイル: tinyxml2.cpp プロジェクト: dominik-uebele/E1
	void XMLPrinter::PushUnknown( const char* value )
	{
		if ( _elementJustOpened ) {
			SealElement();
		}
		if ( _textDepth < 0 && !_firstElement && !_compactMode) {
			Print( "\n" );
			PrintSpace( _depth );
		}
		_firstElement = false;
		Print( "<!%s>", value );
	}
コード例 #6
0
ファイル: tinyxml2.cpp プロジェクト: dominik-uebele/E1
	void XMLPrinter::PushComment( const char* comment )
	{
		if ( _elementJustOpened ) {
			SealElement();
		}
		if ( _textDepth < 0 && !_firstElement && !_compactMode) {
			Print( "\n" );
			PrintSpace( _depth );
		}
		_firstElement = false;
		Print( "<!--%s-->", comment );
	}
コード例 #7
0
ファイル: tinyxml2.cpp プロジェクト: dominik-uebele/E1
	void XMLPrinter::OpenElement( const char* name )
	{
		if ( _elementJustOpened ) {
			SealElement();
		}
		_stack.Push( name );

		if ( _textDepth < 0 && !_firstElement && !_compactMode ) {
			Print( "\n" );
			PrintSpace( _depth );
		}

		Print( "<%s", name );
		_elementJustOpened = true;
		_firstElement = false;
		++_depth;
	}
コード例 #8
0
ファイル: TBV.cpp プロジェクト: arthurjeng/Deep-Blue-and-Gold
void TBV::PrintSqrSet(const Pos& pos) const
{
  // Print a TBV as a set of squares

  bool needspace = false;

  PrintChar('[');
  for (tidType tid = 0; tid < tidLen; tid++)
    if (TestTid(tid))
    {
      const sqrType sqr = pos.GetTidToSqr(tid);

      if (needspace) PrintSpace();
      PrintSqrBasic(sqr); needspace = true;
    };
  PrintChar(']');
}
コード例 #9
0
ファイル: TBV.cpp プロジェクト: arthurjeng/Deep-Blue-and-Gold
void TBV::PrintManSqrSet(const Pos& pos) const
{
  // Print a TBV as a set of chessmen/square pairs

  bool needspace = false;

  PrintChar('[');
  for (tidType tid = 0; tid < tidLen; tid++)
    if (TestTid(tid))
    {
      const sqrType sqr = pos.GetTidToSqr(tid);
      const manType man = pos.GetMan(sqr);

      if (needspace) PrintSpace();
      PrintMan(man); PrintChar('/'); PrintSqrBasic(sqr); needspace = true;
    };
  PrintChar(']');
}
コード例 #10
0
ファイル: gmodelexp.cpp プロジェクト: chenbk85/3dlearn
void GmodelExp::ExportNodeMesh(INode *pNode, int index)
{
	if ( !m_MeshBuilder.BuildMesh(pNode, this) )
	{
		PrintSpace(); fprintf(m_pFile, "{	// not a mesh %d\n", index);
		PushSpace();

		PrintSpace(); fprintf(m_pFile, "name = \"%s\"\n", pNode->GetName());

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");

		return;
	}

	PrintSpace(); fprintf(m_pFile, "{	// mesh %d\n", index);
	PushSpace();

	PrintSpace(); fprintf(m_pFile, "matrix\n");
	PrintSpace(); fprintf(m_pFile, "{\n");
	PushSpace();

	for ( int r=0; r<4; r++ )
	{
		Point3 *pRow = &m_MeshBuilder.m_Matrix.GetRow(r);
		PrintSpace(); fprintf(m_pFile, "%f,%f,%f\n", pRow->x, pRow->y, pRow->z);
	}

	PopSpace();
	PrintSpace(); fprintf(m_pFile, "}\n");

	PrintSpace(); fprintf(m_pFile, "buffers %d\n", m_MeshBuilder.m_iNumVertexArrays);

	for ( int i=0; i<m_MeshBuilder.m_iNumVertexArrays; i++ )
	{
		PrintSpace(); fprintf(m_pFile, "{\n"); 
		PushSpace();

		sMeshVertexArray *pVertexArray = &m_MeshBuilder.m_VertexArray[i];

		// export vertex array
		int num_vertices = pVertexArray->m_VertexArray.size();

		char szVertexFmt[32];

		strcpy(szVertexFmt, "v");

		if ( m_bExportVertexNormals )
		{
			strcat(szVertexFmt, "_n");
		}

		if ( m_bExportVertexColors )
		{
			strcat(szVertexFmt, "_c");
		}

		if ( m_bExportVertexUVs && m_MeshBuilder.m_iNumUVs )
		{
			strcat(szVertexFmt, "_t");

			int strLen = strlen(szVertexFmt);
			szVertexFmt[strLen] = (char) ('0' + m_MeshBuilder.m_iNumUVs);
			szVertexFmt[strLen+1] = '\0';
		}

		if ( m_bExportTangentSpace && m_bExportVertexUVs && m_MeshBuilder.m_iNumUVs )
		{
			strcat(szVertexFmt, "_p_q");
		}

		PrintSpace(); fprintf(m_pFile, "vertices %d\n", num_vertices);
		PrintSpace(); fprintf(m_pFile, "format %s\n", szVertexFmt);
		PrintSpace(); fprintf(m_pFile, "{\n");
		PushSpace();

		for ( int v=0; v<num_vertices; v++)
		{
			Point3 *pPosition = &pVertexArray->m_VertexArray[v].m_Position;
			Point3 *pNormal = &pVertexArray->m_VertexArray[v].m_Normal;
			Point4 *pColor = &pVertexArray->m_VertexArray[v].m_Color;

			PrintSpace(); 

			fprintf(m_pFile, "vertex %f,%f,%f", pPosition->x, pPosition->y, pPosition->z);

			if ( m_bExportVertexNormals )
				fprintf(m_pFile, " normal %f,%f,%f", pNormal->x, pNormal->y, pNormal->z);

			if ( m_bExportVertexColors )
				fprintf(m_pFile, " color %f,%f,%f,%f", pColor->x, pColor->y, pColor->z, pColor->w);

			if ( m_bExportVertexUVs && m_MeshBuilder.m_iNumUVs )
			{
				for ( int t=0; t<m_MeshBuilder.m_iNumUVs; t++ )
				{
					Point3 *pUV = &pVertexArray->m_VertexArray[v].m_UV[t];
					fprintf(m_pFile, " uv%d %f,%f", t, pUV->x, pUV->y);
				}
			}

			if ( m_bExportTangentSpace && m_bExportVertexUVs && m_MeshBuilder.m_iNumUVs )
			{
				Point3 *p = &pVertexArray->m_VertexArray[v].m_Tangent;
				Point3 *q = &pVertexArray->m_VertexArray[v].m_BiNormal;

				fprintf(m_pFile, " tangent %f,%f,%f", p->x, p->y, p->z);
				fprintf(m_pFile, " binormal %f,%f,%f", q->x, q->y, q->z);
			}

			fprintf(m_pFile, "\n");
		}

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");

		// export index array
		int num_indices = pVertexArray->m_IndexArray_TriList.size();

		PrintSpace(); fprintf(m_pFile, "triangle_list_indices %d\n", num_indices);
		PrintSpace(); fprintf(m_pFile, "{\n");
		PushSpace();

		int num_faces = num_indices / 3;
		for ( int f=0; f<num_faces; f++)
		{
			unsigned short *pIndex = &pVertexArray->m_IndexArray_TriList[f*3];
			PrintSpace(); fprintf(m_pFile, "%d %d %d\n", pIndex[0], pIndex[1], pIndex[2]);
		}

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");

		// export batches
		int num_batches = pVertexArray->m_BatchList.size();

		PrintSpace(); fprintf(m_pFile, "batches %d\n", num_batches);
		PrintSpace(); fprintf(m_pFile, "{\n");
		PushSpace();

		for ( int b=0; b<num_batches; b++ )
		{
			sMeshBatch *pBatch = &pVertexArray->m_BatchList[b];

			PrintSpace(); fprintf(m_pFile, "material %d\n", pBatch->m_iMaterialIndex);
			PrintSpace(); fprintf(m_pFile, "faces %d\n", pBatch->m_iNumPrimitives_TriList);
			PrintSpace(); fprintf(m_pFile, "index_begin %d\n", pBatch->m_iIndexArrayBegin_TriList);
		}

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");
	}

	PopSpace();
	PrintSpace(); fprintf(m_pFile, "}\n");
}
コード例 #11
0
ファイル: gmodelexp.cpp プロジェクト: chenbk85/3dlearn
void GmodelExp::ExportMaterial(void)
{
	PrintSpace(); fprintf(m_pFile, "Begin Material\n");
	PrintSpace(); fprintf(m_pFile, "{\n");
	PushSpace();

	m_iNumMaterials = m_MaterialTable.size();

	PrintSpace(); fprintf(m_pFile, "Materials %d\n", m_iNumMaterials);

	for ( int i=0; i<m_iNumMaterials; i++ )
	{
		PrintSpace(); fprintf(m_pFile, "{	// material %d\n", i);
		PushSpace();

		Mtl *mtl = m_MaterialTable[i];
		sMaterial dxMaterial;
		dxMaterial.ConvertMTL(mtl);

		const char *name = mtl->GetName();

		PrintSpace(); fprintf(m_pFile, "name = \"%s\"\n", name ? name : "unknown");

		PrintSpace(); fprintf(m_pFile, "emissive = %f,%f,%f\n", dxMaterial.m_EmissiveColor.r, dxMaterial.m_EmissiveColor.g, dxMaterial.m_EmissiveColor.b);
		PrintSpace(); fprintf(m_pFile, "ambient = %f,%f,%f\n", dxMaterial.m_AmbientColor.r, dxMaterial.m_AmbientColor.g, dxMaterial.m_AmbientColor.b);
		PrintSpace(); fprintf(m_pFile, "diffuse = %f,%f,%f\n", dxMaterial.m_DiffuseColor.r, dxMaterial.m_DiffuseColor.g, dxMaterial.m_DiffuseColor.b);
		PrintSpace(); fprintf(m_pFile, "specular = %f,%f,%f\n", dxMaterial.m_SpecularColor.r, dxMaterial.m_SpecularColor.g, dxMaterial.m_SpecularColor.b);
		PrintSpace(); fprintf(m_pFile, "shininess = %f\n", dxMaterial.m_fShininess);

		PrintSpace(); fprintf(m_pFile, "blendmode = %s\n", dxMaterial.m_BlendMode.c_str());
		PrintSpace(); fprintf(m_pFile, "CullFace = %s\n", dxMaterial.m_bCullFace ? "on" : "off");

		PrintSpace(); fprintf(m_pFile, "diffuseMap = \"%s\" MapChannel = %d\n", dxMaterial.m_Textures[0].length() ? dxMaterial.m_Textures[0].c_str() : "None", dxMaterial.m_MapChannel[0]);
		PrintSpace(); fprintf(m_pFile, "lightMap = \"%s\" MapChannel = %d\n", dxMaterial.m_Textures[1].length() ? dxMaterial.m_Textures[1].c_str() : "None", dxMaterial.m_MapChannel[1]);
		PrintSpace(); fprintf(m_pFile, "environmentMap = \"%s\"\n", dxMaterial.m_Textures[2].length() ? dxMaterial.m_Textures[2].c_str() : "None");

		PopSpace();
		PrintSpace(); fprintf(m_pFile, "}\n");
	}

	PopSpace();
	PrintSpace(); fprintf(m_pFile, "}\n");
	PrintSpace(); fprintf(m_pFile, "End Material\n");
}