Пример #1
0
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 );
		}
	}
}
Пример #2
0
//--------------------------------------------------------------
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 );
    
    
}
Пример #3
0
	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();
			}
		}
	}
Пример #4
0
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();
}
Пример #5
0
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);
}
Пример #6
0
	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
		}
	}
Пример #7
0
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();
}
Пример #8
0
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));
	}
}
Пример #9
0
int main(int argc, char* argv[])
{
    osg::ref_ptr<osg::Group> root(new osg::Group);
    osg::ref_ptr<osg::Geode> sphere(build_sphere());
    root->addChild(sphere.get());

    osg::ref_ptr<osg::Light> light(new osg::Light);
    light->setLightNum(1);
    light->setPosition(osg::Vec4(0., 0., 0., 1.));
    osg::ref_ptr<osg::LightSource> light_source(new osg::LightSource);
    light_source->setLight(light.get());
    osg::ref_ptr<osg::MatrixTransform> transform(new osg::MatrixTransform);
    transform->addChild(light_source.get());
    osg::Matrix matrix;
    matrix.makeTranslate(osg::Vec3(10., 0., 0.));
    transform->setMatrix(matrix);
    root->addChild(transform.get());

    boost::shared_ptr<shade::GLSLWrapper> state(new shade::osg::Wrapper(sphere->getOrCreateStateSet()));

    boost::shared_ptr<shade::Program> shader_program(setup_shading(state));
    shader_program->compile();
    state->make_current();
    shader_program->upload();

    run_viewer(root.get());
}
Пример #10
0
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);
}
Пример #11
0
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;
}
Пример #12
0
MeshLoader::MeshLoader() {
    initQuadBuffers();
    initCubeBuffers();
    initSkyBoxBuffers();
    duckVAOC = MeshLoader::loadFromAszFile("res/models/duck.txt");
    SolidSphere sphere(1, 12, 24);
    initSphereBuffers(sphere.GetVertices(),sphere.numOfVertices);
}
 IndexedSegmentNodeImpl(const _Base it, bool isEnd) :
   _Base(it) {
   if(!isEnd){
       Sphere sphere(*it);
       center = sphere.center;
       range = sphere.radius;
   }
 }
Пример #14
0
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"));
}
Пример #15
0
Sphere AAB::getBoundingSphere() const
{
    Vector3 center = getCenter();
    Vector3 extent = getExtent();
    float radius = (max - center).length();
    Sphere sphere(center, radius);
    return sphere;
}
Пример #16
0
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);
}
Пример #17
0
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();
}
Пример #18
0
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() );
	}
}
Пример #19
0
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();
}
Пример #20
0
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);
    
}
Пример #21
0
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;
}
Пример #22
0
void GraphicsPainter::drawSphere(float radius)
{
    GraphicsSphere sphere(radius);
    GraphicsVertexBuffer *buffer = sphere.tesselate();

    draw(buffer);

    delete buffer;
}
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);
}
Пример #24
0
/*
 * 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();
}
Пример #25
0
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);
    }
}
Пример #26
0
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;
}
Пример #27
0
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;
}
Пример #28
0
	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;
		}
	}
Пример #29
0
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);
}
Пример #30
0
TEST(SphericalBoundary, outside) {
	SphericalBoundary sphere(Vector3d(0, 0, 0), 10);
	sphere.setRejectFlag("I passed the galactic border", "Nothing happened");
	Candidate c;
	c.current.setPosition(Vector3d(0, -10.1, 0));
	sphere.process(&c);
	EXPECT_FALSE(c.isActive());
	EXPECT_TRUE(c.hasProperty("I passed the galactic border"));
}