PrepareModelError$ ( )

Parameters

None.

Description

Returns why the last PrepareModel failed, or an empty string if it worked.

PrepareModel returns 0 when the model cannot be prepared, and never ends the program over it, so a tool can say what went wrong and let you try again. The message names the step: Join parts: input must contain closed solids without self-intersections, Simplify: 'Face' has morph targets, which simplifying would lose, Level 2: none of its parts has the name of a part of the model or the reason the model's file could not load, as ModelLoadError gives it.

There is one string, and it holds the result of the most recent PrepareModel, so read it straight away. A successful PrepareModel clears it.

See also: PrepareModel, ModelSaveError, ModelLoadError.

Example

; PrepareModelError Example
; -------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,1,-5

light=CreateLight()
RotateEntity light,45,45,0

; A model file to prepare
barrel=CreateCylinder(24)
EntityColor barrel,120,90,60
file$=SystemProperty("tempdir")+"barrel.glb"
SaveMesh barrel,file

; A recipe that asks for a level keeping 150% of the triangles fails, and
; PrepareModelError says why, instead of ending the program
bad$="{'lods':[{'keep':1.5}]}"
failed=PrepareModel(file,Replace(bad,"'",Chr(34)))
reason$=PrepareModelError()

; A file that is not there fails too
missing=PrepareModel(SystemProperty("tempdir")+"no_such_model.glb","{}")
missing_reason$=PrepareModelError()

While Not KeyDown(1)

    TurnEntity barrel,0,1,0.5

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrow keys: move camera   Esc: exit"
    Text 0,20,"Bad recipe: PrepareModel returned "+failed
    Text 0,40,"  "+reason
    Text 0,60,"Missing file: PrepareModel returned "+missing
    Text 0,80,"  "+Left(missing_reason,78)

    Flip

Wend

DeleteFile file
End

Index