예제 #1
0
void DebugRenderer::AddSphereSector(const Sphere& sphere, const Quaternion& rotation, float angle,
    bool drawLines, const Color& color, bool depthTest)
{
    if (angle <= 0.0f)
        return;
    else if (angle >= 360.0f)
    {
        AddSphere(sphere, color, depthTest);
        return;
    }

    static const unsigned numCircleSegments = 8;
    static const unsigned numLines = 4;
    static const float arcStep = 45.0f;

    const unsigned uintColor = color.ToUInt();
    const float halfAngle = 0.5f * angle;
    const unsigned numArcSegments = static_cast<unsigned>(std::ceil(halfAngle / arcStep)) + 1;

    // Draw circle
    for (unsigned j = 0; j < numCircleSegments; ++j)
    {
        AddLine(
            sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, halfAngle),
            sphere.center_ + rotation * sphere.GetLocalPoint((j + 1) * 360.0f / numCircleSegments, halfAngle),
            uintColor);
    }

    // Draw arcs
    const unsigned step = numCircleSegments / numLines;
    for (unsigned i = 0; i < numArcSegments - 1; ++i)
    {
        for (unsigned j = 0; j < numCircleSegments; j += step)
        {
            const float nextPhi = i + 1 == numArcSegments - 1 ? halfAngle : (i + 1) * arcStep;
            AddLine(
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, i * arcStep),
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, nextPhi),
                uintColor);
        }
    }

    // Draw lines
    if (drawLines)
    {
        for (unsigned j = 0; j < numCircleSegments; j += step)
        {
            AddLine(sphere.center_,
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, halfAngle),
                uintColor);
        }
    }
}
예제 #2
0
void Edist::SetTarget(Geometry*g)
{
	target = g;
	target->UpdateBox();
	base.renull();
	AddSphere(&base,0.1,50,50);
	mat34 mt(1,1,vec3(1).normalized());
	base.Transform(mt);
	
	flat fl;// = CalcFlat(target->vert);

	center = fl.d;//(target->box1+target->box2)*0.5f;
	axis0 = fl.n;
	vec3 tmpv;
	base.Move(center);
	base.BuildRep2();
	if(0)
	for(int i=0;i<base.vert.size();i++)
	{
		if(base.CrossLine(center,center+base.norm[i]*10,&tmpv))
		{
			base.vert[i] = tmpv;
		}
		else
			base.vert[i] = center;
	}
	base.BuildRep1();

	mesh.vert.resize(base.vert.size());
	mesh.face = base.face;
	mesh.norm = base.norm;

	SetDistance(dist);
	mesh.color = g->color;
	base.color = g->color;
	mesh.color.w *= 0.5f;
	
}
void EnvironmentNotifierExampleTerrainStreamObserver::AddedStreamingResourceToSceneGraph(const Eegeo::Streaming::MortonKey& key)
{
	Eegeo_TTY("Adding Terrain Resource :: %s\n", key.ToString().c_str());
	AddSphere(key);
}
예제 #4
0
void TestFunction1(scene& scene1)
{

	AddSphere(scene1, vector3(1.5, -1.5, 0), 0.5, rgbf(0, 0, 1), false);
	//AddSphere(scene1, vector3(1, 1, 0), 0.5, rgbf(0, 1, 1), true);
		
	sphere_object* s1 = new sphere_object(0.5, vector3(1.5, -1, 0));
	s1->natrual_colour = rgbf(0, 0, 0);
	s1->reflective = true;
	s1->I_refl = 1;
	s1->k_spec = 1;	
	s1->ambient_colour = rgbf(0, 0, 0);
	s1->shininess = 100;
	//scene1.add_object(s1);

	sphere_object* s2 = new sphere_object(0.5, vector3(1.5, 1, 0));
	s2->transparent = true;
	s2->transparency = 0.9;
	s2->refindex = 0.9;
	scene1.add_object(s2);

	rgbf red(1, 0, 0);
	rgbf green(0, 1, 0);
	rgbf blue(0, 0, 1);
	rgbf yellow = red + green;
	rgbf magenta = red + blue;
	rgbf cyan = green + blue;


	AddWall(scene1, vector3(3, 0, -0.5), vector3(0, 1, 0), green * 0.7);
	AddWall(scene1, vector3(0, 3, -0.5), vector3(-1, 0, 0), red* 0.7);
	AddWall(scene1, vector3(-3, 0, -0.5), vector3(0, -1, 0), blue* 0.7);
	AddWall(scene1, vector3(0, -3, -0.5), vector3(1, 0, 0), yellow* 0.7);
	

	AddCeiling(scene1, vector3(0, 0, +3.5), magenta * 0.7);
	AddFloor(scene1, vector3(0, 0, -0.5), cyan * 0.7);

	//AddBox(scene1, vector3(1, -0.5, -0.3), 0.2, rgbf(1, 0, 1), true);

	box* box1 = new box(vector3(1, -0.5, 0), vector3(-0.2, -0.2, -0.2), vector3(0.2, 0.2, 0.2));
	box1->natrual_colour = rgbf(0, 0, 0);
	box1->reflective = false;
	box1->transparent = true;
	box1->transparency = 1;
	box1->I_refr = 1;
	box1->refindex = 2;
	scene1.add_object(box1);

	//AddLightBall(scene1, vector3(-0.8, 0, 3), 3, 0.1);

	AddLight(scene1, vector3(-1.5, 1.5, 3));
	//AddLight(scene1, vector3(2, 0, 4));
	//AddLight(scene1, vector3(-5, 3, 2));

	//IcoSphere(scene1, vector3(4, 0, 2));

	torus_object* tor1 = new torus_object(0.1,0.5,vector3(1,0,-0.5));
	tor1->natrual_colour = rgbf(1, 0, 0);	
	//tor1->ambient_colour = rgbf(0, 0, 0.5);
	//scene1.add_object(tor1);

	mesh* m1 = ReadMesh("teapot.obj", vector3(1, -0.25, -0.5));
	m1->natrual_colour = rgbf(0, 0, 0);
	m1->reflective = false;
	m1->transparent = true;
	m1->transparency = 1;
	m1->I_refr = 1;

	//scene1.add_object(m1);
	
	
}
예제 #5
0
void CalcER()
{
//*'
Table tbl0(2,54);
tbl0.SetValue("nearest_astr",0,0);
tbl0.SetValue("nearest_epr",1,0);
for(int i=0;i<psd.size();i++)
{
	tbl0.SetValue(nearest_geoms(0,psd[i].fl.d),0,1+i);
	tbl0.SetValue(nearest_geoms(4,psd[i].fl.d),1,1+i);
}
tbl0.StoreToFile("distances.txt");
	return;// */
float d0 = 0.01f;
float d1 = 2.5f;
float d_step = 0.01f;
int it_num = int((d1-d0)/d_step);
int opers_left,opers_total;
double start = glfwGetTime ( );

	int psd_num = psd.size();
	opers_left =opers_total= it_num*psd_num;
	float *Vas=new float[it_num*psd_num];
	float *Ver=new float[it_num*psd_num];
	
	memset(Vas,0,it_num*sizeof(float)*psd_num);
	memset(Ver,0,it_num*sizeof(float)*psd_num);
	float *Vas1=new float[it_num];
	float *Ver1=new float[it_num];
	
	memset(Vas1,0,it_num*sizeof(float));
	memset(Ver1,0,it_num*sizeof(float));
	
	float cur_d;
	Geometry *gg0 = new Geometry(),*gg = new Geometry();
	Geometry*gs = new Geometry();

	for(int psd_id=0;psd_id<psd_num;psd_id++)
	{
		float offset=0;//nearest_epr(psd[psd_id].fl.d);

		cur_d=d0+offset;

		gs->renull();
		AddSphere(gs,d1+d_step+offset,40,40);
		mat34 mt(12,vec3(1).normalized());
		gs->Transform(mt);
		gs->Move(psd[psd_id].fl.d);
		gs->RebuildTrBB();
		gs->RebuildTrBB2();
		gg0->renull();
		for(int as=0;as<2;as++)
		{
			GetSection(gs,&neuron[0][as],gg0,1,0);
			GetSection(&neuron[0][as],gs,gg0,1,0);
		}
		gg0->RebuildTrBB();
		gg0->RebuildTrBB2();
			
		for(int i=0;i<it_num;i++)
		{
			
			gg->renull();
			gs->renull();
			AddSphere(gs,cur_d,40,40);
			mat34 mt(12,vec3(1).normalized());
			gs->Transform(mt);
			gs->Move(psd[psd_id].fl.d);
			gs->RebuildTrBB();
			gs->RebuildTrBB2();

			GetSection(gs,gg0,gg,1,0,0);
			float ss = gg->CalcArea();

			float ss1=0;
			for(int as_id=0;as_id<2;as_id++)
			for(int ii=0;ii<CD_depo[as_id].size();ii++)
			{
				Geometry* g_er = &neuron[4][CD_depo[as_id][ii]];
				if(!g_er->tr.size())continue;
				gg->renull();
				GetSection(gs,g_er,gg,1,0,0);
				ss1 += gg->CalcArea()*g_er->color.y;
				
			}
					
			opers_left--;
		

			Vas1[i] = ss/(4*PI*cur_d*cur_d);
			Ver1[i] = ss1/(4*PI*cur_d*cur_d);
			Vas[i+psd_id*it_num] = Vas1[i];
			Ver[i+psd_id*it_num] = Ver1[i];

			cur_d += d_step;
			int sc=((opers_left)*(glfwGetTime ( )-start)/(opers_total-opers_left))/60;
						
			//printf("%dpsd	%dit	%d%	%d:%d\n",psd_id,opers_left,(opers_left*100)/opers_total,sc/60,sc%60);
			printf("%dpsd	%dit	%g %g\n",psd_id,opers_left,ss,ss1);
				
			
		}

	}

				
	//}
//
	Table tbl1(it_num+1,1+3*psd_num);
	tbl1.SetValue("Distance",0,0);
	for(int i=0;i<psd_num;i++)
	{
		tbl1.SetValue("%Vas"+str::ToString(i),0,i+1);
		tbl1.SetValue("%Ver"+str::ToString(i),0,i+1+psd_num);
		tbl1.SetValue("Ver/Vas"+str::ToString(i),0,i+1+psd_num*2);
	}
	
	{
		float cur_d = d0;
		for(int i=0;i<it_num;i++)
		{
			tbl1.SetValue(str::ToString(int((cur_d+0.0001f)*1000))+"nm",i+1,0);
			cur_d += d_step;		
		}
	}
	for(int i=0;i<psd_num;i++)
	for(int j=0;j<it_num;j++)
	{
		tbl1.SetValue(Vas[j+i*it_num],j+1,i+1);
		tbl1.SetValue(Ver[j+i*it_num],j+1,i+1+psd_num);
		if(Vas[j+i*it_num])tbl1.SetValue(Ver[j+i*it_num]/Vas[j+i*it_num],j+1,i+1+psd_num*2);
		
	}
	
	tbl1.StoreToFile("results\\ER_central.txt");
	
	
//
			
		
	delete gg;
	delete gg0;
	delete gs;
	delete[]Vas;
	delete[]Ver;
	delete[]Vas1;
	delete[]Ver1;

}