本文整理汇总了C++中IRenderable::addMaterialGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ IRenderable::addMaterialGroup方法的具体用法?C++ IRenderable::addMaterialGroup怎么用?C++ IRenderable::addMaterialGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderable
的用法示例。
在下文中一共展示了IRenderable::addMaterialGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
Font::createSentenceRenderable(IRenderable &renderable, std::string sentence)
{
assert(mMaterialName != "");
int aux = sentence.length();
int size = 0;
for (int count = 0; count < aux; count++) {
// if char exists in the font definition
if (mChars.count(sentence[count]))
size++;
}
assert(size);
// need to clear previous mesh
//Mesh *renderable = (Mesh *)RESOURCEMANAGER->createRenderable("Mesh", sentence, "Sentence");
//renderable->setDrawingPrimitive(curitiba::render::IRenderer::TRIANGLES);
std::vector<VertexData::Attr> *vertices = new std::vector<VertexData::Attr>(size*6);
std::vector<VertexData::Attr> *texCoords = new std::vector<VertexData::Attr>(size*6);
std::vector<VertexData::Attr> *normals = new std::vector<VertexData::Attr>(size*6);
int i = 0;
float hDisp = 0.0f, vDisp = 0.0f;
for (int count = 0; count < aux; count++) {
// get char at position count
char c = sentence[count];
if (c == ' ') {
if (mFixedSize)
hDisp += mChars[c].C + mChars[c].A;
else
hDisp += mChars[c].C;
}
// if char exists in the font definition
else if (mChars.count(c)) {
vertices->at(6*i ).set(hDisp, vDisp + mHeight, 0.0f, 1.0f);
vertices->at(6*i+1).set(hDisp + mChars[c].width, vDisp, 0.0f, 1.0f);
vertices->at(6*i+2).set(hDisp, vDisp, 0.0f, 1.0f);
vertices->at(6*i+3).set(hDisp + mChars[c].width, vDisp, 0.0f, 1.0f);
vertices->at(6*i+4).set(hDisp, vDisp + mHeight,0.0f, 1.0f);
vertices->at(6*i+5).set(hDisp + mChars[c].width, vDisp + mHeight, 0.0f, 1.0f);
normals->at(6*i ).set(0,0,1);
normals->at(6*i+1 ).set(0,0,1);
normals->at(6*i+2 ).set(0,0,1);
normals->at(6*i+3 ).set(0,0,1);
normals->at(6*i+4 ).set(0,0,1);
normals->at(6*i+5 ).set(0,0,1);
texCoords->at(6*i ).set(mChars[c].x1, 1-mChars[c].y2, 0.0f, 1.0f);
texCoords->at(6*i+1).set(mChars[c].x2, 1-mChars[c].y1, 0.0f, 1.0f);
texCoords->at(6*i+2).set(mChars[c].x1, 1-mChars[c].y1, 0.0f, 1.0f);
texCoords->at(6*i+3).set(mChars[c].x2, 1-mChars[c].y1, 0.0f, 1.0f);
texCoords->at(6*i+4).set(mChars[c].x1, 1-mChars[c].y2, 0.0f, 1.0f);
texCoords->at(6*i+5).set(mChars[c].x2, 1-mChars[c].y2, 0.0f, 1.0f);
if (mFixedSize)
hDisp += mChars[c].C + mChars[c].A;
else
hDisp += mChars[c].C;
i++;
}
// newline
else if (c == '\n') {
vDisp += mHeight;
hDisp = 0.0f;
}
}
VertexData &vertexData = renderable.getVertexData();
vertexData.setDataFor (VertexData::getAttribIndex("position"), vertices);
vertexData.setDataFor (VertexData::getAttribIndex("normal"), normals);
vertexData.setDataFor (VertexData::getAttribIndex("texCoord0"), texCoords);
std::vector<unsigned int> *indices = new std::vector<unsigned int>(size*6);
for (int j = 0; j < size*6 ; j++)
indices->push_back(j);
MaterialGroup* auxMG;
std::vector<IMaterialGroup *> aMatG = renderable.getMaterialGroups();
if (aMatG.size()) {
auxMG = (MaterialGroup *)aMatG[0];
auxMG->setIndexList (indices);
}
else {
auxMG = new MaterialGroup();
auxMG->setMaterialName(mMaterialName);
auxMG->setParent(&renderable);
auxMG->setIndexList (indices);
renderable.addMaterialGroup(auxMG);
}
}