Learning Goal

The goal of this tutorial is to demonstrate the project creation workflow and the structure of a project in PALAIS.

The New Project Dialog

The easiest way to set up a new project in PALAIS is to use the "New project" dialog. You can access the "New project" dialog through the menu bar or by pressing [CTRL] + [N] on Windows or [CMD] + [N] on Mac.

The new project dialog enables you to let PALAIS create the base structure of your project. Simply enter the desired project name, the name of the main JavaScript logic file and a directory in which to place the project. Upon creation PALAIS will create a folder in this directory containing a file named "project.js" that contains the meta data for your project and your project's main logic file.

The Project File

1 {
2   "name" : "my_scene",
3   "scene" : "resources/my_scene.scene",
4   "resources" : ["resources/scene_characters", 
5                  "resources/scene_villains"],
6   "logic"  : "main.js"
7 }

A project file is simply a JSON object with special keys describing the meta data of your project. The following list explains the purpose of each of the available properties.

  • name: The name of your project.
  • scene: A relative path to the scene file you wish to load at startup. Currently only OGRE's .scene files can be loaded. PALAIS can only load a single scene in a project.
  • resources: A list of relative resource directories to load at startup. Currently only resources in OGRE's .mesh format can be loaded. Any 3D models you wish to dynamically instantiate (eg. through javascript code) have to reside in one of these directories or the .scene file's directory.
  • logic: The main JavaScript logic file to load at startup.

The Main Logic File

1 function onSetup() {
2 }
3 
4 function onTeardown() {
5 }
6 
7 function update(deltaTime) {
8 }

The main logic file is your projects entry point. It contains 3 important functions that PALAIS automatically calls at the appropiate times. Note that for PALAIS to be able to call these functions they must exactly match these names. Any code that is placed in the global scope will be evaluated at load time.

  • onSetup(): Called before the first time update is invoked.
  • onTeardown(): Called when a project is closed.
  • update(deltaTime): Called periodically by the simulation environment. Note that for the sake of reproducibility deltaTime is actually a fixed time interval. The simulation is sped up or slowed down by emitting fewer of these events per actual time passed.

Loading Your Project

To load your project bring up the "Open Project" file dialog by clicking the corresponding button in the menu bar or pressing down [CTRL] + [O] on Windows or [CMD] + [O] on Mac. Next, select your project's meta data file ("project.js" in the example above) from your hard drive. PALAIS will automatically load the project according to the configuration given in the meta data file.