Raymond
Demo: Green Dragon

Articles with the tag: Timing

Framework: animation clip subsystem test

Animation base complete: IK is blended with animation clips and morph targets.

Making a couple of looping "idle" animations in Blender dragon rig to make the simulated character more realistic and life-like.

A pre-rendered animation I made in Blender to show off my dragon model:

The skeletal animation works in my animation subsystem for CharSim:

Testing a crude looping "idle" animation - it works with mouse-following IK and facial morphing.:

Read More »


Framework: animation clip attributes

Time structures:

Real time:

double timer; // Time since GLFW initialisation.
float tDelta; // Time per frame (could also be considered Game Time)

Game time:

float tGame; // Time since first frame (i.e. first update-draw cycle)
float tDuration; // Game-time duration for clip, whose clipDuration will be warped to match it.
// Placeholders for time-based events. Likely entered as literals in the animation update logic.
float tStart;
float tStop;

Animation time:

float tAnim // Time taken since animation starts (Animation Time) (could include repeated clips)

Clip time (supports warping):

float tClip // Time taken since clip starts (Clip Time). Calculated by modding tAnim with tClipDuration).
float tWarp; // Ratio by which tClipDuration is warped by to match the given game-time tDuration.
float tClipDuration;

Clips are loaded onto a an array ClipArray. A call to play a clip sets its isPlaying value to 'true' and each clip is iterated through each update cycle.

struct Clip
{
    String clipId;       // Name ...

Read More »


Framework: animation clip sequences

So far I've been implementing the dragon in SkeletonNode for testing purposes. This needs to be abstracted into a separate DragonNode (for the dragon demonstration character) and then the SceneGraph should be implemented with ControllerNode SceneGraphs which handle broad movement. They can also receive user input and control AgencyNodes and InteractiveNodes by calling their animation sequences.

Speaking of animation sequences, they need to be turned into callable functions and be blendable together.

Animation system: how to make a trigger call an animation clip on time.

It can't be based purely on comparison with an elapsed time. For instance, if a trigger is set to play a clip after 10 s (seconds), the elapsed time is likely to be fractional in any specific frame: 9.999... 10.002..., so the trigger will be missed.

A margin of error could be used, but this creates an inaccuracy and the game ...

Read More »


Animation clip timing interval

On the efficiency of hashtables:

Using map for animation list for ease of directly programming the animation. In a real game an array of animations would be more efficient, to be accessed via the index.

On building the animation interpolation method:

An animation clip may consist of a number of keyframes at certain timestamps associated with bone transformations (in seconds, s) in a range, e.g.: 0.0 s, 0.4 s, 1.2 s, 3.2 s, 5.5 s.

Where each keyframe time represents a state of transformation which must be interpolated with the previous one, i.e.: "0.0 -> 0.4", "0.4 -> 1.2"... where each progression can be termed a "step". A way to interpolate the transformations is to linearly interpolate between each timestamp step based on the time elapsed since the animation clip is started, then normalise the value within the range.

For instance ...

Read More »


Performance profiling

CPU is taking up 100%. Profiling.

[28/03/14 15:42]

Used gprof to profile function call times.

The game loop runs at a maximum 60 hz to prevent overloading the CPU, but it still checks whether or not the time is correct as fast as it can, as shown by the code:

while (true)
{
    new_time = glfwGetTime();

    if (new_time - last_time >= (1.0 / 60.0))
        // Update, Render...
}

The checking and conditional for the correct time must be integrated in the 60 hz loop.

Bool flags might be a less taxing option.

Using bool flag method:
Function time: 190 ms or 30 ms...
Using old method:
1.5 seconds.

Well it's better, but it cuts the FPS by a tiny amount which might lead to syncing problems in the future.

[28/03/14 16:09]

Changing conditional's predicate (1.0 / 60.0) to a pre-calculated variable shows that it was ...

Read More »


Game timing and time delta

Looking at throttle and framerates. This is important before setting up a test rotation as time interval is needed for calculating changes in distance. Do mainstream games apply frame limiters? They don't appear to, instead relying on vsync options. Perhaps the simulation updates are limited, but render is called as much as possible (the CPU shouldn't be expected to keep up with the GPU's framerate).

60 frames per second is optimal (at least on my screen), but the framerate must be checked and compensated for if it goes below that to maintain framerate-independent motion.

Frametime at 60 fps = 1/60 s = 16.6 ms

Let frametime be interval t, a parameter.

Thus for consistent position over time: x' = x + v*t

Where x' is the change in position depending on velocity v and frametime t.

ModelNodes and other moving elements should be controlled by SceneGraphs called Controllers ...

Read More »


Page 1 / 1