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


C++ SimObj::dynamics方法代码示例

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


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

示例1: onAction

double RobotController::onAction(ActionEvent &evt)
{
	LOG_MSG(("\ncurrent time : %f", evt.time()));

	static int cnt = 0;

	try {
		const char *name = myname();
		SimObj *obj = getObj(name);
		obj->dump();
		if (!obj->dynamics()) {

			double angle = 2*PI*cnt*0.01;

			double xx = 5*sin(angle);
			double yy = 0.5;
			double zz = 5*cos(angle);
		
			LOG_MSG(("pos (%f, %f, %f)", xx, yy, zz));
			obj->setPosition(xx, yy, zz);
			obj->setAxisAndAngle(0.0, 1.0, 0.0, angle);
		}
		obj->dump();

	} catch(SimObj::NoAttributeException &) {
		
	} catch(SimObj::AttributeReadOnlyException &) {
		
	} catch(SimObj::Exception &) {
		
	}
	cnt++;

	return 0.1;
}
开发者ID:Aharobot,项目名称:SIGServer,代码行数:35,代码来源:GoRound.cpp

示例2: onAction

double DetectEntitiesController::onAction(ActionEvent &evt)
{
	std::vector<std::string> agents;
	std::vector<std::string>::iterator i;
	static int count = 0;

	//	LOG_MSG(("bear onAction(count=%d)\n", count));

	bool b = detectEntities(agents);
	if (b)
	{
		int n = agents.size();
		if (n>0)
		{
			LOG_MSG(("%d entities detected", n));
			for (int i=0; i<n; i++)
			{
				std::string name = agents[i];
				LOG_MSG(("[%d] (%s)", i, name.c_str()));
			}
		}
	}
	else
	{
		LOG_MSG(("detectEntities failed"));
	}

	try {
		SimObj *o = getObj(myname());
		if (o && !o->dynamics())
		{
			double deg = count * 10.0;
			double rad = -3.141592/180*deg;

			o->setAxisAndAngle(0.0, 1.0, 0.0, rad);
		}
	} catch(SimObj::NoAttributeException &) {
	} catch(SimObj::AttributeReadOnlyException &) {
	} catch(SimObj::Exception &) {
	}

	count++;

	return 2.0;
}
开发者ID:Aharobot,项目名称:SIGServer,代码行数:45,代码来源:scDetectEntities.cpp

示例3: onRecvMessage

void SetAttrController::onRecvMessage(RecvMessageEvent &evt)
{
	double x, y, z;

	LOG_MSG(("message from : %s", evt.getSender()));
	int n = evt.getSize();
	for (int i=0; i<n; i++) {
		LOG_MSG(("[%d] (%s)", i, evt.getString(i)));
	}

	SimObj *o = getObj(myname());

	if (n>0 && o && !o->dynamics()) {
		const char *cmd = evt.getString(0);
		if (cmd) {
			if (strcmp(cmd, "p")==0) {
				// ----------------------------
				//	position set (x, y, z)
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set position (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->setPosition(x, y, z);
					}
				}
			} else if (strcmp(cmd, "vp")==0) {
				// ----------------------------
				//	view pos
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set view position (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->vpx(x);
						o->vpy(y);
						o->vpz(z);
					}
				}
			} else if (strcmp(cmd, "vv")==0) {
				// ----------------------------
				//	view vector
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set view vector (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->vvx(x);
						o->vvy(y);
						o->vvz(z);
					}
				}
			} else if (strcmp(cmd, "lep")==0) {
				// ----------------------------
				//	left eye pos
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set left eye position (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->lepx(x);
						o->lepy(y);
						o->lepz(z);
					}
				}
			} else if (strcmp(cmd, "lev")==0) {
				// ----------------------------
				//	left eye vector
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set left eye vector (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->levx(x);
						o->levy(y);
						o->levz(z);
					}
				}
			} else if (strcmp(cmd, "rep")==0) {
				// ----------------------------
				//	right eye pos
				// ----------------------------
				const char *param = evt.getString(1);
				if (param) {
					LOG_MSG(("set right eye position (param=%s)", param));
					if (parseVector3(param, x, y, z)) {
						LOG_MSG(("(%f, %f, %f)", x, y, z));
						o->repx(x);
						o->repy(y);
						o->repz(z);
					}
				}
			} else if (strcmp(cmd, "rev")==0) {
				// ----------------------------
				//	right eye vector
//.........这里部分代码省略.........
开发者ID:SIGVerse,项目名称:SIGServer,代码行数:101,代码来源:scSetAttr.cpp


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