User Tools

Site Tools


hpl3:engine:entities

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
hpl3:engine:entities [2013/10/08 13:03]
ian.thomas Typo
hpl3:engine:entities [2015/09/28 08:29] (current)
mudbill Patched up some sentences and typos.
Line 1: Line 1:
 ===== Entities ===== ===== Entities =====
- 
  
 ==== General ==== ==== General ====
-Generals ​all use .ent files that are created in the model editor tool. Exactly how an entity functions is largely up to the app using the engine. Entities can be background props, enemies, and pretty much whatever. For more specific information on the basic types that are provided in the default game setup, check the [[hpl3:​game:​scripting|Game Scripting Guide]].+ 
 +In general ​all ".ent" ​files are created in the model editor tool. Exactly how an entity functions is largely up to the app using the engine. Entities can be background props, enemies, and pretty much whatever. For more specific information on the basic types that are provided in the default game setup, check the [[:hpl3:​game:​scripting|Game Scripting Guide]].
  
 On this page the more general structure of entities will be covered. On this page the more general structure of entities will be covered.
Line 9: Line 9:
 ==== Lowlevel Structure ==== ==== Lowlevel Structure ====
  
 +At the very basic level, an entity comes as an "​.ent"​ file that is loaded by the engine. The engine provides a basic loader for entities that handles loading of the basic types contained in it. The game can provide its own loader built from scratch, but one almost always wants to use the loader that the engine provides. The default game provides a few basic types like Props (doors, buttons, dynamic crates, etc.) and Agents (enemies, NPCs, etc.) that are used as foundations for the entity used in the game.  The final entity type is defined by a script file, which takes care of all specific entity loading, setup and logic.
  
-At the very basic level an entity comes as an .ent file that is loaded by the engine. The engine provides ​basic loader for entities that handles loading of the basic types contained in it. The game can provide their own loader built from scratchbut one almost always wants to use the loader that the engine providesThe default game provides a few basic types like like Props (doorsbuttons, dynamic crates, etc) and Agents ​(enemies, NPCs, etc) that are used as a foundation for the actual entity used in the game.  The final entity ​type is defined by a script filewhich takes care of all specific entity loading, setup and logic.+In order to specify ​typeit first needs to be added to ''"​config/​EntityTypes.cfg"''​ under the basic game type it should use (PropAgent, etc.). Here the name (used as an identfier), ​the script file, the class name (refering to the main class in the script file) and whether it is forced to have full game save (if all data is always saved) is specified. The editor must also know about this type and to do this ''"​editor/​EntityClasses.def"''​ needs to be updated with the type's [[:​hpl3:​engine:​entities|variables]]. Once this is donethe type is ready to be used in the game and editor.
  
 +Inside the game, each entity has a complete copy of all data, except for mesh and animations. So this means that the type variables are contained in each copy of the entity. This takes up a bit of extra memory but makes it much easier to handle entities. For instance, it is okay to change a type-defined variable for one specific instance of an entity if needed.
  
-In order to specify a type it first needs to be added to ''"​config/​EntityTypes.cfg"''​ under the basic game type is should used (Prop, Agent, etc). Here the name (used as an identfier), the script file, the class name (refering to the main class in the script file) and if it is forced to have full game save (if all data is always saved) is specified. Then the editor must also know about this type and do do this ''"​editor/​EntityClasses.def"''​ needs to be updated with the type's [[:​hpl3:​engine:​entities|variables]]. Once this is done, the type is ready to be used in game and editor. +**Example:​** \\
- +
- +
-Inside the game, each entity has a complete copy of all data, except for mesh and animations. So this means that the type variables are contained in each copy of the entity. This takes up a bit of extra memory but make it much easier to handle entities. For instance it is okay to change a type-defined variable for one specific instance of an entity if needed. +
- +
- +
-**Example:​** \\ +
 The entity "​Prop_Lamp"​ uses the basic type "​Prop"​ and is meant to be used for any lamp-like objects in the game. The file ''"​config/​EntityTypes.cfg"''​ has been updated with: The entity "​Prop_Lamp"​ uses the basic type "​Prop"​ and is meant to be used for any lamp-like objects in the game. The file ''"​config/​EntityTypes.cfg"''​ has been updated with:
 <code xml> <code xml>
-<​PropType ​+<​PropType
  Name = "​Prop_Lamp"​  Name = "​Prop_Lamp"​
  ScriptFile = "​props/​Prop_Lamp.hps"​  ScriptFile = "​props/​Prop_Lamp.hps"​
Line 30: Line 26:
 </​code>​ </​code>​
  
- +This is added to the ''​PropTypes''​ element and contains the needed data for the game.\\ 
-This is added to the ''​PropTypes''​ element and contains the needed data for the game \\  +To use it in the editor, ''"​editor/​EntityClasses.def"''​ has also been updated with the following:
-To use it in the editor, ''"​edtitor/​EntityClasses.def"''​ has also been updated with the following:+
 <code xml> <code xml>
 <Class Name="​Prop_Lamp"​ InheritsFrom="​Prop">​ <Class Name="​Prop_Lamp"​ InheritsFrom="​Prop">​
Line 40: Line 35:
  </​EditorSetupVars>​  </​EditorSetupVars>​
  <​TypeVars>​  <​TypeVars>​
- <Var Name="​CanBeLitByPlayer"​ Type="​Bool" ​ DefaultValue="​true"​ Description="​If the player can lit this lamp by direct interaction."​ />+ <Var Name="​CanBeLitByPlayer"​ Type="​Bool" ​ DefaultValue="​true"​ Description="​If the player can light this lamp by direct interaction."​ />
  ...  ...
  </​TypeVars>​  </​TypeVars>​
Line 50: Line 45:
 </​code>​ </​code>​
  
- +This makes the editors (model and level) aware that the type exists and provides them with info on what variables it should haveas well as any special behavior. More specifics are found [[:​hpl3:​engine:​entities|below]].
-This makes the editors (model and level) aware that the type exists and provides them with info on what variables it should have as well as any special behavior. More specifics are found [[:​hpl3:​engine:​entities|below]].+
  
 ==== Data Structure ==== ==== Data Structure ====
Line 57: Line 51:
 An entity is built up from several different elements, all contained or referenced to by the ent file. An entity is built up from several different elements, all contained or referenced to by the ent file.
  
-**Mesh**\\ +**Mesh** \\ 
-This is the core object for almost all entities. The data is a mesh file ("​.dae"​ or "​.msh"​) ​that can that comes in the form of a separate file which the entity references ​to. An entity can only have a single mesh connected to it. Note that several entities can connect to the same mesh file. This is the only part of the data that is required for the entity to load properly.+This is the core object for almost all entities. The data is a mesh file ("​.dae"​ or "​.msh"​) that comes in the form of a separate file in which the entity references. An entity can only have a single mesh connected to it. Note that several entities can connect to the same mesh file however. This is the only part of the data that is required for the entity to load properly.
  
-**Animations**\\ +**Animations** \\ 
-An entity file can have one or more animations. In order to have animations there needs to be a mesh connected to the entity file as well. Animations are connected to the entity as separate files ("​.dae_anim"​ or "​.anim"​). It is okay if several entities share the same animations. ​+An entity file can have one or more animations. In order to have animations there needs to be a mesh connected to the entity file as well. Animations are connected to the entity as separate files ("​.dae_anim"​ or "​.anim"​). It is okay for several entities ​to share the same animations.
  
-**Bodies**\\ +**Bodies** \\ 
-This gives the entity its physics properties and allows it to collide and interact with the game's world and other entities. A body is made up from more or many shapes. If the mesh has several submeshes and there are several bodies, it must be specified which submesh belong to which body. This data is defined in the entity file. +This gives the entity its physics properties and allows it to collide and interact with the game's world and other entities. A body is made up from more or many shapes. If the mesh has several submeshes and there are several bodies, it must be specified which submesh belong to which body. This data is defined in the entity file.
  
-**Joints**\\ +**Joints** \\ 
-These are used to joint up several bodies in various ways (e.g. create a door hinge between door and frame) or just attach a single body to the world in some way. This data is defined in the entity file. +These are used to joint up several bodies in various ways (e.g. create a door hinge between door and frame) or just attach a single body to the world in some way. This data is defined in the entity file.
  
-**Effects**\\ +**Effects** \\ 
-This includes stuff like particles, billboards, flares, sounds, etc. Everything that can be added to spice the entity up. If there are multiple bodies then it needs to be specified where each effect is attached. Effects can also be attached to the bones of a skinned character. This data is defined in the entity file. +This includes stuff like particles, billboards, flares, sounds, etc. Everything that can be added to spice the entity up. If there are multiple bodies then it needs to be specified where each effect is attached. Effects can also be attached to the bones of a skinned character. This data is defined in the entity file.
  
 ==== Creation Workflow ==== ==== Creation Workflow ====
  
-Here is summary of the basic kind of worlflow ​that is used when creating an entity.+Here is summary of the basic kind of workflow ​that is used when creating an entity.
  
-The creation of an entity mostly starts out with the creation of a mesh. This mesh is made in a program like Blender or Maya and it is then exported as a Collada file. Matierals ​then need be used for the mesh so it can be loaded properly into the engine. For the basic steps on how to create a model, check this [[hpl3:​tutorials:​basic_modeling|tutorial]].+The creation of an entity mostly starts out with the creation of a mesh. This mesh is made in a program like Blender or Maya and it is then exported as a Collada file. Materials ​then need be made for the mesh so it can be loaded properly into the engine. For the basic steps on how to create a model, check this [[:hpl3:​tutorials:​basic_modeling|tutorial]].
  
-Oncee the mesh is done the entity file is created. Usually, there is a one-on-one relationship between the ent file and the mesh file (.dae) so it is best to put both in the same folder and let them have the same name. For example, if the mesh has the name "​my_model.dae"​ the entity file should be name "​my_model.ent"​.+Once the mesh is donethe entity file can be created. Usually, there is a one-on-one relationship between the .ent file and the mesh file (.dae) so it is best to put both in the same folder and let them have the same name. For example, if the mesh has the name "​my_model.dae"​ the entity file should be named "​my_model.ent"​.
  
 It is now time to open the ModelEditor tool. It is now time to open the ModelEditor tool.
  
-Next up comes building the physics for the entity. Not all entities require this (for instance Agents), but most do. One or several bodies are then created that approximate the mesh shape somewhat (here is a [[hpl3:​game:​guides:​artists_guide#​creating_bodies_for_collision|guide]] on how to do that properly). Properties such as mass, material, etc are then set to the bodies and if needed they are connected using joints. ​+Next up comes building the physics for the entity. Not all entities require this (for instance Agents), but most do. One or several bodies are then created that approximate the mesh shape somewhat (here is a [[:hpl3:​game:​guides:​artists_guide|guide]] on how to do that properly). Properties such as mass, material, etcare then set to the bodies and if neededthey are connected using joints.
  
-If needed, now is a good time to add any animation files are needed for the model. Usually these are placed in a folder named ''"​animation"''​ residing in the same path as the mesh file (if animations are shared, another setup is probably required).+If needed, now is a good time to add any animation files that are needed for the model. Usually these are placed in a folder named ''"​animation"''​ residing in the same path as the mesh file (if animations are shared, another setup is probably required).
  
-Particles, lights, sounds, etc are now added and attached to bodies or joints if applicable. The entity can be tested inside the model editor to make sure every thing works according to plan. The entity file is saved and the model editor ​can be closed down.+Particles, lights, sounds, etcare now added and attached to bodies or joints if applicable. The entity can be tested inside the model editor to make sure everything ​works according to plan. The entity file can then be saved.
  
-Now the final step in the model editor: setting up type variables. This is some of the of the variables that have been specified in the ''"​EntityClasses.def"''​ file used by the level editor. Usually this deals with type specific gameplay related properties like how long a door takes to open, how fast a creature is, etc. Each different entity type has a different set of type variables (but share many with other entity types).+Now the final step in the model editor: setting up type variables. This is some of the variables that have been specified in the ''"​EntityClasses.def"''​ file used by the level editor. Usually this deals with type-specific ​and gameplay related properties like how long a door takes to open, how fast a creature is, etc. Each different entity type has a different set of type variables (but share many with other entity types).
  
-Now the entity is ready to be added to the game. To do this the editor is opened and the entity mode is selected. One can now find the menu according to its placement in the file structure (this is usually ''"​entities/​[category]/​[subcategory]/​[entityname]/"''​) and select it. The entity can now be placed in the level. After this, there are some instance variables available (e.g. lamp color, if a door is locked, etc). These variables have also been specified in ''"​EntityTypes.def"''​.+Now the entity is ready to be added to the game. To do this the level editor is opened and the entity mode is selected. One can now find the menu according to its placement in the file structure (this is usually ''"​entities/​[category]/​[subcategory]/​[entityname]/"''​) and select it. The entity can now be placed in the level. After this, there are some instance variables available (e.g. lamp color, if a door is locked, etc). These variables have also been specified in ''"​EntityTypes.def"''​.
  
-Once the game loads up the saved map file the entity will appear there, with bodies, effects and everything.+Once the game loads up the saved map filethe entity will appear there, with bodies, effects and everything.
  
 ==== Level Editor variables ==== ==== Level Editor variables ====
Line 100: Line 94:
 The editor contains three different sets of variables that can be defined in each ''​Class''​ element: The editor contains three different sets of variables that can be defined in each ''​Class''​ element:
  
-**EditorSetupVars**\\+**EditorSetupVars** \\
 These are variables that are used by the editor only. For instance ''​AffectLightsVar''​ specifies that an Instance variable (see below) determines if the light in the entity is shown or not. These are mostly used to make sure user variables affecting the look of the game also show up in the editor. These are variables that are used by the editor only. For instance ''​AffectLightsVar''​ specifies that an Instance variable (see below) determines if the light in the entity is shown or not. These are mostly used to make sure user variables affecting the look of the game also show up in the editor.
  
-**TypeVars**\\ +**TypeVars** \\ 
-These are variables that are set on an entity file basis. ​This is variables that tweaks ​the behavior and look of the entity depending on the gameplay needs (a crank is faster or slower to turn) or depending on how the data in the entity file (more health given to larger ogres). These variables are changed in the ModelEditor.+These are variables that are set on an entity file basis. ​These are variables that tweak the behavior and look of the entity depending on the gameplay needs (like a crank is faster or slower to turn) or depending on the data in the entity file (more health given to larger ogres). These variables are changed in the ModelEditor
 + 
 +**InstanceVars** \\ 
 +These are set on a per placed entity basis. So each instance of an entity placed in a level can have different values on these properties. These can be things like the current health level, callback functions, connections to other entities, etc. These variables are changed in the LevelEditor.
  
-**InstanceVars**\\ 
-These are set on a per placed entity basis. So each instance of an entity placed in a level can have different values on these properties. This can be things like the current health level, callback functions, connections to other entities, etc. These variables are changed in the LevelEditor. 
hpl3/engine/entities.txt · Last modified: 2015/09/28 08:29 by mudbill