Blitz3D+ Command Reference

ClearMorphTargets mesh

Parameters

mesh - mesh node whose shared morph target definitions are cleared; children are not searched

Description

Removes every captured morph target from a mesh.

Every CopyEntity instance sharing that geometry discards its weights and morph animation channel state. Old target indices become invalid. Transform and bone animation, sequence numbers, CPU base vertices and materials are preserved. Existing queued work retains the definitions it submitted.

Clear targets before adding/removing vertices, changing triangle topology, adding surfaces or merging meshes. Capture new shapes with AddMorphTarget after editing; replacement targets start with zero weights and cannot inherit stale crossfade weights:

ClearMorphTargets mesh
ClearSurface GetSurface(mesh,1)
; Rebuild CPU geometry, then capture new targets.

Requires Extended mode.

See also: AddMorphTarget, CountMorphTargets, SetMorphWeight, ClearSurface.

Example

; Extended mode. Space clears or recaptures a shared target schema.
; Capture positions+prepared normals. Tangent capture requires valid tangents.
Graphics3D 800,500,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,0,-7
light=CreateLight()
RotateEntity light,30,20,0
base=CreateSphere(16)
second=CopyEntity(base)
PositionEntity base,-1.5,0,0
PositionEntity second,1.5,0,0
EntityColor base,80,180,240
EntityColor second,245,155,75
active=False
timer=CreateTimer(60)
While Not KeyHit(1)
    WaitTimer timer
    If KeyHit(57)
        If active
            ClearMorphTargets base
        Else
            pose=CopyMesh(base)
            ScaleMesh pose,1,1.6,.7
            UpdateNormals pose
            target=AddMorphTarget(base,pose,"Stretch",3)
            FreeEntity pose
            SetMorphWeight base,target,1
            SetMorphWeight second,target,-.35
        EndIf
        active=Not active
    EndIf
    RenderWorld
    Text 10,10,"Space: clear / capture targets    Escape: exit"
    Text 10,35,"Targets on first: "+CountMorphTargets(base)+"    Targets on copy: "+CountMorphTargets(second)
    Text 10,60,"Clear discards both weights; recapture gives each copy a new independent pose."
    Text 10,455,"Vertex queries and collision see the base spheres. Shared geometry is retained."
    Flip
Wend
FreeTimer timer
FreeEntity second
FreeEntity base
FreeEntity light
FreeEntity camera
EndGraphics
End

Index