本文整理汇总了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);
}
}
示例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 );
}
}