concept animation in category c#

appears as: nimations, n animation, An imation, imation, nimation, imations, Animations
Unity in Action: Multiplatform game development in C# with Unity 5

This is an excerpt from Manning's book Unity in Action: Multiplatform game development in C# with Unity 5.

Continuing the art analogy, you can think of a material as the media (clay, brass, marble, and so on) that the sculpture is made of. Similarly, an animation is also an abstract layer of information that’s attached to a visible object.

Recall that two of the types of art assets discussed in chapter 4 were 3D models and animations. The term 3D model is almost a synonym for mesh object; the 3D model is the static shape defined by vertices and polygons (that is, mesh geometry). For a humanoid character, this mesh geometry is shaped into a head, arms, legs, and so forth (see figure 7.2).

7.4. Setting up animations on the player character

Besides the more complex shape defined by mesh geometry, a humanoid character needs animations. In chapter 4 you learned that an animation is a packet of information that defines movement of the associated 3D object. The concrete example I gave was of a character walking around, and that situation is exactly what you’re going to be doing now! The character is going to run around the scene, so you’ll assign animations that make the arms and legs swing back and forth. Figure 7.11 shows what it’ll look like when the character has an animation playing while it moves around the scene.

Figure 7.11. Character moving around with a run animation playing

A good analogy with which to understand 3D animation is to think about puppeteering: 3D models are the puppets, the animator is the puppeteer, and an animation is a recording of the puppet’s movements. Animations can be created with a few different approaches; most character animation in modern games (certainly all the animations on this chapter’s character) uses a technique called skeletal animation.

Real-World Functional Programming with Examples in F# and C#

This is an excerpt from Manning's book Real-World Functional Programming with Examples in F# and C#.

Listing 1.6 uses a declarative library for creating animations that we’ll develop in chapter 15. You don’t have to fully understand the code to see the benefits of using the declarative style. It’s similar to WPF in a sense that it describes how the animation should look rather than how to draw it using a timer.

Listing 1.6. Creating functional animation (C#)

We’ll explain everything in detail in chapter 15. You can probably guess that the animation creates two ellipses: a green and a blue one. Later, it animates the location of the ellipses using the Translate ❷ method and composes them using the Compose method ❸ into a single animation (represented as the animation value). If we render this animation to a form, we get the result shown in figure 1.1.

Figure 1.1. The ellipse on the right is moving from the left to the right, and the ellipse on the left is moving from the top to the bottom.

The entire declarative description is based on animated values. There’s a primitive animated value called Time.Wiggle, which has a value that swings between −1 and +1. Another primitive construct, x.Forever(), creates an animated value that always has the same value. If we multiply Wiggle by 100, we’ll get an animated value that ranges between –100 and +100 ❶. These animated values can be used for specifying animations of graphical objects such as our two ellipses. Figure 1.1 shows them in a state where the X coordinate of the green one and the Y coordinate of the blue one are close to the +100 state.

In listing 1.6, we don’t have to know anything about the representation of animated values, because we’re describing the whole animation by calculating with the primitive animated value. Another aspect of the declarative style that you can see in the code is that the animation is, in principle, described using a single expression. We made it more readable by declaring several local variables, but if you replaced occurrences of the variable with its initialization code, the animation would remain the same.

Listing 15.1. Specifying animations using discriminated unions (F#)

Using this type, we can now create values describing simple animations. In some sense, the types in listing 15.1 specify the syntax when using the library for creating animations, because it specifies what a valid animation value is. The following snippet shows the same animation as the LISP example:

let animation =
  Compose(
    Disc(Brushes.Green, 50, Rotating(PointF(0.f,0.f), 100.f)),
    Disc(Brushes.Red, 20, Linear(PointF(-100.f,0.f), PointF(100.f,0.f)))
  )

This creates a value with a tree-like structure describing an animation composed from two discs. It specifies how the location of each object changes over time and the F# data structure AnimatedLocation allows us to create objects that are static, rotating, or moving along a line.

You might describe the concept of an animation as a drawing that changes over time. We’ve seen that we can represent a value changing over time as a behavior, so animation is a behavior of a drawing. This means that we can represent animations using the Behavior<Drawing> type.

By that definition, we’ve already implemented a library for creating animations! Let’s see how to create an animation using our existing types. We ended the previous section by creating a simple drawing in F# (a value called greenAndBlue). We can turn it into an animation by using a function that creates a constant behavior:

> let animDrawing = forever greenAndBlue;;
val animDrawing : Behavior<Drawing>

The type of the result is Behavior<Drawing>, which is the type that we’ll use to represent animations. This is only an animation in the weakest possible sense: the drawing always stays the same but it’s enough to let us at least try to display animations. It’s at last time to create the application to run the animations.

15.5.2. Creating animations using behaviors

Now that we have all the underlying machinery to create animations and a form to display them in, we can start creating animations. We’ll start with the drawing of two colorful circles we created in F# earlier and create an animation that moves it. We’ll only use F# in this section as we’ll be using F# Interactive to experiment. You’ll see that the primitives we’ve already written provide quite a lot of flexibility, and we’ll consider what other operations we might want to do with animated graphics. After that we’ll go back to implementing everything in both F# and C#. Listing 15.17 creates the form and displays our first animation.

Listing 15.17. Creating simple animation (F# interactive)

Listing 15.17 begins by creating a version of the translate primitive that works with animations using lifting ❶. The original function created a new drawing by translating an existing drawing in a fixed way. This version creates a new animation by translating an existing animation in a variable way. Whenever the form wants to draw a frame of the animation, the animation will ask the two float32 behaviors what their values are at that point, to work out how to translate the drawing. It will then ask the original animation to draw itself (again, for the specified time), but translated appropriately.

The implementation uses the Behavior.lift3 primitive, which turns a function with three arguments into a function that works with behaviors. As you can see from the inferred type signature, the function now takes two behaviors specifying the offset and one specifying an animation (the use of #<type> isn’t important here, so we can read it as a type Behavior<Drawing>); the return type is another animation.

Don’t worry if you find this a bit confusing to start with:[2] just think of it as combining three entirely separate time-varying values. One specifies a horizontal offset, one specifies a vertical offset, and one specifies what the drawing would look like if we weren’t translating it at all. On the next two lines, we use this primitive to create an animation, which you can see in figure 15.5.

ASP.NET AJAX in Action

This is an excerpt from Manning's book ASP.NET AJAX in Action.

Changing the layout of DOM elements is one of the main tasks in dynamic HTML pages. For example, features like animations, scrolls, and drag and drop rely on the positioning and the style of DOM elements. Let’s return to the Sys.UI.DomElement class to examine a group of methods related to CSS and positioning.

The transition from static pages to Dynamic HTML pages opened the possibility of creating more appealing UIs. Static links, images, and panels turned into floating menus, slideshows, scrollers, and fading panels. Now, clever use of CSS and the DOM is required to obtain a modern web UI that enhances the user experience. Animations and visual effects are the key concepts you need to master. In the following sections, we’ll examine the framework for creating animations and visual effects provided by the Ajax Control Toolkit.

Figure 10.13. Base classes for the animations defined in the Toolkit animation framework

In the Toolkit animation framework, you can create animations three different ways:

The animation extender is a Toolkit extender that defines animations in a web page based on an XML description. Being an extender, the AnimationExtender must extend a server control declared in the page. The extended control—set, as usual, through the TargetControlID property—is a control that triggers one or multiple animations. For example, if you wire the AnimationExtender to a Button control, you can play single or multiple animations based on the events raised by the button element. Listing 10.11 shows the skeleton structure for the AnimationExtender control.

Listing 10.11. Skeleton of the animation extender
<ajaxToolkit:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="Button1"> <Animations> <OnLoad></OnLoad> <OnClick></OnClick> <OnMouseOver></OnMouseOver> <OnMouseOut></OnMouseOut> <OnHoverOver></OnHoverOver> <OnHoverOut></OnHoverOut> </Animations> </ajaxToolkit:AnimationExtender>

The child Animations element contains XML elements mapped to events raised by the DOM element rendered by the extended control. Listing 10.11 assumes the extender is wired to a Button control with the ID of Button1. The elements under the Animations node represent events raised by the DOM button element. In the elements, you specify which animations you want to play in response to the event. For example, animations declared under the OnClick element are played as soon as the element is clicked. The only exception is represented by the OnLoad element:

10.3.5. JSON and animations: adding transitions to the PhotoGallery control

When you use the AnimationExtender or the UpdatePanelAnimationExtender, the XML that defines the animations is parsed on the server side. The result is a JSON-serialized object that is sent on the client side and used to create instances of the animation classes. The following example will give you the opportunity to experiment directly with the JSON syntax for creating animations.