//////////////////////////////////////////////////////////////////////////
// update
//virtual
void GaSpeechBubbleComponent::update( BcF32 Tick )
{
	Super::update( Tick );

	if ( !FontComponent_.isValid() )
	{
		Canvas_ = ParentEntity_->getComponentAnyParentByType< ScnCanvasComponent >();
		FontComponent_ = ParentEntity_->getComponentAnyParentByType< ScnFontComponent >();
	}
	if ( !SpeechBubble_.isValid() )
	{
		SpeechBubble_ = ParentEntity_->getComponentByType<ScnSpriteComponent>( BcName( "SpeechBubbleComponent", 0 ) );
	}
	if ( SpeechBubble_.isValid() )
	{
		SpeechBubble_->setColour( RsColour( 1, 1, 1, Visible_ ? 0.8 : 0 ) );
	}
	if ( !TargetEntity_.isValid() )
	{
		// We aren't even gonna bother
		return;
	}

	MaMat4d TextScaleMatrix;
	//TextScaleMatrix.scale( MaVec4d( 0.04f, 0.04f, 1.0f, 1.0f ) );
	TextScaleMatrix.scale( MaVec4d( 1.00f, -1.00f, 1.0f, 1.0f ) );

	FontComponent_->setAlphaTestStepping( MaVec2d( 0.4f, 0.45f ) );


	if (Visible_)
	{
		TimeBeenVisible_ += Tick;
		if ( TimeBeenVisible_ > VisibleTime_ )
			Visible_ = false;
		//MaMat4d Matrix = getParentEntity()->getWorldMatrix();
		//Matrix = Canvas_->popMatrix();
		Canvas_->pushMatrix( TextScaleMatrix );
	
		MaVec2d Size;
		MaVec3d worldPos = TargetEntity_->getWorldPosition();
		MaVec2d Position( 0 , 0 );
		MaVec2d localPos  = SpeechBubble_->getPosition();
		localPos  = MaVec2d(TargetEntity_->getWorldPosition().x(), -TargetEntity_->getWorldPosition().y() ) + FontOffset_;
		SpeechBubble_->setPosition( MaVec2d( TargetEntity_->getWorldPosition().x(), TargetEntity_->getWorldPosition().y() )  + SpriteOffset_ );
		for( BcU32 Idx = 0; Idx < Text_.size(); ++Idx )
		{
			const auto& Option( Text_[ Idx ] );
			const auto Colour = RsColour::BLACK;
			Size = FontComponent_->drawCentered( Canvas_, localPos + Position, Text_[ Idx ] , Colour, 280 );
			Position += MaVec2d( 0.0f, Size.y() );
		}



		Canvas_->popMatrix();
	}
	//Canvas_->pushMatrix( Matrix );
	//Canvas_->setMatrix( Matrix );
}
示例#2
0
//////////////////////////////////////////////////////////////////////////
// initialise
void ScnModelComponent::initialise()
{
	// Setup base transform.
	MaMat4d Scale;
	Scale.scale( Scale_ );
	BaseTransform_.rotation( Rotation_ );
	BaseTransform_ = BaseTransform_ * Scale;
	BaseTransform_.translation( Position_ );
}