Dragons Pose and Fly

Dragon and DragonBaby Objects

Alice 3 has two types of Dragons, each coming in different colours, with or without tutu (Ballet dress). In addition to all procedures available for quadrupeds, Dragons also have some particular procedures, functions, and properties they do not share with the others. Some gestures are available with ready-made procedures, others as movement of the wings and tail need to be programmed.

Images of instances of classes Dragon and DragonBaby

DragonBaby with tutu

Introduction of the Classes Dragon and DragonBaby

Dragons are a subclass of the abstract class quadrupeds. So all dragons inherit all the procedures, functions, and attributes from their superclass Quadrupeds.

But Dragons also have additional procedures, functions, and attributes we will describe and make use of here, they also vary slightly between Dragon and DragonBaby.

Procedures

So Dragons have the “out of the box” procedures

  • dancingPose
  • setDragonResource

and DragonBabies have

  • leapPose
  • sittingPose
  • setDragonBabyResource

These procedures can be changed, they are editable. Just click at the edit link preceeding each procedure block, and check the code. In particular the poses are interesting to study and reuse if you want to code your own.

So far you may have often used the one shots button in the Scene Editor to check out how certain procedures change subparts of your objects. When you try to figure out how to move the wings of your dragons you will not find any suitable joint functions there. The one shots button only shows you all non-changeable procedures und functions. The movements of the wings of the dragon need to be programmed by yourself. There are functions to get access to several joints at the wings, have a look below. Dragon and DragonBaby have a different joint structure, therefore the movements have to be programmed separately.

In order to move the wings, you have to use the code editor and assemble the procedures by yourself. First, just pick the type of movement and then drag and drop the respective function for the joint you want to bend.

Functions of joints and procedure iFly to move the wings of the Dragon

Functions of joints and procedure iFly to move the wings of the DragonBaby

Above you find two procedures for a basic flying movement of the wings of Dragon and DragonBaby. They are available as DragonFlies.a3c and DragonBabyFlies.a3c on the repository to this website for download. After you have the files on your computer, just import them as shown in one of the previous posts to this series.

Some more information about how to manipulate the joints

4 joints of the Dragon's wings.

The image here shows 4 of the 5 joints the Dragon’s right wing has. The basic wing movement only turns the Base joint of the wing.

You can check out the joints by yourself in the Setup Editor, just select your object (here a Dragon you have created beforehand), then in the upper part of the Property Inspector select your object and the joint, choose Opacity = 0.3 below and click on Show Joints. Your object will become shady, but you can see a lot of coordinate systems with coloured axis appear. Each of those represents one joint you can manipulate. The colours give you an indication about the direction for the movements you want to program.

White is the most important direction, it represents the forward movement, it points in the direction of the tip of the wing. The green axes represents the up direction. For the dragon this translates to a turn backward block to get the down movement of the wing at the beginning.

white -> forward
blue -> backward
red -> right
green -> up

Code for video

This is the complete code used to make the short video at the beginning of the post. In addition, you will need to fix some camera markers so that you can better record the short scene.

Project showing off the dragons' abilities as they are right now

Outlook: Tail of the dragons

Besides the movement of the wings, there is another bodypart you may want to move, that is the tail. When you check in the Code Editor, Functions, others you find a function named getTailArray.

Similar to the wings, the tail consists out of several joints. If you only move one joint, the whole movement looks a bit stiff and not natural. That’s what you may have noticed when looking at the video above showing the flapping of the wings.

For a movement of a trunk (elephant and others) or tail (dragon and others) this looks even more awkward. Therefore, Alice places all joints related to trunks and/or tails into a structure called array so that you can move them jointly.

An array is a list of elements of the same type, here the position of each joint of said limb. These allows you to operate each array element (i.e. joint) with an iterator operating on each element of your array, either in order, sequentially one after the other, or together, simultaneously.

This is not covered here in detail, but you can have a look at this video explaining about joint arrays. The new elements are introduced after the video was running 3:55.

After seeing this video, you should have no problems to make the movements of your animals even more realistic.