python ursina/panda3d - mixamo import and play of model with animation

129 views Asked by At

I'm working on creating a python game using Ursina/Panda3d. I have stumbled upon Mixamo and I wanted to use to it animate my characters. I've downloaded several of their models with animation and tried to have them play in Ursina but failed, once I start the animation, the scale of the character messes up and I don't know how to fix it, I've tried to impose a scale on the character, but the problem only triggers as I start the animation.

  1. Downloaded animated model from Mixamo.
  2. Opened it in Blender and converted it to GLB.
  3. Imported the model into python with below code:
from dataclasses import dataclass, field
from typing import List, Dict, Optional
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from direct.actor.Actor import Actor
import time

app = Ursina()

player = FirstPersonController()
ground = Entity(model='plane',texture='grass',collider='mesh',scale=(100,1,100))
Sky()

@dataclass
class Person:
    model_path : str
    entity : Entity = field(init=False,default=None)
    actor : Actor = field(init=False,default=None)
    
    def __post_init__(self):
        self.entity = Entity(scale=(1,1,1))
        self.actor = Actor(self.model_path)
        self.actor.reparentTo(self.entity)
     
    def animate(self):
        self.actor.loop('animate')
    
    def stop(self):
        self.actor.stop()

person = Person(model_path='person3.glb')

app.run()
 

The result I get: image description here

However, I need it animated, so I add the add the below line:

person = Person(model_path='person3.glb')

person.animate() # new line

app.run()

And I get this: image description here

I've also followed this video to the minor detail,but working. https://www.youtube.com/watch?v=Z158bGot1S4&ab_channel=AtiByte

depedencies:

ursina==5.3.0
Panda3D==1.10.13
panda3d-gltf==0.15.0
panda3d-simplepbr==0.10

link to download code + model: https://mega.nz/folder/0BYCjKqb#E8vEnywTEPU-Tsw6BAT31Q

0

There are 0 answers