SEED: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(fix links)
(remove origin-instructions as they are no longer nec.)
Line 32: Line 32:
== How to use it ==
== How to use it ==


{{infobox|'''IMPORTANT'''<br>The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.
{{infobox|'''IMPORTANT'''<br>The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.}}
 
In addition, the placement of entities is relative to the origin of the LODE entity. If you resize the entity in the editor, the origin can move from the center to some side. In this case select the entity, press {{key|CTRL}}+{{key|v}} to enter Vertic Mode and then move the origin back to the center (which you can easily identify, because linked entities will be drawn with their link exactly from the center).}}




Line 50: Line 48:
* Link each entity from the LODE entity by selecting first the LODE, then the entity, and then press {{CTRL}}+{{Key|K}}.
* Link each entity from the LODE entity by selecting first the LODE, then the entity, and then press {{CTRL}}+{{Key|K}}.
* Put the entities at the height you want them to appear. Alternatively, use the spawnarg '''"lode_floor"''' on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
* Put the entities at the height you want them to appear. Alternatively, use the spawnarg '''"lode_floor"''' on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
* Remember to '''dmap''' whenever you add, delete or change the position/size of a LODE!
* Remember to '''dmap''' whenever you '''add, delete or change''' the position/size of a LODE!


{{clear}}
{{clear}}
Line 67: Line 65:
== Important note ==
== Important note ==


{{infobox|The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.
{{infobox|The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.}}
 
In addition, the placement of entities is relative to the origin of the LODE entity. If you resize the entity in the editor, the origin can move from the center to some side. In this case select the entity, press {{key|CTRL}}+{{key|v}} to enter Vertex Mode and then move the origin back to the center (which you can easily identify, because linked entities will be drawn with their link exactly from the center).}}





Revision as of 05:52, 21 September 2010

Note: This is a design document and not actually implemented or available yet!

Introduction

The new and improved LOD System for TDM v1.03 lets you place entities in your map that reduce their own complexity when being far away from the player. However, there are still some huge drawbacks to this technique:

  • manually placing thousands of entities is very tedious and error prone
  • 3000 entities "thinking" (deciding what LOD they have) takes about 7% of performance, even when they are not visible
  • The overall entity limit of 8192 entities - even if only ever 100 entities are visible to the player, you would not be able to create a forest with 10000 objects (trees, treestumps, flower patches and rocks etc.), unless you combine them manually into func_statics.
  • While it is possible to combine multiple brushes/patches into one func_static to improve performance (less drawcalls), this is not possible for static models (trees, chairs etc) unless you do so in a modelling program (like Blender). But even when you do so, the created models are either too generic or too specific.

To overcome these limitations, the new LODE (Level Of Detail Entity manager) system was created by Tels in June - August 2010.


What is it

It is foremost an entity manager that can:

  • Create entities from "templates" (even multiple)
  • Place created entities on random positions with random rotations
  • Only creates the entities that are "near" the player (saving memory and CPU time)
  • Can create entities depending on the surface of the floor (no trees on metal, or only pebbles on sand etc.)
  • Removes entities "far" from the player, thus overcomes the entity limit
  • Can also manage entities that were manually placed in the map
  • Can combine rendermodels of many entities into one rendermodel, speeding up drawing thousands of things on the screen at the same time dramatically
  • Is tied in with the "Object detail" menu setting
  • Works entirely automatic, but has a lot of manual control for the mapper

The system also includes support for inhibitors, e.g. areas that are clear of generated entities. This way a forest clearing can be specified with only two entities, instead of being pieced together from multiple generators.


How to use it

IMPORTANT
The current system only supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you must set an "angle" spawnarg instead.


A LODE entity in the editor
An entity targeted by the LODE
  • In DarkRadiant, create a brush the size of the area you want to cover
  • With that brush still selected, Click the right mouse button and select Create entity and select Darkmod/Info/atdm:lode
Note:
If you want to resize the LODE entity after creating it, select it with SHIFT + Click the left mouse button and press TAB to select the brush, then resize it normally.
  • Now either add the appropriate spawn spawnargs on the LODE, or create the entities that you want to appear. (These entities are sometimes called "targets (because the LODE targets them) or templates (because they are just a blueprint for other entities that should be created). What types of entities can you use?
    • Place any entity by with Click the right mouse button -> 'Create Entity'. Entities that use the LOD system should be prefered.
    • Draw brushes/patches in DR, then turn them into a func_static.
    • You can also place a model in DR, then use/link it as entity.
  • Link each entity from the LODE entity by selecting first the LODE, then the entity, and then press CTRL+K.
  • Put the entities at the height you want them to appear. Alternatively, use the spawnarg "lode_floor" on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
  • Remember to dmap whenever you add, delete or change the position/size of a LODE!

Area shape and blocking areas

A NO LODE entity blocking an area

At the moment the area covered by the entity is always treated as a (possible rotated) box. That means you cannot get f.i. triangle shaped areas (yet). However, it is possible to block some areas inside the covered area from getting any entities via Darkmod/Info/atdm:no_lode entities. With this "boolean subtract" you can create "holes" or even more complex shapes.

To get this to work, place atdm::no_lode entities and then link them from the LODE. If you want to have one LODE inhibitor to block more than one intersecting LODE, simply link it from both. See screenshot at right for an example.


Important note

The current system only supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you must set an "angle" spawnarg instead.


GUI Setting

The current "Object detail" setting influences LOD distances, and also slightly the density spawnarg.

We want to avoid overly complicated settings like some other games have, where you can control the density, the visibility distance, the texture quality etc all on their own. But rendering slightly less mushrooms for a playable framerate is still a good idea, so LOD distance and density are coupled.

If you want a LODE that always creates the same number of entities (e.g. does not scale wit the GUI setting), see lod_scaling_limit.


Spawnargs

Please see the LODE - Spawnargs article for the spawnargs you can set.


Script events

There exist a few script events that can be used either from scripts, or by setting up a trigger that links to an atdm:target_callobjectfunction with the spawnarg call set to one of the script functions below:

disable()

Disabled the thinking of this LODE. Spawned entities are no longer culled and culled entities no longer respawned.

enable()

Enables the thinking of this LODE again. E.g. spawned entities are culled and respawned if necessary.

Activate()

Activates the LODE, e.g. if wait_for_trigger is true, it starts spawning entities.

CullAll()

Removes all entities under control of this LODE from the game. Only useful if either the player is very far away, or if you have called Deactivate() before - otherwise the entities might be spawned again in the next frame.


Ideas

Worth considering:

lode_strategy

How the entities will be placed. Default: "random", but can be "grid" (needs a way to specifiy grid-size, grid spacing, and random-offset from grid position).

lode_oriented_z

If true, orient the entity perpendicular to the floor, before applying the random rotation values. Good for things that should stand on step inclines.

See also