dxCopyEntity%(entity,parent)

Parameters

entity - Entity Handle
parent (optional) - Entity that will act as Parent to the copy.

Description

Creates a copy of an entity and returns the handle of the newly created copy. This is a new entity instance of an existing entity's mesh! Anything you do to the original Mesh (such as dxRotateMesh) will effect all the copies. Other properties (such as dxEntityColor, Position etc.) since they are 'Entity' properties, will be individual to the copy.

If a parent entity is specified, the copied entity will be created at the parent entity's position. Otherwise, it will be created at 0,0,0.

Example

; dxCopyEntity Example
; This example creates an entity and
; allows you to make copies of it.

dxGraphics3D 640,480
dxApptitle "dxCopyEntity Example"

Cam = dxCreateCamera()
Lit = dxCreateLight()

dxPositionEntity Lit,-5,-5,0
dxPositionEntity Cam,0,0,-5

AnEntity = dxCreateCube() ; This is our Test Entity
dxScaleMesh anEntity,0.4,0.4,0.4
While Not dxKeyDown(1) ; Until we press ESC

If dxKeyHit(57) Then

; When we hit Space, a new Entity is created
; These share the same internal mesh structure though!
; Hence although we are only Rotating the original MESH
; Linked to the original Entity, since it is a Mesh command,
; all the Entity Copies are linked to it..

NewEntity = dxCopyEntity(AnEntity) ; Hit Space to Copy!

; Change the dxColor of the Entity. Since this is an entity
; Property, it doesn't effect the other copies.
dxEntityColor NewEntity,dxRand(255),dxRand(255),dxRand(255)
dxPositionEntity NewEntity,dxRand(4)-2,dxRand(4)-2,0
EndIf

dxSeedRnd MilliSecs()

dxRotateMesh AnEntity,.25,.35,.45

dxRenderWorld ; Draw the Scene
dxFlip ; dxFlip it into View
Wend

End

Index