当前位置: 首页>>代码示例>>C++>>正文


C++ Mesh::AddPrimitive方法代码示例

本文整理汇总了C++中Mesh::AddPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::AddPrimitive方法的具体用法?C++ Mesh::AddPrimitive怎么用?C++ Mesh::AddPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mesh的用法示例。


在下文中一共展示了Mesh::AddPrimitive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParsePrimitive

      //разбор примитива
    void ParsePrimitive (Parser::Iterator primitive_iter, Mesh& mesh)
    {
      static const char* METHOD_NAME = "media::geometry::XmlMeshLibraryLoader::ParsePrimitive";
      
      const char*   type_string         = get<const char*> (*primitive_iter, "type");
      PrimitiveType type                = get_primitive_type (type_string);
      const char*   material            = get<const char*> (*primitive_iter, "material", "");
      unsigned int  vertex_buffer_index = get<unsigned int> (*primitive_iter, "vertex_buffer"),
                    first               = get<unsigned int> (*primitive_iter, "first"),
                    count               = get<unsigned int> (*primitive_iter, "count"),
                    base_vertex         = get<unsigned int> (*primitive_iter, "base_vertex", 0u);

      if (type >= PrimitiveType_Num)
        throw xtl::make_argument_exception (METHOD_NAME, "type", type_string);

      if (vertex_buffer_index >= mesh.VertexBuffersCount ())
        throw xtl::make_range_exception (METHOD_NAME, "vertex_buffer", vertex_buffer_index, mesh.VertexBuffersCount ());

      const VertexBuffer& vertex_buffer  = mesh.VertexBuffer (vertex_buffer_index);
      unsigned int        vertices_count = vertex_buffer.VerticesCount (),
                          indices_count  = mesh.IndexBuffer ().Size (),
                          max_primitives_count = 0,
                          max_count      = indices_count ? indices_count : vertices_count;                          

      if (first > max_count)
        throw xtl::make_range_exception (METHOD_NAME, "first", first, max_count);

      max_count -= first;

      switch (type)
      {
        case PrimitiveType_LineList:
          max_primitives_count = max_count / 2;
          break;
        case media::geometry::PrimitiveType_LineStrip:          
          max_primitives_count = max_count > 1 ? max_count - 1 : 0;
          break;
        case media::geometry::PrimitiveType_TriangleList:
          max_primitives_count = max_count / 3;
          break;
        case media::geometry::PrimitiveType_TriangleStrip:
          max_primitives_count = max_count > 2 ? max_count - 2 : 0;
          break;          
        case media::geometry::PrimitiveType_TriangleFan:
          max_primitives_count = max_count > 2 ? max_count - 2 : 0;
          break;            
        default:
          break;
      }

      if (count > max_primitives_count)
        throw xtl::make_range_exception (METHOD_NAME, "count", count, max_primitives_count + 1);

      if (base_vertex >= vertices_count)
        throw xtl::make_range_exception (METHOD_NAME, "base_vertex", base_vertex, vertices_count);

      if (!count)
      {
        primitive_iter->Log ().Warning (*primitive_iter, "Empty primitive");
        return;
      }

      mesh.AddPrimitive (type, vertex_buffer_index, first, count, base_vertex, material);
    }
开发者ID:untgames,项目名称:funner,代码行数:65,代码来源:geometry_xmesh_loader.cpp


注:本文中的Mesh::AddPrimitive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。