Saturday, March 31, 2018

Basic 3D Animation with SceneMax language

Animating a 3D model is fairly easy with SceneMax. The language comes with a few built-in models so we can use them for this tutorial.
Let's dive in directly to the actual animation code:

Sinbad is a model ;
this tells the computer to look for a resource called Sinbad which is a 3D model 

David is a Sinbad ;
this line declares a variable named David a new instance of Sinbad.
let's run these two lines of code and see what happens.


Now, let's rotate our model
David.rotate(y+360) in 2 seconds ;
this will rotate our model a full 360 degrees revolution around Y axis



And finally let's do some bones (or skeleton) animation. Sinbad model comes with a few built-in skeleton animations. let's try some of them
David.Dance then SliceVertical ;
we told the computer to first run the Dance animation and then the SliceVertical animation

Pretty impressive for a 4 lines of code program...

Friday, March 30, 2018

2D Sprite Animation with SceneMax

Sprite Animation

Sprite animation is easy and fun with SceneMax. All we need is a image divided to small frames such as this one:

Here we have one image divided to 5 rows and 6 columns giving us a total of 30 frames. We call that kind of image a Sprite Sheet.

In SceneMax, write the following program:

RunningMan is a sprite ;
David is a RunningMan ;

Let's run the program


The entire image with all its frames is shown on the screen.
Now let's refine our program and divide the image to 5 rows and 6 columns:

RunningMan is a sprite having rows=5 and cols=6;
David is a RunningMan ;

Now, let's run the program


Great! the image is now divided into 30 frames and we see only one small frame every time. By default the first frame (frame number 0) is shown.

Now let's add some animation to the RunningMan sprite:
.
RunningMan is a sprite having rows=5 and cols=6;
David is a RunningMan ;
David.play(frames 0 to 29 in 2 seconds) ;

Run the program and see how the sprite is playing its frames from 0 to 29 in 2 seconds giving us the illusion of a running man.
By default the frames are played just once. We can change the playing strategy for one of the following options:

Loop - play the frames any number of times for example:
David.play(frames 0 to 29 in 2 seconds)  loop 3 times ;

If we just type Loop, then it will play the frames forever for example:
David.play(frames 0 to 29 in 2 seconds)  loop ;

Time duration - play the frames for a given amount of time for example:
David.play(frames 0 to 29 in 2 seconds)  for 10 seconds ;


Moving the sprite

We can move our sprite on any of the 3 axes - X, Y or Z for example:
David.move(z+5) in 2 seconds ;

this will move the sprite on along the Z axis