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


C++ TransformComponent::getRotation方法代码示例

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


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

示例1: update

void RenderComponent::update()
{
	//hmm
	if (m_Sprite) {
		if (m_Obj->hasComponent("Transform")) {
			TransformComponent* tc = (TransformComponent*)m_Obj->getComponent("Transform");
			m_Sprite->setX(tc->getPositionX());
			m_Sprite->setY(tc->getPositionY());
			m_Sprite->setAngle(tc->getRotation());
		}
	}
	if (m_SpriteSheet) {
		m_SpriteSheet->update();
		if (m_Obj->hasComponent("Transform")) {
			TransformComponent* tc = (TransformComponent*)m_Obj->getComponent("Transform");
			m_SpriteSheet->setX(tc->getPositionX());
			m_SpriteSheet->setY(tc->getPositionY());
			m_SpriteSheet->setAngle(tc->getRotation());
		}
	}
}
开发者ID:ChadyG,项目名称:MUGE,代码行数:21,代码来源:SceneObject.cpp

示例2: update

void SpriteComponent::update() 
{
	// setting position from Transform Component
	TransformComponent* transform = parent.getComponent<TransformComponent>();
 	
	sprite.setPosition(utils::mToPx(transform->getX()),
	                   utils::mToPx(transform->getY()) );

	sprite.setRotation(utils::radToDeg(transform->getRotation()) );
	
	GameManager& gameManager = GameManager::getInstance();
	gameManager.getWindow().draw(sprite);
}
开发者ID:czeslavo,项目名称:magpie,代码行数:13,代码来源:SpriteComponent.cpp

示例3: updateView

void Camera::updateView(void){
	if(isFollowing_){
		TransformComponent* transformation = followee_->getComponent<TransformComponent>();
		glm::fquat rotation = transformation->getRotation() * rotation_;
		// glm::vec3 pos = pos_ + transformation->getPosition();
		view_matrix_ = glm::translate(glm::mat4(1.0), transformation->getPosition()) * glm::mat4_cast(rotation) * glm::translate(glm::mat4(1.0), pos_);
	}
	else if(isMimicking_){
		glm::vec3 pos = pos_ + followee_->getComponent<TransformComponent>()->getPosition();
		view_matrix_ = glm::translate(glm::mat4(1.0), pos) * glm::mat4_cast(rotation_);
	}
	else{
		view_matrix_ = glm::translate(glm::mat4(1.0), pos_) * glm::mat4_cast(rotation_);
	}
	
	view_matrix_ = glm::inverse(view_matrix_);
}
开发者ID:Grieverheart,项目名称:SimpleGameEngine,代码行数:17,代码来源:camera.cpp

示例4: setTexture

void SpriteComponent::setTexture(std::string textureName) 
{
	// load texture from AssetManager
	AssetManager& assetManager = AssetManager::getInstance();
	sprite.setTexture(assetManager.getTextureByName(textureName));
	//assetManager.getTextureByName(textureName).setSmooth(true);

	// set origin in the center 
	float xOrigin, yOrigin;
	sf::Vector2u size = sprite.getTexture()->getSize();
	xOrigin = size.x / 2;
	yOrigin = size.y / 2;
	sprite.setOrigin(xOrigin, yOrigin);

	// if the parent GameObject has a transform component, get the transform from it
	TransformComponent* transformComponent = parent.getComponent<TransformComponent>();
	if (transformComponent) {
		sprite.setPosition(utils::mToPx(transformComponent->getX()),
						   utils::mToPx(transformComponent->getY()) );
		sprite.setRotation(utils::radToDeg(transformComponent->getRotation()));
	}
}
开发者ID:czeslavo,项目名称:magpie,代码行数:22,代码来源:SpriteComponent.cpp


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