Hi there . Lastly this cuestion have been asked . How to load an animation from Wavefront(.obj) . When we have our object riggid and ready to export, take kare of marking the animation box .
Blender (in this case) will save every frame as a single mesh . Then we can use this code :
// Project: Loading .Obj animation
// Created: 2020-01-26
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Loading .Obj animation" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
loadimage(1,"gnomo.png")
`Loading all meshes
for i= 1 to 20
loadobject(i ,str(i)+".obj")
CreateMemblockFromObjectMesh(i,i,1) `Creating meshes to add to the main object
deleteobject( i ) `deleting objects as we don't need them any longer
next
`Loading our object . The main prota
loadobject(1,"1.obj")
SetObjectMeshImage(1,1,1,0) `time for asing an image to mesh 1
`Adding the rest of meshes to the main object
for i= 2 to 20
AddObjectMeshFromMemblock(1,i)
SetObjectMeshImage(1,i,1,0)
next
`hiding all meshes at start
for i= 1 to 20
setObjectMeshVisible(1,i,0)
next
setcameraposition(1,-25,20,-25)
SetCameraLookAt(1,0,0,0,0)
do
`keeping all meshes invisible to show only the one we need
for i= 1 to 20
SetObjectMeshVisible(1,i,0)
next
`Animation speed
frame=frame+1
if frame>10 then frame=0
if frame=1 then ms=ms+1
if ms>20 then ms=1
SetObjectMeshVisible(1,ms,1)
g#=g#+0.1
setobjectrotation(1,0,g#,0)
Print( ScreenFPS() )
Sync()
loop
In order to make collision work with all differntet meshes we have to
SetObjectMeshCollisionMode(my_obj,mesh,0)
I'm not a grumpy grandpa