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


C++ sphere函数代码示例

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


在下文中一共展示了sphere函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:env_headcrabcanister.cpp

示例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,代码来源:ofApp.cpp

示例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,代码来源:sphere_painter.cpp

示例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,代码来源:Municao.cpp

示例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,代码来源:F13.cpp

示例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,代码来源:sphere_painter.cpp

示例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,代码来源:oigraphix.cpp

示例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,代码来源:SpiralScene.cpp

示例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,代码来源:drawExtraStuff.c

示例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,代码来源:圣诞.c

示例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,代码来源:MeshLoader.cpp

示例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,代码来源:TestKDTree.hpp

示例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,代码来源:testBreakCondition.cpp

示例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,代码来源:AAB.cpp

示例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,代码来源:sphere.cpp


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