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


C++ setRotation函数代码示例

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


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

示例1: ASSERT_LOG

	SceneObjectPtr LinearGradient::createRenderable()
	{
		ASSERT_LOG(color_stops_.size() >= 2, "Must be at least two color stops.");
		//ASSERT_LOG(std::abs(color_stops_.front().length) < FLT_EPSILON, "First stop must be at 0");
		//ASSERT_LOG(std::abs(color_stops_.back().length - 1.0f) < FLT_EPSILON, "Last stop must be at 1");
		// attempt one.
		int number_strips = color_stops_.size() - 1;

		auto gr = std::make_shared<GradientRenderable>();
		gr->setRotation(-angle_, z_axis);
		//auto clip_mask = std::make_shared<SimpleClipShape>();
		//clip_mask->setRotation(angle_, z_axis);
		//gr->setClipSettings(get_stencil_mask_settings(), clip_mask);
		
		std::vector<KRE::vertex_color> vc;
		vc.reserve(6 * number_strips);

		// assume a box size from 0 -> 1, 0 -> 1
		for(int strip = 0; strip < number_strips; ++strip) {
			
			const float vx1 = -0.5f;
			const float vy1 = color_stops_[strip].length - 0.5f;
			const float vx2 = 0.5f;
			const float vy2 = color_stops_[strip + 1].length - 0.5f;

			vc.emplace_back(glm::vec2(vx1, vy1), color_stops_[strip].color.as_u8vec4());
			vc.emplace_back(glm::vec2(vx1, vy2), color_stops_[strip + 1].color.as_u8vec4());
			vc.emplace_back(glm::vec2(vx2, vy2), color_stops_[strip + 1].color.as_u8vec4());

			vc.emplace_back(glm::vec2(vx1, vy1), color_stops_[strip].color.as_u8vec4());
			vc.emplace_back(glm::vec2(vx2, vy2), color_stops_[strip + 1].color.as_u8vec4());
			vc.emplace_back(glm::vec2(vx2, vy1), color_stops_[strip].color.as_u8vec4());
		}
		
		gr->update(&vc);

		return gr;
	}
开发者ID:sweetkristas,项目名称:hex_test,代码行数:38,代码来源:Gradients.cpp

示例2: setRotation

void PowerUp::updateSelf( const double & delta )
{
	mRotationAngle += delta * 100.0f;
	setRotation( QQuaternion::fromAxisAndAngle( 0,1,0, mRotationAngle ) );

	QSharedPointer<Player> player = mLandscape->world()->player();

	float dist = ( player->worldPosition() - worldPosition() ).length();

	if( mRespawning )
	{
		mRespawnCoolDown -= delta;
		if( mRespawnCoolDown < 0.0f )
		{
			mRespawnCoolDown = 0.0f;
			mRespawning = false;
		}
	}
	else
	{
		if( dist <= 2.0f )
		{
			switch( mPowerType )
			{
				case HEALTH:
					player->setLife( qMin( player->life() + 25, 100 ) );
					break;
				case ARMOR:
					player->setArmor( qMin( player->armor() + 40, 100 ) );
					break;
				case WEAPON_LASER:
					player->giveWeapon( QSharedPointer<AWeapon>( new Laser( world() ) ) );
					break;
			}
			respawn();
		}
	}
}
开发者ID:splatterlinge,项目名称:Ununoctium,代码行数:38,代码来源:PowerUp.cpp

示例3: setPosition

void EnPlayer::spawn()
{
    osg::Quat  rotation;
    osg::Vec3f position;

    // check if the level has spawn points
    EnSpawnPoint* p_spwanEntity = static_cast< EnSpawnPoint* >( yaf3d::EntityManager::get()->findEntity( ENTITY_NAME_SPAWNPOINT ) );
    if ( p_spwanEntity )
    {
        if ( !EnSpawnPoint::getNextSpawnPoint( position, rotation ) )
        {
            log_error << "EnPlayer: all spawn points are occupied, taking default position and rotation!" << std::endl;
        }
    }
    else
    {
        position = _attributeContainer._pos;
        rotation = osg::Quat( osg::DegreesToRadians( _attributeContainer._rot ), osg::Vec3f( 0.0f, 0.0f, 1.0f ) );
    }
    // set initial rotation and position
    setPosition( position );
    setRotation( rotation );
}
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:23,代码来源:vrc_player.cpp

示例4: acquireTarget

void Samsquamptch::updateCurrent(sf::Time dt, sf::Vector2f target, sf::Vector2f bounds)
{
    acquireTarget(target,bounds);

    m_velocity *= dt.asSeconds()*m_aggressionLevel;

    if(getPosition().y >= m_target.y
            && getPosition().y < m_target.y + m_bounds.y
            && getPosition().x >= m_target.x
            && getPosition().x < m_target.x + m_bounds.y)
    {
        //achieved goal - target acquired
    }
    else
    {
        //work towards goal
        setRotation(toDegree(m_angle) + 90.f);
        move(m_velocity);
        m_rect.setPosition(getPosition());
        m_rect.setRotation(getRotation());
        //std::cout<<"Chasing..."<<std::endl;
    }
}
开发者ID:pushbuttonreceivecode,项目名称:Top-Down-Shooter-Mechanics-Part-2,代码行数:23,代码来源:Samsquamptch.cpp

示例5: setMapUnits

void QgsMapCanvas::readProject( const QDomDocument & doc )
{
  QDomNodeList nodes = doc.elementsByTagName( "mapcanvas" );
  if ( nodes.count() )
  {
    QDomNode node = nodes.item( 0 );

    QgsMapSettings tmpSettings;
    tmpSettings.readXML( node );
    setMapUnits( tmpSettings.mapUnits() );
    setCrsTransformEnabled( tmpSettings.hasCrsTransformEnabled() );
    setDestinationCrs( tmpSettings.destinationCrs() );
    setExtent( tmpSettings.extent() );
    setRotation( tmpSettings.rotation() );
    mSettings.datumTransformStore() = tmpSettings.datumTransformStore();

    clearExtentHistory(); // clear the extent history on project load
  }
  else
  {
    QgsDebugMsg( "Couldn't read mapcanvas information from project" );
  }
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:23,代码来源:qgsmapcanvas.cpp

示例6: updateGeometry

void FaceModel::simulate(float deltaTime, bool fullUpdate) {
    updateGeometry();
    Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
    glm::vec3 neckPosition;
    if (!owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) {
        neckPosition = owningAvatar->getPosition();
    }
    setTranslation(neckPosition);
    glm::quat neckParentRotation;
    if (!owningAvatar->getSkeletonModel().getNeckParentRotationFromDefaultOrientation(neckParentRotation)) {
        neckParentRotation = owningAvatar->getOrientation();
    }
    setRotation(neckParentRotation);
    setScale(glm::vec3(1.0f, 1.0f, 1.0f) * _owningHead->getScale());
    
    setPupilDilation(_owningHead->getPupilDilation());
    setBlendshapeCoefficients(_owningHead->getBlendshapeCoefficients());
    
    if (isActive()) {
        setOffset(-_geometry->getFBXGeometry().neckPivot);
        Model::simulateInternal(deltaTime);
    }
}
开发者ID:RyanDowne,项目名称:hifi,代码行数:23,代码来源:FaceModel.cpp

示例7: setFlag

void
TrackMoveHandle::registerLowSlot(TrackComponent *trackComponent)
{
    lowSlot_ = trackComponent;

    // Observer //
    //
    lowSlot_->attachObserver(this);

    // Transformation //
    //
    if (!highSlot_) // do not set pos twice
    {
        setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
        setPos(lowSlot_->getGlobalPoint(lowSlot_->getSEnd()));
        setRotation(lowSlot_->getGlobalHeading(lowSlot_->getSEnd()));
        setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
    }

    // Degrees Of Freedom Fries //
    //
    updateDOF();
}
开发者ID:nixz,项目名称:covise,代码行数:23,代码来源:trackmovehandle.cpp

示例8: PrimitiveTextGraphicsItem

TextGraphicsItem::TextGraphicsItem(Text&                           text,
                                   const IF_GraphicsLayerProvider& lp,
                                   QGraphicsItem* parent) noexcept
  : PrimitiveTextGraphicsItem(parent), mText(text), mLayerProvider(lp) {
  setFont(TextGraphicsItem::Font::SansSerif);
  setPosition(mText.getPosition());
  setRotation(mText.getRotation());
  setText(mText.getText());
  setHeight(mText.getHeight());
  setAlignment(mText.getAlign());
  setLayer(mLayerProvider.getLayer(*mText.getLayerName()));
  setFlag(QGraphicsItem::ItemIsSelectable, true);
  setZValue(5);

  // add origin cross
  mOriginCrossGraphicsItem.reset(new OriginCrossGraphicsItem(this));
  mOriginCrossGraphicsItem->setSize(UnsignedLength(1000000));
  mOriginCrossGraphicsItem->setLayer(
      mLayerProvider.getLayer(GraphicsLayer::sSchematicReferences));  // TODO

  // register to the text to get attribute updates
  mText.registerObserver(*this);
}
开发者ID:LibrePCB,项目名称:LibrePCB,代码行数:23,代码来源:textgraphicsitem.cpp

示例9: sprintf

void RenderTextureSave::saveImage(cocos2d::Ref *sender)
{
    static int counter = 0;

    char png[20];
    sprintf(png, "image-%d.png", counter);
    
    auto callback = [&](RenderTexture* rt, const std::string& path)
    {
        auto sprite = Sprite::create(path);
        addChild(sprite);
        sprite->setScale(0.3f);
        sprite->setPosition(Vec2(40, 40));
        sprite->setRotation(counter * 3);
    };
    
    _target->saveToFile(png, Image::Format::PNG, true, callback);
    //Add this function to avoid crash if we switch to a new scene.
    Director::getInstance()->getRenderer()->render();
    CCLOG("Image saved %s", png);

    counter++;
}
开发者ID:SPUDevelopers,项目名称:Naturalize,代码行数:23,代码来源:RenderTextureTest.cpp

示例10: switch

void GameScene::addEnemyTankBullet(Node* node)
{
    auto* enemyTankGun = (EnemyTankGun*)node;
    auto etankbullet = Sprite::create(enemyName[enemyTankGun->getEnemyTankIndex()-1].c_str());
    switch (enemyTankGun->getEnemyTankIndex()) {
        case 1:
        case 2:
            enemyBullet->addChild(etankbullet);
            break;
        case 3:
        case 4:
            enemyBazooka->addChild(etankbullet);
            break;
        default:
            break;
    }
    
    float enemyTankGunRotation = enemyTankGun->getRotation();
    etankbullet->setRotation(enemyTankGunRotation);
    enemyTankGunRotation = enemyTankGunRotation*pi/180.0f;
    
    Vec2 enemyTankGunPos = enemyTankGun->getPosition();
    enemyTankGunPos = enemyTankGun->convertToWorldSpaceAR(enemyTankGunPos);
    etankbullet->setPosition(enemyTankGunPos.x+40*sin(enemyTankGunRotation),enemyTankGunPos.y+40*cos(enemyTankGunRotation));
    
    auto moveAct = MoveTo::create(8, Vec2(enemyTankGunPos.x+1600*sin(enemyTankGunRotation),enemyTankGunPos.y+1200*cos(enemyTankGunRotation)));

    if (enemyTankGun->getEnemyTankIndex() < 3) {
        auto funcAct = CallFuncN::create(CC_CALLBACK_1(GameScene::removeEnemyTankBullet, this));
        etankbullet->runAction(Sequence::create(moveAct,funcAct, NULL));
    }
    else
    {
        auto funcAct = CallFuncN::create(CC_CALLBACK_1(GameScene::removeEnemyTankBazooka, this));
        etankbullet->runAction(Sequence::create(moveAct,funcAct, NULL));
    }
}
开发者ID:wuwenjuan,项目名称:Tank1,代码行数:37,代码来源:GameScene.cpp

示例11: lineToCenter

void obj::advance(int step)
{
    if (!step)
        return;
    // Don't move too far away
    QLineF lineToCenter(QPointF(0, 0), mapFromScene(0, 0));
    if (lineToCenter.length() > 150) {
        qreal angleToCenter = ::acos(lineToCenter.dx() / lineToCenter.length());
        if (lineToCenter.dy() < 0)
            angleToCenter = TwoPi - angleToCenter;
        angleToCenter = normalizeAngle((Pi - angleToCenter) + Pi / 2);

        if (angleToCenter < Pi && angleToCenter > Pi / 4) {
            // Rotate left
            angle += (angle < -Pi / 2) ? 0.25 : -0.25;
        } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) {
            // Rotate right
            angle += (angle < Pi / 2) ? 0.25 : -0.25;
        }
    } else if (::sin(angle) < 0) {
        angle += 0.25;
    } else if (::sin(angle) > 0) {
        angle -= 0.25;
    }

    if (qrand() % 1)
        angle += (qrand() % 100) / 500.0;
    else
        angle -= (qrand() % 100) / 500.0;

    speed += (-50 + qrand() % 100) / 100.0;

    qreal dx = ::sin(angle) * 10;

    setRotation(rotation() + dx);
    setPos(mapToParent(0, -(3 + sin(speed) * 3)));
}
开发者ID:Batyan,项目名称:Eliminator,代码行数:37,代码来源:obj.cpp

示例12: setEnabled

void Widget::copyProperties(Widget *widget)
{
    setEnabled(widget->isEnabled());
    setVisible(widget->isVisible());
    setBright(widget->isBright());
    setTouchEnabled(widget->isTouchEnabled());
    _touchPassedEnabled = false;
    setLocalZOrder(widget->getLocalZOrder());
    setTag(widget->getTag());
    setName(widget->getName());
    setActionTag(widget->getActionTag());
    _ignoreSize = widget->_ignoreSize;
    _size = widget->_size;
    _customSize = widget->_customSize;
    copySpecialProperties(widget);
    _sizeType = widget->getSizeType();
    _sizePercent = widget->_sizePercent;
    _positionType = widget->_positionType;
    _positionPercent = widget->_positionPercent;
    setPosition(widget->getPosition());
    setAnchorPoint(widget->getAnchorPoint());
    setScaleX(widget->getScaleX());
    setScaleY(widget->getScaleY());
    setRotation(widget->getRotation());
    setRotationSkewX(widget->getRotationSkewX());
    setRotationSkewY(widget->getRotationSkewY());
    setFlippedX(widget->isFlippedX());
    setFlippedY(widget->isFlippedY());
    setColor(widget->getColor());
    setOpacity(widget->getOpacity());
    Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary;
    for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter)
    {
        setLayoutParameter(iter->second->clone());
    }
    onSizeChanged();
}
开发者ID:1007650105,项目名称:RockChipmunk2D,代码行数:37,代码来源:UIWidget.cpp

示例13: setEnable

void	PhysShape::unpack(BitStream* stream)
{
    bool enabled = stream->readFlag();
    if (isEnabled()!=enabled)
        setEnable(enabled);
    if (enabled)
    {
        bool active = stream->readFlag();
        bool toInactive = false;
        if (!active)
        {
            toInactive = stream->readFlag();
            if (!toInactive)
                return;
        }

        if (!isActive())
            setActive(true);
        QuatF q;
        VectorF vec;
        mathRead(*stream, &vec);
        setPosition(vec);
        mathRead(*stream, &q);
        setRotation(q);
        mathRead(*stream, &vec);
        setForce(vec);
        mathRead(*stream, &vec);
        setTorque(vec);
        mathRead(*stream, &vec);
        setLinVelocity(vec);
        mathRead(*stream, &vec);
        setAngVelocity(vec);

        if (toInactive)
            setActive(false);
    }
}
开发者ID:Bloodknight,项目名称:GMK,代码行数:37,代码来源:physShape.cpp

示例14: getSize

/// Creds to http://chess.eecs.berkeley.edu/eecs149/documentation/differentialDrive.pdf
double Robby::go(int motLeft,int motRight,double speed,double deltaTime) {
	double mLeft = -(((double)motLeft)/200)*speed;
	double mRight = -(((double)motRight)/200)*speed;

	double xprime,yprime,rprime;
	double length = getSize().x;

	double rX = getPosition().x;
	double rY = getPosition().y;
	double rTheta = getRotation()*0.0174532925;
	double omega = (mRight-mLeft)/length;

	if (mLeft == mRight) {
		xprime = rX + mLeft*cos(rTheta)*deltaTime;
		yprime = rY + mLeft*sin(rTheta)*deltaTime;
		rprime = rTheta;
	} else {
		double radius = (length/2)*(mLeft+mRight)/(mRight-mLeft);

		double iccX = rX - radius*sin(rTheta);
		double iccY = rY + radius*cos(rTheta);

		xprime = iccX + (cos(omega*deltaTime)*(rX-iccX)+
						 -sin(omega*deltaTime)*(rY-iccY));
		yprime = iccY + (sin(omega*deltaTime)*(rX-iccX)+
						 cos(omega*deltaTime)*(rY-iccY));
		rprime = rTheta + omega*deltaTime;
	}

	setPosition(xprime,yprime);
	setRotation(rprime*57.2957795);

	m1Last = motLeft;
	m2Last = motRight;

	return omega*10000;
}
开发者ID:FlyingGraysons,项目名称:Fido,代码行数:38,代码来源:Robby.cpp

示例15: setTag

bool RoleEmemyBig::init() {
	//////////////////////////////
	// 1. super init first
	if (!Sprite::initWithSpriteFrameName("hero1.png")) {
		return false;
	}

	setTag(TAG_ENEMY_PLANE);
	auto body = PhysicsBody::createBox(getContentSize());
	body->setGroup(PHYSICAL_BODY_ENEMY_GROUP);
	body->setCategoryBitmask(PHYSICAL_BODY_ENEMY_BITMASK_CATEGORY);
	body->setContactTestBitmask(PHYSICAL_BODY_ENEMY_BITMASK_CONTACT_TEST);
	body->setCollisionBitmask(PHYSICAL_BODY_ENEMY_BITMASK_COLLISION);
	setPhysicsBody(body);
	setRotation(-90);

	Point endPos = Point(0, 100);
	runAction(
			Sequence::create(MoveTo::create(3.0, endPos),
					CallFunc::create(
							CC_CALLBACK_0(RoleEmemyBig::doRemoveSelf, this, this)),
					NULL));
	return true;
}
开发者ID:sangdev90,项目名称:CollisionDetection,代码行数:24,代码来源:RoleEmemyBig.cpp


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