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


C++ BodyPart::getName方法代码示例

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


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

示例1: buildPartList

void Body::buildPartList(std::vector<GuiObjectLink*>* list, Part* p, int depth)
{
	//debug_print("Depth: %i, Part: %s \n", depth, p->getId());
	if (p->getType() == PartType::TYPE_ORGAN)
	{
		//Append to end of list "gui_list_indent_char [times depth] ORGAN_NAME"
		std::string str = "";

		for (int i = 0; i <= depth; i++)
		{
			str.append(gui_list_indent_char);
		}

		str.append(p->getName());

		list->push_back(
			new GuiObjectLink(
			p->getUUID(),
			new ColoredText(str, part_gui_list_color_organ)
			)
			);

		return;
	}
	if (p->getType() == PartType::TYPE_BODYPART)
	{
		//Append to end of list "gui_list_indent_char [times depth] BODYPART_NAME"
		BodyPart *bp = (BodyPart*)p;
		std::string str = "";

		for (int i = 0; i <= depth; i++)
		{
			str.append(gui_list_indent_char);
		}

		str.append(bp->getName());

		list->push_back(
			new GuiObjectLink(
			bp->getUUID(),
			new ColoredText(str, part_gui_list_color_bodypart)
			)
			);

		//Call this function on all children of the BodyPart
		for (auto it = bp->getChildListRW()->begin(); it != bp->getChildListRW()->end(); it++)
		{
			boost::shared_ptr<Part> part = getPartByUUID(*it);
			if (part == nullptr) { continue; }
			buildPartList(list, part.get(), depth + 1);
		}

		bp = nullptr;

		return;
	}

	debug_error("ERROR: Tried to call recursive part list building function on invalid Part* (neither TYPE_BODYPART nor TYPE_ORGAN)!\n");
	return;
}
开发者ID:bilwis,项目名称:RMD,代码行数:60,代码来源:Body.cpp

示例2: showBodyDetails

    void MainWindow::showBodyDetails( const Creature& creature, const BodyPart& body ) {
        getUiInspector().lst_body_details->addItem(QString(
                body.getName().c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                ("  Mass: " + TO_STRING(body.getMass())).c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                ("  Torque: " + TO_STRING(body.getMaxTorque())).c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                std::string("  Size").c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                ("  [x]: " + TO_STRING(body.getSizeX())).c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                ("  [y]: " + TO_STRING(body.getSizeY())).c_str()));
        getUiInspector().lst_body_details->addItem(QString(
                ("  [z]: " + TO_STRING(body.getSizeZ())).c_str()));
        //Angles

        BodyPart* parent = body.getParentId() == Creature::B_NONE
                ? NULL : &creature.getBodyPart(body.getParentId());
        if (parent) {
            getUiInspector().lst_body_details->addItem(QString(
                    ("  Parent: " + parent->getName()).c_str()));
            //            getUiInspector().lst_body_details->addItem(QString(std::string("  Angles:").c_str()));
            //            getUiInspector().lst_body_details->addItem(QString(
            //                    ("   XY:" + TO_STRING(
            //                    MathUtil::getAngle(MathUtil::XY,
            //                    parent->getRigidBody()->getCenterOfMassPosition(),
            //                    body.getRigidBody()->getCenterOfMassPosition()))).c_str()));
            //            getUiInspector().lst_body_details->addItem(QString(
            //                    ("   YZ:" + TO_STRING(
            //                    MathUtil::getAngle(MathUtil::YZ,
            //                    parent->getRigidBody()->getCenterOfMassPosition(),
            //                    body.getRigidBody()->getCenterOfMassPosition()))).c_str()));
            //            getUiInspector().lst_body_details->addItem(QString(
            //                    ("   ZX:" + TO_STRING(
            //                    MathUtil::getAngle(MathUtil::ZX,
            //                    parent->getRigidBody()->getCenterOfMassPosition(),
            //                    body.getRigidBody()->getCenterOfMassPosition()))).c_str()));
        }
    }
开发者ID:jcrada,项目名称:jcrada-creatures,代码行数:40,代码来源:OldMainWindowCreature.cpp

示例3: evalute_BodyPart

std::string evalute::evalute_BodyPart(Watch* watch)
{
    std::string name = watch->MemberName;
    std::string result = "";
    BodyPart* part = boost::get<BodyPart*>(watch->Object);

    if( name == "MaxKindleLevel") result = FloatToStr(part->getMaxKindleLevel());
    else if( name == "MaxDampness") result = FloatToStr(part->getMaxDampness());
    else if( name == "AcceptsCord") result = BoolToStr(part->getAcceptsCord());
    else if( name == "Name") result = part->getName();

    if(result == "") result = "Can't evalute";
    return result;
}
开发者ID:Phosfor,项目名称:Themisto,代码行数:14,代码来源:EvaluteFunctions.cpp

示例4: enter

string Body::enter(rapidxml::xml_node<> *node, std::map<string, string>* child_map, std::map<string, string>* organ_link_map) {
	using namespace rapidxml;

	int organ_count, bodyparts, it;
	xml_node<> *temp;
	xml_node<> **organ_node_list;

	char *id = nullptr, *name = nullptr, *_name = nullptr;
	float surface = 0.0f;

	//Make a count of the body_part nodes in this node and parse all standard
	// nodes for the bodypart of this node
	temp = node->first_node();
	bodyparts = 0;
	while (temp != nullptr){
		_name = temp->name();

		if (!strcmp(_name, "body_part")) { bodyparts++; }

		if (!strcmp(_name, "id")) { id = temp->value(); }
		if (!strcmp(_name, "name")) { name = temp->value(); }
		if (!strcmp(_name, "surface")) { surface = atof(temp->value()); }


		temp = temp->next_sibling();
	}

	//if any of the mandatory vars for bodyparts are NULL, ERROR!
	if (id == nullptr || name == nullptr){
		throw new bdef_parse_error("Not all mandatory BodyPart variables defined!", node);
	}

	//make the bodypart, make the pointer to it shared and store it in the part_map
	BodyPart* bp = new BodyPart((string)id, (string)name, surface, this);

	boost::shared_ptr<BodyPart> p (bp);

	part_map->insert(
		std::pair<std::string, boost::shared_ptr<Part>>(
		bp->getUUID(), boost::static_pointer_cast<Part>(p)));

	//reset temporary variables for reuse with the organs
	id = nullptr; name = nullptr;

	//DEBUG: Print new BodyPart
	debug_print("New BodyPart created: \n\tID: %s \n\tName: %s \n\tSurface: %f\n",
			bp->getId().c_str(), bp->getName().c_str(), bp->getSurface());

	//If there are no body_part nodes...
	if (bodyparts == 0){
		//...there must be organs instead!
		// variables
		Organ **organs;
		xml_attribute<> *attr;
		xml_node<> *tdef_node;

		char *connector = nullptr;
		bool symmetrical = false;

		it = 0;

		//  temp vars for tissue definitions
		char *tdef_id, *tdef_custom_id, *tdef_name;
		float tdef_hit_prob;

		tissue_def *tdefs = nullptr;
		int tdef_count = 0, tdef_it = 0;


		//Reset back to the first node in the given node
		temp = node->first_node();

		//scan for organ nodes in the given node
		organ_count = 0;
		while (temp != nullptr){
			if (!strcmp(temp->name(),"organ")) { organ_count++; }
			temp = temp->next_sibling();
		}

		//If there are no organs AND no bodyparts, ERROR!
		if (organ_count == 0){
			throw bdef_parse_error("No body part and no organ definition!", node);
		}

		//compile a list of nodes holding the organ definitions
		//and parse the remaining nodes to make the bodypart
		organ_node_list = new xml_node<>*[organ_count];
		temp = node->first_node();

		while (temp != nullptr){
			_name = temp->name();

			if (!strcmp(_name,"organ")) {
				organ_node_list[it] = temp;
				it++;
			}

			temp = temp->next_sibling();
		}

//.........这里部分代码省略.........
开发者ID:bilwis,项目名称:RMD,代码行数:101,代码来源:Body.cpp


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