本文整理汇总了C++中Ptr::AddTriangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::AddTriangle方法的具体用法?C++ Ptr::AddTriangle怎么用?C++ Ptr::AddTriangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::AddTriangle方法的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
Mesh::Mesh(const String& filename)
{
//Analizamos JSON
String content = String::Read( filename );
rapidjson::Document json;
if( json.Parse<0>( content.ToCString() ).HasParseError() ) return;
rapidjson::Value& sub = json[ "submeshes" ];
for( unsigned int index = 0; index < sub.Size(); index++ )
{
String tex = "";
if ( sub[ index ].HasMember("texture") )
{
tex = sub[ index ][ "texture" ].GetString();
String path = filename.ExtractDir();
if ( path != "" )
{
tex = path + "/" + tex;
}
}
Ptr< Texture > pTex = ResourceManager::Instance()->LoadTexture(tex);
Ptr< Submesh > pSub = Submesh::Create( pTex );
if ( sub[index].HasMember("color") )
{
rapidjson::Value& color = sub[ index ][ "color" ];
if ( color.Size() != 3 ) return;
//for (int nColor = 0; nColor < color.Size(); nColor++)
//{
float red = float(color[rapidjson::SizeType(0)].GetDouble());
float green = float(color[rapidjson::SizeType(1)].GetDouble());
float blue = float(color[rapidjson::SizeType(2)].GetDouble());
pSub->SetColor(red, green, blue);
//}
}
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;
//.........这里部分代码省略.........