本文整理汇总了C++中VertexLayout::addElement方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexLayout::addElement方法的具体用法?C++ VertexLayout::addElement怎么用?C++ VertexLayout::addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexLayout
的用法示例。
在下文中一共展示了VertexLayout::addElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getParticleQuad
//////////////////////////////////////////////////////////////////////////
/// Particle Quad
gfx::ModelMesh* ContentManager::getParticleQuad()
{
if (m_ParticleQuad == nullptr)
{
using namespace gfx;
VertexLayout layout;
layout.addElement(VertexElement(eShaderAttribute_Position, eShaderAttributeType_Float, eShaderAttributeTypeComponents_3, 0));
he::ObjectList<VertexPos> vertices(4);
vertices.add(VertexPos(vec3(-1, 1, 0.0f)));
vertices.add(VertexPos(vec3(1, 1, 0.0f)));
vertices.add(VertexPos(vec3(-1, -1, 0.0f)));
vertices.add(VertexPos(vec3(1, -1, 0.0f)));
he::PrimitiveList<uint16> indices(6);
indices.add(1); indices.add(0); indices.add(2);
indices.add(1); indices.add(2); indices.add(3);
ObjectHandle handle(ResourceFactory<ModelMesh>::getInstance()->create());
m_ParticleQuad = ResourceFactory<ModelMesh>::getInstance()->get(handle);
m_ParticleQuad->setName(he::String("Particle quad"));
m_ParticleQuad->init(layout, gfx::MeshDrawMode_Triangles);
m_ParticleQuad->setVertices(&vertices[0], 4, gfx::MeshUsage_Static, false);
m_ParticleQuad->setIndices(&indices[0], 6, gfx::IndexStride_UShort, gfx::MeshUsage_Static);
m_ParticleQuad->setLoaded(eLoadResult_Success);
}
m_ParticleQuad->instantiate();
return m_ParticleQuad;
}
示例2: load
void SkyBox::load( const he::String& asset )
{
HE_ASSERT(m_Drawable == nullptr, "Skybox is loaded twice!");
m_Drawable = HENew(Drawable)();
m_Drawable->setLocalScale(vec3(1000000000)); // bounds must be huge
//////////////////////////////////////////////////////////////////////////
/// Load Model
//////////////////////////////////////////////////////////////////////////
ModelMesh* const cube(
ResourceFactory<gfx::ModelMesh>::getInstance()->get(ResourceFactory<gfx::ModelMesh>::getInstance()->create()));
cube->setName(he::String("skybox-") + asset);
he::PrimitiveList<vec3> vertices(8);
vertices.add(vec3(-1, 1, -1));
vertices.add(vec3( 1, 1, -1));
vertices.add(vec3(-1, -1, -1));
vertices.add(vec3( 1, -1, -1));
vertices.add(vec3(-1, 1, 1));
vertices.add(vec3( 1, 1, 1));
vertices.add(vec3(-1, -1, 1));
vertices.add(vec3( 1, -1, 1));
he::PrimitiveList<uint16> indices(36);
indices.add(0); indices.add(1); indices.add(2); //front
indices.add(1); indices.add(3); indices.add(2);
indices.add(5); indices.add(4); indices.add(7); //back
indices.add(4); indices.add(6); indices.add(7);
indices.add(4); indices.add(0); indices.add(6); //left
indices.add(0); indices.add(2); indices.add(6);
indices.add(1); indices.add(5); indices.add(3); //right
indices.add(5); indices.add(7); indices.add(3);
indices.add(4); indices.add(5); indices.add(0); //top
indices.add(5); indices.add(1); indices.add(0);
indices.add(3); indices.add(7); indices.add(2); //bottom
indices.add(7); indices.add(6); indices.add(2);
VertexLayout layout;
layout.addElement(VertexElement(eShaderAttribute_Position, eShaderAttributeType_Float, eShaderAttributeTypeComponents_3, 0));
cube->init(layout, MeshDrawMode_Triangles);
cube->setVertices(&vertices[0], static_cast<uint32>(vertices.size()), MeshUsage_Static, false);
cube->setIndices(&indices[0], static_cast<uint32>(indices.size()), IndexStride_UShort, MeshUsage_Static);
cube->setLoaded(eLoadResult_Success);
m_Drawable->setModelMesh(cube);
cube->release();
Material* const material(CONTENT->loadMaterial("engine/sky.material"));
m_Drawable->setMaterial(material);
material->release();
const int8 cubeMap(m_Drawable->getMaterial()->findParameter(HEFS::strcubeMap));
if (cubeMap >= 0)
{
const TextureCube* cube(CONTENT->asyncLoadTextureCube(asset));
m_Drawable->getMaterial()->getParameter(cubeMap).setTextureCube(cube);
cube->release();
}
}