The X format is broken and the animation doesn't play

Blender 2.8 came out and the egg format is outdated and there is no alternative yet. I decided to check out other suitable animation formats. First of all, I checked the X format. However, the code that works in 1.7.2 and 1.8.0 refuses to work 1.10.3

import direct.directbase.DirectStart
from direct.actor.Actor import Actor

DemoAnim = Actor()
DemoAnim.loadModel('model.X')
DemoAnim.loadAnims({'Anim':'model.X'})
DemoAnim.loop('Anim', 'Anim-2')
DemoAnim.reparentTo(render)

run()

Animation just doesn’t play. Actually, what will this code look like on 1.10.3?

X.zip (205.4 KB)

I found out that in panda3D 1.10.3 the loop () method does not work for third-party formats.

Worked:

DemoAnim = Actor('model.X', {'Anim':'model.X',})
DemoAnim.play('Anim')
DemoAnim.reparentTo(render)

No worked:

DemoAnim = Actor('model.X', {'Anim':'model.X',})
DemoAnim.loop('Anim')
DemoAnim.reparentTo(render)

Error:

DemoAnim = Actor('model.X', {'Anim':'model.X',})
DemoAnim.actorInterval("Anim", playRate = 2).loop()
DemoAnim.reparentTo(render)
Using deprecated DirectStart interface.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
Traceback (most recent call last):
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 444, in __playTask
    again = self.stepPlay()
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 329, in stepPlay
    self.privInstant()
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 233, in privInstant
    self.privStep(self.getDuration())
  File "C:\Panda3D-1.10.3-x64\direct\interval\ActorInterval.py", line 144, in privStep
    intFrame = int(math.floor(absFrame + 0.0001))
ValueError: cannot convert float NaN to integer
:task(error): Exception occurred in PythonTask Actor-Anim-1-play
Traceback (most recent call last):
  File "Demo.py", line 19, in <module>
    base.run()
  File "C:\Panda3D-1.10.3-x64\direct\showbase\ShowBase.py", line 3121, in run
    self.taskMgr.run()
  File "C:\Panda3D-1.10.3-x64\direct\task\Task.py", line 531, in run
    self.step()
  File "C:\Panda3D-1.10.3-x64\direct\task\Task.py", line 485, in step
    self.mgr.poll()
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 444, in __playTask
    again = self.stepPlay()
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 329, in stepPlay
    self.privInstant()
  File "C:\Panda3D-1.10.3-x64\direct\interval\Interval.py", line 233, in privInstant
    self.privStep(self.getDuration())
  File "C:\Panda3D-1.10.3-x64\direct\interval\ActorInterval.py", line 144, in privStep
    intFrame = int(math.floor(absFrame + 0.0001))
ValueError: cannot convert float NaN to integer
1 Like

I suspect that the difference is that 1.10 might prefer using the Assimp-based X importer as opposed to the old x2egg process. What if you explicitly invoke x2egg and load the resulting egg?

When converting, the play method does not even work. The most amazing thing is that the animation is played by Pview.

egg.zip (203.0 KB)

Add.
However it works:

        DemoAnim = Actor('model', {'Anim':'model',})
        DemoAnim.actorInterval("Anim", playRate = 2).loop()
        DemoAnim.reparentTo(render)

I found that the animation does not play without .self
The file X converted to egg produces animation.

from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
 
class MyApp(ShowBase):
 
    def __init__(self):
        ShowBase.__init__(self)

        self.DemoAnim = Actor("file", {"Anim":"file",})
        self.DemoAnim.reparentTo(render)
        self.DemoAnim.loop("Anim")

app = MyApp()
app.run()

However, the X file if available. .self, not play.

from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor
 
class MyApp(ShowBase):
 
    def __init__(self):
        ShowBase.__init__(self)

        self.DemoAnim = Actor("model.X", {"Anim":"model.X",})
        self.DemoAnim.reparentTo(render)
        self.DemoAnim.loop('Anim', 'Anim-2')

app = MyApp()
app.run()

Now that you mention it, I seem to recall that that’s normal behaviour in Panda: Actors to which you don’t keep a reference don’t animate.

(This doesn’t, however, speak to animations not working with “.x” files.)