您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sphere函数代码示例

51自学网 2021-06-03 08:09:16
  C++
这篇教程C++ sphere函数代码示例写得很实用,希望能帮到您。

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

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

示例1: TestForCollisionsAgainstWorld

void CEnvHeadcrabCanister::TestForCollisionsAgainstWorld( const Vector &vecEndPosition ){	// Splash damage!	// Iterate on all entities in the vicinity.	float flDamageRadius = m_flDamageRadius;	float flDamage = m_flDamage;	CBaseEntity *pEntity;	for ( CEntitySphereQuery sphere( vecEndPosition, flDamageRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )	{		if ( pEntity == this )			continue;		if ( !pEntity->IsSolid() )			continue;		// Get distance to object and use it as a scale value.		Vector vecSegment;		VectorSubtract( pEntity->GetAbsOrigin(), vecEndPosition, vecSegment ); 		float flDistance = VectorNormalize( vecSegment );		float flFactor = 1.0f / ( flDamageRadius * (INNER_RADIUS_FRACTION - 1) );		flFactor *= flFactor;		float flScale = flDistance - flDamageRadius;		flScale *= flScale * flFactor;		if ( flScale > 1.0f ) 		{ 			flScale = 1.0f; 		}				// Check for a physics object and apply force!		Vector vecForceDir = vecSegment;		IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject();		if ( pPhysObject )		{			// Send it flying!!!			float flMass = PhysGetEntityMass( pEntity );			vecForceDir *= flMass * 750 * flScale;			pPhysObject->ApplyForceCenter( vecForceDir );		}		if ( pEntity->m_takedamage && ( m_flDamage != 0.0f ) )		{			CTakeDamageInfo info( this, this, flDamage * flScale, DMG_BLAST );			CalculateExplosiveDamageForce( &info, vecSegment, pEntity->GetAbsOrigin() );			pEntity->TakeDamage( info );		}		if ( pEntity->IsPlayer() )		{			if (vecSegment.z < 0.1f)			{				vecSegment.z = 0.1f;				VectorNormalize( vecSegment );								}			float flAmount = SimpleSplineRemapVal( flScale, 0.0f, 1.0f, 250.0f, 1000.0f );			pEntity->ApplyAbsVelocityImpulse( vecSegment * flAmount );		}	}}
开发者ID:EspyEspurr,项目名称:game,代码行数:60,


示例2: sphere

//--------------------------------------------------------------void ofApp::update() {        if( bSpacebar ) {        shared_ptr< ofxBulletSphere > sphere( new ofxBulletSphere() );        float trad = fabs(sin( ofGetElapsedTimef() ) * 5);        sphere->create( world.world, ofVec3f( cos( ofGetElapsedTimef()*10.)*trad ,-6, sin(ofGetElapsedTimef()*10)*trad ), 1., 0.75 );        sphere->add();        bulletSpheres.push_back( sphere );        bSpacebar = false;    }        for( int i = 0; i < bulletSpheres.size(); i++ ) {        ofVec3f spos = bulletSpheres[i]->getPosition();        if( spos.y > 5 ) {            bulletSpheres.erase( bulletSpheres.begin() + i );            break;        }    }        if(bAnimated) {        vector< glm::vec3 >& verts = mesh.getVertices();        vector< glm::vec3 >& overts = omesh.getVertices();        for( int i = 0; i < verts.size(); i++ ) {            verts[i].y = ofSignedNoise( verts[i].x*0.025, verts[i].y*0.025 + verts[i].z*0.025, ofGetElapsedTimef() * 0.75 ) * 3;        }        bulletMesh->updateMesh( world.world, mesh );    }        world.update( ofGetLastFrameTime(), 12 );        }
开发者ID:NickHardeman,项目名称:ofxBullet,代码行数:33,


示例3: on_paint_mesh

	void on_paint_mesh(const k3d::mesh& Mesh, const k3d::gl::painter_render_state& RenderState, k3d::iproperty::changed_signal_t& ChangedSignal)	{		const k3d::color color = RenderState.node_selection ? k3d::color(1, 1, 1) : k3d::color(0.8, 0.8, 0.8);		const k3d::color selected_color = RenderState.show_component_selection ? k3d::color(1, 0, 0) : color;		for(k3d::mesh::primitives_t::const_iterator primitive = Mesh.primitives.begin(); primitive != Mesh.primitives.end(); ++primitive)		{			boost::scoped_ptr<k3d::sphere::const_primitive> sphere(k3d::sphere::validate(Mesh, **primitive));			if(!sphere)				continue;			glPolygonOffset(1.0, 1.0);			glEnable(GL_POLYGON_OFFSET_FILL);			glEnable(GL_LIGHTING);			glMatrixMode(GL_MODELVIEW);			for(k3d::uint_t i = 0; i != sphere->matrices.size(); ++i)			{				k3d::gl::material(GL_FRONT_AND_BACK, GL_DIFFUSE, sphere->selections[i] ? selected_color : color);				glPushMatrix();				k3d::gl::push_matrix(sphere->matrices[i]);				draw_solid(RenderState, sphere->radii[i], sphere->z_min[i], sphere->z_max[i], sphere->sweep_angles[i]);				glPopMatrix();			}		}	}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:27,


示例4: sphere

Municao::Municao(){    sphere();    changeBoundingVolume(Solid::SPHERE);    label(LABEL_MUNICAO);    scale(1.0);    body().gravityScale(0.001);    body().damping(0.0);    light.color(255,180,60);    light.intensity(5.0);    light.attenuation(0.4);    light.quadraticAttenuation(0.01);    visible(false);    disappear();    bala.generate(Particle::GLOW);    bala.setAnimationType(Particle::FIRE);    bala.color(130,70,20);    bala.scale(1.25);    spark.load("media/sprites/spark.tga");    spark.setAnimationType(Particle::FOG);    spark.color(200,100,40);    spark.scale(1.0);    spark.animationMotionOffset(3.5);    spark.stop();}
开发者ID:filipexts,项目名称:CompGraf_URGE,代码行数:29,


示例5:

double F13::compute(vector<double> x){	int i,k;	double result=0.0;	if(Ovector==NULL)	{		Ovector=createShiftVector(dimension,minX,maxX-1);		Pvector=createPermVector(dimension);	}	for(i=0;i<dimension;i++)	{		anotherz[i]=x[i]-Ovector[i];	}	for(k=1;k<=dimension/(2*nonSeparableGroupSize);k++)	{		result+=rosenbrock(anotherz,nonSeparableGroupSize,k);	}//	printf("Rosenbrock = %1.16E/n", result);//	printf("Sphere = %1.16E/n", sphere(anotherz, dimension, 2));	result+=sphere(anotherz, dimension, 2);	return(result);}
开发者ID:mikeagn,项目名称:CEC2010SS-LSGO-Benchmarks-CPP,代码行数:26,


示例6: on_select_mesh

	void on_select_mesh(const k3d::mesh& Mesh, const k3d::gl::painter_render_state& RenderState, const k3d::gl::painter_selection_state& SelectionState, k3d::iproperty::changed_signal_t& ChangedSignal)	{		if(!SelectionState.select_component.count(k3d::selection::SURFACE))			return;		k3d::uint_t primitive_index = 0;		for(k3d::mesh::primitives_t::const_iterator primitive = Mesh.primitives.begin(); primitive != Mesh.primitives.end(); ++primitive, ++primitive_index)		{			boost::scoped_ptr<k3d::sphere::const_primitive> sphere(k3d::sphere::validate(Mesh, **primitive));			if(!sphere)				continue;			k3d::gl::push_selection_token(k3d::selection::PRIMITIVE, primitive_index);			glDisable(GL_LIGHTING);			glMatrixMode(GL_MODELVIEW);			for(k3d::uint_t i = 0; i != sphere->matrices.size(); ++i)			{				k3d::gl::push_selection_token(k3d::selection::SURFACE, i);				glPushMatrix();				k3d::gl::push_matrix(sphere->matrices[i]);				draw_solid(RenderState, sphere->radii[i], sphere->z_min[i], sphere->z_max[i], sphere->sweep_angles[i]);				glPopMatrix();				k3d::gl::pop_selection_token(); // SURFACE			}			k3d::gl::pop_selection_token(); // PRIMITIVE		}	}
开发者ID:AwesomeDoesIt,项目名称:k3d,代码行数:32,


示例7: sphere

void OiGraphix::drawSphere(Sphere* s){    OiGraphixSphere sphere(s->radius,24,24);    sphere.draw((GLfloat)s->xyz.getAt(0),(GLfloat)s->xyz.getAt(1),(GLfloat)s->xyz.getAt(2));    //TODO Verbesserungen darstellen    drawResiduals();}
开发者ID:cedmayer,项目名称:OpenIndy,代码行数:7,


示例8: rootNode

void SpiralScene::setupObjects(){	int numSpheres = 100;	double sphereScaling = .6;	Angle angleBetweenSpheres = Angle::degrees(25);	double depthBetweenSpheresBase = 1.2;	double depthBetweenSpheresMultiple = 1.10;	int firstSphereDepth = 10;	double radius = 2;	NodePointer rootNode(new TransformNode(getCamera().getTransform()));	MaterialNodePointer material(new MaterialNode(rootNode));	Color white(1, 1, 1);	material->setAmbient(white * .1);	material->setDiffuse(white * .5);	material->setSpecular(white);	material->setShininess(20);	NodePointer firstDepthTranslation(new TranslationNode(0, 0, -firstSphereDepth, material));	NodePointer lastDepthTranslation = firstDepthTranslation;	for (int i = 0; i < numSpheres; i++) {		Angle rotationAngle = angleBetweenSpheres * i;		NodePointer rotation(new RotationNode(rotationAngle, Vector3d::UnitZ(), lastDepthTranslation));		NodePointer radiusTranslation(new TranslationNode(radius, 0, 0, rotation));		NodePointer sphereScalingNode(new ScalingNode(sphereScaling, sphereScaling, sphereScaling, radiusTranslation));		RayObjectPointer sphere(new Sphere(sphereScalingNode));		addObject(sphere);		double depthBetweenSpheres = depthBetweenSpheresBase * pow(depthBetweenSpheresMultiple, i);		lastDepthTranslation = NodePointer(new TranslationNode(0, 0, -depthBetweenSpheres, lastDepthTranslation));	}}
开发者ID:orangejulius,项目名称:jaytrace,代码行数:33,


示例9: drawLight

void drawLight(void){  if (light) {    float Ambient[]   = {0.01*ambient ,0.01*ambient ,0.01*ambient ,1.0};    float Diffuse[]   = {0.01*diffuse ,0.01*diffuse ,0.01*diffuse ,1.0};    float Specular[]  = {0.01*specular,0.01*specular,0.01*specular,1.0};    float Position[]  = {lightY,distance*Sin(lightPh),distance*Cos(lightPh),1.0};    glColor3fv(white);    sphere(Position[0],Position[1],Position[2] , 0.1,0);    glEnable(GL_NORMALIZE);    glEnable(GL_LIGHTING);    glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);    glEnable(GL_COLOR_MATERIAL);    glEnable(GL_LIGHT0);    glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);    glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);    glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);    glLightfv(GL_LIGHT0,GL_POSITION,Position);  }  else    glDisable(GL_LIGHTING);}
开发者ID:gaganthesky,项目名称:TowerDefense_CG,代码行数:31,


示例10: f

float f(Mat m, int n) {    float z = -1.0f;    for (float r = 0.0f; r < 0.8f; r += 0.02f) {        Vec v = { 0.0f, r, 0.0f, 1.0f };        transformPosition(&v, m, v);        z = opUnion(z, sphere(v, transformLength(m, 0.05f * (0.95f - r))));    }    if (n > 0) {        Mat ry, rz, s, t, m2, m3;        rotateZ(&rz, 1.8f);        for (int p = 0; p < 6; p++) {            rotateY(&ry, p * (2 * PI / 6));            mul(&m2, ry, rz);            float ss = 0.45f;            for (float r = 0.2f; r < 0.8f; r += 0.1f) {                scale(&s, ss);                translate(&t, 0.0f, r, 0.0f);                mul(&m3, s, m2);                mul(&m3, t, m3);                mul(&m3, m, m3);                z = opUnion(z, f(m3, n - 1));                ss *= 0.8f;            }        }    }    return z;}
开发者ID:Lyrics1,项目名称:learn_git,代码行数:30,


示例11: initQuadBuffers

MeshLoader::MeshLoader() {    initQuadBuffers();    initCubeBuffers();    initSkyBoxBuffers();    duckVAOC = MeshLoader::loadFromAszFile("res/models/duck.txt");    SolidSphere sphere(1, 12, 24);    initSphereBuffers(sphere.GetVertices(),sphere.numOfVertices);}
开发者ID:lukaszw896,项目名称:OpenGL-Duck,代码行数:8,


示例12: IndexedSegmentNodeImpl

 IndexedSegmentNodeImpl(const _Base it, bool isEnd) :   _Base(it) {   if(!isEnd){       Sphere sphere(*it);       center = sphere.center;       range = sphere.radius;   } }
开发者ID:kallaballa,项目名称:DebugIndexSegmentTree,代码行数:8,


示例13: TEST

TEST(SphericalBoundary, inside) {	SphericalBoundary sphere(Vector3d(0, 0, 0), 10);	Candidate c;	c.current.setPosition(Vector3d(9, 0, 0));	sphere.process(&c);	EXPECT_TRUE(c.isActive());	EXPECT_FALSE(c.hasProperty("Rejected"));}
开发者ID:rafaelab,项目名称:CRPropa3,代码行数:8,


示例14: getCenter

Sphere AAB::getBoundingSphere() const{    Vector3 center = getCenter();    Vector3 extent = getExtent();    float radius = (max - center).length();    Sphere sphere(center, radius);    return sphere;}
开发者ID:KrasusC,项目名称:OppositeRenderer,代码行数:8,


示例15: sphere

sphere sphere::operator +(const sphere& other) const{	glm::vec4 center = (c + other.getCenter()) * 0.5f;	float radius = glm::distance(c, center) + glm::max(r, other.getRadius());	return sphere(center, radius);}
开发者ID:EddyGun,项目名称:Vulkan,代码行数:8,


示例16: sphere

void MainWindow::on_sphereButton_released(){    DialogSphere sphere(this);    if(sphere.exec())        ui->glwidget->scene.addSphere( sphere.getX(), sphere.getY(), sphere.getZ(), sphere.getR(), sphere.getDisc() );    ui->glwidget->updateGL();}
开发者ID:Quixotic7,项目名称:brep,代码行数:8,


示例17: ResetSequence

void CASW_Boomer_Blob::CheckNearbyTargets( ){		// see if an alien is nearby	if ( gpGlobals->curtime >= m_fEarliestAOEDetonationTime )	{		if ( !m_bModelOpening && gpGlobals->curtime >= (m_fDetonateTime - ASW_BOOMER_WARN_DELAY) )		{			// we are one second from detonating, commit to detonating and start the opening sequence			// regardless of anyone nearby			m_bModelOpening = true;			ResetSequence( LookupSequence( "MortarBugProjectile_Opening" ) );			CEffectData	data;			data.m_vOrigin = GetAbsOrigin();			CPASFilter filter( data.m_vOrigin );			filter.SetIgnorePredictionCull(true);			DispatchParticleEffect( "boomer_grenade_open", PATTACH_ABSORIGIN_FOLLOW, this, -1, false, -1, &filter );		}		// if we exceeded the detonation time, just detonate		if ( gpGlobals->curtime >= m_fDetonateTime )		{			Detonate();			return;		}		// if the model is opening, do the animation advance		if ( m_bModelOpening )		{			StudioFrameAdvance();			SetNextThink( gpGlobals->curtime );			return;		}		float flRadius = asw_boomer_blob_radius_check_scale.GetFloat() * m_DmgRadius;		Vector vecSrc = GetAbsOrigin();		CBaseEntity *pEntity = NULL;		for ( CEntitySphereQuery sphere( vecSrc, flRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )		{			if ( !pEntity || !pEntity->IsPlayer() )				continue;			// give them a 2 second warning before detonation			m_fDetonateTime = MIN( m_fDetonateTime, m_fDetonateTime + ASW_BOOMER_WARN_DELAY );		}	}		if ( m_fDetonateTime <= gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() )	{		SetThink( &CASW_Boomer_Blob::Detonate );		SetNextThink( m_fDetonateTime );	}	else	{		SetThink( &CASW_Boomer_Blob::CheckNearbyTargets );		SetNextThink( gpGlobals->curtime + asw_boomer_blob_radius_check_interval.GetFloat() );	}}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:58,


示例18: display

void display(){   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   glEnable(GL_DEPTH_TEST);   glEnable(GL_CULL_FACE);   glLoadIdentity();      //view angle   if (mode == 0) //rotation for ortho mode   {      glRotatef(ph, 1,0,0);      glRotatef(th, 0,1,0);      glScaled(0.4,0.4,0.4);   }   else if (mode == 1) //rotation for perspective mode   {      ex = Sin(-th)*Cos(ph)*8;      ey = Sin(ph)*8;      ez = Cos(-th)*Cos(ph)*8;      gluLookAt(ex,ey,ez , 0,0,0 , 0,Cos(ph),0);      //glScaled(0.3,0.3,0.3);   }   else //mode == 2              // rotation and movement for FP mode   {                             // occur in keyboard & special      vx = ex - Sin(th)*Cos(ph); // here we simply update      vy = ey - Sin(ph);         // location of view target      vz = ez - Cos(th)*Cos(ph);      gluLookAt(ex,ey,ez , vx,vy,vz , 0,Cos(ph),0);   }   sphere(0, 0, 0, 1.5*r, 0.5); //Jupiter   glPushMatrix();   glRotated(r/2, 0,1,0);   cube(1, 0, 0, r, 0.25); //IO   glPopMatrix();   glPushMatrix();   glRotated(r/4, 0,1,0);   octahedron(-2, 0, 0, 4.0/3.0*r, 0.25); //Europa   glPopMatrix();   glPushMatrix();   glRotated(r/8, 0,1,0);   dodecahedron(3, 0, 0, -1.125*r, 0.25); //Ganymede   glPopMatrix();   glPushMatrix();   glRotated(r/18.4, 0,1,0);   icosahedron(4, 0, 0, 0.75*r, 0.25); //Callisto   glPopMatrix();   r = glutGet(GLUT_ELAPSED_TIME)*rate;   r = fmod(r, 360*24*18.4);   glFlush();   glutSwapBuffers();}
开发者ID:jchan1e,项目名称:graphics,代码行数:58,


示例19: ghost

static void ghost(double x,double y,double z, double r, int rotate, int col){        //  Save transformation    glPushMatrix();    //  Offset and scale    glTranslated(x,y,z);    if (rotate != 0){        glRotated(rotate,0,1,0);    }    glScaled(r,r,r);       //Draw Body    sphere(x,y,z,r,rotate,col);        //draw body    glPushMatrix();    glTranslated(x,y,z);    glRotated(90,1,0,0);    if (rotate != 0){        glRotated(rotate,0,1,0);    }    glScaled(r,r,r);        cylinder(r);        // Draw eyes    // offset for right eye    glPushMatrix();    glPolygonOffset(0,0);    glTranslated(x+(r/2),y,z+r);    glScaled(r/3,r/3,r/3);        // right eye    sphere(x,y,z,r,rotate,4);        // offset for left eye    glPushMatrix();    glTranslated(x-(r/2),y,z+r);    glScaled(r/3,r/3,r/3);        //left eye    sphere(x,y,z,r,rotate,4);    }
开发者ID:denzelr,项目名称:Pacman,代码行数:45,


示例20: cb2sph

int cb2sph(float *cube, Vec3i volsize, int    ri, Vec3i origin,            int    nnz0, int     *ptrs, int *cord, float *sphere) {    int    xs, ys, zs, xx, yy, zz, rs, r2;    int    ix, iy, iz, jnz, nnz, nrays;    int    ftm = 0, status = 0;      int xcent = (int)origin[0];    int ycent = (int)origin[1];    int zcent = (int)origin[2];    int nx = (int)volsize[0];    int ny = (int)volsize[1];    int nz = (int)volsize[2];    r2      = ri*ri;    nnz     = 0;    nrays    = 0;    ptrs(1) = 1;    for (ix = 1; ix <= nx; ix++) {       xs  = ix-xcent;       xx  = xs*xs;       for ( iy = 1; iy <= ny; iy++ ) {           ys = iy-ycent;           yy = ys*ys;           jnz = 0;           ftm = 1;           // not the most efficient implementation           for (iz = 1; iz <= nz; iz++) {               zs = iz-zcent;               zz = zs*zs;               rs = xx + yy + zz;               if (rs <= r2) {                  jnz++;                  nnz++;                  sphere(nnz) = cube(iz, iy, ix);                   //  record the coordinates of the first nonzero ===                  if (ftm) {  		     nrays++;                     cord(1,nrays) = iz;                      cord(2,nrays) = iy;                      cord(3,nrays) = ix;                     ftm = 0;                  }               }            } // end for (iz..)            if (jnz > 0) {		ptrs(nrays+1) = ptrs(nrays) + jnz;	    }  // endif (jnz)       } // end for iy    } // end for ix    if (nnz != nnz0) status = -1;    return status;}
开发者ID:C-CINA,项目名称:2dx,代码行数:57,


示例21: sphere

void GraphicsPainter::drawSphere(float radius){    GraphicsSphere sphere(radius);    GraphicsVertexBuffer *buffer = sphere.tesselate();    draw(buffer);    delete buffer;}
开发者ID:armando-2011,项目名称:chemkit,代码行数:9,


示例22: point

bool MeshAppearanceTemplate::testCollide(float x, float z, float y, float radius) {	Vector3 point(x, z, y);	Sphere sphere(point, radius);	//Logger::console.info("checking collide in mesh", true);	return aabbTree->testCollide(sphere);}
开发者ID:Mesagoppinmypants,项目名称:Tools,代码行数:9,


示例23: tree_ball

/* * Draws a ball tree - cyclinder with spher ontop of it. */void tree_ball(float x, float y, float z, float c){    glPushMatrix();        glTranslatef(x,y,z);        glScalef(TREE_SCALE_FACTOR,TREE_SCALE_FACTOR,TREE_SCALE_FACTOR);        cyclinder();        glColor3f(0.0,c,0.0);        sphere(0.0,1.0,0.0);    glPopMatrix();}
开发者ID:JperF,项目名称:openGL_3D_virtual_env,代码行数:12,


示例24: powf

void SurfacePointsRenderer::Render(const Scene &scene) {    // Declare shared variables for Poisson point generation    BBox octBounds = scene.WorldBound();    octBounds.Expand(.001f * powf(octBounds.Volume(), 1.f/3.f));    Octree<SurfacePoint> pointOctree(octBounds);    // Create scene bounding sphere to catch rays that leave the scene    Point sceneCenter;    float sceneRadius;    scene.WorldBound().BoundingSphere(&sceneCenter, &sceneRadius);    Transform ObjectToWorld(Translate(sceneCenter - Point(0,0,0)));    Transform WorldToObject(Inverse(ObjectToWorld));    Reference<Shape> sph = new Sphere(&ObjectToWorld, &WorldToObject,        true, sceneRadius, -sceneRadius, sceneRadius, 360.f);    //Reference<Material> nullMaterial = Reference<Material>(NULL);    Material nullMaterial;    GeometricPrimitive sphere(sph, nullMaterial, NULL);    int maxFails = 2000, repeatedFails = 0, maxRepeatedFails = 0;    if (PbrtOptions.quickRender) maxFails = max(10, maxFails / 10);    int totalPathsTraced = 0, totalRaysTraced = 0, numPointsAdded = 0;    ProgressReporter prog(maxFails, "Depositing samples");    // Launch tasks to trace rays to find Poisson points    PBRT_SUBSURFACE_STARTED_RAYS_FOR_POINTS();    vector<Task *> tasks;    RWMutex *mutex = RWMutex::Create();    int nTasks = NumSystemCores();    for (int i = 0; i < nTasks; ++i)        tasks.push_back(new SurfacePointTask(scene, pCamera, time, i,            minDist, maxFails, *mutex, repeatedFails, maxRepeatedFails,            totalPathsTraced, totalRaysTraced, numPointsAdded, sphere, pointOctree,            points, prog));    EnqueueTasks(tasks);    WaitForAllTasks();    for (uint32_t i = 0; i < tasks.size(); ++i)        delete tasks[i];    RWMutex::Destroy(mutex);    prog.Done();    PBRT_SUBSURFACE_FINISHED_RAYS_FOR_POINTS(totalRaysTraced, numPointsAdded);    if (filename != "") {        // Write surface points to file        FILE *f = fopen(filename.c_str(), "w");        if (!f) {            Error("Unable to open output file /"%s/" (%s)", filename.c_str(),                  strerror(errno));            return;        }        fprintf(f, "# points generated by SurfacePointsRenderer/n");        fprintf(f, "# position (x,y,z), normal (x,y,z), area, rayEpsilon/n");        for (u_int i = 0; i < points.size(); ++i) {            const SurfacePoint &sp = points[i];            fprintf(f, "%g %g %g %g %g %g %g %g/n", sp.p.x, sp.p.y, sp.p.z,                sp.n.x, sp.n.y, sp.n.z, sp.area, sp.rayEpsilon);        }        fclose(f);    }}
开发者ID:bernstein,项目名称:pbrt-v2,代码行数:57,


示例25: main

int main(void) {    printout();    bool dobreak = false;    char response;    double r = 0;    for (;!dobreak;) {        response = 'a';        int dimensions = promptdimensions();        switch (dimensions) {            case 2:                // Get parameters                while( r <= 0.0 ) {                    printf("Please give a length: ");                    scanf("%lf", &r);                }                circle(r);                square(r);                break;            case 3:                // Get parameters                while( r <= 0.0 ) {                    printf("Please give a length: ");                    scanf("%lf", &r);                }                sphere(r);                cube(r);                break;            default:                break;        }        for(;;) {            printf("Do you want to do this again? (y/n)/n");            scanf(" %c", &response);            if (response == 'y' ||  response == 'Y') {                printf("Restarting/n");                break;            }            else if (response == 'N' || response == 'n') {                printf("Quitting/n");                dobreak = true;                break;            }            else {                printf("That is not an acceptable response/n");            }        }    }    return 0;}
开发者ID:ben-albrecht,项目名称:eg,代码行数:57,


示例26: Intersects

bool BOTechTreeNode::Intersects(int2 p_mousePosition){    // Intersection test.    if (BOPhysics::CheckCollisionSphereToSphere(sphere(float2((float)p_mousePosition.x, (float)p_mousePosition.y), 1), sphere(m_position, (m_size.x / 2) - 3)))    {        return true;    }    return false;}
开发者ID:BTHAgileProject2014,项目名称:BO360,代码行数:9,


示例27: switch

	bool bounding_sphere::intersects(const bounding_volume & volume) const	{		switch (volume.get_type())		{			case bounding_volume::type::aabb: return intersects(box(volume.get_origin(), volume.get_extent()));			case bounding_volume::type::sphere: return intersects(sphere(volume.get_origin(), volume.get_extent().x));			default: return false;		}	}
开发者ID:levka17,项目名称:Engine-Editor,代码行数:9,


示例28: sphere

void SphericalMapping2D::Map(const DifferentialGeometry &dg,        float *s, float *t, float *dsdx, float *dtdx,        float *dsdy, float *dtdy) const {    sphere(dg.p, s, t);    // Compute texture coordinate differentials for sphere $(u,v)$ mapping    float sx, tx, sy, ty;    const float delta = .1f;    sphere(dg.p + delta * dg.dpdx, &sx, &tx);    *dsdx = (sx - *s) / delta;    *dtdx = (tx - *t) / delta;    if (*dtdx > .5) *dtdx = 1.f - *dtdx;    else if (*dtdx < -.5f) *dtdx = -(*dtdx + 1);    sphere(dg.p + delta * dg.dpdy, &sy, &ty);    *dsdy = (sy - *s) / delta;    *dtdy = (ty - *t) / delta;    if (*dtdy > .5) *dtdy = 1.f - *dtdy;    else if (*dtdy < -.5f) *dtdy = -(*dtdy + 1);}
开发者ID:AmeliaMesdag,项目名称:pbrt-v2,代码行数:18,



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


C++ spiRec函数代码示例
C++ speex_resampler_destroy函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。