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


C++ Point3::Z方法代码示例

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


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

示例1:

    Point3 Point3::operator-(const Point3& rhs) const
    {
        Point3 difference;
        difference.X() = this->X() - rhs.X();
        difference.Y() = this->Y() - rhs.Y();
        difference.Z() = this->Z() - rhs.Z();

        return difference;
    }
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:9,代码来源:Point3.cpp

示例2: setGPUParameters

void Kdtree::setGPUParameters( CShader& shader, GPUAccelerationStructureData& accelStructData ) 
{
#ifndef STUB
    CGparameter& cell_info = shader.GetNamedParameter("cellData0", true);
    cgGLSetTextureParameter(cell_info, accelStructData.m_CellTexture[0]);

    //accelStructData.SaveTextureData();

    CGparameter& v0 = shader.GetNamedParameter("v0t", true);
    cgGLSetTextureParameter(v0, accelStructData.m_VertexTexture[0]);

    CGparameter& v1 = shader.GetNamedParameter("v1t", true);
    cgGLSetTextureParameter(v1, accelStructData.m_VertexTexture[1]);

    CGparameter& v2 = shader.GetNamedParameter("v2t", true);
    cgGLSetTextureParameter(v2, accelStructData.m_VertexTexture[2]);

    /*
    CGparameter& maxDepth = shader.GetNamedParameter("maxDepth");
    cgGLSetParameter1f( maxDepth, (float) m_MaxDepth );
    */


    Point3 minPt = m_Bounds.getPos();
    Point3 maxPt = minPt + m_Bounds.getSize();

    CGparameter& minPoint = shader.GetNamedParameter("gmin");
    cgGLSetParameter3f( minPoint, minPt.X(), minPt.Y(), minPt.Z() );

    CGparameter& maxPoint = shader.GetNamedParameter("gmax");
    cgGLSetParameter3f( maxPoint, maxPt.X(), maxPt.Y(), maxPt.Z() );

    CGparameter& maxloop = shader.GetNamedParameter("maxloop");
    cgGLSetParameter1f( maxloop, 1000 );

#endif
}
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:37,代码来源:Kdtree.cpp

示例3:

 // construct a floatVector3 from two 3-dimensional points
 //   vector = end - start
 Vector3::Vector3(const Point3& start, const Point3& end)
 {
     this->X() = end.X() - start.X();
     this->Y() = end.Y() - start.Y();
     this->Z() = end.Z() - start.Z();
 }
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:8,代码来源:Vector3.cpp

示例4: construct

// recursive construction algorithm
//void Kdtree::construct(unsigned int fn, const AABB& box, const std::list<unsigned int>& triList, AABB * bounds, unsigned int depth)
//void Kdtree::construct(unsigned int fn, AABB& box, std::list<IPrimitive*>& primList, AABB * bounds, unsigned int depth)
void Kdtree::construct(unsigned int fn, AABB& box, unsigned int size,
                       unsigned int depth, bool isLeft, unsigned int rIndex, 
                       unsigned int pre_size, bool dsize, int tries)
{
    //BSPNode *node = &m_pTree[fn];
    //printf("max num: %i\n", m_pTree.max_size());
    //m_pTree.assign(BSPNode(), fn);
    BSPNode *node = &m_pTree[fn];

    //unsigned int size = (unsigned int)primList.size();
    //std::list<IPrimitive*>::iterator p;

    //printf(".");
    // if end condition met
    // if(abs(previous size - size) <= 3 ...
    if((int)abs((int)(pre_size-size)) <= 3)
    {
        dsize = true;
        tries++;
    }
    else
    {
        dsize = false;
        tries = 0;
    }
    if(size <= m_MaxItemPerNode || depth >= m_MaxDepth || (dsize && tries == 3))
    {
        IPrimitive** myList = 0;
        if(size > 0)
            myList = new IPrimitive*[size];
        //std::list<IPrimitive*>* myList = new std::list<IPrimitive*>;
        if(depth == 0)
        {
            std::list<IPrimitive*>::iterator tit;
            int i = 0;
            for(tit = m_PrimList.begin(); tit != m_PrimList.end(); tit++, i++)
                myList[i] = (*tit);
        }
        else if(isLeft)
        {
            for(unsigned int i = 0; i < size; i++)
                myList[i] = leftBOX[i];
        }
        else
        {
            for(unsigned int i = 0; i < size; i++)
                myList[i] = rightBOX[rIndex+i];
        }
        node->initLeaf(size, myList);

        // increment counts
        m_TotalTreeTri += size;
        totalLeaf++;
        return; // leaf with triangle
    }

    // each node must have a split axis and split position
    int axis = 0;
    float splitpos = 0;
    unsigned int i;

#ifdef SAH    

    AABB tbox;
    // build up information of bounding box and edges
    if(depth == 0)
    {
        i = 0;
        std::list<IPrimitive*>::iterator tit;
        for(tit = m_PrimList.begin(); tit != m_PrimList.end(); tit++, i++)
        {
            tbox = (*tit)->getAABB();
            AABB* mybox = &(box.Intersection(tbox)); // get intersection of triangle box + bounding box of this node
            Point3 minp = mybox->getPos();
            Point3 maxp = minp + mybox->getSize();

            // add x position to the list
            edge[0][i*2].set(minp.X(), (*tit), true); 
            edge[0][i*2+1].set(maxp.X(), (*tit), false); 			
            // add y
            edge[1][i*2].set(minp.Y(), (*tit), true); 
            edge[1][i*2+1].set(maxp.Y(), (*tit), false);
            // add z
            edge[2][i*2].set(minp.Z(), (*tit), true); 
            edge[2][i*2+1].set(maxp.Z(), (*tit), false);
        }
    }
    else if(isLeft)
    {
        for(i = 0; i < size; i++)
        {
            tbox = leftBOX[i]->getAABB();
            AABB* mybox = &(box.Intersection(tbox)); // get intersection of triangle box + bounding box of this node
            Point3 minp = mybox->getPos();
            Point3 maxp = minp + mybox->getSize();

            // add x position to the list
//.........这里部分代码省略.........
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:101,代码来源:Kdtree.cpp

示例5: Translate

BoundingBox BoundingBox::Translate(Point3 const& point) const {
	return BoundingBox(point.X() + minX_, point.X() + maxX_, point.Y() + minY_,
			point.Y() + maxY_, point.Z() + minZ_, point.Z() + maxZ_);
}
开发者ID:jawline,项目名称:ParticlesEngine,代码行数:4,代码来源:BoundingBox.cpp

示例6: GetNearestNPhotons

void PhotonMap::GetNearestNPhotons(
    const int N, 
    float rSquared, 
    const Point3& location, 
    const Vector3& normal, 
    const int minIndex, 
    const int maxIndex,
    vector<PhotonDistPair>& nearest)
{
	if(maxIndex - minIndex >= 0)
	{
		int nodeIndex = (maxIndex + minIndex) / 2;

        // CONSIDER ADDING THIS NODE TO PHOTON HEAP
		const Photon* p = &m_photons[nodeIndex];
        float x = location.X() - p->Position().X();
        float y = location.Y() - p->Position().Y();
        float z = location.Z() - p->Position().Z();
        float distSquared = (x*x)+(y*y)+(z*z);
		
        if(distSquared < rSquared && (IGNORE_NORMAL || p->SurfNormal() == normal))
        {
            if((int)nearest.size() < N - 1)
            {
                nearest.push_back(PhotonDistPair(p, distSquared));
            }
            else if((int)nearest.size() == N - 1)
            {
                nearest.push_back(PhotonDistPair(p, distSquared));
                std::make_heap(nearest.begin(), nearest.end());

                rSquared = nearest[0].m_Distance;
            }
            else
            {
                nearest.push_back(PhotonDistPair(p, distSquared));
                std::make_heap(nearest.begin(), nearest.end());

                if(nearest.size() > N)
                {
                    std::pop_heap(nearest.begin(), nearest.end());
                    nearest.pop_back();
                }
                
                rSquared = nearest[0].m_Distance;
            }
        }
	
        AXIS plane = m_photons[nodeIndex].Plane();
        float distanceToPlane = location[plane] - m_photons[nodeIndex].Position()[plane];

		//// SEARCH PHOTON MAP 
		if(distanceToPlane*distanceToPlane > rSquared)
		{
            if(distanceToPlane > 0)
            {
                // check right tree
			    GetNearestNPhotons(N, rSquared, location, normal, nodeIndex+1, maxIndex, nearest);
                
            }
            else
            {
                // check left tree
			    GetNearestNPhotons(N, rSquared, location, normal, minIndex, nodeIndex-1, nearest);
            }
        }
        else
        {
            // check both
            GetNearestNPhotons(N, rSquared, location, normal, minIndex, nodeIndex-1, nearest);
            GetNearestNPhotons(N, rSquared, location, normal, nodeIndex+1, maxIndex, nearest);
        }                                               
	}
}
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:74,代码来源:PhotonMap.cpp

示例7: buildGPU

void Bvh::buildGPU(std::list<IModel*> &modelList, std::list<Triangle*> &triangleList, GPUAccelerationStructureData& l_pASD )
{
#ifndef STUB
    l_pASD.setTraversalShaderFilename( "shaders\\BVH.cg" );
#ifdef USEUPDATE
    if(bTree)
        update(modelList);
    else
        build(modelList);
#else
    build( modelList );
#endif

    // need enough room for the nodes and the triangles
    l_pASD.setVertexCount( m_NodeUsed * 3 ); 
    l_pASD.setNormalCount( m_NodeUsed * 3 );
    l_pASD.setMaterialCount( m_NodeUsed * 3 );

    float* pV0 = l_pASD.m_pVertex0Array;
    float* pV1 = l_pASD.m_pVertex1Array;
    float* pV2 = l_pASD.m_pVertex2Array;

    float* pN0 = l_pASD.m_pNormal0Array;
    float* pN1 = l_pASD.m_pNormal1Array;
    float* pN2 = l_pASD.m_pNormal2Array;

    float* pM = l_pASD.m_pMaterial0Array;

    std::deque<bvhNode*> todo;
    bvhNode* current = NULL;

    todo.push_back( &bTree[0] );

    int nProcessedNodes = 0;

//    while( nProcessedNodes < ( m_NodeUsed + triangleList.size() ) )
    while ( !todo.empty() ) // while there are nodes to process
    {
        // get the first node to process and then remove it from the queue
        current = todo[0];
        todo.pop_front();

        if( current->extra == 1 ) // is leaf
        {
            std::list< Triangle* >* pTris = current->pTris->getNewTesselation();
            std::list< Triangle* >::iterator t;
            for ( t = pTris->begin(); t != pTris->end(); t++ )
            {
                Triangle* tri = *t;
                Point3 v0 = tri->getVertex0()->getCoordinates();
                Point3 v1 = tri->getVertex1()->getCoordinates();
                Point3 v2 = tri->getVertex2()->getCoordinates();

                Vector3 n0 = tri->getVertex0()->getNormal();
                Vector3 n1 = tri->getVertex1()->getNormal();
                Vector3 n2 = tri->getVertex2()->getNormal();

                // vertices
                *pV0 = v0.X(); ++pV0;
                *pV0 = v0.Y(); ++pV0;
                *pV0 = v0.Z(); ++pV0;
                *pV0 = 0.0f;   ++pV0; // 0 = triangle node

                *pV1 = v1.X();    ++pV1;
                *pV1 = v1.Y();    ++pV1;
                *pV1 = v1.Z();    ++pV1;
                *pV1 = 1.0f; ++pV1;// just go to the next index

                *pV2 = v2.X(); ++pV2;
                *pV2 = v2.Y(); ++pV2;
                *pV2 = v2.Z(); ++pV2;
                *pV2 = 0;      ++pV2; // TODO: Material Pointer

                // normals
                *pN0 = n0.X(); ++pN0;
                *pN0 = n0.Y(); ++pN0;
                *pN0 = n0.Z(); ++pN0;
                *pN0 = 0.0f; ++pN0;

                *pN1 = n1.X(); ++pN1;
                *pN1 = n1.Y(); ++pN1;
                *pN1 = n1.Z(); ++pN1;
                *pN1 = 0.0f; ++pN1;

                *pN2 = n2.X(); ++pN2;
                *pN2 = n2.Y(); ++pN2;
                *pN2 = n2.Z(); ++pN2;
                *pN2 = 0.0f;   ++pN2;

                encore::Color diffuse = tri->getMaterial()->GetDiffuse();
                float spec = tri->getMaterial()->GetSpecularExponent();
                *pM = diffuse.R(); ++pM;
                *pM = diffuse.G(); ++pM;
                *pM = diffuse.B(); ++pM;
                *pM = spec; ++pM;

                
                delete *t;
                *t = NULL;
                // increase node count
//.........这里部分代码省略.........
开发者ID:PeterLValve,项目名称:ENCORE,代码行数:101,代码来源:BVH.cpp


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