CreateEntity()

Syntax

Result = CreateEntity(#Entity, MeshID, MaterialID, [x, y, z [, PickMask [, VisibilityMask]])
Description
Creates a new #Entity using the specified Mesh and Material.

Parameters

#Entity The number to identify the new entity. #PB_Any can be used to auto-generate this number.
MeshID The mesh to use to create the entity. To get a valid mesh id, use MeshID(). Dynamic meshes are not supported (meshes created with the #PB_Mesh_Dynamic flag).
MaterialID The material to use to create the entity. To get a valid material id, use MaterialID(). #PB_Material_None can be used as parameter value, to use the .material script associated to the mesh. Parse3DScripts() should be called before using #PB_Material_None.
x, y, z (optional) The position of the new entity in the world.
PickMask (optional) A special value used by RayPick() and MousePick() to select which entity group will be handled. As it's a mask, each value should be a power of two. 31 different masks are available. To create a mask value easily, the '<<' operator can be used:
  - 1 << 1  : First valid mask value
  - 1 << 2  : Second valid mask value
  - 1 << 3  : Third valid mask value
  - ...
  - 1 << 31 : Last valid mask value
To ease the use, constants should be used to store the mask value and used later. When calling the pick functions, masks can be combined with the '|' operator to select more than one type of entity.
VisibilityMask (optional) A mask to select on which camera the entity should be displayed. If this mask match the mask specified in CreateCamera(), the entity will be displayed on the camera. See 'PickMask' to build correct masks. If this parameter is omitted, then the entity will be visible on all cameras.

Return value

Returns zero if the entity can't be created. If #PB_Any is used as '#Entity' parameter, the new entity number is returned.

See Also

FreeEntity()

Supported OS

All

<- CopyEntity() - Entity Index - CreateEntityBody() ->