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


C++ ShapeBuilder类代码示例

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


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

示例1: create_shape

void CreateWireframeDialog::create_shape() {

    ShapeBuilder *builder = ShapeBuilder::instance();
    const std::string name = m_nameEntry->get_text().raw();

    if (!name.empty()) {
        std::vector<Coord<double>*> coords;
        if (m_coordBox->fill_coords(coords)) {

            // Check for minimum number of points.
            if (coords.size() >= 3) {
                m_minVertices = true;
                builder->add_name(name);
                builder->set_filled(m_filled);
                for (unsigned i = 0; i < coords.size(); i++) {
                    builder->add_point(coords[i]->x(), coords[i]->y(), coords[i]->z());
                }
                std::cout << "Added wireframe to ShapeBuilder." << std::endl;
            } else {
                std::cout << "Rolling back." << std::endl;
                builder->rollback();
            }
        }
        // Clean coords
        for_each (coords.begin(),
                  coords.end(),
                  DeleteList<Coord<double>*>());
    }
}
开发者ID:LeonardoEichs,项目名称:MyIGS,代码行数:29,代码来源:CreateWireframeDialog.cpp

示例2: Shape

    Shape(const Program& prog, const ShapeBuilder& builder)
      : make_shape(builder)
      , shape_instr(make_shape.Instructions())
      , shape_indices(make_shape.Indices())
      , vbos(4) {
        // bind the VAO for the shape
        vao.Bind();

        typename ShapeBuilder::VertexAttribs vert_attr_info;
        const GLchar* vert_attr_name[] = {
          "Position", "Normal", "Tangent", "TexCoord"};
        for(int va = 0; va != 4; ++va) {
            const GLchar* name = vert_attr_name[va];
            std::vector<GLfloat> data;
            auto getter = vert_attr_info.VertexAttribGetter(data, name);
            if(getter != nullptr)
                try {
                    // bind the VBO for the vertex attribute
                    vbos[va].Bind(Buffer::Target::Array);
                    GLuint npv = getter(make_shape, data);
                    // upload the data
                    Buffer::Data(Buffer::Target::Array, data);
                    // setup the vertex attribs array
                    VertexArrayAttrib attr(prog, name);
                    attr.Setup<GLfloat>(npv);
                    attr.Enable();
                } catch(Error&) {
                }
        }
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:30,代码来源:029_flares.cpp

示例3: ShapeAnalyzerGraphData

	ShapeAnalyzerGraphData(const ShapeBuilder& builder)
	 : _instr(builder.Instructions())
	 , _index(_adapt(builder.Indices()))
	 , _main_va()
	 , _main_vpv(builder.Positions(_main_va))
	 , _smooth_va()
	 , _smooth_vpv(builder.Normals(_smooth_va))
	 , _eps(1.0e-9)
	{
		_initialize();
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:11,代码来源:analyzer_data.hpp

示例4: ShapeWrapperWithAdjacency

	ShapeWrapperWithAdjacency(
		const StdRange& names,
		const ShapeBuilder& builder
	): ShapeWrapperBase(
		names.begin(),
		names.end(),
		builder,
		builder.IndicesWithAdjacency(),
		builder.InstructionsWithAdjacency()
	)
	{ }
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:11,代码来源:wrapper.hpp

示例5: builderExample

// Patterns
static void builderExample() {
	ShapeBuilder *myRectangleBuilder = new RectangleBuilder();
	myRectangleBuilder->createShape();
	myRectangleBuilder->setHeight();
	myRectangleBuilder->setWidth();
	Shape *myRectangle = myRectangleBuilder->getShape();
	cout << "Area of the Rectangle is: " << myRectangle->getArea() << endl;
	delete myRectangleBuilder;

	ShapeBuilder *myTriangleBuilder = new TriangleBuilder();
	myTriangleBuilder->createShape();
	myTriangleBuilder->setHeight();
	myTriangleBuilder->setWidth();
	Shape *myTriangle = myTriangleBuilder->getShape();
	cout << "Area of the Triangle is: " << myTriangle->getArea() << endl;
	delete myTriangleBuilder;
}
开发者ID:gi-tux,项目名称:CppExamples,代码行数:18,代码来源:CppExample.cpp

示例6: ShapeWrapperBase

	ShapeWrapperBase(
		Iterator names_begin,
		Iterator names_end,
		const ShapeBuilder& builder
	): _face_winding(builder.FaceWinding())
	 , _shape_instr(builder.Instructions())
	 , _index_info(builder)
	 , _vbos(std::distance(names_begin, names_end)+1)
	 , _npvs(std::distance(names_begin, names_end)+1, 0)
	 , _names(std::distance(names_begin, names_end))
	{
		this->_init(
			builder,
			builder.Indices(),
			names_begin,
			names_end
		);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:18,代码来源:wrapper.hpp

示例7: Shape

	Shape(const Program& prog, const ShapeBuilder& builder)
	 : make_shape(builder)
	 , shape_instr(make_shape.Instructions(shapes::DrawMode::Default()))
	 , edge_instr(make_shape.Instructions(shapes::DrawMode::Edges()))
	 , shape_indices(make_shape.Indices(shapes::DrawMode::Default()))
	 , edge_indices(make_shape.Indices(shapes::DrawMode::Edges()))
	 , vbos(3)
	{
		// bind the VAO for the shape
		vao.Bind();

		typename ShapeBuilder::VertexAttribs vert_attr_info;
		const GLuint nva = 3;
		const GLchar* vert_attr_name[nva] = {
			"Position",
			"Normal",
			"TexCoord"
		};
		for(GLuint va=0; va!=nva; ++va)
		{
			const GLchar* name = vert_attr_name[va];
			std::vector<GLfloat> data;
			auto getter = vert_attr_info.VertexAttribGetter(data, name);
			if(getter != nullptr)
			{
				// bind the VBO for the vertex attribute
				vbos[va].Bind(Buffer::Target::Array);
				GLuint n_per_vertex = getter(make_shape, data);
				// upload the data
				Buffer::Data(Buffer::Target::Array, data);
				// setup the vertex attribs array
				VertexArrayAttrib attr(prog, name);
				attr.Setup<GLfloat>(n_per_vertex);
				attr.Enable();
			}
		}
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:37,代码来源:031_sketch.cpp

示例8: _init

	void _init(
		const ShapeBuilder& builder,
		const ShapeIndices& shape_indices,
		Iterator name,
		Iterator end
	)
	{
		VertexArray::Unbind();
		typename ShapeBuilder::VertexAttribs vert_attr_info;
		unsigned i = 0;
		std::vector<GLfloat> data;
		while(name != end)
		{
			auto getter = vert_attr_info.VertexAttribGetter(
				data,
				*name
			);
			if(getter != nullptr)
			{
				_vbos[i].Bind(Buffer::Target::Array);
				_npvs[i] = getter(builder, data);
				_names[i] = *name;

				Buffer::Data(Buffer::Target::Array, data);
			}
			++name;
			++i;
		}

		if(!shape_indices.empty())
		{
			assert((i+1) == _npvs.size());
			assert((i+1) == _vbos.size());

			_npvs[i] = 1;
			_vbos[i].Bind(Buffer::Target::ElementArray);
			Buffer::Data(
				Buffer::Target::ElementArray,
				shape_indices
			);
		}

		builder.BoundingSphere(_bounding_sphere);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:44,代码来源:wrapper.hpp

示例9: Draw

	void Draw(void)
	{
		vao.Bind();
		gl.FrontFace(make_shape.FaceWinding());
		shape_instr.Draw(shape_indices, 1);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:6,代码来源:029_flares.cpp

示例10: Draw

	void Draw(const std::function<bool (GLuint)>& drawing_driver)
	{
		vao.Bind();
		gl.FrontFace(make_shape.FaceWinding());
		shape_instr.Draw(shape_indices, 1, 0, drawing_driver);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:6,代码来源:033_metal_and_glass.cpp


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