Recent Changes - Search:

ZGameEditor

Documentation

Community

Edit sidebar

Model

Model

Defines a moving graphical object. Contains information on how to render and move the object. To create a instance of a model use the SpawnModel -component.

Example usage: See "BallModel" in ZPong sample project

Properties

Definitions

List of private data for this model. Use the DefineVariable-component to define private variables. Every instance of a model will have their own copy of the components in this list. This allows creating models that have unique geometry for every instance. Other components such as Mesh or Bitmap can be placed here as well. However, the data is created during spawning, so only use very small meshes or bitmaps, otherwise there will be noticeable delays in your game when the models are spawned. See MonkeyModel in TripleE-sample project

States

A list of ModelState-components for this model.

OnRender

This componentlist is called when it's time to render this model to the screen. Use render-command component such as RenderMesh to render your models.

OnUpdate

Called between every frame update. Here you should put components that update your models position.

OnSpawn

Called once when this model is spawned (created). Use components that initialize your models local variables here.

OnRemove

Called when the model is removed.

OnCollision

Called when this model has collided with another model. Collision detection must have been enabled using a DefineCollision-component. A ZExpression defined here can examine which category the model has collided with using the App.CollidedCategory property.

Position

The models current position in 3D-space.

Rotation

The models current rotation in 3D-space in cycles (one cycle = 360 degrees = 2PI).

Velocity

Current velocity in 3D-space. Assign a velocity (by setting a value in the editor, or using a ZExpression) to make your model move. The unit of Model.Velocity is the amount that the model will move in one second. So for example if Velocity.X is set to 5, then the model will move 5 units per second in the X-axis, which is about half the screen width using the default camera settings.

Scale

Current scale of model. Default value is 1 for the scale in x,y,z directions. A model can be scaled up and down, for instance 0.5 is half size and 2.0 doubles the size.

RotationVelocity

Set a value to this property to animate the models rotation in each axis. For example: Setting RotationVelocity.Y to 1 will rotate the model one full circle per second around the Y axis.

Category

Use a separate category for every kind of model for which a separate collision detection should be used. See DefineCollision.

CollisionBounds

The size of this model when it is tested for collision. This value is interpreted differently depending on the value of the CollisionStyle-property:

  • CollisionStyle is Rect2D or Rect2D_OBB: The first value represents the width, and the second value is the height.
  • CollisionStyle is Sphere3D or Circle2D: The first value is the radius of the sphere.
  • CollisionStyle is Box3D: The first value represents the width, the second is height, and the third value is the depth (x,y,z).

CollisionOffset

Offset-value for the models position when it is tested for collision. This can be used for moving the center point of collision from the center point of the geometry, for instance a "weak spot" on a enemy boss. First value is offset in X axis, second is Y.

CollisionStyle

How to determine collision of this model:

  • Rect2D - Use 2-dimensional rectangular collision.
  • Sphere3D - Use 3-dimensional spherical collision.
  • Box3D - Use 3-dimensional rectangular collision.
  • Rect2D_OBB - Use 2-dimensional rectangular collision taking the scale and rotation of the model into account. If your model does not rotate or scale then use Rect2D instead for improved performance.
  • Circle2D - Use 2-dimensional circle collision.

RenderOrder

  • Normal - Model1, Model2, etc.
  • Depthsorted - for transparent geometry in 3D games.

Personality

This is a read only value that is automatically assigned a random value between 0 and 1 when a model is spawned. Use this value in expressions for making every instance of a model slightly unique. For example see BoidModel in Steering sample project, it uses the Personality-value for modifying the locally defined mesh to give every boid a separate appearance.

Edit - History - Print - Recent Changes - Search
Page last modified on April 14, 2010, at 04:53 pm