Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0125-preview· openaiHugging Face Suzhen/CodeChat

#Import necessary modules from direct.showbase.ShowBase import ShowBase from…

  1. User

    #Import necessary modules from direct.showbase.ShowBase import ShowBase from direct.actor.Actor import Actor from panda3d.core import AmbientLight, DirectionalLight, LightAttrib

    Define the game class

    class CharacterTestGame(ShowBase): def init(self): # Initialize the ShowBase class super().init()

        # Load the character model
        model_path = "C:\\Users\\Vusum\\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx"
        self.character = Actor(model_path)
    
        # Set the initial position and orientation of the character
        self.character.reparentTo(self.render)
        self.character.setScale(0.5)  # Adjust the scale as needed
        self.character.setPos(0, 0, 0)  # Set the initial position
    
        # Set up lighting
        ambient_light = AmbientLight("ambient_light")
        ambient_light.setColor((0.2, 0.2, 0.2, 1))
        directional_light = DirectionalLight("directional_light")
        directional_light.setDirection((-5, -5, -5))
        render.attachNewNode(directional_light.upcastToPandaNode())
        render.attachNewNode(ambient_light.upcastToPandaNode())
        render.setLight(render.attachNewNode(directional_light.upcastToPandaNode()))
        render.setLight(render.attachNewNode(ambient_light.upcastToPandaNode()))
    
        # Set up the camera
        self.disableMouse()
        self.camera.setPos(0, -20, 5)
        self.camera.lookAt(self.character)
    
        # Set up keyboard controls
        self.accept("w", self.move_forward)
        self.accept("s", self.move_backward)
        self.accept("a", self.move_left)
        self.accept("d", self.move_right)
    
    def move_forward(self):
        self.character.setY(self.character, 0.5)
    
    def move_backward(self):
        self.character.setY(self.character, -0.5)
    
    def move_left(self):
        self.character.setX(self.character, -0.5)
    
    def move_right(self):
        self.character.setX(self.character, 0.5)
    

    Run the game

    game = CharacterTestGame() game.run() i get this error C:\Users\Vusum>python c6.py Known pipe types: wglGraphicsPipe (all display modules loaded.) :assimp(error): Unable to open file "/c/Users/Vusum/C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx". :assimp(error): Unable to open file "/d/Panda3D-1.10.14-x64/etc/../C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx". :assimp(error): Unable to open file "/d/Panda3D-1.10.14-x64/etc/../models/C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx". :loader(error): Couldn't load file C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx: not found on model path (currently: "/c/Users/Vusum;/d/Panda3D-1.10.14-x64/etc/..;/d/Panda3D-1.10.14-x64/etc/../models") Traceback (most recent call last): File "C:\Users\Vusum\c6.py", line 55, in game = CharacterTestGame() File "C:\Users\Vusum\c6.py", line 14, in init self.character = Actor(model_path) File "D:\Panda3D-1.10.14-x64\direct\actor\Actor.py", line 293, in init self.loadModel(models, copy = copy, okMissing = okMissing) File "D:\Panda3D-1.10.14-x64\direct\actor\Actor.py", line 1916, in loadModel raise IOError("Could not load Actor model %s" % (modelPath)) OSError: Could not load Actor model C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx

  2. Assistant

    The error you're encountering suggests that Panda3D is unable to locate the specified model file at the path you provided. This can occur due to an incorrectly specified path or other issues related to how Panda3D identifies and accesses files on the filesystem.

    Here's how you can potentially resolve or troubleshoot this error:

    1. Check the File Path: Ensure that the file path to your model is correct. It appears that you're using an absolute path, which should generally work, but it's always good to double-check for typos or incorrect directory names.

    2. Path Format: Given that Panda3D is cross-platform, it's possible that using Windows-style backslashes (\) in file paths might cause issues, particularly if Panda3D internally converts or handles paths differently. Try using forward slashes (/) instead, or Python's raw string notation to avoid having to escape backslashes. For example:

      model_path = r"C:\Users\Vusum\Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx"
      

      or

      model_path = "C:/Users/Vusum/Wii - Naruto Shippuden Clash of Ninja Revolution 3 - Sasuke.fbx"
      
    3. File Access Permissions: Ensure that the file is not locked or inaccessible due to permissions. This is less likely the issue here, but worth checking if you're running out of options.

    4. File Existence: Confirm that the file actually exists at the specified path. You might have moved it or deleted it by accident.

    5. Other Panda3D Model Loading Issues:

      • Ensure that the version of Panda3D you're using supports loading .fbx files directly. While Panda3D does support a wide range of model formats through the Assimp library, there might be specific versions or configurations where support is limited or needs to be explicitly enabled.
      • Try converting the .fbx model to a format known to be highly compatible with Panda3D, such as .egg or .bam, using a tool like fbx2egg or similar converters provided with Panda3D or third-party tools.

    If after trying these steps the issue persists, consider checking the Panda3D documentation for any version-specific notes on model loading or seeking assistance on Panda3D community forums, as there may be version-specific nuances or additional dependencies required for handling .fbx files.