本文整理汇总了C++中Cube::SetTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::SetTexture方法的具体用法?C++ Cube::SetTexture怎么用?C++ Cube::SetTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cube
的用法示例。
在下文中一共展示了Cube::SetTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void MyGame::Update(float elapsedTime)
{
static float spawnTimer = 0;
spawnTimer += elapsedTime;
if(spawnTimer >= 0.15f)
{
Cube* c = new Cube(Vector3f(1.f, 1.f, 1.f));
c->SetTexture(Texture::Get("!debug.png"));
GetScene().GetRoot()->AddChild(c);
RigidBody* rb = c->AddToPhysic(1, Vector3f(0, 25, 7.5));
rb->ApplyForce(Vector3f(0, -10.f, 0));
spawnTimer = 0;
m_cubeCount++;
}
std::ostringstream fps;
fps << "FPS: " << GetFps();
m_txtFps->SetText(fps.str());
std::ostringstream CubeCount;
CubeCount << "Cube count: " << m_cubeCount;
m_txtCubeCount->SetText(CubeCount.str());
}
示例2: LoadResource
bool MyGame::LoadResource()
{
// Build scene graph
ContainerNode* root = new ContainerNode();
OrthographicProjectionNode* ortho = new OrthographicProjectionNode();
Texture* texTile = Texture::Get("!tile.png");
Texture* texStair = Texture::Get("!stair.png");
Font* texFont = Font::Get("!DroidSans.ttf|texture_size=256");
Cube* floor = new Cube(Vector3f(50.f, 1.f, 50.f), 50.f, "Floor");
floor->SetTexture(texTile);
root->AddChild(floor);
floor->AddToPhysic(0, Vector3f(0, -.5f, 0));
// Stair
float sw = 1.f; // stair depth
float sh = 1.0f; // stair height
for(int i = 0; i < 5; ++i)
{
Cube* stair = new Cube(Vector3f(6.f, sh, sw), 4);
stair->SetTexture(texStair);
root->AddChild(stair);
stair->AddToPhysic(0, Vector3f(0, sh / 2.f + (i * sh), 5 + (i * sw)));
}
TextNode* title = new TextNode(texFont, 12.f, "TAK game sample");
title->SetShader(Shader::Get("!nolight"));
title->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 25, 0);
ortho->AddChild(title);
TextNode* instruction = new TextNode(texFont, 12.f, "Drag and hold left mouse button to rotate, hold right mouse button to zoom");
instruction->SetShader(Shader::Get("!nolight"));
instruction->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 45, 0);
ortho->AddChild(instruction);
m_txtFps = new TextNode(texFont);
m_txtFps->SetShader(Shader::Get("!nolight"));
m_txtFps->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 65, 0);
ortho->AddChild(m_txtFps);
m_txtCubeCount = new TextNode(texFont);
m_txtCubeCount->SetShader(Shader::Get("!nolight"));
m_txtCubeCount->SetPositionAbsolute(10, GetScene().GetParams().GetHeight() - 85, 0);
ortho->AddChild(m_txtCubeCount);
Cube* pc1;
// front wall
pc1 = new Cube(Vector3f(5.5f, 7.f, .5f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(0, pc1->GetSize().y / 2.f, 9.75f));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(-3, pc1->GetSize().y / 2.f, 5));
// right wall
pc1 = new Cube(Vector3f(.5f, 7.f, 10.f), 10.f);
pc1->SetTexture(texTile);
root->AddChild(pc1);
pc1->AddToPhysic(0, Vector3f(3, pc1->GetSize().y / 2.f, 5));
// Flag engine logo
Sprite* flag = new Sprite(128, 128, Texture::Get("!engineflag.png"));
flag->SetShader(Shader::Get("!nolight"));
flag->SetPositionAbsolute(GetScene().GetParams().GetWidth() - flag->GetWidth() / 2.f, flag->GetHeight() / 2.f - 20.f, 0);
ortho->AddChild(flag);
root->AddChild(ortho);
GetScene().SetRoot(root);
// Setup camera:
Camera* camera = new LookAtCamera(Vector3f(0, 0, 5), 25.f);
GetScene().SetCamera(camera);
return true;
}