本文整理汇总了C++中Texture2DEffect::GetDepthState方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture2DEffect::GetDepthState方法的具体用法?C++ Texture2DEffect::GetDepthState怎么用?C++ Texture2DEffect::GetDepthState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2DEffect
的用法示例。
在下文中一共展示了Texture2DEffect::GetDepthState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateScene
//.........这里部分代码省略.........
vba.ApplyTo(ground);
for (int i = 0; i < vba.GetNumVertices(); ++i)
{
Float2& tcoord = vba.TCoord<Float2>(0, i);
tcoord[0] *= 128.0f;
tcoord[1] *= 128.0f;
}
std::string path = Environment::GetPathR("Horizontal.wmtf");
Texture2D* texture = Texture2D::LoadWMTF(path);
ground->SetEffectInstance(Texture2DEffect::CreateUniqueInstance(texture,
Shader::SF_LINEAR_LINEAR, Shader::SC_REPEAT, Shader::SC_REPEAT));
mScene->AttachChild(ground);
// Partition the region above the ground into 5 convex pieces. Each plane
// is perpendicular to the ground (not required generally).
VertexColor3Effect* vceffect = new0 VertexColor3Effect();
vceffect->GetCullState(0, 0)->Enabled = false;
vceffect->GetWireState(0, 0)->Enabled = true;
Vector2f v0(-1.0f, 1.0f);
Vector2f v1(1.0f, -1.0f);
Vector2f v2(-0.25f, 0.25f);
Vector2f v3(-1.0f, -1.0f);
Vector2f v4(0.0f, 0.0f);
Vector2f v5(1.0f, 0.5f);
Vector2f v6(-0.75f, -7.0f/12.0f);
Vector2f v7(-0.75f, 0.75f);
Vector2f v8(1.0f, 1.0f);
BspNode* bsp0 = CreateNode(v0, v1, vceffect, Float3(1.0f, 0.0f, 0.0f));
BspNode* bsp1 = CreateNode(v2, v3, vceffect, Float3(0.0f, 0.5f, 0.0f));
BspNode* bsp2 = CreateNode(v4, v5, vceffect, Float3(0.0f, 0.0f, 1.0f));
BspNode* bsp3 = CreateNode(v6, v7, vceffect, Float3(0.0f, 0.0f, 0.0f));
bsp0->AttachPositiveChild(bsp1);
bsp0->AttachNegativeChild(bsp2);
bsp1->AttachPositiveChild(bsp3);
// Attach an object in each convex region.
float height = 0.1f;
Vector2f center;
TriMesh* mesh;
// The texture effect for the convex objects.
Texture2DEffect* cvxeffect =
new0 Texture2DEffect(Shader::SF_LINEAR_LINEAR);
cvxeffect->GetDepthState(0, 0)->Enabled = false;
cvxeffect->GetDepthState(0, 0)->Writable = true;
// The texture effect for the torus.
Texture2DEffect* toreffect =
new0 Texture2DEffect(Shader::SF_LINEAR_LINEAR);
// The texture image shared by the objects.
path = Environment::GetPathR("Flower.wmtf");
texture = Texture2D::LoadWMTF(path);
// Region 0: Create a torus mesh.
mesh = sm.Torus(16, 16, 1.0f, 0.25f);
mesh->SetEffectInstance(toreffect->CreateInstance(texture));
mesh->LocalTransform.SetUniformScale(0.1f);
center = (v2 + v6 + v7)/3.0f;
mesh->LocalTransform.SetTranslate(APoint(center[0], center[1], height));
bsp3->AttachPositiveChild(mesh);
// Region 1: Create a sphere mesh.
mesh = sm.Sphere(32, 16, 1.0f);
mesh->SetEffectInstance(cvxeffect->CreateInstance(texture));
mesh->LocalTransform.SetUniformScale(0.1f);
center = (v0 + v3 + v6 + v7)/4.0f;
mesh->LocalTransform.SetTranslate(APoint(center[0], center[1], height));
bsp3->AttachNegativeChild(mesh);
// Region 2: Create a tetrahedron.
mesh = sm.Tetrahedron();
mesh->SetEffectInstance(cvxeffect->CreateInstance(texture));
mesh->LocalTransform.SetUniformScale(0.1f);
center = (v1 + v2 + v3)/3.0f;
mesh->LocalTransform.SetTranslate(APoint(center[0], center[1], height));
bsp1->AttachNegativeChild(mesh);
// Region 3: Create a hexahedron (cube).
mesh = sm.Hexahedron();
mesh->SetEffectInstance(cvxeffect->CreateInstance(texture));
mesh->LocalTransform.SetUniformScale(0.1f);
center = (v1 + v4 + v5)/3.0f;
mesh->LocalTransform.SetTranslate(APoint(center[0], center[1], height));
bsp2->AttachPositiveChild(mesh);
// Region 4: Create an octahedron.
mesh = sm.Octahedron();
mesh->SetEffectInstance(cvxeffect->CreateInstance(texture));
mesh->LocalTransform.SetUniformScale(0.1f);
center = (v0 + v4 + v5 + v8)/4.0f;
mesh->LocalTransform.SetTranslate(APoint(center[0], center[1], height));
bsp2->AttachNegativeChild(mesh);
mScene->AttachChild(bsp0);
}