Exemplo n.º 1
0
void VPathNode::updateWorldData( void )
{
    if ( !mPath )
    {
        setWorldPosition( getLocalPosition() );
        setWorldRotation( getLocalRotation() );
        return;
    }

    // Fetch Path Details.
    const MatrixF &pathTransform = mPath->getTransform();
    const QuatF   &pathRotation( pathTransform );

    // Calculate the World Position.
    Point3F newPosition = getLocalPosition();
    newPosition.convolve( mPath->getScale() );
    pathTransform.mulP( newPosition );

    // Calculate the new Rotation.
    QuatF newRotation;
    newRotation.mul( getLocalRotation(), pathRotation );

    // Apply.
    setWorldPosition( newPosition );
    setWorldRotation( newRotation );
}
Exemplo n.º 2
0
//test
void Light::Update()
{
    if(_type == MGE_LIGHT_DIRECTIONAL)
    {
        glm::vec3 tPos = _target->getWorldPosition();
        setWorldPosition(tPos + _storedOffset);
    }
}
Exemplo n.º 3
0
//--------------------------------------------------------------------
// setWorldMatrix()
//--------------------------------------------------------------------
void LLJoint::setWorldMatrix( const LLMatrix4& mat )
{
LL_INFOS() << "WARNING: LLJoint::setWorldMatrix() not correctly implemented yet" << LL_ENDL;
	// extract global translation
	LLVector3 trans(	mat.mMatrix[VW][VX],
						mat.mMatrix[VW][VY],
						mat.mMatrix[VW][VZ] );

	// extract global rotation
	LLQuaternion rot( mat );

	setWorldPosition( trans );
	setWorldRotation( rot );
}
Exemplo n.º 4
0
	void GameOverAPS::resize( int w, int h )
	{
		setWorldPosition(Vec2(w/2,h/2));
	}
Exemplo n.º 5
0
void HelpState::addPlankton(PlanktonController::Type type)
{
    auto entity = std::make_unique<Entity>(m_messageBus);
    entity->setWorldPosition({ static_cast<float>(Util::Random::value(0, 1920)), static_cast<float>(Util::Random::value(0, 1080)) });

    auto physComponent = m_physWorld.addBody(planktonSize);
    physComponent->setPosition(entity->getWorldPosition());
    physComponent->setTriggerOnly(true);
    physComponent->setName("control");
    entity->addComponent<PhysicsComponent>(physComponent);

    auto& appInstance = getContext().appInstance;
    bool colourblind = appInstance.getGameSettings().colourblindMode;
    AnimatedDrawable::Ptr ad;
    auto ident = ParticleSystem::create(Particle::Type::Ident, m_messageBus);
    ident->setTexture(appInstance.getTexture("assets/images/particles/ident.png"));
    auto text = std::make_unique<TextDrawable>(m_messageBus);
    text->setFont(appInstance.getFont("assets/fonts/Ardeco.ttf"));
    switch (type)
    {
    case PlanktonController::Type::Good:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food01.png"));
        ad->loadAnimationData("assets/images/player/food01.cra");
        (colourblind) ? ident->setColour({ 14u, 160u, 225u }) : ident->setColour({ 84u, 150u, 75u });
        text->setString("+50 HP");
        break;
    case PlanktonController::Type::Bad:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food02.png"));
        ad->loadAnimationData("assets/images/player/food02.cra");
        (colourblind) ? ident->setColour({ 214u, 190u, 25u }) : ident->setColour({ 184u, 67u, 51u });
        text->setString("-35 HP");
        break;
    case PlanktonController::Type::Bonus:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/food03.png"));
        ad->loadAnimationData("assets/images/player/food03.cra");
        ident->setColour({ 158u, 148u, 224u });
        text->setString("+100 HP");
        break;
    case PlanktonController::Type::UberLife:
        ad = std::make_unique<AnimatedDrawable>(m_messageBus, appInstance.getTexture("assets/images/player/bonus.png"));
        ad->loadAnimationData("assets/images/player/bonus.cra");
        ident->setColour({ 158u, 148u, 224u });
        text->setString("FULL HEALTH");
        break;
    default:
        break;
    }
    ident->setName("ident");
    entity->addComponent<ParticleSystem>(ident);

    text->setCharacterSize(40u);
    Util::Position::centreOrigin(*text);
    text->setPosition(0.f, 40.f);
    text->setName("text");
    entity->addComponent<TextDrawable>(text);

    ad->setBlendMode(sf::BlendAdd);
    ad->setOrigin(sf::Vector2f(ad->getFrameSize()) / 2.f);
    if (!ad->getAnimations().empty()) ad->play(ad->getAnimations()[0]);
    ad->setName("drawable");
    entity->addComponent<AnimatedDrawable>(ad);

    auto trail = ParticleSystem::create(Particle::Type::Trail, m_messageBus);
    trail->setTexture(appInstance.getTexture("assets/images/particles/circle.png"));
    float particleSize = planktonSize / 12.f;
    trail->setParticleSize({ particleSize, particleSize });
    trail->setName("trail");
    trail->setEmitRate(10.f);
    entity->addComponent<ParticleSystem>(trail);

    if (type == PlanktonController::Type::UberLife)
    {
        auto tails = std::make_unique<TailDrawable>(m_messageBus);
        tails->addTail(sf::Vector2f(-18.f, -15.f));
        tails->addTail(sf::Vector2f(-8.f, -5.f));
        tails->addTail(sf::Vector2f(-8.f, 5.f));
        tails->addTail(sf::Vector2f(-18.f, 15.f));
        tails->setName("tail");
        entity->addComponent<TailDrawable>(tails);
    }

    auto controller = std::make_unique<PlanktonController>(m_messageBus);
    controller->setType(type);
    controller->setDecayRate(0.f);
    controller->setColourblind(colourblind);
    entity->addComponent<PlanktonController>(controller);

    m_rootNode.addChild(entity);
}