示例#1
0
void ofxLayout::loadAnimationsFromFile(string animationsFilename){
    ofxJSONElement animationData;
    if(animationData.open(animationsFilename)){
        populateJSON(&animationData);
        am.load(animationData);
        applyAnimations();
    }
    contextTreeRoot.setState("default",true, true);
}
示例#2
0
void SVGTimer::notifyAll()
{
    if (m_enabledNotifySet.isEmpty())
        return;

    // First build a list of animation elements per target element
    double elapsedSeconds = m_scheduler->elapsed() * 1000.0; // Take time now.
    TargetAnimationMap targetMap = animationsByElement(elapsedSeconds);
    
    // Then composite those animations down to final values and apply
    applyAnimations(elapsedSeconds, targetMap);
}
示例#3
0
void ClawUnitActor::act(Unit *unit)
{
	// here we may want to cast the unit to ClawUnit or something...

	UnitType *unitType = unit->getUnitType();
	assert(unitType != NULL);

	VC3 oldPosition = unit->getPosition();

	bool rotated = false;
	bool accelerated = false;

	float rotationAngle = 0.0f;

	float oldYRotation = unit->getRotation().y;

	UnitActAnimationRequests animRequests;
	
	// animated units don't do normal acting...
	if (unit->isAnimated())
	{
		if(game->gameMap->isWellInScaledBoundaries(oldPosition.x, oldPosition.z))
		{
			// but update obstacles...
			removeUnitObstacle(unit);
			addUnitObstacle(unit);
		}

		return;
	}

	if (unit->isDestroyed())
	{
		// a destroyed unit, don't do much...
		actDestroyed(unit, &animRequests);
	} else {

		VC3 waypoint = unit->getWaypoint();

		bool doRotation = false;
		bool doMove = false;
		bool doForwardMove = false;
		bool doLeftMove = false;
		bool doRightMove = false;
		bool doBackMove = false;
		bool doLeftRotation = false;
		bool doRightRotation = false;
		bool doFire = false;

		if (unit->getWalkDelay() > 0)
		{
			unit->setWalkDelay(unit->getWalkDelay() - 1);

			// player cannot move yet...
			// (probably fired a heavy weapon a moment ago)
			//actNotYetAllowedToWalk(unit, &animRequests);
// HACK: ..
unit->setVelocity(VC3(0,0,0));
animRequests.setSpecialAnim = ANIM_STAND_TYPE1;

		} else {
			if (unit->isDirectControl())
			{
				// the unit is directly controlled by the player...

				actDirectClawControls(unit);

			} else {
				// the unit is not directly controlled by the player,
				// thus we need to use the AI to decide walking and turning...
				decideTurnAndWalk(unit, &doMove, &doRotation, &rotationAngle);

				actTurn(unit, &animRequests, doRotation, rotationAngle, doMove,
					&rotated);

				actWalk(unit, &animRequests, doMove, doForwardMove, doBackMove,
					doLeftMove, doRightMove, rotated, &accelerated);
			}
		}

		// target destroyed?
		/*
		if (unit->targeting.hasTarget())
		{
			if (unit->targeting.getTargetUnit() != NULL
				&& unit->targeting.getTargetUnit()->isDestroyed())
			{
				unit->targeting.clearTarget();
				game->gameUI->setPointersChangedFlag(unit->getOwner());
			}
		}
		*/

		//actTargeting(unit, &animRequests, doFire, rotated, doMove,
		//	doForwardMove, doBackMove, doLeftMove, doRightMove);

		//actWeaponry(unit, &animRequests, doFire, doMove);

		actMisc(unit, &animRequests);
	}

	if (!unit->isDestroyed()
		|| (unit->getDisappearCounter() < (SimpleOptions::getInt(DH_OPT_I_CORPSE_DISAPPEAR_TIME) * 1000) / GAME_TICK_MSEC - UNIT_DISAPPEAR_FADE_TICKS)
		|| SimpleOptions::getInt(DH_OPT_I_CORPSE_DISAPPEAR_TIME) == 0)
	{
		// change position based on velocity
		actVelocity(unit, &animRequests, oldPosition);

		actGravity(unit, &animRequests);

		actHover(unit, &animRequests, accelerated);

		VC3 position = unit->getPosition();
		bool onground = false;

		float mapY = game->gameMap->getScaledHeightAt(position.x, position.z);
		if ((unitType->isSticky() && unit->isOnGround())
			|| position.y <= mapY + 0.001f)
		{
			onground = true;
		}
		if (onground)
		{
			actOnGround(unit, &animRequests);
		} else {
			actAirborne(unit, &animRequests, accelerated);
		}
	}

	actDelayedProjectiles(unit);

	/*
	VC3 curPosition = unit->getPosition();
	if (game->gameMap->isWellInScaledBoundaries(oldPosition.x, oldPosition.z)
		&& game->gameMap->isWellInScaledBoundaries(curPosition.x, curPosition.z))
	{
		actCollisions(unit, &animRequests, oldPosition);
	}
	*/

	//actEffects(unit);

/*
	float newYRotation = unit->getRotation().y;

if (unit->getIdString() != NULL
	&& strcmp(unit->getIdString(), "player1") == 0)
{
static int fooRight = 0;
static int fooLeft = 0;

	if (newYRotation > oldYRotation + 1.0f 
		|| newYRotation < oldYRotation - 180.0f)
	{
		//animRequests.turnRight = true;
		if (fooRight < 16)
			fooRight += 2;
	} else {
		if (fooRight > 0)
			fooRight--;
	}
	if (newYRotation < oldYRotation - 1.0f
		|| newYRotation > oldYRotation + 180.0f)
	{
		//animRequests.turnLeft = true;
		if (fooLeft < 16)
			fooLeft += 2;
	} else {
		if (fooLeft > 0)
			fooLeft--;
	}

	if (fooRight > 14)
		animRequests.turnRight = true;
	if (fooLeft > 14)
		animRequests.turnLeft = true;
}
*/

	// finally set animation based on what we did...
	if (!unit->isDirectControl())
	{
		applyAnimations(unit, animRequests);
	}
}
示例#4
0
bool Charts::Chart::update(void)
{
	preUpdate();
	const glm::float_t width = this->size.width;
	const glm::float_t height = this->size.height;
	if (!TR_VERIFY(width > 0.0 && height > 0.0)) {
		return false;
	}
	bool changed = false;
	if (title) {
		changed = changed || title->versionChanged();
	}
	Margin internalMargin;
	for (auto axis : axisList) {
		addAxisInternalMargin(internalMargin, axis);
	}
	renderArgs.margin = Margin::add(margin, internalMargin);

	if (renderArgs.screenSize.x != width || renderArgs.screenSize.y != height) {
        if(!doRelayout) {
            const glm::vec2 marginProjection(renderArgs.margin.left + renderArgs.margin.right, renderArgs.margin.top + renderArgs.margin.bottom);
            const glm::vec2 newSize(width - marginProjection.x, height - marginProjection.y);
            if (resizeMode == ResizeMode::Rescale) {
                if (renderArgs.screenSize.x > 0.0 && renderArgs.screenSize.y > 0.0) {
                    const glm::vec2 oldSize(renderArgs.screenSize.x - marginProjection.x, renderArgs.screenSize.y - marginProjection.y);
                    scale *= (newSize / oldSize);
                } else {
                    offset = glm::vec2(0.f);
                    scale = newSize;
                }
            } else if (resizeMode == ResizeMode::Relayout) {
                offset = glm::vec2(0.f);
                scale = newSize;
            }
        }
		renderArgs.screenSize = glm::vec2(width, height);
		renderArgs.contentScaleFactor = contentScaleFactor;
		renderArgs.projection = glm::ortho(0.f, renderArgs.screenSize.x, 0.f, renderArgs.screenSize.y, -1000.f, +1000.f);
	}
    
	if (glm::float_t(contentScaleFactor) != renderArgs.contentScaleFactor) {
		renderArgs.contentScaleFactor = contentScaleFactor;
	}

	renderArgs.areaStart = glm::vec2(renderArgs.margin.left, renderArgs.margin.bottom);
	renderArgs.areaSize = renderArgs.screenSize - glm::vec2(renderArgs.margin.left + renderArgs.margin.right, renderArgs.margin.top + renderArgs.margin.bottom);
    
    if (doRelayout) {
        offset = glm::dvec2(0.f);
        scale = renderArgs.areaSize;
        doRelayout = false;
    } else {
        applyAnimations();
        applyConstraints();
    }
    
    // must check this AFTER applying animations and constraints
    changed = changed || versionChanged();

	renderArgs.offset = offset;
	renderArgs.scale = scale;
    
	renderArgs.clearColor = Utils::colorToVec4(backgroundColor);
    
	for (auto axis : axisList) {
		//if (axis->isEnabled()) {
			changed |= axis->update(renderArgs);
		//}
	}
	for (auto series : seriesList) {
		//if (series->isEnabled()) {
			changed |= series->update(renderArgs);
		//}
	}
	for (auto decoration : decorationList) {
		//if (decoration->isEnabled()) {
			changed |= decoration->update(renderArgs);
		//}
	}
	if (!preRendered) {
		// we mark the chart as changed if it has not been pre-rendered, the purpose of the update changed value is
		// conditional rendering and if we update twice before calling render we will still need to render again.
		changed = true;
	}
    if(changed) {
        preRendered = false;
    }
	preUpdated = false;
	markVersion();
	if (title) {
		title->markVersion();
	}
	updated = true;
	return changed;
}