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


C++ VertexAttribute类代码示例

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


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

示例1: CCSubdivision

void Surface_Subdivision_Plugin::CCSubdivision(
	const QString& mapName,
	const QString& positionAttributeName, bool interp)
{
	MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
	if(mh == NULL)
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
	if(!position.isValid())
		return;

	pythonRecording("CCSubdivision", "", mapName, positionAttributeName,interp);

	PFP2::MAP* map = mh->getMap();
	if (interp)
		Algo::Surface::Modelisation::CatmullClarkInterpolSubdivision<PFP2>(*map, position);
	else
		Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position);

	mh->notifyAttributeModification(position);
	mh->notifyConnectivityModification();

	foreach(View* view, mh->getLinkedViews())
		view->updateGL();
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:26,代码来源:surface_subdivision.cpp

示例2:

void ShapeMatching<PFP>::computeVelocities(VertexAttribute<VEC3, MAP>& velocity, VertexAttribute<VEC3, MAP>& fext, REAL h, REAL alpha)
{
    for(unsigned int i = velocity.begin() ; i < velocity.end() ; velocity.next(i))
    {
        velocity[i] = velocity[i] + alpha * ((m_goal[i] - m_position[i]) / h ) + (h * fext[i]) / m_mass[i];
    }
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:7,代码来源:shapeMatching.hpp

示例3: updateTF

    void updateTF (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {
        qDebug() << "UPDATING TF2";
        tf.bind();
        //mesh.setAttributeLocation(tf);
        glEnable(GL_RASTERIZER_DISCARD);
        mesh.bindBuffers();
        Tucano::Misc::errorCheckFunc(__FILE__, __LINE__);
        //VertexAttribute* va = mesh.getAttribute("nPos");

        write_va->disable();
        //glDisableVertexAttribArray(mesh.getAttributeLocation("nPos"));

        read_va->enable(tf.getAttributeLocation("inPos"));
        Tucano::Misc::errorCheckFunc(__FILE__, __LINE__);
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, write_va->getBufferID());
        glBeginTransformFeedback(GL_POINTS);
        glEnable(GL_DEPTH_TEST);
        mesh.renderPoints();
        glEndTransformFeedback();
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
        mesh.unbindBuffers();
        glDisable(GL_RASTERIZER_DISCARD);
        tf.unbind();
    }
开发者ID:brunoferraz,项目名称:advRendering,代码行数:25,代码来源:simpleTF.hpp

示例4: updateAttributeData

void ofVbo::updateAttributeData(int location, const float * attr0x, int total){
	VertexAttribute * attr = nullptr;
	if (ofIsGLProgrammableRenderer()) {
		switch (location){
			case ofShader::POSITION_ATTRIBUTE:
				attr = &positionAttribute;
				break;
			case ofShader::COLOR_ATTRIBUTE:
				attr = &colorAttribute;
				break;
			case ofShader::NORMAL_ATTRIBUTE:
				attr = &normalAttribute;
				break;
			case ofShader::TEXCOORD_ATTRIBUTE:
				attr = &texCoordAttribute;
				break;
			default:
				if(customAttributes.find(location)!=customAttributes.end()) {
					attr = &customAttributes[location];
				}
				break;
		}
	} else {
		if(customAttributes.find(location)!=customAttributes.end()) {
			attr = &customAttributes[location];
		}
	}
	if (attr !=nullptr && attr->isAllocated()) {
		attr->updateData(0, total*attr->stride, attr0x);
	}
}
开发者ID:imohame,项目名称:openFrameworks,代码行数:31,代码来源:ofVbo.cpp

示例5: computeNormal

void Surface_DifferentialProperties_Plugin::computeNormal(
	const QString& mapName,
	const QString& positionAttributeName,
	const QString& normalAttributeName,
	bool autoUpdate)
{
	MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
	if(mh == NULL)
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> position = mh->getAttribute<PFP2::VEC3, VERTEX>(positionAttributeName);
	if(!position.isValid())
		return;

	VertexAttribute<PFP2::VEC3, PFP2::MAP> normal = mh->getAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);
	if(!normal.isValid())
		normal = mh->addAttribute<PFP2::VEC3, VERTEX>(normalAttributeName);

	PFP2::MAP* map = mh->getMap();
	Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);

	computeNormalLastParameters[mapName] =
		ComputeNormalParameters(positionAttributeName, normalAttributeName, autoUpdate);

	mh->notifyAttributeModification(normal);
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:26,代码来源:surface_differentialProperties.cpp

示例6: testVAbyNames

/**
 * @brief test if map has a Vertex Attribute of VEC3 named name
 * @param map  the map
 * @param name name of attribute
 */
void testVAbyNames(MAP& map, const std::string& name)
{
	VertexAttribute<VEC3, MAP> testPos = map.getAttribute<VEC3, VERTEX, MAP>(name);
	if (testPos.isValid())
		std::cout << "Attribute "<< name <<" valid"<< std::endl;
	else
		std::cout << "Attribute "<< name <<"invalid"<< std::endl;
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:13,代码来源:simple_attribs.cpp

示例7: writeAttributeData

std::size_t VertexDataManager::writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute, GLsizei instances)
{
    Buffer *buffer = attribute.mBoundBuffer.get();

    int inputStride = attribute.stride();
    int elementSize = attribute.typeSize();
    const FormatConverter &converter = formatConverter(attribute);
    std::size_t streamOffset = 0;

    void *output = NULL;
    
    if (vertexBuffer)
    {
        output = vertexBuffer->map(attribute, spaceRequired(attribute, count, instances), &streamOffset);
    }

    if (output == NULL)
    {
        ERR("Failed to map vertex buffer.");
        return -1;
    }

    const char *input = NULL;

    if (buffer)
    {
        int offset = attribute.mOffset;

        input = static_cast<const char*>(buffer->data()) + offset;
    }
    else
    {
        input = static_cast<const char*>(attribute.mPointer);
    }

    if (instances == 0 || attribute.mDivisor == 0)
    {
        input += inputStride * start;
    }

    if (converter.identity && inputStride == elementSize)
    {
        memcpy(output, input, count * inputStride);
    }
    else
    {
        converter.convertArray(input, inputStride, count, output);
    }

    vertexBuffer->unmap();

    return streamOffset;
}
开发者ID:dog-god,项目名称:iptv,代码行数:53,代码来源:VertexDataManager.cpp

示例8:

void UniversalLoader<MapType, AttrTypeLoader>::UnpackOnVertex(MapType& map, const unsigned int* verticesId, const AHEMHeader* hdr, const char* attrName, const void* buffer) const
{
	VertexAttribute<typename AttrTypeLoader::ATTR_TYPE> attr = map.template getAttribute<typename AttrTypeLoader::ATTR_TYPE, VERTEX>(attrName);

	if (!attr.isValid())
		attr = map.template addAttribute<typename AttrTypeLoader::ATTR_TYPE, VERTEX>(attrName);

	char* p = (char*)buffer;

	for(unsigned int i = 0 ; i < hdr->meshHdr.vxCount ; i++)
	{
		AttrTypeLoader::Extract(&attr[verticesId[i]], p);
		p += AttrTypeLoader::TYPE_SIZE_IN_BUFFER;
	}
}
开发者ID:Peiffert,项目名称:CGoGN,代码行数:15,代码来源:AHEMImporterDefAttr.hpp

示例9:

bool VertexAttribute::operator==(const VertexAttribute& VertexAttribute) const
{
	if (m_nNumItems != VertexAttribute.GetNumAttributeItems()) return false;

	for (int i = 0; i < m_nNumItems; ++i)
	{
		const ATTRIBUTE_ITEM* pAttrItem = VertexAttribute.GetAttributeItem(i);

		if (m_AttributeItems[i].nSize != pAttrItem->nSize) return false;
		if (m_AttributeItems[i].eItemType != pAttrItem->eItemType) return false;
		if (!StringUtil::IsEqual(m_AttributeItems[i].szParamName, pAttrItem->szParamName)) return false;
	}

	return true;
}
开发者ID:mshandle,项目名称:spank,代码行数:15,代码来源:VertexAttribute.cpp

示例10:

void AHEMImporter<PFP>::LoadPosition(AHEMAttributeDescriptor* posDescr)
{
	VertexAttribute<typename PFP::VEC3, typename PFP::MAP> position = map->template getAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	if (!position.isValid())
		position = map->template addAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	f.seekg(posDescr->fileStartOffset, std::ios_base::beg);
	f.read(buffer, posDescr->attributeChunkSize);

	float* q = (float*)buffer;

	for(unsigned int i = 0 ; i < hdr.meshHdr.vxCount ; i++)
	{
		position[verticesId[i]] = typename PFP::VEC3(q[0], q[1], q[2]);
		q += 3;
	}
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:18,代码来源:AHEMImporter.hpp

示例11: lookupAttribute

std::size_t StaticVertexBuffer::lookupAttribute(const VertexAttribute &attribute)
{
    for (unsigned int element = 0; element < mCache.size(); element++)
    {
        if (mCache[element].type == attribute.mType &&
            mCache[element].size == attribute.mSize &&
            mCache[element].stride == attribute.stride() &&
            mCache[element].normalized == attribute.mNormalized)
        {
            if (mCache[element].attributeOffset == attribute.mOffset % attribute.stride())
            {
                return mCache[element].streamOffset;
            }
        }
    }

    return -1;
}
开发者ID:dog-god,项目名称:iptv,代码行数:18,代码来源:VertexDataManager.cpp

示例12: render

    /** * @brief Render the mesh given a camera and light, using a Phong shader
     * @param mesh Given mesh
     * @param camera Given camera
     * @param lightTrackball Given light camera
     */
    void render (Tucano::Mesh& mesh, const Tucano::Camera& camera, const Tucano::Camera& lightTrackball)
    {

        if (read_va == NULL)
        {
            read_va = mesh.getAttribute("positions1");
            write_va = mesh.getAttribute("positions2");
        }

        if (read_va == NULL || write_va == NULL)
            qDebug() << "AHHH morri";

        updateTF(mesh, camera, lightTrackball);
        Eigen::Vector4f viewport = camera.getViewport();
        glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
        simple.bind();
        // sets all uniform variables for the phong shader

        simple.setUniform("projectionMatrix", camera.getProjectionMatrix());
        simple.setUniform("modelMatrix", mesh.getModelMatrix());
        simple.setUniform("viewMatrix", camera.getViewMatrix());

        glEnable(GL_DEPTH_TEST);
        //mesh.setAttributeLocation(simple);
        mesh.bindBuffers();
//            mesh.resetLocations();
        //qDebug() << mesh.getAttribute("nPos")->getLocation();
        read_va->disable();
        write_va->enable(simple.getAttributeLocation("inPos"));


        mesh.setAttributeLocation("nColor",  simple.getAttributeLocation("inColor"));

        mesh.renderPoints();
        mesh.unbindBuffers();

        simple.unbind();

        VertexAttribute *tmp_va;
        tmp_va = read_va;
        read_va = write_va;
        write_va = tmp_va;
    }
开发者ID:brunoferraz,项目名称:advRendering,代码行数:48,代码来源:simpleTF.hpp

示例13: getVertexAttribute

      void VertexAttributeSet::combineBuffers()
      {
        // calculate stride & number of vertices
        unsigned int stride = 0;
        unsigned int numberOfVertices = 0;
        for ( unsigned int index = 0; index < static_cast<unsigned int>(AttributeID::VERTEX_ATTRIB_COUNT); ++index )
        {
          AttributeID id = static_cast<AttributeID>(index);
          if ( isEnabled( id ) )
          {
            VertexAttribute attribute = getVertexAttribute( id );
            stride += attribute.getVertexDataBytes();

            if ( !numberOfVertices )
            {
              numberOfVertices = attribute.getVertexDataCount();
            }
            else
            {
              DP_ASSERT( numberOfVertices == attribute.getVertexDataCount() );
            }
          }
        }

        // create one big buffer with all data
        BufferSharedPtr newBufferSharedPtr = BufferHost::create();
        newBufferSharedPtr->setSize( numberOfVertices * stride );
        unsigned int offset = 0;
        for ( unsigned int index = 0; index < static_cast<unsigned int>(AttributeID::VERTEX_ATTRIB_COUNT); ++index )
        {
          AttributeID id = static_cast<AttributeID>(index);
          if ( isEnabled( id ) )
          {
            VertexAttribute attributeNew;
            const VertexAttribute& attributeOld = getVertexAttribute( id );
            attributeNew.setData( attributeOld.getVertexDataSize(), attributeOld.getVertexDataType(), newBufferSharedPtr, offset, stride, numberOfVertices );

            Buffer::DataReadLock drl(attributeOld.getBuffer());
            Buffer::DataWriteLock dwl(attributeNew.getBuffer(), Buffer::MapMode::READWRITE );
            dp::util::stridedMemcpy( dwl.getPtr(), attributeNew.getVertexDataOffsetInBytes(), attributeNew.getVertexDataStrideInBytes(),
              drl.getPtr(), attributeOld.getVertexDataOffsetInBytes(), attributeOld.getVertexDataStrideInBytes(),
              attributeOld.getVertexDataBytes(), numberOfVertices
              );
            offset += attributeOld.getVertexDataBytes();
            setVertexAttribute( id, attributeNew, true );
          }
        }
      }
开发者ID:aonorin,项目名称:pipeline,代码行数:48,代码来源:VertexAttributeSet.cpp

示例14: sizeof

void AHEMImporter<PFP>::LoadTopology()
{
    // Allocate vertices

	AttributeContainer& vxContainer = map->template getAttributeContainer<VERTEX>();

	verticesId = new unsigned int[hdr.meshHdr.vxCount];

	for(unsigned int i = 0 ; i < hdr.meshHdr.vxCount ; i++)
		verticesId[i] = vxContainer.insertLine();

	// Ensure vertices are created by querying the position attribute

	VertexAttribute<typename PFP::VEC3, typename PFP::MAP> position = map->template getAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	if (!position.isValid())
		position = map->template addAttribute<typename PFP::VEC3, VERTEX, typename PFP::MAP>("position");

	// Read faces stream and create faces [only intra-face links]
	
	HESorter* addedHE = new HESorter[hdr.meshHdr.heCount];

	facesId = new Dart[hdr.meshHdr.faceCount];

	f.read(buffer, hdr.meshHdr.meshChunkSize);
	char* batch = buffer;

	unsigned int fId = 0;
	unsigned int heId = 0;

	while(fId < hdr.meshHdr.faceCount)
	{
		AHEMFaceBatchDescriptor* fbd = (AHEMFaceBatchDescriptor*)batch;
		stUInt32* ix = (stUInt32*)(batch + sizeof(AHEMFaceBatchDescriptor));

		for(unsigned int i = 0 ; i < fbd->batchLength ; i++)
		{
			Dart d = map->newFace(fbd->batchFaceSize);							// create face
			facesId[fId++] = d;

			unsigned int firstVx = verticesId[*ix++];							// setup face's vertices up to last HE
			unsigned int prevVx = firstVx;

			for(unsigned int k = 0 ; k < fbd->batchFaceSize - 1 ; k++)
			{
				addedHE[heId].d = d;
				addedHE[heId].vxIdFrom = prevVx;
				addedHE[heId].vxIdTo = verticesId[*ix];

				map->setDartEmbedding<VERTEX>(d, prevVx);
				d = map->phi1(d);

				prevVx = *ix++;
				heId++;
			}

			// last HE

			addedHE[heId].d = d;
			addedHE[heId].vxIdFrom = prevVx;
			addedHE[heId].vxIdTo = firstVx;

			map->setDartEmbedding<VERTEX>(d, prevVx);
			heId++;
		}

		batch = (char*)ix;
	}

	// Sort the HE for fast retrieval

	std::sort(addedHE, addedHE + hdr.meshHdr.heCount);

	// Sew faces [inter-face links]

	for(unsigned int i = 0 ; i < hdr.meshHdr.heCount ; i++)
	{
		HESorter* opposite = (HESorter*)bsearch(addedHE + i, addedHE, hdr.meshHdr.heCount, sizeof(HESorter), OppositeSearch);

		if(opposite && opposite->d == map->phi2(opposite->d))
			map->sewFaces(addedHE[i].d, opposite->d);
	}
}
开发者ID:abletterer,项目名称:CGoGN-1,代码行数:83,代码来源:AHEMImporter.hpp

示例15: foff

bool MeshTablesVolume<PFP>::importOFFWithELERegions(const std::string& filenameOFF, const std::string& filenameELE, std::vector<std::string>& attrNames)
{
    VertexAttribute<VEC3> position =  m_map.template getAttribute<VEC3, VERTEX>("position") ;

    if (!position.isValid())
        position = m_map.template addAttribute<VEC3, VERTEX>("position") ;

    attrNames.push_back(position.name()) ;

    AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;

    // open files
    std::ifstream foff(filenameOFF.c_str(), std::ios::in);
    if (!foff.good())
    {
        CGoGNerr << "Unable to open OFF file " << CGoGNendl;
        return false;
    }

    std::ifstream fele(filenameELE.c_str(), std::ios::in);
    if (!fele.good())
    {
        CGoGNerr << "Unable to open ELE file " << CGoGNendl;
        return false;
    }

    std::string line;

    //OFF reading
    std::getline(foff, line);
    if(line.rfind("OFF") == std::string::npos)
    {
        CGoGNerr << "Problem reading off file: not an off file"<<CGoGNendl;
        CGoGNerr << line << CGoGNendl;
        return false;
    }

    //Reading number of vertex/faces/edges in OFF file
    unsigned int nbe;
    {
        do
        {
            std::getline(foff,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVertices;
        oss >> nbe;
        oss >> nbe;
        oss >> nbe;
    }

    //Reading number of tetrahedra in ELE file
    unsigned int nbv;
    {
        do
        {
            std::getline(fele,line);
        }while(line.size() == 0);

        std::stringstream oss(line);
        oss >> m_nbVolumes;
        oss >> nbv ;
        oss >> nbv;
    }

    //Reading vertices
    std::vector<unsigned int> verticesID;
    verticesID.reserve(m_nbVertices);

    for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
    {
        do
        {
            std::getline(foff,line);
        }while(line.size() == 0);

        std::stringstream oss(line);

        float x,y,z;
        oss >> x;
        oss >> y;
        oss >> z;
        //we can read colors informations if exists
        VEC3 pos(x,y,z);

        unsigned int id = container.insertLine();
        position[id] = pos;
        verticesID.push_back(id);
    }

    // reading tetrahedra
    m_nbFaces.reserve(m_nbVolumes*4);
    m_emb.reserve(m_nbVolumes*12);

    for(unsigned i = 0; i < m_nbVolumes ; ++i)
    {
        do
        {
            std::getline(fele,line);
//.........这里部分代码省略.........
开发者ID:cgogn,项目名称:Mesher,代码行数:101,代码来源:import2tablesVolume.hpp


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