Beispiel #1
0
//---------------------------------------------------------------------------------------------------------
Vehicle::Vehicle(const std::string &fileName,Ogre::SceneManager* sm,
				 Ogre::RenderWindow* win, NxScene* ns, 
				 const Ogre::Vector3 pos, const Ogre::Quaternion ori):
                 mSpeed(0), mAngle(0),mAngleDelta(0),mTurnLeft(0),mTurnRight(0),mRollAngle(0)
{

	//初始化各种变量
	mSceneMgr		= sm;
	mWindow			= win;
	mOriginalPos	= pos;
	mOriginalQuat	= ori;
	mNxScene		= ns;
	//mVehicleInfo.loadFromFile("carinfo.cfg");	
	mDecalShadow = NULL;

	VehicleWheel vw;
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);
	mWheels.push_back(vw);

	loadScene(fileName);

	//load parameter data from file
	Ogre::FileInfoListPtr fp = 
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Popular", fileName + ".vpf");
	Ogre::String total = fp->back().archive->getName() + "\\" + fileName + ".vpf";
	mVehicleParam.loadFromFile(total);
	refreshParameter();

	mCarNode = mBaseCarNode;

	//创建摄像机节点
	mCameraDerivedNode = mCarNode->createChildSceneNode(Ogre::Vector3(0.0f, mBoundingBox.getSize().y, -mBoundingBox.getSize().z*2));
	mVehicleCamer = new VehicleCamera(fileName + "VehicleCamera", mWindow, mSceneMgr);
	mVehicleCamer->setTarget(mCameraDerivedNode, mCarNode);
	mVehicleCamer->setTightness(2.5f);

	//获取VehicleCamera计算后得到的CameraNode
	mCameraNode = mVehicleCamer->getCameraNode();

	//创建车的附加物体外设
	createPeriphery();

	CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0), "Radial Blur");
	CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), "Radial Blur", false);

	tforce = ttortue = NxVec3(0, 0, 0);
	isJet = false;
}
Beispiel #2
0
bool GameState::loadSceneFile(Ogre::String filename,NXU::NXU_FileType type)
{
	bool success = false;

	if (mPhysicsSDK)
	{
		Ogre::String totalname;

		//获得完整文件路径
		Ogre::FileInfoListPtr svp = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Popular", filename);
		totalname = svp->back().archive->getName() + "/" + filename;
		Ogre::StringVector sv = Ogre::StringUtil::split(totalname, "/");
		totalname = sv[0];
		for (unsigned int i = 1;i<sv.size();i++)
			totalname += "\\\\" + sv[i];

		//读取场景
		NXU::NxuPhysicsCollection *c = NXU::loadCollection(totalname.c_str(), type );
		if ( c )
		{
			if (mPhysicScene)
			{
				mPhysicsSDK->releaseScene(*mPhysicScene);
			}

			if (mPhysicsSDK)
			{
				success = NXU::instantiateCollection( c, *mPhysicsSDK, 0, 0, 0);
				mPhysicScene = mPhysicsSDK->getScene(0);
			}
			NXU::releaseCollection(c);
		}
		else
		{
		}
	}

	return success;
}