Skip to content

Projects

Shaye Garg edited this page Oct 4, 2021 · 10 revisions

A behave project can (and should) consist of many files:

  1. The main file (required)
  2. Several secondary files (highly recommended)

The file extension for behave files is .beh. You must follow this otherwise no secondary files will be detected or imported. Secondary files can be placed in nested folders or alongside the main file.

Uses

Every file can contain uses. They are used to bring items (structs, enums, templates, and functions) from secondary files into scope so they can be referred to by Item instead of This.Very.Long.Path.To.My.Item.

Uses are handled at a scope level, so you can put them anywhere.

A use statement is written:

use Path.To.File.Or.Folder;

The path is relative to the main file, so use This.That would look for a file or a folder named This in the same folder as the main file.

It will then bring That into scope. If That is a file, all the items inside it will be brought into scope as That.{item}. If That is a folder, all files and subfolders inside it will be brought into scope as That.{sub}.

Main File

The main file of a behave project can contain two elements: lods and behavior. The behavior element is optional.

lods

The lods element allows you to define the .gltf files to use as LODs in your model.

It is written:

lods {
    <min_size> -> <lod_file>,
    // Which would look something like:
    50 -> "LOD1.gltf",
    0 -> "LOD2.gltf"
}

Note that trailing commas are not allowed.

min_size: The minimum size of the bounding sphere of your object as a percentage of the size it takes on the screen. This is followed then the graphics setting Object Level of Detail is set to 100. Other values will scale these values down as appropriate.

lod_file: The path to the .gltf file to use, relative to the directory where the output .xml is placed. This is checked at compile-time, and if the file does not exist, an error is raised.

behavior

The behavior element defines how the model will behave (haha get it). It is optional as not all models require behaviors.

It is written:

behavior {
    <behavior_expressions_or_declarations>
}

The behavior element contains a list of behavior expressions or variable declarations.

Secondary Files

All the secondary files can contain a list of items:

  1. structs
  2. enums
  3. templates
  4. functions (fn)

Functions are declared much like in here, but since they are items you need to add an <ident> between the fn and argument list:

fn <ident>(<args>) -> <ret> {
    <code>
}
Clone this wiki locally