How I can check before if a mesh is animated or not animated in order to use LoadMesh or LoadANimMesh respectively
Thanks!
Thanks!
Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() light=CreateLight() RotateEntity light,90,0,0 arialfont = LoadFont("Arial", 16) SetFont arialfont model% = LoadMesh("the_static_model") If model <> 0 Then PositionEntity model,0,0,MeshDepth(model)*2 ; Load mesh animmodel% = LoadAnimMesh("the_static_model") If animmodel <> 0 Animate animmodel anim_length% = AnimLength(animmodel) animate_ing% = Animating(animmodel) EndIf While Not KeyDown( 1 ) RenderWorld UpdateWorld If animmodel <> 0 Text 0,0,"Model is valid" Text 0,20, "Width = "+MeshWidth(animmodel) Text 0,40, "Height = "+MeshHeight(animmodel) Text 0,60, "Depth = "+MeshDepth(animmodel) Text 0,80, "Anim length = "+anim_length Text 0,100, "Animating = "+animate_ing Else Text 0,0,"Model is not valid" EndIf Flip Wend End
Function CopyMeshAt(mesh) mesh2 = CopyMesh(mesh) ScaleMesh mesh2, EntityWidth(mesh), EntityHeight(mesh), EntityDepth(mesh) RotateMesh mesh2, GlobalEntityPitch(mesh), GlobalEntityYaw(mesh), GlobalEntityRoll(mesh) PositionMesh mesh2, EntityX(mesh,1), EntityY(mesh,1), EntityZ(mesh,1) Return mesh2 End Function Function EntityWidth#( mesh ) If EntityClass$(mesh) <> "Mesh" Then Return 1 If MeshWidth(mesh) = 0 Then Return 1 TFormPoint MeshWidth(mesh), 0, 0, mesh, 0 xx# = TFormedX() yy# = TFormedY() zz# = TFormedZ() TFormPoint 0, 0, 0, mesh, 0 xx# = TFormedX()-xx yy# = TFormedY()-yy zz# = TFormedZ()-zz ll# = Sqr(xx * xx + yy * yy + zz * zz) / MeshWidth(mesh) If ll = 0 Then ll = 1 Return ll End Function Function EntityHeight#( mesh ) If EntityClass$(mesh) <> "Mesh" Then Return 1 If MeshHeight(mesh) = 0 Then Return 1 TFormPoint 0, MeshHeight(mesh), 0, mesh, 0 xx# = TFormedX() yy# = TFormedY() zz# = TFormedZ() TFormPoint 0, 0, 0, mesh, 0 xx# = TFormedX()-xx yy# = TFormedY()-yy zz# = TFormedZ()-zz ll# = Sqr(xx * xx + yy * yy + zz * zz) / MeshHeight(mesh) If ll = 0 Then ll = 1 Return ll End Function Function EntityDepth#( mesh ) If EntityClass$(mesh) <> "Mesh" Then Return 1 If MeshDepth(mesh) = 0 Then Return 1 TFormPoint 0, 0, MeshDepth(mesh), mesh, 0 xx# = TFormedX() yy# = TFormedY() zz# = TFormedZ() TFormPoint 0, 0, 0, mesh, 0 xx# = TFormedX()-xx yy# = TFormedY()-yy zz# = TFormedZ()-zz ll# = Sqr(xx * xx + yy * yy + zz * zz) / MeshDepth(mesh) If ll = 0 Then ll = 1 Return ll End Function Function GlobalEntityPitch#(entity) pit# = Int(EntityPitch(entity)*1000)/1000.0 Return pit End Function Function GlobalEntityYaw#(entity) pit# = Int(EntityPitch(entity)*1000)/1000.0 yaw# = Int(EntityYaw(entity)*1000)/1000.0 If Abs(pit)>GIMBAL_LIMIT temp = CreatePivot(entity) EntityParent temp, GetParent(entity) TurnEntity temp,Sgn(pit)*-90.0,0,0 yaw# = Int(EntityYaw(temp)*1000)/1000.0 FreeEntity temp EndIf Return yaw End Function Function GlobalEntityRoll#(entity) pit# = Int(EntityPitch(entity)*1000)/1000.0 rol# = Int(EntityRoll(entity)*1000)/1000.0 If Abs(pit)>GIMBAL_LIMIT temp = CreatePivot(entity) EntityParent temp, GetParent(entity) TurnEntity temp,Sgn(pit)*-90.0,0,0 rol# = Int(EntityRoll(temp)*1000)/1000.0 FreeEntity temp EndIf Return rol End Function