本文整理汇总了C++中CL_GraphicContext::mult_modelview方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::mult_modelview方法的具体用法?C++ CL_GraphicContext::mult_modelview怎么用?C++ CL_GraphicContext::mult_modelview使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::mult_modelview方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recursive_render
void App::recursive_render(CL_GraphicContext &gc, const struct aiScene *sc, const struct aiNode* nd, bool use_texture_coords)
{
int i;
unsigned int n = 0, t;
struct aiMatrix4x4 m = nd->mTransformation;
// update transform
aiTransposeMatrix4(&m);
gc.push_modelview();
gc.mult_modelview((float*)&m);
// draw all meshes assigned to this node
for (; n < nd->mNumMeshes; ++n)
{
const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
if (mesh->mNormals == NULL)
throw CL_Exception("This example expects normals to be set");
std::vector<CL_Vec3f> normals;
std::vector<CL_Vec3f> vertices;
std::vector<CL_Vec3f> tex_coords;
normals.reserve(mesh->mNumFaces * 3);
vertices.reserve(mesh->mNumFaces * 3);
if (use_texture_coords)
{
if (mesh->mTextureCoords == NULL || mesh->mTextureCoords[0] == NULL)
throw CL_Exception("This example expects texcoords to be set for this object");
tex_coords.reserve(mesh->mNumFaces * 3);
}
for (t = 0; t < mesh->mNumFaces; ++t)
{
const struct aiFace* face = &mesh->mFaces[t];
if (face->mNumIndices != 3)
throw CL_Exception("This example only supports triangles");
for(i = 0; i < face->mNumIndices; i++)
{
int index = face->mIndices[i];
normals.push_back(&mesh->mNormals[index].x);
vertices.push_back( &mesh->mVertices[index].x);
if (use_texture_coords)
tex_coords.push_back( &mesh->mTextureCoords[0][index].x);
}
}
if (!vertices.empty())
{
CL_PrimitivesArray prim_array(gc);
prim_array.set_attributes(cl_attrib_position, &vertices[0]);
prim_array.set_attribute(cl_attrib_color, CL_Colorf::white);
prim_array.set_attributes(cl_attrib_normal, &normals[0]);
if (use_texture_coords)
prim_array.set_attributes(cl_attrib_texture_position, &tex_coords[0]);
gc.draw_primitives(cl_triangles, vertices.size(), prim_array);
}
}
// draw all children
for (n = 0; n < nd->mNumChildren; ++n)
{
recursive_render(gc, sc, nd->mChildren[n], use_texture_coords);
}
gc.pop_modelview();
}