Documentation/Programming Articles/Map System

From NeoAxis Engine Wiki

Jump to: navigation, search
Go to higher level

Contents

Description

Map System is a substructure of the Game Object System that enables object positioning in 3D space, working with physical models etc. The system consists of numerous game classes used for map and map object implementation.

In this article you will find the description of the basic map system classes such as: (Map) and (MapObject) that build upon game classes of the Entity System thereby making functionality of maps and map objects.

We would recommend you to read the Tutorial in creating a simple game object first.

Game classes and basic types

The list of map system game classes and game types (based on these classes) includes:

Class Base type Description
MapGeneralObject Base class for all map objects. This one is used as a CHILD by many game classes. ????потомка????.
MapObject Base class for map objects. Unlike MapGeneralObject it has a map position (set in Position, Rotation, Scale properties). It can also be a subject to physical interactions, since it has a physical model. This one is used as a basic class for many game classes.
StaticMesh StaticMesh.type An object used for the creation of a static geometry on the map.
CameraAttachedObject An auxiliary class used for the implementation of camera-following objects. This object may control models, particle systems and billboards and can be used for the creation of advanced (or high-quality) sky or rain.
CubemapZone CubemapZone.type This type is used for cubic texture calculation.
Fog Fog.type Fog.
Light Light.type Light source.
MapCamera MapCamera.type This type is used for arranging cameras on the map.
MapCameraCurve MapCameraCurve.type This type is used for setting camera curve.
MapCurve MapCurve.type This type is used for setting map curve from point to point.
Occluder Occluder.type This type is used for portal switch off (it is a component of the portal system).
Portal Portal.type Portal (a component of the portal system as well)
Region Region.type Map region.
SkyBox SkyBox.type Skies implemented as a cubemap.
SkyDome SkyDome.type Skies implemented as a hemisphere.
StaticLightingManager StaticLightingManager.type Static light manager (used for creation of precalculated static light).
StaticSound StaticSound.type Static sound source.
Zone Zone.type Zone (component of the portal system).

Object’s map position

Description

In order to set object’s map position the following three parameters are used: Position, Rotation and Scale.

Previous Position

The tick frequency of the game world is not so high (by default it is set to 30 ticks per second). Thus, objects are updated only 30 times per second.

However, the frame rate may be higher than 30 FPS. Therefore, it is necessary to interpolate object position while rendering to make its movement look smooth. For this purpose the information on position from the previous tick is used. The engine is using the information on the previous and the next position of the object to interpolate its position while rendering.

API

MapObject class

Name Description
PublicProperty.gif Vec3 Position Returns or sets object position.
PublicProperty.gif Quat Rotation Returns or sets object rotation.
PublicProperty.gif Vec3 Scale Returns or sets object scale.
PublicMethod.gif Void SetTransform( Vec3 pos, Quat rot, Vec3 scl ) Sets object position . Use this one if you need to set several parameters.
ProtectedMethod.gif VirtualMember.gif Void OnSetTransform( ref Vec3 pos, ref Quat rot, ref Vec3 scl ) A method called on object position change.
PublicProperty.gif Vec3 OldPosition Returns or sets the previous object position.
PublicProperty.gif Quat OldRotation Returns or sets the previous object rotation.
PublicProperty.gif Vec3 OldScale Returns or sets the previous object scale.
PublicMethod.gif Void SetOldTransform( Vec3 pos, Quat rot, Vec3 scl ) Returns the previous object position.
PublicMethod.gif Vec3 GetInterpolatedPosition() Returns an interpolated object position.
PublicMethod.gif Quat GetInterpolatedRotation() Returns an interpolated object rotation.
PublicMethod.gif Vec3 GetInterpolatedScale() Returns an interpolated object scale.
PublicMethod.gif Void GetInterpolatedTransform( out Vec3 pos, out Quat rot, out Vec3 scl ) Returns an interpolated object position.

Working with Attached Objects

Description

Any object of the game world has some physical properties. This can be a 3D model, effects or sound.

This is implemented the following way: any MapObject has its list of attached objects. Thus, various resources can be attached to the game object including:

  • 3D models
  • Particle systems
  • Billboards
  • Ленты траекторий
  • Light sources
  • In-game UI
  • Sounds
  • Game objects. You can attach any game object to another game object (this can be used for the creation of complex dynamic constructions). For example, you can attach a machine gun to a helicopter (keeping the machine gun functionality). You can also use this system to attach arms and armor to characters.

There is a number of ways how an object can be attached: relative to game object’s position, directly to object’s physical model or to the skeleton bones of a 3D model.

Resource Editor

You can adjust attached objects in the Game Objects Editor. For work with attached objects the AttachedObjects property is used.

You can learn more about working with attached objects in the Resource Editor here.

Run-time

You can not only attach game objects in the game type but also do this during simulation (e.g. attach a gun to the character when he picks it up).

Below you can see a list of classes that can be attached:

Example

Attaching a particle system:

MapObject obj = ...;
 
MapObjectAttachedParticle attachedParticle = new MapObjectAttachedParticle();
attachedParticle.SetParticleSystem( "SmokeParticle" );
obj.Attach( attachedParticle );


API

MapObject class

Name Description
PublicMethod.gif void Attach( MapObjectAttachedObject attachedObject ) Object attachment.
PublicMethod.gif void Detach( MapObjectAttachedObject attachedObject ) Object detachment.
ProtectedMethod.gif VirtualMember.gif void OnAttach( MapObjectAttachedObject attachedObject ) A method called on object attachment.
ProtectedMethod.gif VirtualMember.gif void OnDetach( MapObjectAttachedObject attachedObject ) A method called on object detachment.
PublicProperty.gif MapObjectAttachedObject[] AttachedObjects Displays the list of attached objects.
PublicProperty.gif MapObject AttachedMapObjectParent Ruturns the object to which the given object is attached (if there is one).
PublicMethod.gif MapObjectAttachedObject GetAttachedObjectByAlias( String alias ) Returns the attached object by its alias.

Object sampling

Description

It is often necessary to make a list of object located in a certain region. To do this you can go over all objects selecting those you need. However, with a large number of objects on the map this can take a long time, so there is a function for selecting certain objects in an area.

The Map class contains methods for object sampling in regions of various forms????:

Sampling is performed by object dimensions (the MapBounds property). This property is automatically calculated taking into account the size of object's 3D and physical model etc.

The engine supports object creation and removal during sampling.

Sampling by groups is also available and enables even greater increase of performance.

Example

Sampling by size.

Bounds bounds = new Bounds( new Vec3( 10, 10, 10 ), new Vec3( 20, 20, 20 ) );
Map.Instance.GetObjects( bounds, delegate( MapObject obj )
{
    ... //Some work with "obj"
 
} );

API

Map class

Name Description
PublicMethod.gif void GetObjects( Bounds bounds, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by size with group filter.
PublicMethod.gif void GetObjects( Bounds bounds, GetObjectsDelegate callback ) Sampling by size.
PublicMethod.gif void GetObjects( Frustum frustum, Boolean accurateCheck, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by camera frustum with group filter.
PublicMethod.gif void GetObjects( Frustum frustum, Boolean accurateCheck, GetObjectsDelegate callback ) Sampling by camera frustum.
PublicMethod.gif void GetObjects( Plane[] clipPlanes, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by clip planes with group filter.
PublicMethod.gif void GetObjects( Plane[] clipPlanes, GetObjectsDelegate callback ) Sampling by clip planes.
PublicMethod.gif void GetObjects( Sphere sphere, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by sphere with group filter.
PublicMethod.gif void GetObjects( Sphere sphere, GetObjectsDelegate callback ) Sampling by sphere.
PublicMethod.gif bool GetObjects( Ray ray, GetObjectsRayDelegate callback ) Sampling by ray.
PublicMethod.gif void GetObjects( Box box, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by parallelepiped with group filter.
PublicMethod.gif void GetObjects( Box box, GetObjectsDelegate callback ) Sampling by parallelepiped.
PublicMethod.gif bool GetObjects( Ray ray, FilterGroups filterGroups, GetObjectsRayDelegate callback ) Sampling by ray with group filter.
PublicMethod.gif void GetObjectsByScreenRectangle( Camera camera, Rect rect, GetObjectsDelegate callback ) Sampling by screen rectangle of the given camera.
PublicMethod.gif void GetObjectsByScreenRectangle( Camera camera, Rect rect, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by screen rectangle of the given camera with group filter.
PublicMethod.gif void GetObjectsByScreenRectangle( Rect rect, GetObjectsDelegate callback ) Sampling by screen rectangle.
PublicMethod.gif void GetObjectsByScreenRectangle( Rect rect, FilterGroups filterGroups, GetObjectsDelegate callback ) Sampling by screen rectangle with group filter.