Beispiel #1
0
void FileManager::LoadStaticObjects(int levelNum)
{
	std::string temp;
	std::vector<std::string> levelVector = LoadLevelFile(levelNum);
	std::vector<std::string>::iterator stringIter;
	std::vector<std::string>::iterator stringIter2;
	
	const int *tileSize = LoadLevelProperties(levelNum);

	const int tileWidth = tileSize[0];
	const int tileHeight = tileSize[1];

	temp="";

	for(stringIter = levelVector.begin(); stringIter!=levelVector.end(); stringIter++)
	{
		if((*stringIter) == "[map]")
		{
			int x=0,y=0;
			std::string temp;
			for(stringIter2 = stringIter+1; stringIter2!=levelVector.end(); stringIter2++)
			{
				if((*stringIter2) == ";")
					break;
				else
				{
					for(unsigned int i=0; i<(*stringIter2).size(); i++)
					{
						if((*stringIter2)[i] != ' ' && (*stringIter2)[i] != '|')
							temp += (*stringIter2)[i];
						else
						{
							if(temp=="--")
							{
								y--;
								temp="";
								break;
							}
							CreateStaticObject(temp, x*tileWidth, y*tileHeight);
							x++;
							temp="";
						}
					}
					y++;
					x=0;
				}
			}
		}
		else if((*stringIter) == "END")
			break;
	}
}
	virtual bool	Setup(Pint& pint, const PintCaps& caps)
	{
		if(!CylinderTest::Setup(pint, caps))
			return false;

		// Create ramp
		{
			Matrix3x3 M;
			M.RotZ(-0.2f);
			const Quat R = M;

			PINT_BOX_CREATE BoxDesc(10.0f, 1.0f, 10.0f);
			BoxDesc.mRenderer	= CreateBoxRenderer(BoxDesc.mExtents);
			PintObjectHandle Handle = CreateStaticObject(pint, &BoxDesc, Point(0.0f, 0.0f, 0.0f), &R);
			ASSERT(Handle);
		}

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

		if(!caps.mSupportCylinders || UseConvexes)
		{
			// Create cylinder as a convex object
			PINT_CONVEX_CREATE ConvexCreate(mCylinder.mNbVerts, mCylinder.mVerts);
			ConvexCreate.mRenderer	= GetRegisteredRenderers()[0];
			PintObjectHandle Handle = CreateDynamicObject(pint, &ConvexCreate, Point(0.0f, mCylinder.mRadius+2.0f, 0.0f));
			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(0.0f, mCylinder.mRadius+2.0f, 0.0f), &Q);
			ASSERT(Handle);
		}
		return true;
	}