コード例 #1
0
	virtual bool	Setup(Pint& pint, const PintCaps& caps)
	{
		if(!CylinderTest::Setup(pint, caps))
			return false;

		const bool UseConvexes = mCheckBox_UseConvexesForAll ? mCheckBox_UseConvexesForAll->IsChecked() : false;

		Matrix3x3 M;
		M.RotX(HALFPI);
		const Quat R = M;

		udword Nb = 14;

		const float Radius = mCylinder.mRadius;
		const float HalfHeight = mCylinder.mHalfHeight;
		float Altitude = mCylinder.mRadius;
		float OffsetX = 0.0f;
		while(Nb)
		{
			for(udword i=0;i<Nb;i++)
			{
				if(!caps.mSupportCylinders || UseConvexes)
				{
					PINT_CONVEX_CREATE ConvexCreate(mCylinder.mNbVerts, mCylinder.mVerts);
					ConvexCreate.mRenderer	= GetRegisteredRenderers()[0];
					PintObjectHandle Handle = CreateDynamicObject(pint, &ConvexCreate, Point(OffsetX + float(i)*Radius*2.2f, Altitude, 0.0f), &R);
					ASSERT(Handle);
				}
				else
				{
					PINT_CYLINDER_CREATE CylinderCreate(mCylinder.mRadius, mCylinder.mHalfHeight);
					CylinderCreate.mRenderer	= GetRegisteredRenderers()[1];
//					const Quat Q = ShortestRotation(Point(0.0f, 1.0f, 0.0f), Point(0.0f, 0.0f, 1.0f));
					PintObjectHandle Handle = CreateDynamicObject(pint, &CylinderCreate, Point(OffsetX + float(i)*Radius*2.2f, Altitude, 0.0f)/*, &R*/);
					ASSERT(Handle);
				}
			}
			Nb--;
			Altitude += HalfHeight*2.0f+0.01f;
			OffsetX += Radius*1.1f;
		}
		return true;
	}
コード例 #2
0
ファイル: TestScenes_Overlap.cpp プロジェクト: DevO2012/PEEL
	virtual bool OverlapAny_BoxesVsPlanetSide::CommonSetup()
	{
		TestBase::CommonSetup();
		mRepX = CreateRepXContext("Planetside_Statics.repx", 1.0f, false);

		const Point Min(0.0f, -20.f, 0.0f);
		const Point Max(1000.0f, 20.0f, 1000.0f);
		const Point Center = (Max + Min)*0.5f;
		const Point Extents = (Max - Min)*0.5f;

		BasicRandom Rnd(42);
		Matrix3x3 Rot;
		Rot.RotX(45.0f * DEGTORAD);
		for(udword i=0;i<4096;i++)
		{
			Point p;
			UnitRandomPt(p, Rnd);
			Point Pos = Center + Extents*p;
//			Pos.y = 0.0f;
			RegisterBoxOverlap(OBB(Pos, Point(10.0f, 10.0f, 10.0f), Rot));
		}
		mCreateDefaultEnvironment = false;
		return true;
	}
コード例 #3
0
ファイル: TestScenes_Overlap.cpp プロジェクト: DevO2012/PEEL
	virtual bool OverlapAny_BoxesVsTerrain::CommonSetup()
	{
		TestBase::CommonSetup();
		LoadMeshesFromFile_(*this, "terrain.bin");

		const Point Min(-128.0f, -432.117371f, -128.0f);
		const Point Max(3968.0f, 710.848145f, 3968.0f);
		const Point Center = (Max + Min)*0.5f;
		const Point Extents = (Max - Min)*0.5f;

		BasicRandom Rnd(42);
		Matrix3x3 Rot;
		Rot.RotX(45.0f * DEGTORAD);
		for(udword i=0;i<4096;i++)
		{
			Point p;
			UnitRandomPt(p, Rnd);
			Point Pos = Center + Extents*p;
			Pos.y = 0.0f;
			RegisterBoxOverlap(OBB(Pos, Point(20.0f, 20.0f, 20.0f), Rot));
		}
		mCreateDefaultEnvironment = false;
		return true;
	}
コード例 #4
0
ファイル: Loader_Bin.cpp プロジェクト: DevO2012/PEEL
static bool LoadBIN(const char* filename, SurfaceManager& test, const float* scale=null, bool mergeMeshes=false, udword tesselation=0, TesselationScheme ts = TESS_BUTTERFLY)
{
	IceFile BinFile(filename);
	if(!BinFile.IsValid())
		return false;

	const udword NbMeshes = BinFile.LoadDword();
	printf("LoadBIN: loading %d meshes...\n", NbMeshes);

	AABB GlobalBounds;
	GlobalBounds.SetEmpty();
	udword TotalNbTris = 0;
	udword TotalNbVerts = 0;
	if(!mergeMeshes)
	{
		for(udword i=0;i<NbMeshes;i++)
		{
			const udword Collidable = BinFile.LoadDword();
			const udword Renderable = BinFile.LoadDword();

			const udword NbVerts = BinFile.LoadDword();
			const udword NbFaces = BinFile.LoadDword();

//			TotalNbTris += NbFaces;
//			TotalNbVerts += NbVerts;

			IndexedSurface* IS = test.CreateManagedSurface();
			bool Status = IS->Init(NbFaces, NbVerts);
			ASSERT(Status);

			Point* Verts = IS->GetVerts();
			for(udword j=0;j<NbVerts;j++)
			{
				Verts[j].x = BinFile.LoadFloat();
				Verts[j].y = BinFile.LoadFloat();
				Verts[j].z = BinFile.LoadFloat();
				if(scale)
					Verts[j] *= *scale;

				if(0)
				{
					Matrix3x3 RotX;
					RotX.RotX(HALFPI*0.5f);
					Verts[j] *= RotX;
					Verts[j] += Point(0.1f, -0.2f, 0.3f);
				}

				GlobalBounds.Extend(Verts[j]);
			}

			IndexedTriangle* F = IS->GetFaces();
			for(udword j=0;j<NbFaces;j++)
			{
				F[j].mRef[0] = BinFile.LoadDword();
				F[j].mRef[1] = BinFile.LoadDword();
				F[j].mRef[2] = BinFile.LoadDword();
			}

/*			if(tesselation)
			{
				for(udword j=0;j<tesselation;j++)
				{
					if(ts==TESS_BUTTERFLY)
					{
						ButterflyScheme BS;
						IS->Subdivide(BS);
					}
					else if(ts==TESS_POLYHEDRAL)
					{
						PolyhedralScheme PS;
						IS->Subdivide(PS);
					}
				}
			}*/
			if(tesselation)
				Tesselate(IS, tesselation, ts);

			if(gUseMeshCleaner)
			{
				MeshCleaner Cleaner(IS->GetNbVerts(), IS->GetVerts(), IS->GetNbFaces(), IS->GetFaces()->mRef);
				IS->Init(Cleaner.mNbTris, Cleaner.mNbVerts, Cleaner.mVerts, (const IndexedTriangle*)Cleaner.mIndices);
			}

			TotalNbTris += IS->GetNbFaces();
			TotalNbVerts += IS->GetNbVerts();

//			SaveBIN("c:\\TessBunny.bin", *IS);
		}
	}
	else
	{
		IndexedSurface* IS = test.CreateManagedSurface();

		for(udword i=0;i<NbMeshes;i++)
		{
			const udword Collidable = BinFile.LoadDword();
			const udword Renderable = BinFile.LoadDword();

			const udword NbVerts = BinFile.LoadDword();
			const udword NbFaces = BinFile.LoadDword();

			IndexedSurface LocalIS;
			bool Status = LocalIS.Init(NbFaces, NbVerts);
			ASSERT(Status);

			Point* Verts = LocalIS.GetVerts();
			for(udword j=0;j<NbVerts;j++)
			{
				Verts[j].x = BinFile.LoadFloat();
				Verts[j].y = BinFile.LoadFloat();
				Verts[j].z = BinFile.LoadFloat();
				if(scale)
					Verts[j] *= *scale;
				GlobalBounds.Extend(Verts[j]);
			}

			IndexedTriangle* F = LocalIS.GetFaces();
			for(udword j=0;j<NbFaces;j++)
			{
				F[j].mRef[0] = BinFile.LoadDword();
				F[j].mRef[1] = BinFile.LoadDword();
				F[j].mRef[2] = BinFile.LoadDword();
			}

			IS->Merge(&LocalIS);
		}

/*		if(tesselation)
		{
			for(udword j=0;j<tesselation;j++)
			{
				ButterflyScheme BS;
				IS->Subdivide(BS);
			}
		}*/
		if(tesselation)
			Tesselate(IS, tesselation, ts);

		TotalNbTris = IS->GetNbFaces();
		TotalNbVerts = IS->GetNbVerts();
	}

	test.SetGlobalBounds(GlobalBounds);

	const udword GrandTotal = sizeof(Point)*TotalNbVerts + sizeof(IndexedTriangle)*TotalNbTris;
	printf("LoadBIN: loaded %d tris and %d verts, for a total of %d Kb.\n", TotalNbTris, TotalNbVerts, GrandTotal/1024);
	printf("LoadBIN: min bounds: %f | %f | %f\n", GlobalBounds.GetMin(0), GlobalBounds.GetMin(1), GlobalBounds.GetMin(2));
	printf("LoadBIN: max bounds: %f | %f | %f\n", GlobalBounds.GetMax(0), GlobalBounds.GetMax(1), GlobalBounds.GetMax(2));
	return true;
}