• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ setDirection函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setDirection函数的典型用法代码示例。如果您正苦于以下问题:C++ setDirection函数的具体用法?C++ setDirection怎么用?C++ setDirection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: planRoute

void TREnemy::moveAlongPath(){
    planRoute(false);
    if(path.empty()){
        return;
    }
    int topX = path.front().first;
    int topY = path.front().second;
    int curX = getX();
    int curY = getY();
    if(!undoed && curX != topX){
        if(std::abs(curX - topX) < vel){
            if(curX > topX){
                setDirection(TRDirectionLeft);
                curX = topX;
            }else{
                setDirection(TRDirectionRight);
                curX = topX;
            }
        }else{
            if (curX > topX) {
                setDirection(TRDirectionLeft);
                curX -= vel;
            }else{
                setDirection(TRDirectionRight);
                curX += vel;
            }
        }
        if(curX == topX && curY == topY){
            path.pop();
        }
        setX(curX);
        return;
    }
    if(curY != topY){
        undoed = false;
        if(std::abs(curY - topY) < vel){
            if(curY > topY){
                setDirection(TRDirectionUp);
                curY = topY;
            }else{
                setDirection(TRDirectionDown);
                curY = topY;
            }
        }else{
            if (curY > topY) {
                setDirection(TRDirectionUp);
                curY -= vel;
            }else{
                setDirection(TRDirectionDown);
                curY += vel;
            }
        }
        if(curX == topX && curY == topY){
            path.pop();
        }
        setY(curY);
        return;
    }
    if(curX == topX && curY == topY){
        path.pop();
    }
    return;
}
开发者ID:hahaschool,项目名称:TombRaider,代码行数:63,代码来源:TREnemy.cpp


示例2: pcrotor_stop

static int
pcrotor_stop(ROT *rot)
{
  /* CW=0, CCW=0, Power-up=0 */
  return setDirection(&rot->state.rotport, 0);
}
开发者ID:DF4OR,项目名称:hamlib,代码行数:6,代码来源:pcrotor.c


示例3: plane

void App::createScene()
{
#pragma region Plane
	// Define the mathematical plane
	Ogre::Plane plane(Vector3::UNIT_Y, 0);
	
	// Create the plane into memory
	Ogre::MeshManager::getSingleton().createPlane(
		"plane",
		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		plane,
		500, 500, // size
		25, 25,   // how many quads are used to make the plane
		true,
		1, 5, 5, Vector3::UNIT_Z);

	// Create an instance of the plane
	auto planeEnt = mSceneMgr->createEntity("PlaneEntity", "plane");
	planeEnt->setMaterialName("Examples/BeachStones");

	// Create a node for the plane and attach he plane to it
	mSceneMgr->getRootSceneNode()->createChildSceneNode("planeNode")->attachObject(planeEnt);
#pragma endregion

#pragma region Lights
	// Directional
	auto sunlight = mSceneMgr->createLight("sun");
	sunlight->setType(Ogre::Light::LT_DIRECTIONAL);
	sunlight->setDirection(Ogre::Vector3(0, -1, -1));
	sunlight->setDiffuseColour(Ogre::ColourValue(.30, .30, 0));
	sunlight->setSpecularColour(Ogre::ColourValue(.30, .30, 0));

	// Spotlight
	auto spotlight = mSceneMgr->createLight("spotlight");
	spotlight->setType(Ogre::Light::LT_SPOTLIGHT);
	
	spotlight->setSpotlightRange(
		Ogre::Degree(5.0f),  // inner angle
		Ogre::Degree(15.0f), // outer angle
		0.0f);               // falloff
	
	spotlight->setDiffuseColour(Ogre::ColourValue(1.0f, 0.0f, 0.0f));

	// Sphere to visualize the spotlights source
	auto sphereEnt = mSceneMgr->createEntity("sphere", "sphere.mesh");
	sphereEnt->setMaterialName("Examples/checker");
	auto sphereNode = mSceneMgr->getSceneNode("planeNode")->createChildSceneNode("spotlightNode");
	sphereNode->attachObject(sphereEnt);
	sphereNode->attachObject(spotlight);
	sphereNode->scale(0.02f, 0.02f, 0.02f);
	sphereNode->translate(0.0f, 15.0f, 0.0f);
	sphereNode->lookAt(Ogre::Vector3(0, 0, 0), Ogre::Node::TS_PARENT);
#pragma endregion

#pragma region Entities
	std::array<Ogre::Entity*, 6> entities;
	auto entParentNode = mSceneMgr->getSceneNode("planeNode")->createChildSceneNode("entParentNode");

	float angleOffset = 360.0f / 6.0f;
	float radius = 30.0f;

	for (int i = 0; i < entities.size(); ++i)
	{
		auto e = mSceneMgr->createEntity("Sinbad.mesh");
		entParentNode->createChildSceneNode(Ogre::Vector3(
			radius * Math::Cos(Math::DegreesToRadians(angleOffset * i)),  // x = r cos(t)
			6.75f,                                                        // y = height
			radius * Math::Sin(Math::DegreesToRadians(angleOffset * i)))) // z = r sin(t)
		->attachObject(e);
	}

	// Barrel
	auto barrel = mSceneMgr->createEntity("barrel.mesh");
	mSceneMgr->getSceneNode("planeNode")->createChildSceneNode("barrel", Ogre::Vector3(0, 2.5f, 0))->attachObject(barrel);
#pragma endregion

	// Skybox
	mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 5000, false);
}
开发者ID:ZachMassia,项目名称:GAME303,代码行数:79,代码来源:App.cpp


示例4: vec

// -----------------------------------------------------------------------------------------
void CPepeEngineCamera::setDirection(float x, float y, float z)
{
    CPepeEngineVector3 vec(x, y, z);
    setDirection(vec);
}
开发者ID:pepewuzzhere,项目名称:PepeEngine,代码行数:6,代码来源:CPepeEngineCamera.cpp


示例5: getStudentWorld

int FrackMan::doSomething() {
	//check if collided with dirt
	bool removedDirt = false;
	for (int i = getX(); i < getX() + 4; i++) {
		for (int j = getY(); j < getY() + 4; j++) {
			if (getStudentWorld()->isDirt(i, j)) {
				getStudentWorld()->removeDirt(i, j);
				removedDirt = true;
			}
		}
	}
	if (removedDirt) {
		getStudentWorld()->playSound(SOUND_DIG);
		getStudentWorld()->setUpdateSearch();
	}
	int ch;
	int originalX = getX(), originalY = getY();
	if (getStudentWorld()->getKey(ch)) {
		switch (ch) {
		case KEY_PRESS_UP: case 'W':
			if (getDirection() == up) moveTo(getX(), getY() + 1);
			else setDirection(up); break;
		case KEY_PRESS_DOWN: case 'S':
			if (getDirection() == down) moveTo(getX(), getY() - 1);
			else setDirection(down); break;
		case KEY_PRESS_RIGHT: case 'D':
			if (getDirection() == right) moveTo(getX() + 1, getY());
			else setDirection(right); break;
		case KEY_PRESS_LEFT: case 'A':
			if (getDirection() == left) moveTo(getX() - 1, getY());
			else setDirection(left); break;
		case KEY_PRESS_TAB:
			if (gold > 0) {
				gold--;
				getStudentWorld()->useGold();
			}
			break;
		case KEY_PRESS_SPACE:
			if (water > 0) {
				water--;
				getStudentWorld()->useWater();
			}
			break;
		case 'z': case 'Z':
			if (sonar > 0) {
				sonar--;
				getStudentWorld()->useSonar();
			}
			break;
		case KEY_PRESS_ESCAPE: return Actor::PLAYER_DIED;
		default: moveTo(originalX, originalY); break;
		}

		//check if collided with edges
		if (getX() < 0 || getY() < 0 || getX() > VIEW_WIDTH - 4 * getSize() || getY() > VIEW_HEIGHT - 4 * getSize())
			for (int i = 0; i < 4; i++) moveTo(originalX, originalY); //run moveTo multiple times to run through animation
		//check collisions with boulders and makes some objects visible if they are close enough
		getStudentWorld()->frackmanCollisions(this, originalX, originalY);
	}
	if(health > 0) return Actor::CONTINUE;
	else return Actor::PLAYER_DIED;
}
开发者ID:preethamrn,项目名称:FrackMan,代码行数:62,代码来源:Actor.cpp


示例6: setDirection

//
// Private slots
//
void QuickFindMux::changeQuickFind(
        const QString& new_pattern, QFDirection new_direction )
{
    pattern_->changeSearchPattern( new_pattern );
    setDirection( new_direction );
}
开发者ID:devpack,项目名称:glogg,代码行数:9,代码来源:quickfindmux.cpp


示例7: updateView

void ElCamera::lookAt(const D3DXVECTOR3& targetPoint)
{
	updateView();
	setDirection(targetPoint - mRealPosition);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:5,代码来源:ElCamera.cpp


示例8: GPIO_init

static int
GPIO_init(GPIO *self, PyObject *args, PyObject *kwds)
{
	int fd = -1;
	int gpio = -1;
	
	PyObject * direction = NULL;
	PyObject * trigger = NULL;
	PyObject * tmp = NULL;

	static char *kwlist[] = { "gpio", "direction", "trigger", NULL };

	if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|OO:__init__",
			kwlist, &gpio, &direction, &trigger ) )
		return -1;

	if (gpio < 0)
		return -1;

	self->gpio = gpio;

	GPIO_VALUE( gpio, self->v_path );
	if ( ( fd = open( self->v_path, O_RDWR, 0 ) ) == -1 ) {
		// try to get gpio exported:
		if ( exportGpio( gpio ) == 0 ) {
			// check if export was (really) successful
			
			if ( ( fd = open( self->v_path, O_RDWR ) ) == -1) {
				// export failed
				PyErr_SetFromErrno( PyExc_IOError );
				return -1;
			}
		} else {
			PyErr_SetString( PyExc_StandardError,
				"Export failed." );
			return -1;
		}
	}

	GPIO_EDGE(gpio, self->e_path);
	GPIO_DIREC(gpio, self->d_path);

	self->fd_val = fd;
	if ( ( self->fd_dir = open( self->d_path, O_RDWR ) ) == -1 ) {
		return -1;
	}

	if ( ( self->fd_edge = open( self->e_path, O_RDWR ) ) == -1 ) {
		return -1;
	}

	if (direction) {
		setDirection( self, direction );
		tmp = self->direction;
		Py_INCREF(direction);
		self->direction = direction;
		Py_XDECREF(tmp);
	} else {
		// no direction requested, use current
		Py_XDECREF(self->direction);
		self->direction = getDirection( self );
		Py_INCREF(self->direction);
	}

	if (trigger) {
		setTrigger( self, trigger );
		tmp = self->trigger;
		Py_INCREF(trigger);
		self->trigger = trigger;
		Py_XDECREF(tmp);
	} else {
		// no trigger requested, use current
		Py_XDECREF(self->trigger);
		self->trigger = getTrigger( self );
		Py_INCREF(self->trigger);
	}

	return 0;
}
开发者ID:rascalmicro,项目名称:pyap7k,代码行数:79,代码来源:gpiomodule.c


示例9: inPlaceTurn

void inPlaceTurn(int degrees, int maxSpeed, int accel, int decel)
{	
	setDirection(0, 1);
	straight(degrees * 42, 0, maxSpeed, 0, accel, decel);
}
开发者ID:JMarple,项目名称:FFRobot2014,代码行数:5,代码来源:FFRModel_StepperControl.c


示例10: setId

ParticleState::ParticleState(int id, double E, Vector3d pos, Vector3d dir) {
	setId(id);
	setEnergy(E);
	setPosition(pos);
	setDirection(dir);
}
开发者ID:phyytang,项目名称:CRPropa3,代码行数:6,代码来源:ParticleState.cpp


示例11: setNormalIrradiance

// Constructor
Light::Light(Rgb normalIrradiance, Rgb ambientIrradiance, Vector3 direction)
{
	setNormalIrradiance(normalIrradiance);
	setAmbientIrradiance(ambientIrradiance);
	setDirection(direction);
}	
开发者ID:jadmr,项目名称:CS548_BasicRayTracer,代码行数:7,代码来源:light.cpp


示例12: nlassert

void CStreamSource::play()
{
	nlassert(!_Playing);
	bool play = false;
	CAudioMixerUser *mixer = CAudioMixerUser::instance();
	
	{
		CAutoMutex<CMutex> autoMutex(m_BufferMutex);
		
		//if ((mixer->getListenPosVector() - _Position).sqrnorm() > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance())
		if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance())
		{
			// Source is too far to play
			if (_Spawn)
			{
				if (_SpawnEndCb != NULL)
					_SpawnEndCb(this, _CbUserParam);
				delete this;
			}
			// nldebug("CStreamSource %p : play FAILED !", (CAudioMixerUser::IMixerEvent*)this);
			return;
		}
		
		CAudioMixerUser *mixer = CAudioMixerUser::instance();

		if (!hasPhysicalSource())
			initPhysicalSource();

		if (hasPhysicalSource())
		{
			ISource *pSource = getPhysicalSource();
			nlassert(pSource != NULL);
			
			for (uint i = 0; i < m_NextBuffer; ++i)
				pSource->submitStreamingBuffer(m_Buffers[i]);
			
			// pSource->setPos( _Position, false);
			pSource->setPos(getVirtualPos(), false);
			if (!m_Buffers[0]->isStereo())
			{
				pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false);
				setDirection(_Direction); // because there is a workaround inside
				pSource->setVelocity(_Velocity);
			}
			pSource->setGain(_Gain);
			pSource->setSourceRelativeMode(_RelativeMode);
			// pSource->setLooping(_Looping);
			pSource->setPitch(_Pitch);
			pSource->setAlpha(m_Alpha);
			
			// and play the sound
			play = pSource->play();
			// nldebug("CStreamSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this);
		}
		else
		{
			if (_Priority == HighestPri)
			{
				// This sound is not discardable, add it in waiting playlist
				mixer->addSourceWaitingForPlay(this);
				return;
			}
			else
			{
				// No source available, kill.
				if (_Spawn)
				{
					if (_SpawnEndCb != NULL)
						_SpawnEndCb(this, _CbUserParam);					
					delete this;
				}
				return;
			}
		}
		
		if (play)
			CSourceCommon::play();
	}

	nlassert(play);
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:81,代码来源:stream_source.cpp


示例13: setDirection

void WGM63::stop()
{
  setDirection(STOP);
}
开发者ID:metarobotics,项目名称:arduino_tests,代码行数:4,代码来源:WGM63.cpp


示例14: setDirection

void Listener::setDirection(const Vector3f& direction)
{
    setDirection(direction.x, direction.y, direction.z);
}
开发者ID:AlexLusitania,项目名称:Stickman-project,代码行数:4,代码来源:Listener.cpp


示例15: Q_ASSERT

bool Chaser::loadXML(QDomDocument* doc, QDomElement* root)
{
	t_fixture_id step_fxi = KNoID;
	int step_number = 0;
	QString str;
	
	QDomNode node;
	QDomElement tag;
	
	Q_ASSERT(doc != NULL);
	Q_ASSERT(root != NULL);

	if (root->tagName() != KXMLQLCFunction)
	{
		qWarning("Function node not found!");
		return false;
	}

	/* Load chaser contents */
	node = root->firstChild();
	while (node.isNull() == false)
	{
		tag = node.toElement();
		
		if (tag.tagName() == KXMLQLCBus)
		{
			/* Bus */
			str = tag.attribute(KXMLQLCBusRole);
			Q_ASSERT(str == KXMLQLCBusHold);

			Q_ASSERT(setBus(tag.text().toInt()) == true);
		}
		else if (tag.tagName() == KXMLQLCFunctionDirection)
		{
			/* Direction */
			setDirection(Function::stringToDirection(tag.text()));
		}
		else if (tag.tagName() == KXMLQLCFunctionRunOrder)
		{
			/* Run Order */
			setRunOrder(Function::stringToRunOrder(tag.text()));
		}
		else if (tag.tagName() == KXMLQLCFunctionStep)
		{
			step_number = 
				tag.attribute(KXMLQLCFunctionNumber).toInt();
			step_fxi = tag.text().toInt();

			if (step_number > m_steps.size())
				m_steps.append(step_fxi);
			else
				m_steps.insert(m_steps.at(step_number),
					       step_fxi);
			
		}
		else
		{
			qWarning("Unknown chaser tag: %s",
				 (const char*) tag.tagName());
		}
		
		node = node.nextSibling();
	}

	return true;
}
开发者ID:speakman,项目名称:qlc,代码行数:66,代码来源:chaser.cpp


示例16: Emitter

	SphericEmitter::SphericEmitter(const vec3& direction,float angleA,float angleB) :
		Emitter()
	{
		setDirection(direction);
		setAngles(angleA,angleB);
	}
开发者ID:LastSupertim,项目名称:libSpark,代码行数:6,代码来源:SPK_SphericEmitter.cpp


示例17: setDirection

/**
 * 断续指定方向移动
 */
void SimpleMoveComponent::continueMoveWithDirection(float direction)
{
	setDirection(direction);
    calcSpeedVector(cosf(direction), sinf(direction));
	m_moveState=MoveContinue;
}
开发者ID:trarck,项目名称:yhge,代码行数:9,代码来源:SimpleMoveComponent.cpp


示例18: Size

void TestList::runThisTest()
{
    _cellTouchEnabled = true;
    auto director = Director::getInstance();
    auto scene = Scene::create();

    auto visibleSize = director->getVisibleSize();
    auto origin = director->getVisibleOrigin();

    auto tableView = TestCustomTableView::create(this, Size(400, visibleSize.height));
    tableView->setPosition(origin.x + (visibleSize.width - 400) / 2, origin.y);
    tableView->setDirection(ScrollView::Direction::VERTICAL);
    tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
    tableView->setDelegate(this);
    scene->addChild(tableView);
    tableView->reloadData();

    if (_shouldRestoreTableOffset)
    {
        tableView->setContentOffset(_tableOffset);
    }

    if (_parentTest)
    {
        //Add back button.
        TTFConfig ttfConfig("fonts/arial.ttf", 20);
        auto label = Label::createWithTTF(ttfConfig, "Back");

        auto menuItem = MenuItemLabel::create(label, std::bind(&TestBase::backsUpOneLevel, this));
        auto menu = Menu::create(menuItem, nullptr);

        menu->setPosition(Vec2::ZERO);
        menuItem->setPosition(Vec2(VisibleRect::right().x - 50, VisibleRect::bottom().y + 25));

        scene->addChild(menu, 1);
    }
    else
    {
        //Add close and "Start AutoTest" button.
        auto closeItem = MenuItemImage::create(s_pathClose, s_pathClose, [](Ref* sender){
            TestController::getInstance()->stopAutoTest();
            TestController::destroyInstance();
            Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
            exit(0);
#endif
        });
        closeItem->setPosition(VisibleRect::right().x - 30, VisibleRect::top().y - 30);

        auto autoTestLabel = Label::createWithTTF("Start AutoTest","fonts/arial.ttf",16);
        auto autoTestItem = MenuItemLabel::create(autoTestLabel, [&](Ref* sender){
            TestController::getInstance()->startAutoTest();
        });
        autoTestItem->setPosition(Vec2(VisibleRect::right().x - 70, VisibleRect::bottom().y + 25));

        auto menu = Menu::create(closeItem, autoTestItem, nullptr);
        menu->setPosition(Vec2::ZERO);
        scene->addChild(menu, 1);
    }

    director->replaceScene(scene);
}
开发者ID:AomXD,项目名称:workspace,代码行数:62,代码来源:BaseTest.cpp


示例19: setDirection

void Node::lookAt(Ogre::Vector3 target, Ogre::Vector3 front_vector, RelativeTo rel) {
    setDirection(target - getPosition(rel), front_vector);
}
开发者ID:EternalWind,项目名称:ducttape-engine,代码行数:3,代码来源:Node.cpp


示例20: setDirection

void DirectionalLight::setDirection(float x, float y, float z) {
	setDirection(glm::vec3(x, y, z));
}
开发者ID:jejatu,项目名称:3d,代码行数:3,代码来源:DirectionalLight.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setDirty函数代码示例发布时间:2022-05-30
下一篇:
C++ setDir函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap