Entities can be created in three ways:
Entities placed or created in the level are named Level Entities; entities defined in the script are either visible in front of the screen (View Entities) or in the background of the level (Sky Entities). View entities are visible even if there is no level loaded at all, and 'survive' level changes. They can be used to display 3D elements of the user interface, like a rotating compass or a steering wheel . Here's a short table with the main differences between level, view, or sky entities:
Level entities |
View entities |
Sky entities |
|
Entitity types | Model, map, sprite, terrain | Model, sprite | Model, sprite |
Created with | WED, ent_create | ENTITY* struct, ent_createlayer | ENTITY* struct, ent_createlayer |
Used for | actors, vehicles, vegetation | 3D panel elements | sky, background, horizon |
Rendered in | level | screen foreground | level background |
Visible when | INVISIBLE flag not set | SHOW flag set (flags2) | SHOW flag set (flags2) |
Removed by | ent_remove, level_load | ent_remove* | ent_remove* |
Events | collision & mouse | none | none |
Visual order | view distance | layer | layer, view distance |
Coordinates | world coordinates | view coordinates | view position, world rotation |
View entities are defined in the following way:
ENTITY* compass_panel = { type = "compass.mdl"; layer = 2; // display above panels with layer 1 flags2 = SHOW; // visible on screen from the start
x = 100; // place 100 quants ahead of the view y = -50; // 50 to the right z = 0; // and center vertically }
Sky entities are defined in the following way:
Sky entities are either dome, cylinder, or cube mapped, depending on flags given in the definition. When no such flag is set, the sky entity is rendered into the level background at its x y z position given. This way, sun, moon or other celestial objects can be drawn onto the sky. LC In lite-C, sky entities are defined the same way as view entities, except that their SKY flag is set.
In a level without map geometry (blocks), a sky that you activate in the script is automatically visible in the background. In a level with map geometry (blocks), the sky is only visible when a block with a sky surface is visible. When using several sky layers, take care to disable any sky layer that is covered by other intransparent layers, and also disable the background color (sky_color). This avoids unnecessary rendering and keeps the frame rate high.
ENTITY* skycube =
{
type = "skycube+6.tga"; // the image for a backdrop scene
flags2 = SKY | CUBE | SHOW; // sky cube, visible
}
SKY skycube =
{
type = "skycube+6.tga"; // the image for a backdrop scene
flags = CUBE | SHOW; // sky cube, visible
}