예제 #1
0
btRigidBody* BulletPhysics::CreateSphere(float radius, const glm::mat4* world,
float mass, float restitution, float friction, float linear_damp, float angular_damp, bool kinematic, unsigned short group, unsigned short mask)
{
	btCollisionShape* shape = new btSphereShape(radius);
	if (kinematic) mass = 0;
	return CreateShape(shape, world, mass, restitution, friction, linear_damp, angular_damp, kinematic, group, mask);
}
예제 #2
0
btRigidBody* BulletPhysics::CreateBox(float width, float height, float depth, const glm::mat4* world,
float mass, float restitution, float friction, float linear_damp, float angular_damp, bool kinematic, unsigned short group, unsigned short mask)
{
	btVector3 halfExtents(width/2, height/2, depth/2);
	btCollisionShape* shape = new btBoxShape(halfExtents);
	if (kinematic) mass = 0;
	return CreateShape(shape, world, mass, restitution, friction, linear_damp, angular_damp, kinematic, group, mask);
}
예제 #3
0
btRigidBody* BulletPhysics::CreateCylinder(float radius, float length, const glm::mat4* world,
float mass, float restitution, float friction, float linear_damp, float angular_damp, bool kinematic, unsigned short group, unsigned short mask)
{
	btVector3 halfExtents(radius, radius, length/2);
	btCollisionShape* shape = new btCylinderShape(halfExtents);
	if (kinematic) mass = 0;
	return CreateShape(shape, world, mass, restitution, friction, linear_damp, angular_damp, kinematic, group, mask);
}
예제 #4
0
파일: Task_4.cpp 프로젝트: Smi1le/OOP
int main()
{
	std::string name = "input.txt";
	auto elements = ReadFromFile(name);
	std::vector<std::shared_ptr<IShape>> parametersShapes;
	for (auto element : elements)
	{
		if (CheckVectorForSize(element))
		{
			parametersShapes.push_back(CreateShape(element));
		}
		else
		{
			std::cout << "Wrong name or the wrong set of data for the figures" << std::endl;
		}
	}
	OutputDataInSortedOrder(parametersShapes);
	system("pause");
	return 0;
}
예제 #5
0
bool surfaceVectorField::write_shapefile(std::string rootName)
{
	double xCoord = 0;
	double yCoord = 0;
	double velocity = 0;
	double direction = 0;
	double AVdirection = 0;
	double AMdirection = 0;
	double phi = 0;

	
	if(!poX || !poY || !poZ)
	{
		#ifdef SURFACE_VECTOR_FIELD_DEBUG
			std::cout << "This data has not been created." << std::endl;
		#endif
		return false;
	}
	
	ShapeFileName = rootName;
	ShapeFileName = ShapeFileName + ".shp";
	DataBaseName = rootName;
	DataBaseName = DataBaseName + ".dbf";

	#ifdef SURFACE_VECTOR_FIELD_DEBUG
		std::cout << "Opening file for writing..." << std::endl;
	#endif
	
	CreateShape();
     OpenShape();

	#ifdef SURFACE_VECTOR_FIELD_DEBUG
		std::cout << "File opened." << std::endl;
	#endif
	
	for(int i = 0; i < poX->get_nRows(); i++)
	{
		for (int j = 0; j < poX->get_nCols(); j++)
		{
			poX->get_cellPosition(i, j, &xCoord, &yCoord);
			uvw_to_rThetaPhi((*poX)(i,j), (*poY)(i,j), (*poZ)(i,j), &velocity, &direction, &phi);	//at this point, direction is the direction the wind vector points TO (not from)
			
			AVdirection = 360.0 - direction;	//pervert the angle for display in ArcView

			AMdirection = direction - 90.0;	//pervert the angle for display in ArcMap
			if(AMdirection < 0.0)
				AMdirection += 360.0;

			direction += 180.0;				//flip direction so it's the direction the wind COMES FROM
			if(direction > 360.0)
				direction -= 360.0;
			

			WriteShapePoint(xCoord, yCoord, velocity, (long)(direction+0.5), (long)(AVdirection + 0.5), (long)(AMdirection + 0.5));	//write shapefile point, add 0.5 because of double to long conversion
		}
	}

	#ifdef SURFACE_VECTOR_FIELD_DEBUG
		std::cout << "File written." << std::endl;
	#endif
	CloseShape();
	#ifdef SURFACE_VECTOR_FIELD_DEBUG
		std::cout << "File closed." << std::endl;
	#endif
	return true;
}
예제 #6
0
void sampleNewThetas(int** VarSetsMarg,int* lenVarSetsMarg,int nVarSetsMarg,
                     int* amodel,int* aModelGenerators,LPTable mytable,LPTable Y,LPTable Theta,LPTable nextTheta)
{
	int i,j,k;
	double r,s;
		
	int nMssShape = 0;
	for(i=0;i<nVarSetsMarg;i++)
	{
		nMssShape += aModelGenerators[i];
	}

	int* lenC = new int[nMssShape];
	int** C = new int*[nMssShape];
	for(i=0;i<nMssShape;i++)
	{
		C[i] = new int[mytable->nDimens];
	}

	LPNTable PriorMssShape = new NTable[nMssShape];
	LPNTable tau = new NTable[nMssShape];
	LPNTable theta = new NTable[nMssShape];
	
	nMssShape = 0;
	for(i=0;i<nVarSetsMarg;i++)
	{
		if(aModelGenerators[i])
		{
			k = 0;
			for(j=0;j<mytable->nDimens;j++)
			{
				if(VarSetsMarg[i][j])
				{
					C[nMssShape][k]=j;
					k++;
				}
			}
			lenC[nMssShape] = k;
		
			tau[nMssShape].Create(lenC[nMssShape],C[nMssShape],mytable);
			theta[nMssShape].Create(lenC[nMssShape],C[nMssShape],mytable);
			PriorMssShape[nMssShape].Create(lenC[nMssShape],C[nMssShape],mytable);
			CreateShape(VarSetsMarg,lenVarSetsMarg,nVarSetsMarg,
						lenC[nMssShape],C[nMssShape],Y,&PriorMssShape[nMssShape]);
			nMssShape++;
		}
	}
	
	double beta = 1.0/Y->Data[0];
	for(k=0;k<nMssShape;k++)
	{
		s = 0;
		for(j=0;j<tau[k].Total;j++)
		{
			r = -1;
			while(r<=0)
			{
				//vdRngGamma(METHOD,stream,1,&r,PriorMssShape[k].Data[j],0,beta);
				r = gsl_ran_gamma(stream, PriorMssShape[k].Data[j], beta);
			}
			tau[k].Data[j] = r;
			s += r;
		}
		for(j=0;j<tau[k].Total;j++)
		{
			tau[k].Data[j] /= s;
		}
			
		getThetaMarginal(&theta[k],&tau[k]);
		getNextTheta(VarSetsMarg,lenVarSetsMarg,nVarSetsMarg,
					 amodel,lenC[k],C[k],&theta[k],Theta,nextTheta);
		for(i=0;i<Theta->Total;i++)
		{
			Theta->Data[i] = nextTheta->Data[i];
		}
	}	
	
	//clean memory
	for(i=0;i<nMssShape;i++)
	{
		PriorMssShape[i].Reset();
		tau[i].Reset();		
		theta[i].Reset();
	}
	delete[] PriorMssShape; PriorMssShape = NULL;
	delete[] tau; tau = NULL;
	delete[] theta; theta = NULL;
	for(i=0;i<nMssShape;i++)
	{
		delete[] C[i]; C[i] = NULL;
	}
	delete[] C; C = NULL;
	delete[] lenC; lenC = NULL;

	return;
}
예제 #7
0
bool Scape03::Init() 
{
	nrSegmentsX = 127;
	nrSegmentsZ = 127;
	left   = -150;
	top    = -150;
	right  =  150;
	bottom =  150;

	scene = new Scene();

	scene->addObject(genPlane(nrSegmentsX, 300, "vulcanfinal"));

	CreateShape(NULL, scene->object[0]->vertex, 4.f, 0.8f, 0);

	Vertex *vertex = scene->object[0]->vertex;

	// vulkaan creeeren in het midden
	for (int y = 0; y < nrSegmentsZ + 1; y++)
	{
		for (int x = 0; x < nrSegmentsX + 1; x++)
		{
			int index = (y * (nrSegmentsX + 1)) + x;

			float vx = vertex[index].x;
			float vy = vertex[index].y;
			float vz = vertex[index].z;

			float x = vx - 30.f;
			float z = vz + 25.f;
			

			float length = sqrt((x * x) + (z * z));
			float amp = 40.f;
			if (length < 25.f)
			{
				if (length > 10)
				{
					vy += sin((25.f - length) * (_PI / 15.f)) * 10.f;
				}
				else
				{
					vy -= 20.f;
				}
			}


			vertex[index].x = vx;
			vertex[index].y = vy;
			vertex[index].z = vz;
		}
	}

	int width, height;	
//	dword *grond1 = loadATSFromMem(ATS_GROUND2, width, height);
//	dword *grond2 = loadATSFromMem(ATS_GROUND1, width, height);
//	dword *grond1 = loadATSFromMem(ATS_VULCANGROUND1, width, height);
//	dword *grond2 = loadATSFromMem(ATS_VULCANGROUND2, width, height);
//	dword *grond3 = loadATSFromMem(ATS_GROUND3, width, height);
//	dword *grond4 = loadATSFromMem(ATS_WIT,   width, height);

	dword *grond1 = extraTextures[5];//loadATSFromMem(ATS_VULCANGROUND1, width, height);
	dword *grond2 = extraTextures[4];//loadATSFromMem(ATS_VULCANGROUND2, width, height);
	dword *grond3 = extraTextures[0];//loadATSFromMem(ATS_GROUND3, width, height);
	dword *grond4 = extraTextures[3];//loadATSFromMem(ATS_WIT,   width, height);

	dword *textureFinal = CreateTexture(1024, 1024, grond1, grond2, grond3, grond4, -6.f, 1.8f);

	uniTextureCreate("vulcanfinal", textureFinal, 1024, 1024, UNI_MIPMAP);

//	delete [] grond1;
//	delete [] grond2;
//	delete [] grond3;
//	delete [] grond4;

	scene->fog = true;
	scene->fogColor = 0x000000;
	scene->fogStart = 50;
	scene->fogEnd = 200;//150;
	scene->fogSprites = true;

//	scene->camera->farPlane = 220;//170;

//	scene->ambient = 0x202020;
	scene->ambient = 0x404040;

	scene->addLight(new Light(1, 1, 1, 1));

	scene->addLight(new Light(0.1f, 0, 0, 1));
	scene->light[1]->setLoc(PARTSTARTX, 60, PARTSTARTZ);
	scene->light[1]->setRange(80);


#ifdef NRPARTS
	scene->addSpriteGroup(new SpriteGroup(NRPARTS, 0.7f, 0xffffffff, "vulcansprite"));

	for (int i = 0; i < NRPARTS; i++)
	{
		float t = rand()%360;
		float x = sin((t * _PI) / 180.f) * 200.f;
		float y = 0;
		float z = cos((t * _PI) / 180.f) * 200.f;
		parts[i].eindX = x;
		parts[i].eindY = y;
		parts[i].eindZ = z;
		parts[i].time = rand()%12000;
		parts[i].opzij = false;
	}
#endif

#ifdef SCAPE03_NRSMOKEPARTS
	scene->addSpriteGroup(new SmokeSys(SCAPE03_NRSMOKEPARTS, 15.7f, 0xcccccccc,   10, UniVector(PARTSTARTX, 20, PARTSTARTZ), "smoke01"));
	scene->addSpriteGroup(new SmokeSys(SCAPE03_NRFIREPARTS,  5.7f, 0xffffffff, 2.8f, UniVector(PARTSTARTX, 20, PARTSTARTZ), "vulcansprite"));
#endif

#ifdef DO_SPIKEY
	oldPlane = genPlane(nrSegmentsX, 300, "vulcanfinal");
	for (i = 0; i < oldPlane->nrVertices; i++)
	{
		oldPlane->vertex[i] = scene->object[0]->vertex[i];
	}

	scene->object[0]->finish(true);
#endif

	currentCam = 1;
	camTimer1  = 0;
	camTimer2  = 0;
	camTimer3  = camTimer4 = camTimer5 = -999999;

#ifdef VULCAN_SKY
	scene2 = new Scene();
	scene2->addObject(genSphere(4, 2000.f, "vulcanback"));
	scene2->object[0]->cull = CULL_ACW;
	scene2->camera->farPlane = 5000;
	scene2->object[0]->scaleUV(2, 2);
#endif

	scene->object[0]->finish(false);
	scene2->object[0]->finish(false);

	ShowLoader(0.8f);

	return true;
}