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


C++ Ptr::AddVertex方法代码示例

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


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

示例1: PopulatePreloadScene

void OculusWorldDemoApp::PopulatePreloadScene()
{
    // Load-screen screen shot image
    String fileName = MainFilePath;
    fileName.StripExtension();

    Ptr<File>    imageFile = *new SysFile(fileName + "_LoadScreen.tga");
    Ptr<Texture> imageTex;
    if (imageFile->IsValid())
        imageTex = *LoadTextureTgaTopDown(pRender, imageFile, TextureLoad_SrgbAware, 255);

    // Image is rendered as a single quad.
    if (imageTex)
    {
        imageTex->SetSampleMode(Sample_Anisotropic|Sample_Repeat);
        Ptr<Model> m = *new Model(Prim_Triangles);
        m->AddVertex(-0.5f,  0.5f,  0.0f, Color(255,255,255,255), 0.0f, 1.0f);
        m->AddVertex( 0.5f,  0.5f,  0.0f, Color(255,255,255,255), 1.0f, 1.0f);
        m->AddVertex( 0.5f, -0.5f,  0.0f, Color(255,255,255,255), 1.0f, 0.0f);
        m->AddVertex(-0.5f, -0.5f,  0.0f, Color(255,255,255,255), 0.0f, 0.0f);
        m->AddTriangle(2,1,0);
        m->AddTriangle(0,3,2);

        Ptr<ShaderFill> fill = *new ShaderFill(*pRender->CreateShaderSet());
        fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
        fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
        fill->SetTexture(0, imageTex);
        m->Fill = fill;

        LoadingScene.World.Add(m);
    }
}
开发者ID:Interaptix,项目名称:OvrvisionPro,代码行数:32,代码来源:OculusWorldDemo_Scene.cpp

示例2: float


//.........这里部分代码省略.........



		if ( sub[index].HasMember("shininess")	)
		{
				rapidjson::Value& shininess	= sub[ index ][ "shininess"	];
				pSub->SetShininess(shininess.GetInt());
		}
		
		
		if ( sub[index].HasMember("indices")	)
		{
			rapidjson::Value& indexes   = sub[ index ][ "indices"   ];

			for( unsigned int nIndex = 0; nIndex < indexes.Size(); nIndex += 3 )
			{
				pSub->AddTriangle( indexes[ nIndex ].GetInt(), indexes[ nIndex + 1 ].GetInt(), indexes[ nIndex + 2 ].GetInt() );
			}
		}

		
		Array< Vector3 > vertexPositions;
        if ( sub[index].HasMember("coords")		)
		{
			rapidjson::Value& coords    = sub[ index ][ "coords"    ];

			for( unsigned int nCoords = 0; nCoords < coords.Size(); nCoords += 3 )
			{
				vertexPositions.Add( 
									Vector3(
											static_cast<float>( coords[ nCoords     ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 1 ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 2 ].GetDouble() ) 
											)
								   );
			}
		}


		Array< Vector3 > normalPositions;
        if ( sub[index].HasMember("normals")		)
		{
			rapidjson::Value& coords    = sub[ index ][ "normals"    ];

			for( unsigned int nCoords = 0; nCoords < coords.Size(); nCoords += 3 )
			{
				normalPositions.Add( 
									Vector3(
											static_cast<float>( coords[ nCoords     ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 1 ].GetDouble() ), 
											static_cast<float>( coords[ nCoords + 2 ].GetDouble() ) 
											)
								   );
			}
		}

        Array< float > uTextCoords;
		Array< float > vTextCoords;
		if ( sub[index].HasMember("texcoords")	)		
		{
			rapidjson::Value& texCoords = sub[ index ][ "texcoords" ];

			for( unsigned int nTex = 0; nTex < texCoords.Size(); nTex += 2 )
			{
				//uTextCoords.Add( static_cast<float>( texCoords[nTex + 0].GetDouble() );
				//vTextCoords.Add( static_cast<float>( texCoords[nTex + 1].GetDouble() );

				float u = static_cast<float>( texCoords[ nTex     ].GetDouble() ); 
				float v = static_cast<float>( texCoords[ nTex + 1 ].GetDouble() );

				uTextCoords.Add(u);
				vTextCoords.Add(v);

				/*pSub->AddVertex( 
								Vertex( 
										vertexPositions[ nTex / 2 ],
										normalPositions[ nTex / 2 ],
										static_cast<float>( texCoords[ nTex     ].GetDouble() ), 
										static_cast<float>( texCoords[ nTex + 1 ].GetDouble() ) 
									   )
							   );*/
			}
		}

		

		for (unsigned int i = 0; i < vertexPositions.Size(); i++)
		{
			//if ( !uTextCoords[i] ) uTextCoords[i] = 0;
			//if ( !vTextCoords[i] ) uTextCoords[i] = 0;

			//pSub->AddVertex	( Vertex(vertexPositions[i], normalPositions[i], uTextCoords[i], vTextCoords[i]) );
			pSub->AddVertex	( Vertex(vertexPositions[i], normalPositions[i], 0, 0) );
		}
		
        
		//Add to mesh
        AddSubmesh( pSub );
    }
}
开发者ID:diboh,项目名称:CPP,代码行数:101,代码来源:mesh.cpp


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