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


C++ ofVec3f::distance方法代码示例

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


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

示例1: disturbMidpoint

    void disturbMidpoint(ofVec3f & midPoint, ofVec3f const & bottomLeft, ofVec3f const & topLeft, ofVec3f const & topRight, ofVec3f const & bottomRight) {
      //if (std::rand() % 2 == 0) {
      //  return;
      //}
        midPoint[2] += (topLeft.distance(bottomRight) + topRight.distance(bottomLeft)) * randomValue();
        
        if (midPoint[2] < minHeight) {
            minHeight = midPoint[2];
        }
        if (midPoint[2] > maxHeight) {
            maxHeight = midPoint[2];
        }

    }
开发者ID:elchan,项目名称:Terrain_Generation,代码行数:14,代码来源:Terrain.hpp

示例2: moveback

//--------------------------------------------------------------
ofVec3f ofApp::moveback(ofVec3f fltPos, ofVec3f aggPos,float aggRadius, float fltRadius){
    float disAct = fltPos.distance(aggPos);
    float disShould = aggRadius + fltRadius;
    ofVec3f tpmoveBack = fltPos - aggPos;
    tpmoveBack.normalize();
    tpmoveBack = tpmoveBack * (disShould - disAct);
    fltPos = fltPos + tpmoveBack;
    return fltPos;
}
开发者ID:Artrustee,项目名称:SHANGHAI_2015_FALL_STUDENTS,代码行数:10,代码来源:ofApp.cpp

示例3: frameBoundingBox

//----------------------------------------
void ofxViewportCam::frameBoundingBox(const ofVec3f &minCorner,
                                     const ofVec3f &maxCorner)
{
    ofVec3f center((minCorner + maxCorner) * 0.5f);
    setTargetPosition(center);
    this->distance = minCorner.distance(maxCorner);
    
    setPosition(target.getGlobalPosition());
    dolly(this->distance);
}
开发者ID:clinthidinger,项目名称:ofxPickableScene,代码行数:11,代码来源:ofxViewportCam.cpp

示例4: update

//--------------------------------------------------------------
void testApp::update(){
    
    ofVec3f diff ;          //Difference between particle and mouse
    float dist ;            //distance from particle to mouse ( as the crow flies ) 
    float ratio ;           //Ratio of how strong the effect is = 1 + (-dist/maxDistance) ;
    const ofVec3f mousePosition = ofVec3f( mouseX , mouseY , 0 ) ; //Allocate and retrieve mouse values once.
    const ofVec3f origin = ofVec3f(0,0,0);
    //Create an iterator to cycle through the vector
    std::vector<Particle>::iterator p ; 
    for ( p = particles.begin() ; p != particles.end() ; p++ ) 
    {
        ratio = 1.0f ; 
        p->velocity *= friction ; 
        //reset acceleration every frame
        p->acceleration = ofVec3f() ; 
        diff = mousePosition - p->position ;  
        dist = mousePosition.distance( p->position ) ; 
        //If within the zone of interaction
        if ( dist * .5 < forceRadius )  
        {
            ratio = -1 + dist / forceRadius ; 
            //Repulsion
            if ( cursorMode == 0 ) 
                p->acceleration -= ( diff * ratio) ;
            //Attraction
            else
                p->acceleration += ( diff * ratio ) ; 
        }
        if ( springEnabled ) 
        {
            //Move back to the original position
            p->acceleration += springFactor * (p->spawnPoint - p->position );
        }
        
        p->velocity += p->acceleration * ratio ; 
        p->position += p->velocity ; 
    }
    
    if ( ofGetFrameNum() % 300 == 0 ) 
    {
        curImageIndex++ ;
        setupParticles() ;
    }
}
开发者ID:benMcChesney,项目名称:PixelForces3D,代码行数:45,代码来源:testApp.cpp

示例5: getVertexforPos

TerrainVertex  ChunkHandler::getVertexforPos(const ofVec3f &pos, int detailLevel)
{
	TerrainVertex  vert ;
	vert.position.y =0;
	
	Chunk *chunk = getClosestChunk(pos,  detailLevel);
	if (chunk==NULL) {
	return vert;
	}

	ofVec2f posSearch;
	posSearch.x = pos.x;
	posSearch.y= pos.z;
	posSearch.x-=chunk->center.x-chunkSize/2;
	posSearch.y-=chunk->center.z-chunkSize/2;

	posSearch.x/=4.0f;
	posSearch.y/=4.0f;

	int posX0 =floor( posSearch.x+0.5);
	int posY0 =floor(  posSearch.y+0.5);

	v0 =  chunk->getVertexForXY( posX0,posY0);
	float difx = posSearch.x-posX0;
	float dify = posSearch.y;
	int	posX1= posX0 ;
	int	posX2= posX0 ;
	int	posY1= posY0 ;
	int	posY2= posY0 ;

	if (pos.x <v0->position.x)
	{
		if (pos.z >v0->position.z)
		{
			posX2-=1;
			posY2+=1;
	
			v1 =  chunk->getVertexForXY( posX0-1,posY0);
			v2 =  chunk->getVertexForXY( posX0,posY0+1);

			if(pos.distance(v1->position)<pos.distance(v2->position))
			{
				posX1-=1;
			
			
			}else
			{
				posY1+=1;
				
			}

		}else
		{
			
			posY2-=1;
			posX1-=1;
		}
	}else
	{
		if (pos.z >v0->position.z)
		{
			posY2+=1;
			posX1+=1;
		
		}else
		{
			posX2+=1;
			posY2-=1;
		
			v1 =  chunk->getVertexForXY( posX0+1,posY0);
			v2 =  chunk->getVertexForXY( posX0,posY0-1);
			if(pos.distance(v1->position)<pos.distance(v2->position))
			{
				posX1+=1;
				
			}
			else
			{
				posY1-=1;
					
			}

		}
	}
	

	v1 =  chunk->getVertexForXY( posX1,posY1);
	v2 =  chunk->getVertexForXY( posX2,posY2);


	ofVec3f normal= terrainFunctions->getNormal(v0->position,v1->position,v2->position);

	///
	
	ofVec3f  rayStartPoint;
	rayStartPoint.set(pos.x,10000,pos.z);
	ofVec3f  raydir;
	raydir.set(0,-1,0);
	if (normal.y<0)normal*=-1;
	ofVec3f  tv0 = rayStartPoint -v0->position;    
//.........这里部分代码省略.........
开发者ID:Cap123,项目名称:npDeferredS,代码行数:101,代码来源:ChunkHandler.cpp


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