To animate objects, you will need to write a script using the Pascal programming language. Don't worry, it's easy to learn the basics of its syntax.
Let's start from scratch. Assuming you have a spaceship in SketchUp that you want to animate. First, convert the spaceship to a component and give it a name. Then, change the axis of the component to the bottom middle of the spaceship, that will be its rotating point. We define the axis as x, y, and z. In Sketchup, the x-axis is the green line, the y-axis is the red line, and the z-axis is the blue line. Knowing this will make it easy for you to know which axis to rotate or move the object along.
Now that your spaceship is set up properly in SketchUp, export your model to Raylectron using the CPU icon in the Raylectron toolbar.
Once Raylectron is open and your model is loaded, select Draft Mode and Simple Draft Mode from the toolbar. This will make updating the viewport much faster than if it is in render mode. Next, open the Animation tab on the right side of the screen. For this example, set the length of the animation to 30 seconds and the frame rate to 30 frames per second for smooth animations.
Now, right-click on your spaceship to load it, or select it from the list of available objects. You are now ready to enter a script in the editor. Let's rotate the spaceship along its up/down axis, which is called "yaw". Enter the following script in the editor:
Code: Select all
Yaw(360,1,10);
If you want the spaceship to accelerate in its forward direction, assuming the red line in Sketchup is aligned on the front to back of the spaceship, enter the following line of code in the script:
Code: Select all
py := Accelerate(1, meters, 0, 20);
That's it for this example. In the next section, we will explain all the variables and functions in more detail.
Here is the script for the following animation...
Code: Select all
// the video length is 30 sec at 30 fps
Roll(360,1,10); // roll 360 deg starting at 1 sec until 10
Yaw(360,11,29); // spin around 360 deg at 11 sec until 29 sec