Table of Contents

2. Creating Models

2.1 Geometry

IMPORTANT NOTE:
When you want an object to have physics simulated it is very important that it is placed with its mass center as the center of the scene (not the map, the scene in the maya, 3ds, etc file). When you have several objects, when creating joint’s for example, it is important that the pivot of each object is at their mass center (Note that simply changing the pivot point may not be the best option since that changes the transformation, the best thing is to go into vertex mode and move the entire object until the center is where you want it to be). This may also be used to your advantage when creating bodies that would be hard to tip or have the mass center offset for some other reason.

You should always try to center the object to the editor’s scene center!

As of July 2006 the engine automatically calculates the body center if it's a single mesh model. However, it is still recommended that you do the above as a proper work method for the engine.

All geometry must be triangles. This can be made sure by either triangulating or choosing an “export as triangles” option in the exporter.

Currently all types of meshes are supported except for shadow casting meshes where triangles that share the same 3 vertices (or 3 vertices with the exact same coordinates) are forbidden. This means that double sided polygons are not handled on shadow casters for the time being. (For those interested this is due to a limitation in the edge detection algorithm, used when creating shadows, but may be fixed if it is really needed.) Shadow casters does not handle edges with more than 2 triangles as well.

Also note that closed meshes with normals facing away from its center (i.e. a closed room) cannot cast shadows since the shadow will be omnidirectional and will fill the entire screen. This will most likely only apply to scene geometry and the ways to fix it are the following:



2.2 Animations

IMPORTANT NOTE 1:
Animated objects do not have any physical simulation. Bodies may collide with them but they will not push other bodies around in a convincing matter and bodies might also get stuck. So use animation with colliders carefully.

IMPORTANT NOTE 2:
When creating the skeleton for an object then the joints can NOT be rotated. You may only use translations for the initial placement. Rotation may be used in animations as normal though.

At the moment the engine can not handle animations with scale!

Currently both skeletal (using skinned bones) and object (just key framing objects) are supported. Objects may not be attached to bones and the two they may not be mixed.

To create models with several animations you need to use entity files (covered in chapter 6). These allow the user to add more files with animation. When doing this there are two types of files:

When using skeletal animations make sure that the skeleton root is at the root of the scene. If not, the engine will not find it.

Main file: This is the file that defines the geometry, material, skinning and so on of the model. This also contains colliders. If the animation is not skeletal then there must be an animation in this file for the engine to determine the data needs. The animation data in the main file is NOT added though!

Animation files: These files should contain exactly the same data as the main file except for colliders.

At the moment the engine cannot load animation data alone since it depends on whether the model is skinned or not and the placement of nodes. So the extra animation files must also contain all other data as the main file. However the animation files should not contain physics data like colliders. These should only be in the main file.

If you want to add colliders to the animation you can do either group them with the object they should move relative to or not group them at all. If not grouped they will be placed relative to the center of the entity (this mean the center of all objects apart of the animation). It is possible to combine these two types.

If you have 2 boxes spinning around each other and want to add colliders to them you simply create two collider objects and place them correctly. Them you select collider 1 and box 1, press group, select collider 2 and box 2 and after that you press group again. Now the colliders will be attached to the boxes.

Since animated objects do not interact physically with other bodies then sometimes you might want to encapsulate the entire animation inside an animation. To do this just create the collider and do not group it with anything (it MUST lie in the scene root, so that it has no parent node).

When you want to change material or perhaps even alter the look of an object this only has to be done in the Main File, as long as the placement (transform) is the same.

Maya specific: If an animation doesn’t show up correctly try sampling it. In Collada options mark Sample and set the sampling function to the sampling rate, which is the time for each frame you sample. If you want to sample 5 times a second write “0.2” (1/5), for a sample rate 30 times a sec write “.033333” (1/30) and so on.

2.3 UV-Mapping

Since the HPL-Engine uses per pixel lighting and normalmapping extra care has to be used when creating mapping the uv for a model. The best advice is to have as few pieces as possible and to put the seams in hidden or flat surfaces. It is also good if the seems are close to each other on the texture map and if the angle between the edges making the seam is a small as possible.

2.4 Colliders

Colliders are used by the physics system to calculate collisions. Models that don’t have any colliders cannot collide with anything. Unlike static map meshes (see chapter 3) you don’t have to add a “nocollide”-parameter to show that the model doesn’t have any collision, models never have any collision unless it has one or more colliders.

Colliders are made with normal geometry that is named in a special way. The naming has the following syntax:

_collider_[shape type]_[name]

The first variable “shape type” is the type of shape and “name” can be anything you like. The following shapes are available:

sphere A normal sphere, nonuniform spheres are not allowed
box A 6 sided box
cylinderA cylinder where height is the Y axis
capsule A cylinder but with rounded caps

An example of a name is “_collider_box_pCube1”, this defines a box collider.

When creating a shape only rotate, scale and translate should be used (as well as setting the size in Input). If you alter the vertices by hand make sure this pivot is at the mass center, however this untested and might not work very well.

The way in which colliders are added to the scene varies depending on the context. Below is a list of the different types used:

Normal Model
A normal model is a model without joints or skeleton. In this case the colliders are simply added to the scene and they all will become a single body. The centre of mass will be the centre of the scene. The body will be named [entity name] + “_” + [name of model file].

Joint Model
This is a model where one or more joints has been added. This most likely means that the model will consist of several physical bodies This means that it must be shown which body belongs to which body. This is done by grouping the mesh and the bodies in a group. Note that there can only be one mesh per group, if more is wanted these must be children of the first mesh. The centre of mass for each body will be the centre of it’s mesh. The bodies will be named [entity name] + “_” + [name of mesh].

Skeletal Model
If a model contains a skeleton the colliders must be attached to the bones. The bone that a collider belongs to must be its parent, several colliders can share the same bone parent. The centre of mass for each body will be the combined center of all colliders. The bodies will be named [entity name] + “_” + [name of bone parent].

Animated Objects (non skeletal)
The same rules as Joint Model applies.

TIPS: If you need to have several meshes connected to the same collider. For example, a door with a glass window. This is done by placing one of the meshes as children the to the other. The “top mesh” can have as many children as you like.

2.5 Joints

2.5.1 General

Joints are used to constrain the movement between to bodies. They are a very powerful tool and can be used to do a lot of stuff such as lamps that can sway back and forth, drawers that can be interacted with and even a car with wheels and suspenders.

All joints are made up from an anchor (also called pivot point) and an axis (also called pin direction), these have different meanings for the different joint types and describe the constraint. All bodies also have some limits to limit the constraint. If all of these values are set to 0 the limit is disabled. It can also be set if the two bodies on the joint will collide or not.

2.5.2 Joint types

Ball and socket joint
Name in engine: ball
Limits:
Max twist angle, this is the maximum angle that bodies can twist relative to each other. Has a value from 0 – 180. Max cone angle, this is the maximum angle between Body1 and the axis. Has value from 0 – 180.