当前位置: 首页>>代码示例>>C++>>正文


C++ DataLibrary::getData方法代码示例

本文整理汇总了C++中DataLibrary::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataLibrary::getData方法的具体用法?C++ DataLibrary::getData怎么用?C++ DataLibrary::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataLibrary的用法示例。


在下文中一共展示了DataLibrary::getData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Trigger

void MapDataManager::Trigger(std::string triggertype, LuaTempContext * tempcontext)
{
    if(tempcontext == NULL)
        return;
    DataLibrary* datalib = DataLibrary::getSingletonPtr();
    std::vector<std::string> triggerlist;
    triggerlist = datalib->getChildList("GameData/BattleData/Trigger");
    std::vector<std::string>::iterator ite;
    for(ite = triggerlist.begin(); ite != triggerlist.end(); ite++)
    {
        std::string datapath = std::string("GameData/BattleData/Trigger/") + (*ite);
        int active;
        datalib->getData(datapath,active);
        if(!active)
            continue;
        std::string type;
        datalib->getData(datapath + std::string("/type"),type);
        if(type != triggertype)
            continue;
        std::string context,filename,funcname;
        datalib->getData(datapath + std::string("/file"),filename);
        datalib->getData(datapath + std::string("/func"),funcname);
        datalib->getData(datapath + std::string("/context"),context);
        LuaSystem::getSingleton().executeFunction(filename,funcname,context,tempcontext);
    }
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:26,代码来源:MapDataManager.cpp

示例2: turnStart

void BattleSquad::turnStart()
{
	if (this->getUnitNum()==0)
	{
		return;
	}

	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	float ap = getAttr(ATTR_ACTIONPOINT,ATTRCALC_FULL);
	setActionPoint(ap);
	setAPSetup(0.0f);
	setAPBattle(0.0f);

	std::vector<std::string> activeskills;
	activeskills = datalib->getChildList(mPath + "/Skill");
	std::vector<std::string>::iterator ite;
	for(ite = activeskills.begin(); ite != activeskills.end(); ite++)
	{
		int cooldown = 0;
		datalib->getData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown);
		if(cooldown > 0)
			cooldown -= 1;
		datalib->setData(mPath + "/Skill/" + (*ite) + "/CoolDown", cooldown);
	}	

	LuaTempContext* luatempcontext = new LuaTempContext();
	luatempcontext->strMap["squadid"] = getSquadId();
	Trigger("TurnStart", luatempcontext);
	delete luatempcontext;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:30,代码来源:BattleSquad.cpp

示例3: getSkillApCost

float BattleSquad::getSkillApCost(std::string skillid)
{
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	std::vector<std::string> skilllist;
	skilllist = datalib->getChildList("StaticData/SkillData");
	std::vector<std::string>::iterator ite;
	ite = std::find(skilllist.begin(), skilllist.end(), skillid);
	if(ite == skilllist.end())
		return 0.0f;
	int skillaptype;
	float skillapcost;
	datalib->getData(str(boost::format("StaticData/SkillData/%1%/APType")%skillid),skillaptype);
	datalib->getData(str(boost::format("StaticData/SkillData/%1%/APCost")%skillid),skillapcost);
	switch(skillaptype)
	{
	case SKILLAPTYPE_SETUP:
	case SKILLAPTYPE_BATTLE:
		return getAPTypeCostModify(skillaptype) + skillapcost;
	case SKILLAPTYPE_DEFENCE:
		{
			float ap = getActionPoint();
			return (ap > skillapcost)?ap:skillapcost;
		}
	}
	return 0.0f;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:26,代码来源:BattleSquad.cpp

示例4: loadMapFormSave

bool MapLoader::loadMapFormSave()
{
	DataLibrary* datalibrary = DataLibrary::getSingletonPtr();
	int mapsize;
	datalibrary->getData("GameData/BattleData/MapData/MapSize", mapsize);
	MapDataManager::getSingleton().mMapSize = mapsize;
	std::vector<std::string> arealist = datalibrary->getChildList("GameData/BattleData/MapData/Area");
	std::vector<std::string>::iterator ite = arealist.begin();
	for( ; ite != arealist.end(); ite++)
	{
		Area area(str(boost::format("GameData/BattleData/MapData/Area/%1%/CoordList")%(*ite)));
		MapDataManager::getSingleton().mMapArea.insert(std::make_pair(*ite, area));
	}
	Terrain::getSingleton().createTerrain();
	std::string music;
	datalibrary->getData("GameData/StoryData/MusicName", music);
	AudioSystem::getSingleton().playStream(music,true,2000);
	return true;
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:19,代码来源:Maploader.cpp

示例5: getPassable

bool MapDataManager::getPassable(int x, int y, int faction)
{
    //PROFILE_FUNC();
    if(x < 0 || x >= mMapSize || y < 0 || y >= mMapSize)
        return false;
    DataLibrary* datalib = DataLibrary::getSingletonPtr();
    int maxpassable;
    int minpassable;
    int passable;
    int id;
    std::string path = std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(getGridId(x, y));
    bool re = datalib->getData(path + std::string("/GroundType"), id);
    std::string ground;
    datalib->getData(str(boost::format("GameData/BattleData/MapData/Ground/G%1%")%id),ground);
    re = datalib->getData(str(boost::format("StaticData/GroundData/%1%/GroundModifier/Passable")%ground), passable);
    maxpassable = passable;
    minpassable = passable;
    re = datalib->getData(path + std::string("/TerrainType"), id);
    re = datalib->getData(std::string("StaticData/TerrainData/Terrain") + Ogre::StringConverter::toString(id) + std::string("/GroundModifier/Passable"), passable);
    maxpassable = (maxpassable > passable)? maxpassable:passable;
    minpassable = (minpassable < passable)? minpassable:passable;
    std::string groundobj;
    re = datalib->getData(path + std::string("/MapObjType"), groundobj,true);
    if(re)
    {
        path = str(boost::format("StaticData/MapObjType/%1%/GroundModifier/Passable")%groundobj);
        re = datalib->getData(path, passable);
        maxpassable = (maxpassable > passable)? maxpassable:passable;
        minpassable = (minpassable < passable)? minpassable:passable;
    }

    //¶îÍâÐÞÕý

    //С¶Ó×èµ²
    if(faction >= 0)
    {
        BattleSquadManager* battlesquadmanager = BattleSquadManager::getSingletonPtr();
// 		BattleSquadManager::BattleSquadIte ite;
// 		for(ite = battlesquadmanager->mSquadList.begin(); ite != battlesquadmanager->mSquadList.end(); ite++)
// 		{
// 			int xx = ite->second->getGridX();
// 			int yy = ite->second->getGridY();
// 			if(xx ==x && yy == y)
// 				return false;
// 		}
        BattleSquad* squad = battlesquadmanager->getBattleSquadAt(x, y, faction, true);
        if(squad)
            return false;
    }

    if(maxpassable == 2)
        return true;
    if(minpassable == 0)
        return false;
    return true;
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:56,代码来源:MapDataManager.cpp

示例6: loadMapObj

void MapLoader::loadMapObj()
{
	DataLibrary* datalibrary = DataLibrary::getSingletonPtr();
	Terrain* terrain = Terrain::getSingletonPtr();
	std::string datapath("GameData/BattleData/MapData/MapObjModleInfo");
	std::vector<std::string> childlist;
	childlist = datalibrary->getChildList(datapath);
	if(childlist.size()>0)
	{
		for(unsigned int n = 0; n < childlist.size(); n++)
		{
			std::string meshname;
			int x,y,dir;
			datalibrary->getData(datapath + std::string("/") + childlist[n] + std::string("/Mesh"),meshname);
			datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridX"),x);
			datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridY"),y);
			datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/Direction"),dir);
			int index;
			index = terrain->createMapObj(x,y,meshname, dir);
			datalibrary->setData(datapath + std::string("/") + childlist[n] + std::string("/Index"),index);
		}
	}
	datapath = "GameData/BattleData/MapData/MapParticleInfo";
	childlist = datalibrary->getChildList(datapath);
	if(childlist.size()>0)
	{
		for(unsigned int n = 0; n < childlist.size(); n++)
		{
			std::string particlename;
			int x,y;
			datalibrary->getData(datapath + std::string("/") + childlist[n] + std::string("/Particle"),particlename);
			datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridX"),x);
			datalibrary->getData(datapath + std::string("/") +childlist[n] + std::string("/GridY"),y);
			int index;
			index = terrain->createMapParticle(x,y,particlename);
			datalibrary->setData(datapath + std::string("/") + childlist[n] + std::string("/Index"),index);
		}
	}
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:39,代码来源:Maploader.cpp

示例7: getCovert

float MapDataManager::getCovert(int x, int y, int faction)
{
    TerrainType t = getTerrainType(x,y);
    GroundType g = getGroundType(x,y);
    float terraincost;
    float groundcost;
    std::string ground;
    DataLibrary::getSingleton().getData(str(boost::format("GameData/BattleData/MapData/Ground/G%1%")%g),ground);
    bool re = DataLibrary::getSingleton().getData(str(boost::format("StaticData/GroundData/%1%/GroundModifier/Covert")%ground), groundcost);
    re = DataLibrary::getSingleton().getData(std::string("StaticData/TerrainData/Terrain") + Ogre::StringConverter::toString(t) + std::string("/GroundModifier/Covert"), terraincost);
    DataLibrary* datalib = DataLibrary::getSingletonPtr();
    std::string path =  std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(getGridId(x, y));
    std::string groundobj;
    float groundobjcost = 0.0f;
    re = datalib->getData(path + std::string("/MapObjType"), groundobj, true);
    if(re)
    {
        path = str(boost::format("StaticData/MapObjType/%1%/GroundModifier/Covert")%groundobj);
        re = datalib->getData(path, groundobjcost);
    }
    return groundcost + terraincost + groundobjcost;
}
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:22,代码来源:MapDataManager.cpp

示例8: useSkillAt

bool BattleSquad::useSkillAt(int x, int y, std::string skillid)
{
	if(canUseSkill(skillid) != SKILLSTATE_AVAILABLE)
		return false;
		DataLibrary* datalib = DataLibrary::getSingletonPtr();
	std::string skillpath = getPath() + std::string("/Skill/") + skillid;
	std::string skillinfopath = std::string("StaticData/SkillData/")+ skillid;
	std::string skillscript;
	datalib->getData(skillinfopath + std::string("/Script"),skillscript);
	LuaTempContext* context = new LuaTempContext;
	context->strMap.insert(std::make_pair("squadid", getSquadId()));
	context->intMap.insert(std::make_pair("targetx", x));
	context->intMap.insert(std::make_pair("targety", y));
	context->intMap.insert(std::make_pair("castsuccess", 0));
	bool re = LuaSystem::getSingleton().executeFunction(skillscript, "useskill" , skillpath + std::string("/ScriptContext"), context);
	if(re)
	{
		if(context->intMap["castsuccess"] == 1)
		{
			float apcost = getSkillApCost(skillid);
			float apleft = getActionPoint() - apcost;
			setActionPoint(apleft);
			int aptype = SKILLAPTYPE_BATTLE;
			datalib->getData(skillinfopath + "/APType", aptype);
			if(aptype != SKILLAPTYPE_DEFENCE)
			{
				apcost = getAPTypeCostModify(aptype);
				apcost += 1.0f;
				setAPTypeCostModify(aptype, apcost);
			}
			int cooldown;
			datalib->getData(skillinfopath + "/CoolDown", cooldown);
			datalib->setData(skillpath + "/CoolDown", cooldown);
		}
	}
	delete context;
	return false;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:38,代码来源:BattleSquad.cpp

示例9: canUseSkill

BattleSquad::SkillState BattleSquad::canUseSkill(std::string skillid)
{
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	std::vector<std::string> activeskills;
	activeskills = datalib->getChildList(mPath + "/Skill");
	std::vector<std::string>::iterator ite;
	ite = std::find(activeskills.begin(), activeskills.end(), skillid);
	if(ite == activeskills.end())
		return SKILLSTATE_NOSKILL;
	if(getActionPoint() < getSkillApCost(skillid))
		return SKILLSTATE_NOTAVAILABLE;
	int cooldown = 0;
	datalib->getData(mPath + "/Skill/" + skillid + "/CoolDown", cooldown);
	if(cooldown > 0)
		return SKILLSTATE_NOTAVAILABLE;
	return SKILLSTATE_AVAILABLE;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:17,代码来源:BattleSquad.cpp

示例10: getAttackRolls

AttackInfo BattleSquad::getAttackRolls(bool rangedattack,bool asdefender, int d)
{
	DataLibrary *datalib = DataLibrary::getSingletonPtr();
	AttackInfo attackinfo;
	int soildernum = getUnitNum();
	int atktime =  floor((-0.010907f) * soildernum * soildernum  + 1.37256f * soildernum+ 8.638347f + 0.5f);
	if(asdefender)
	{
		attackinfo.AtkTime = atktime * getAttr(ATTR_CONTER,ATTRCALC_FULL) / 10.0f;
	}
	else
	{
		attackinfo.AtkTime = atktime;
	}

	float atkf;
	if(rangedattack)
	{
		atkf = getAttr(ATTR_RANGEDATTACK, ATTRCALC_FULL);
	}
	else
	{
		atkf = getAttr(ATTR_ATTACK, ATTRCALC_FULL);
		float formation;
		formation = getAttr(ATTR_FORM, ATTRCALC_FULL);
		formation = (formation < 0.0f)?0.0f:formation;
		formation = formation * soildernum / 50.0f;
		int formtype = getFormation();
		int mydir = getDirection();
		int side = GetSide(mydir,d);
		formation *= GetFormationBonus(side, formtype);
		atkf += formation;
	}
	attackinfo.Atk = atkf;

	std::string soilderid = getSoilderId();
	float randomness;
	datalib->getData(std::string("StaticData/SoilderData/") + soilderid + std::string("/Randomness"),randomness);
	attackinfo.Randomness = randomness;

	return attackinfo;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:42,代码来源:BattleSquad.cpp

示例11: loadMapFormFile


//.........这里部分代码省略.........
	//delete element;

	//element = doc.FirstChildElement("MapObject");
	element = doc.first_node("MapObject");
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child; child =child->next_sibling())
	{
		std::string objname;
		//child->GetValue(&objname);
		objname = child->name();
		datapath = std::string("GameData/BattleData/MapData/MapObjModleInfo/") + objname;
		int objx,objy, objdir;
		std::string meshname,objtype;
		//child->GetAttribute("GridX",&objx);
		rapidxml::xml_attribute<> *attr = child->first_attribute("GridX");
		objx = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("GridY",&objy);
		attr = child->first_attribute("GridY");
		objy = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("Mesh",&meshname);
		attr=child->first_attribute("Mesh");
		meshname = attr->value();
		//child->GetAttribute("Type",&objtype);
		attr=child->first_attribute("Type");
		objtype = attr->value();
		attr=child->first_attribute("Direction");
		objdir = Ogre::StringConverter::parseInt(attr->value());
		datalibrary->setData(datapath + "/GridX", objx);
		datalibrary->setData(datapath + "/GridY", objy);
		datalibrary->setData(datapath + "/Mesh", meshname);
		datalibrary->setData(datapath + "/Direction", objdir);
		//物品类型脚本
		std::string mapobjscript("none");
		datalibrary->getData(str(boost::format("StaticData/MapObjType/%1%/Script")%objtype), mapobjscript);
		datapath = std::string("GameData/BattleData/MapData/Map/M") + Ogre::StringConverter::toString(MapDataManager::getSingleton().getGridId(objx, objy)) + std::string("/MapObjType");
		if(mapobjscript != "none")
		{
			MapObjScriptInfo scriptinfo;
			scriptinfo.x = objx;
			scriptinfo.y = objy;
			scriptinfo.script = mapobjscript;
			scriptinfo.path = datapath + "/ScriptContext";
			mMapObjScriptInfo.push(scriptinfo);
		}
		datalibrary->setData(datapath, objtype);
		datalibrary->setData(datapath + "/MapObjModuleId", objname);
	}
	//delete element;

	//element = doc.FirstChildElement("MapEffect");
	element = doc.first_node("MapEffect");
	//for(child = child.begin(element); child != child.end(); child++)
	for(child = element->first_node(); child; child =child->next_sibling())
	{
		std::string particlename;
		//child->GetValue(&particlename);
		particlename = child->name();
		datapath = std::string("GameData/BattleData/MapData/MapParticleInfo/") + particlename;
		int particlex,particley;
		std::string name;
		//child->GetAttribute("GridX",&particlex);
		rapidxml::xml_attribute<> *attr = child->first_attribute("GridX");
		particlex = Ogre::StringConverter::parseInt(attr->value());
		//child->GetAttribute("GridY",&particley);
		attr = child->first_attribute("GridY");
		particley = Ogre::StringConverter::parseInt(attr->value());
开发者ID:parhelia512,项目名称:fdux-slg-game,代码行数:67,代码来源:Maploader.cpp

示例12: init

bool BattleSquad::init(std::string srcpath, int team, int unitnum, int x, int y, int d)
{
	if(!Squad::init(srcpath))
		return false;
	DataLibrary *datalib = DataLibrary::getSingletonPtr();
	setTeam(team);
	setGridX(x);
	setGridY(y);
	setDirection(d);

	setUnitNum(unitnum);
	int squadtype2;
	datalib->getData(srcpath + std::string("/Type"), squadtype2);
	if(squadtype2 == SQUAD_NORMAL)
	{
		setUnitMaxNum(unitnum);
		setFormation(Line);
	}
	else
	{
		setUnitMaxNum(20);
		setFormation(Loose);
	}

	float covert;
	covert = getAttr(ATTR_COVERT, ATTRCALC_FULL);
	if(covert > 0.0f)
	{
		switch(getFaction())
		{
		case 0:
			setViewbyPlayer(1);
			setViewbyEnemy1(0);
			setViewbyEnemy2(0);
			setViewbyEnemy3(0);
			break;
		case 1:
			setViewbyPlayer(0);
			setViewbyEnemy1(1);
			setViewbyEnemy2(0);
			setViewbyEnemy3(0);
			break;
		case 2:
			setViewbyPlayer(0);
			setViewbyEnemy1(0);
			setViewbyEnemy2(1);
			setViewbyEnemy3(0);

			break;
		case 3:
			setViewbyPlayer(0);
			setViewbyEnemy1(0);
			setViewbyEnemy2(0);
			setViewbyEnemy3(1);
			break;
		}
	}
	else
	{
		setViewbyPlayer(1);
		setViewbyEnemy1(1);
		setViewbyEnemy2(1);
		setViewbyEnemy3(1);
	}

	setAmbushPlayer(0);
	setAmbushEnemy1(0);
	setAmbushEnemy2(0);
	setAmbushEnemy3(0);

	setActionPoint(0.0f);
	setAPSetup(0.0f);
	setAPBattle(0.0f);
	return true;
}
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:75,代码来源:BattleSquad.cpp

示例13: getAttr

float BattleSquad::getAttr(int attrtype , int calctype)
{
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	std::vector<std::string> modifierlist = datalib->getChildList(mPath + std::string("/ModifierList"));
	if(modifierlist.size() == 0)
		return 0.0f;
	if(attrtype == ATTR_RANGEDDEFENCE )
		attrtype = ATTR_DEFENCE;
	float base = 0.0f;
	float mbouse = 0.0f;
	float mbane = 0.0f;
	float resist = 0.0f;
	float cbouse = 0.0f;
	float cbane = 0.0f;
	std::vector<std::string>::iterator ite;
	for(ite = modifierlist.begin(); ite != modifierlist.end(); ite++)
	{
		int type = ATTRMODIFIER_BASE;
		float attrval = 0.0f;
		std::string datapath = mPath + std::string("/ModifierList/") + (*ite);
		datalib->getData(datapath + std::string("/Type"), type);
		switch(attrtype)
		{
		case ATTR_ATTACK:
			datalib->getData(datapath + std::string("/Attack"), attrval);
			break;
		case ATTR_RANGEDATTACK:
			datalib->getData(datapath + std::string("/RangedAttack"), attrval);
			break;
		case ATTR_DEFENCE:
			datalib->getData(datapath + std::string("/Defence"), attrval);
			break;
		case ATTR_FORM:
			datalib->getData(datapath + std::string("/Formation"), attrval);
			break;
		case ATTR_INITIATIVE:
			datalib->getData(datapath + std::string("/Initiative"), attrval);
			break;
		case ATTR_ACTIONPOINT:
			datalib->getData(datapath + std::string("/ActionPoint"), attrval);
			break;
		case ATTR_DETECTION:
			datalib->getData(datapath + std::string("/Detection"), attrval);
			break;
		case ATTR_COVERT:
			datalib->getData(datapath + std::string("/Covert"), attrval);
			break;
		case ATTR_TOUGHNESS:
			datalib->getData(datapath + std::string("/Toughness"), attrval);
			break;
		case ATTR_CONTER:
			datalib->getData(datapath + std::string("/Conter"), attrval);
			break;
		}
		switch(type)
		{
		case ATTRMODIFIER_BASE:
			base += attrval;
			break;
		case ATTRMODIFIER_MAGIC:
			if(attrval > mbouse)
				mbouse = attrval;
			if(attrval < mbane)
				mbane = attrval;
			break;
		case ATTRMODIFIER_COMMAND:
			if(attrval > cbouse)
				cbouse = attrval;
			if(attrval < cbane)
				cbane = attrval;
			break;
		case ATTRMODIFIER_RESISTANCE:
			if(attrval > resist)
				resist = attrval;
			break;
		}
	}
	float bouse = cbouse + mbouse;
	float bane = cbane + mbane;
	float terrainbouse = 0.0f;
	switch(attrtype)
	{
		case ATTR_DEFENCE:
			terrainbouse = MapDataManager::getSingleton().getDefModify(getGridX(), getGridY(), getTeam());
			break;
		case ATTR_COVERT:
			terrainbouse = MapDataManager::getSingleton().getCovert(getGridX(), getGridY(), getTeam());
			break;
	}
	if(terrainbouse > 0.0f)
		bouse += terrainbouse;
	else
		bane += terrainbouse;
	if(bane < -resist)
	{
		bane += resist;
		resist = 0.0f;
	}
	else
	{
//.........这里部分代码省略.........
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:101,代码来源:BattleSquad.cpp

示例14: createTerrain

bool Terrain::createTerrain()
{

	if(mMainViewport == NULL) 
		mMainViewport = Core::getSingleton().mCamera->getViewport();
	Ogre::CompositorManager::getSingleton().addCompositor(mMainViewport, "DemoCompositor");
	Ogre::CompositorManager::getSingleton().setCompositorEnabled(mMainViewport, "DemoCompositor", true);

	mMapData = MapDataManager::getSingletonPtr();
	DataLibrary* datalib = DataLibrary::getSingletonPtr();
	int terrainszie = mMapData->getMapSize() + 2 * MAPBOLDER + 1;

	Core::getSingleton().mSceneMgr->setSkyBox(true, "SkyBox",200);

	Ogre::GpuSharedParametersPtr sharedparams = Ogre::GpuProgramManager::getSingleton().getSharedParameters("TestSharedParamsName");
	float border = mMapData->getMapSize() * 12.0f;
	sharedparams->setNamedConstant("border", border);

	//创建灯光
	Core::getSingleton().mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
	mLight = Core::getSingleton().mSceneMgr->createLight("TerrainLight");
	mLight->setType(Ogre::Light::LT_DIRECTIONAL);
	mLight->setPosition(-500.0f,500.0f, 500.0f);
	mLight->setDirection(1.0f, -1.0f, -1.0f);
	mLight->setDiffuseColour(Ogre::ColourValue(0.5f, 0.5f,0.5f));
	mLight->setSpecularColour(Ogre::ColourValue(0.8f, 0.8f,0.8f));

	//设置深度图投影
	Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName("shadowdepthmap");
	if(tex.isNull())
		tex = Ogre::TextureManager::getSingleton().createManual("shadowdepthmap",
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 2048, 2048, 0, Ogre::PF_FLOAT16_R, Ogre::TU_RENDERTARGET);
	mShadowDepthMapTarget = tex->getBuffer()->getRenderTarget();
	Ogre::Viewport* vp = mShadowDepthMapTarget->addViewport(CameraContral::getSingleton().getShadowMapCamera());
	vp->setSkiesEnabled(false);
	vp->setOverlaysEnabled(false);
	vp->setVisibilityMask(VISMASK_OPAQUE);
	vp->setMaterialScheme("WriteDepthMap");
	vp->setBackgroundColour(Ogre::ColourValue(1.0f,1.0f,1.0f));
	mShadowDepthMapTarget->addListener(this);
	//弱爆了……
	Ogre::MaterialPtr mat;
	mat = Ogre::MaterialManager::getSingleton().getByName("TerrainTile");
	Ogre::AliasTextureNamePairList texAliasList;
	std::string texname;
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse1",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse2",texname));
	datalib->getData("GameData/BattleData/MapData/Ground/G3Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse3",texname));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat1");
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat2");
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat3");
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("CliffMat4");
	datalib->getData("GameData/BattleData/MapData/Ground/G3Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat1");
	datalib->getData("GameData/BattleData/MapData/Ground/G0Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat2");
	datalib->getData("GameData/BattleData/MapData/Ground/G1Tex",texname);
	texAliasList.insert(std::make_pair("Diffuse",texname));
	texAliasList.insert(std::make_pair("Diffuse1","Cliff.tga"));
	mat->applyTextureAliases(texAliasList);
	texAliasList.clear();

	mat = Ogre::MaterialManager::getSingleton().getByName("BankMat3");
	datalib->getData("GameData/BattleData/MapData/Ground/G2Tex",texname);
//.........这里部分代码省略.........
开发者ID:weimingtom,项目名称:fdux-slg-game,代码行数:101,代码来源:Terrain.cpp


注:本文中的DataLibrary::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。