Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor glft light/texture issue #568

Open
volodyaleo opened this issue Aug 17, 2023 · 2 comments
Open

Actor glft light/texture issue #568

volodyaleo opened this issue Aug 17, 2023 · 2 comments

Comments

@volodyaleo
Copy link

volodyaleo commented Aug 17, 2023

I have read faq and added Actor.

But models are black. The model can be found here.

        self.actor = Actor(model)
        self.actor.reparent_to(self)
        self.actor.setScale((scale * (1 / model_width), scale * (1 / model_height), scale * (1 / model_width)))
        if model_rotation_correction:
            self.actor.setH(model_rotation_correction)
        if model_y:
            self.actor.setPos(0, model_y, 0)

Can someone help me? What the reason might be?

Снимок экрана от 2023-08-18 00-06-31

@imbomania
Copy link

imbomania commented Sep 25, 2023

You're lucky, at least gltf works. When i tried to use gltf, all i've got is a path error, no matter how i exported and place model :D

For Actor it's better to use .egg format of models, works 100%.

@necr0potenc3
Copy link

necr0potenc3 commented Feb 16, 2025

I know this is an old issue, but have you tried setting the texture stage? Sometimes messing with flipped_faces or double_sided will help, see this class for an example on setting the texture stage:

from direct.actor import Actor
#from direct.actor.Actor import Actor
from panda3d.core import Shader as psha
from panda3d.core import TextureStage, TexGenAttrib
class Human(Entity):
   def __init__(self):
       super().__init__(parent=scene, shader=basic_lighting_shader)
       #super().__init__(parent=scene, shader=basic_lighting_shader, flipped_faces=False, double_sided=True)
       
       # https://docs.panda3d.org/1.10/python/programming/models-and-actors/actor-animations
       
       self.actor = Actor.Actor("models/CatPilot.gltf")
       
       # for physics
       self.model = self.actor
       
       tex = loader.loadTexture('textures/CatPilot.png')
       self.actor.setTexture(self.actor.find_texture_stage('*'), tex, 1)
       
       # CatPilot model comes with three textures (pbr, emission and normal)
       # When loading, it's necessary to change the existant texture stage
       ####ts = TextureStage('ts')
       #ts = self.actor.find_texture_stage('0')
       #ts.setMode(TextureStage.MAdd)
       #self.actor.setTexture(ts, tex, 1)
       
       # https://discourse.panda3d.org/t/settexture-makes-model-black/28620/7
       #print('***DEBUG ', self.actor.findAllTextures())
       #oldTexture = self.actor.findTexture('pbr-fallback')
       #newTexture = loader.loadTexture('textures/CatPilot.png')
       #self.actor.replaceTexture(oldTexture, newTexture)
       
       #self.actor.setColorScale(1, 0, 0, 1) # set to color red
       
       self.actor.reparentTo(self)
       
       #print('======= ANIM DICT ======')
       #print(self.actor._Actor__animControlDict.get('common').get('modelRoot'))
       #{'PutOnGogglesBlink': Actor.AnimDef(None), 'WalkBlink': Actor.AnimDef(None), 'Cheer': Actor.AnimDef(None), 'Default': Actor.AnimDef(None), 'FlyingPlane': Actor.AnimDef(None), 'DefaultAnim': Actor.AnimDef(None), 'PutOnGoggles': Actor.AnimDef(None), 'Run': Actor.AnimDef(None), 'GogglesOn': Actor.AnimDef(None), 'Walk': Actor.AnimDef(None)}
       
       #self.model_bounds = self.actor.bounds
       #self.actor.showTightBounds()
       
       action = lambda: print('OW!')
       self.on_click = action
       
       self.scale = (1, 1, 1)
       self.rotation = (0, 0, 0)
       self.color = color.white
       self.position = (1, 2, 1)
       self.collider = 'box'
       self.gravity = 1
       
       MeshCollider(world, self, mass=1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants